Skip to main content
DC

February: one session did everything

In February the agent checked its own build and merged straight to main. None of this started as a system. There was a rules file, CLAUDE.md, which the agent reads at the start of each session, and the instructions in it were the whole safety net.

Rules are cheap. They take a minute to write, and they carry judgment calls a script can't make, such as when a failure is worth writing down. The weak spot shows when one session writes the code, runs the check and then decides whether the check passed, because from the outside a skipped step and a passing one look the same. A rule is an instruction the model can skip, and nothing in that setup would have noticed if it did.

October: a script checks, a second session reads

The loop works through a run of Linear issues on its own, one after another, each on its own branch from a clean main. On 15 October the checks moved out of the agent's hands. Once the agent says the work is ready, a script runs the type checks, the build and the tests. A failure there skips review and starts a fix round with the error output. If everything passes, a second Claude session, one that hadn't written the code and starts with no context, reads the diff and can reject it.

That reviewer has caught things on this site that the type checks, build and tests let through. It flagged a cookie panel that rendered at 98.8px against a 96px limit, and a consent bug that left PostHog opted out.

Screenshots, then the live site

Screenshots of every page at desktop and phone width came later. The script starts the app in a real browser and takes them, and the reviewer reads them next to the diff. It rejects page errors, text that overlaps or clips, and anything the issue asks for that isn't visible on the page. The issue's own pages come at full size and the rest arrive 9 to an image. When the reviewer rejects, a third session fixes only the flagged problem and the work goes back through the checks, up to 3 rounds.

Merging changed next. The branch is rebased onto main and the checks run again, so a conflict blocks that one issue and the rest of the run carries on. After the deploy the loop waits, signs in to the live site, takes screenshots and posts them on the issue in Linear. A broken page moves the issue to Blocked with a note that says why.

One issue through the loop. A failed check or a rejected review goes to a fix round, up to 3, then back through the checks.

Each session also has a cap on how many steps it can take: 150 to implement, 80 to review and 60 per fix. An issue that hits one goes back to the backlog with its work saved on its branch, and the next run picks it up from there.

Rules ask, hooks enforce

Each of those steps took a job that used to be a sentence in the rules file and made it a step the agent can't skip. The loop's script does that for the whole run. Inside each session, hooks do the same job. A hook is a script that Claude Code runs on an event, such as a session starting or a command about to run, and it can block the action.

One of the hooks on my laptop is a short script that runs before an AI agent's commands and blocks any migration which drops or truncates a table. It also blocks any remote database reset. A rule could ask for the same thing. The hook runs whether or not the model remembers the rule, and it stops the command before it reaches the database.

The other hooks are smaller:

  • session-orient, at session start, prints the last log entry, recent commits and the project's open Linear issues.
  • block-secret-commits runs before every shell command and stops a commit that carries a secret. Next to it, a deny rule in the settings keeps agents out of .env files, where the passwords and keys live, even with permission prompts turned off.
  • Three more keep the agent's notes on each project well formed, committed and pushed every hour.

The rules are still there. CLAUDE.md and 9 more rule files load into every session. One of them says that any approach that took 2 or more attempts goes into ERRORS.md, which the agent loop reads before it starts work.

The limit, and what to copy

The database guard reads commands. If the agent puts the same DROP TABLE inside a script and then runs the script, the hook sees only the command that starts it and lets it through. That gap is still open. Closing the laptop lid also stops a run.

The database guard reads the command it is given. A DROP TABLE inside a script gets past it. Commands are illustrative.

The tests had a blind spot of their own. One app the loop built passed every unit test against fake API responses. Its first real orders still found 3 bugs: order IDs in a format the tests never used, a permission the app didn't have, and a payment sandbox that wouldn't say how much could be refunded.

The cheapest piece to copy is one CLAUDE.md, one SessionStart hook that prints your open issues, and an ERRORS.md that your rules tell the agent to read. Each session then opens on the work that's waiting and the approaches that already failed. The rest of what's in this post was added one failure at a time.

Which step in your own setup is still a sentence in a rules file?