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.
5.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 a diff you did not write. A machine never glazes over.
5.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, and flags the moment you use one wrong: passing text where a number belongs, 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.
5.6.3Add static analysis for the deeper risks
Past style and types, static analysis reads your code for risky patterns without running it: a secret left in the source, an input used without checking, 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.
5.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:
# The agent runs these before saying "done":
format -> prettier --write .
lint -> eslint .
types -> tsc --noEmit
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. Now the gate is automatic, and broken code cannot quietly reach you in the first place.
This prompt wires the checks and the standing rule for your stack:
Act as a senior engineer setting up my quality gate.
For my stack, set up a formatter, a linter, and a
type checker, and one static-analysis tool if it
fits. Give me the exact command for each. Then add a
rule to the file you read every session: no task is
done until all of them pass, and you run them
yourself before saying so.
My 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.