(Possibly) The last chapter of the AI odyssey π«‘
After trying all approaches with AI coding, and seeing all the pitfalls, I emerge with a definitive strategy
In practice: structure codebase, prompt well, let AI write, you read π
Structure codebase
You must be always in control of how the code is structured, aka "architecture".
Libraries, folders, pattern, conventions are all up to you, and they must be enforced at all times, and early π
This has 2 practical implications:
- Initially the project moves slower, you must check each file and config
- Guardrails and automated checks are key, and must be added early
Plus another major requirement:
You must have enough expertise to fully understand the full picture, and steer even smaller deviation and details π
In fact, broader architecture and automatic checks setup may be (become) more important than the details of the code π€
Prompt well
Automatic checks in place, it's time to turn on the AI.
And prompting is also a skill that need to be acquired and honed π
General principles:
- Give references to files, as many as possible
- Manage the scope of each feature, keep it small(er)
- Be precise in the requirements, as much as you can
Use "plan" mode, or at least make sure that AI does some research before writing code, and that you agree with the plan ποΈ
In fact, let me give you an obvious but overlooked advice:
Read the plan ππΌββοΈ
You job is not writing anymore, but it shifts a lot more into reading.
Read the plan, correct any small deviations, and add more and more context until it's all aligned. All.
Let AI write
Forget about actually writing most of the code.
With proper guardrails and an aligned plan, the AI can do a great (and faster) job π«‘
If the previous two steps are checked, just let AI run with it. In fact, don't even bother checking any work in progress.
Let AI write the full implementation until completion, don't bother with any intermediate steps ππΌββοΈ
Again, if plan and guardrails are solid, the AI tends to self-correct before notifying you when finished.
You read
Again, sounds obvious? It's not.
I have yet to read AI-generated code (for anything non-trivial) without finding at least one thing that needs to be fixed/refactored. Every single time. Read the code.
This is the missing link. The corner stone that may never go away.
And it's also where the quality of the previous steps shows up:
- No architecture/check = AI added folders, bad patterns, code slop
- Bad prompt = AI wrote something, not what you wanted, not how you wanted, or way too much
"But it takes too much to review all those changes" cit. π€―
Long review time causes:
- Scope too large, reset and prompt for a smaller piece
- Architecture too scattered, too many random files and patterns
- You don't understand the code (anymore)
The last point is key:
The moment the AI gets ahead of you in your own codebase, you won't be able to review simply because you don't understand what the app is doing π
You don't write code anymore. But you are still the owner of it.
Your job shifted more into management: of architecture, of prompt and scope, and as reviewer.
The above process and principles are generic and always valid (as of today), no matter what kind of code your write.
That's why I would consider this the ultimate AI guide, and not sure how much more there is to say about this.
See you next π
