A blue and cream mechanical keyboard and a silver trackball on a lavender desk.

· AI workflows · 5 min read

A working agreement for coding agents

Three agreements that make agent-written code reviewable: rules in the repository, one worktree per task, and gates that are scripts.

A coding agent can write a week of code in an afternoon. Whether you can use that code depends on things that have little to do with the model: where it worked, what it was told, and how you check the result. This article describes the three agreements I work by, with what the Claude Code documentation says about each and what they look like in my own repositories. It is for developers who already use an agent and want its work to survive review.

The agent forgets, the repository remembers

An agent starts each session without yesterday. Whatever it should know about your project has to be somewhere it reads at the start: a CLAUDE.md file in the repository, or the AGENTS.md file that several tools share. Claude Code reads both.

Two details from the documentation shape how I write these files. The first is size: the advice is to keep such a file under two hundred lines, and to move anything that only matters for part of the codebase into a rule scoped to that path. The second is more important. The documentation is plain that these files are context, not enforced configuration. The agent will usually follow them. Nothing guarantees it.

So a rules file is the right place for things like:

  • how to run the tests and the type check;
  • conventions that are not visible from the code, such as a naming rule or a banned phrase in copy;
  • where the documentation for the installed version lives.

That last one is not hypothetical. Next.js now writes a block into AGENTS.md itself, telling agents to read the documentation that ships inside the installed package instead of relying on what they remember about older versions. It is a good pattern to copy: when the agent's memory is likely to be out of date, point it at the source.

A rule is not a guarantee

If something must happen every time, a sentence in a file is the wrong tool. Claude Code has hooks for that: shell commands that run at fixed points, such as before a tool is used or after a file is edited. The documentation describes them as deterministic control, as opposed to hoping the model chooses to do the right thing.

The split I use:

It is a preferenceIt must always hold
Written in CLAUDE.md or AGENTS.mdEnforced by a hook or by a check in the pipeline
"Prefer small components""The type check passes before a commit"
The agent can weigh itThe agent cannot skip it

If you find yourself writing "never" or "always" in capitals in a rules file, that is usually a hook or a test trying to get out.

Hands using an ivory mechanical keyboard on a blue desk mat.
Illustration made for this article.

One task, one worktree

Two agents editing the same checkout will overwrite each other. Git has had the answer for years: a worktree is a second checkout of the same repository, on its own branch, in its own folder. Claude Code can create one for a session with a single flag:

claude --worktree feature-auth

In practice this turns every task into a branch that can be read, tested and thrown away on its own. In my repositories it is the default. Finance OS has had 72 worktrees and PulseDash 29, each for one task. A cleanup script removes the ones that are clean and have not been touched for three days, because the cost of this habit is disk space and a long list of folders.

It also sets the size of a task. If a change cannot be reviewed as one diff in one sitting, it should have been two worktrees.

Gates are scripts

"Looks good" is not a gate. A gate is a command that exits with zero or does not. The ones that matter for a web application are the type check, the linter, unit tests, end-to-end tests in a real browser, an accessibility check and visual baselines that catch a layout that moved.

On PulseDash a full run on 29 October 2026 was 66 unit tests, 349 end-to-end tests, no accessibility violations and 46 visual baselines that matched. I mention the numbers because they explain why agent-written code is usable there at all: a change that breaks something old is caught by a script, not by me reading every line.

Gates have a blind spot, and it is worth being exact about it. They catch regressions. They do not tell you the feature was the right one to build, or that the new code is tested by anything other than the tests the agent wrote for it.

The report is not the result

At the end of a task an agent writes a summary: what it changed, what it tested, that everything passes. That summary is a claim. It is often right and sometimes wrong, and it reads the same either way.

So the last agreement is with myself. Before I repeat a result to anyone, I look at the thing itself: the diff, the output of the test run, the page in a browser. If a summary says a check passed, I want to see the command and its output, not the sentence.

What this does not solve

None of this makes the work unattended. Someone still chooses what gets built and answers for it when it is wrong. And all of it is tied to tools that change every few months: flags get renamed, files get new conventions. The three agreements should outlast that. Isolate the work, write down what the agent needs to know, and let scripts say whether it is done.

How this looks across my own projects is on the agent workbench page.

Sources

All documentation was consulted on 10 November 2026.