The agent writes code that looks right and runs, right up until a typo, a value of the wrong type, or an unused variable quietly hides a real bug. It generates faster than you can read, and you cannot eye every line. This chapter sets up the automated checks that catch whole classes of mistakes for you, before they ever reach a user.
4.6.1Let the linter catch the small bugs
You already set up a formatter and a linter to keep the code in one consistent style. The linter does a second job that matters more here: it flags likely mistakes. An unused variable, an unreachable line, a comparison that is always true, the small errors that read as fine but signal a real bug.
These are exactly the things your eyes glaze over on line four hundred of code you did not write. A machine never glazes over.
4.6.2Turn on type checking
The single highest-value check is a type checker. It knows what shape each value is meant to be: a number, a name, a user. Then it flags the moment you use one wrong, like passing text where a number belongs, or reading a field that might not exist.
That catches a whole class of bugs before the code runs at all. The common one is TypeScript; most stacks have an equivalent. It turns a crash a user would have hit into a red underline you fix in seconds.
4.6.3Add static analysis for the deeper risks
Past style and types, static analysis reads your code for risky patterns without running it. It finds a secret left in the source, an input used without checking, or a whole file nobody calls anymore.
You do not need it on day one, but one tool wired in early keeps a class of security and dead-code problems from ever accumulating.
4.6.4Make the agent run them every time
Checks you run when you remember are checks you do not really have. The move is to make the agent run them itself, every time, before it declares a task done:
Write that into the rules file the agent reads every session, as a hard line: no task is finished until format, lint, and type checks pass.
Then back it with the git hook you left empty when you set up version control. A rules file is an instruction your agent can drop under pressure; a hook is a gate that runs whether anyone remembered or not. Put the same commands in both and you are covered twice: the agent runs them before it says done, and nothing lands if it did not.
This prompt wires the checks and the standing rule for your stack:
Do this now: paste the prompt, wire the checks for your stack, and add the "not done until they pass" rule so your agent runs them on every change.