Article

Clean code rules the AI obeys

Newsletter

One email on Fridays, and nothing else.

  • Practical B2B tips

  • 4-min read on Fridays

  • For anyone in B2B growth

Clean code rules the AI obeys

Left alone, an AI will happily produce a working app that is quietly rotting: enormous files, dead code it forgot to remove, the same thing done three different ways. It runs today and becomes unmaintainable next month. This is not a hypothetical: industry studies have found AI-generated code carries materially more issues than human-written code, and the volume only makes it worse, since you are merging far more code than you would ever hand-write. A few standing rules keep it clean without you reviewing every line.

Cap how large any single file is allowed to get. Past a certain size, a file becomes hard for both you and the AI to reason about, and the right move is to split it into smaller pieces, one section per file. Smaller files also help the AI, because it can hold a focused piece in context and change it cleanly instead of rewriting a sprawling one and dropping things on the way. The exact limit depends on your stack, so if you are unsure, ask the AI what a sensible ceiling is for what you are building, and then hold it to that.

Give it a standing instruction to write like a senior engineer: clean, scalable code, no dead files, fewer lines rather than more. This one rule, applied to everything, lifts the quality of the output more than almost anything else you can do, because it changes the default the AI writes toward.

Add a small rule that the AI summarises each change in a sentence or two, with a marker you can scan. Then you can glance at what it did across a session and actually follow the story of the work, instead of trying to reconstruct it from a wall of diffs.

The theme is that you are setting defaults, not policing output. Write the rules once so the AI writes clean code by habit, and reserve your attention for the decisions that actually need a human.

More articles

FAQ

Questions about this topic

Academy

Growth Academy

Start free

A free account opens the first course and keeps your progress.

  • A free course

  • Track your own skills

  • Every playbook you unlock