Skip to main content
Handbook/Build/Page 41 · Guardrails

Catching Bugs Early

Share

Share this page

Pass it to someone who needs it.

Star on GitHub

Key takeaway: Automate the quality checks

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:

# The agent runs these before saying "done": format -> prettier --write . lint -> eslint . types -> tsc --noEmit
No task is done until format, lint, and type checks all pass.

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:

Ready prompt
Act as a senior engineer setting up my quality gate. Read my rules file first, Conventions section included, and configure tools that enforce what is already written there rather than a different house style. For my stack, set up a formatter, a linter, and a type checker, plus one static-analysis tool if it fits. Give me the exact command for each. Then add a standing rule to my rules file: no task is done until all of them pass, and you run them yourself before saying so. Wire the same commands into my commit hook, so they still run on anything that slips past you. If you need the full reasoning behind this step, read https://zalt.me/guides/vibe-coding/build/guardrails 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.

Mahmoud Zalt

Mahmoud Zalt

Software engineer, 16+ yrs · built Sistava.com in 3 months, idea to production, using these methods

Resources
Star on GitHubContribute
Donate

Support my work

A small tip keeps the free work coming.

© 2026 Mahmoud Zalt. Free to read, not to republish.
Copyright & license