AI Coding Tips Thread

Yeah, totally. That's what I see in my tests so far, what it does is impressive but flawed, it needs work -- and more importantly knowledge -- to get it to generate code fit to check in.
Context is king with these things and it takes time actively using an agent to understand how you can improve that for your specific scenario - also why I've stopped changing and trying other agents because they all do things differently.

I've spent hours building MCP servers and refining instructions, which is essentially like training an employee, but it improves the workflow significantly when you don't have to keep reminding it of basic things.
 
Yeah, totally. That's what I see in my tests so far, what it does is impressive but flawed, it needs work -- and more importantly knowledge -- to get it to generate code fit to check in.
Context is king with these things and it takes time actively using an agent to understand how you can improve that for your specific scenario - also why I've stopped changing and trying other agents because they all do things differently.

I've spent hours building MCP servers and refining instructions, which is essentially like training an employee, but it improves the workflow significantly when you don't have to keep reminding it of basic things.
Yes it takes time, but if you keep iterating on your processes you can get it to the point where it's producing quality code. The most important tools :

CLAUDE.MD

Step 1 is sorting your Claude.MD, make sure all your naming, architectural and coding patterns are in there. This file is included at the top of the context for every agent.

When prompting, stick to 'positive' instructions. Avoid negative instructions like DON'T DO XYZ....even though the DON'T is there you're still making it ingest tokens representing the negative instructions, it's inefficient as well as potentially confusing.

Keep prompts small and concise. The larger the prompt, the less chance of it adhering to any one thing in it.

Make sure to keep the file updated as you work on the project.

Linters
Depending on your language and toolset, make sure you have the strictest linter and static code analysis tools enabled to enforce your coding standards. Make your your Claude.MD contains instructions to always fix linter errors, without applying exceptions. CC in VS Code can see linter errors from the IDE.

VCS Hooks (Git/Husky)
Following on from the linters....as well as having the linting rules enabled, make sure they are enforced with pre-commit and/or pre-push hooks (using Husky or whatever, depending on language).

You do need to keep an eye on CC still even with all these rules....it's #1 objective is to do what you asked it, and if it gets stuck because of a linting rule, it will start trying to work around the linting and hooks. Hit the escape and tell it off if you catch it!

Claude Code hooks
This is a bit more advanced, but you can specify an agent to run on various Claude hooks, like post-edit file. So every time Claude edits a file, a Haiku agent reviews it. This does slow down things a fair bit, but really does help enforce things.

Agents

For my Unreal projects, I have a UE5-Code-Reviewer agent that is instructed to review code and ensure it adheres to UE best practices and enforce my architectural and performance patterns. CC will run it automatically before committing anything.

WORKFLOW
Probably the single most important thing to learn....how to work with Claude.

  1. Use the CLI version of Claude Code. If you're in Visual Studio Code, open Settings for the Claude Code plugin, and tick the 'Use Terminal' option. This uses the CLI interface for the plugin rather than the prettier one....but the pretty one is always significantly behind the CLI in terms of functionality including a really important one.
  2. ALWAYS start a new task by typing /clear to wipe your context.
  3. Press shift+tab to cycle to PLAN MODE
  4. Now tell Claude what you want it to do. Feel free to have a conversation with it first like "I need to do XYZ and I'm not sure of the best approach"
  5. Make sure to ask it to do a web search for up to date API docs rather than relying on it's training data
  6. I'll come back with a plan for what it's going to do.....review it and use the 'type something else' option to make amendments until you're happy.
  7. IMPORTANT - Make sure to select the 'Clear context and continue' option once you're happy with the plan. You've just used a load of context planning, so clearing the context here will free it up and keep the agent fully focused on the plan. (this option only exists on the CLI, hence point #1).
  8. Let it work
  9. When it's done, and it's committed and you're ready to move on to the next task......remember to /clear to wipe context before continuing.
It's really bad to let the context fill up to the point it needs compaction. By its nature the compacting process is a bit of a lottery. Try to make your tasks atomic enough to complete before you exhaust your context.


This last bit about using Plan mode is the single best habit you can get into. It not only give you an opportunity to review everything before it starts work, but makes the orchestrator make good decision by researching properly before it begins.

I am putting together a Youtube series on specifically using CC for game dev work. Hopefully get started on it soon!
 
Last edited:
Back
Top Bottom