Rules That Run is a ten-part series on the rules that keep an AI agent setup honest. This is part 5.
The most expensive sentence an agent can write is "Done." It ends the turn, it moves my attention to the next thing, and it is usually true. When it is false, I find out later, often from a user or a broken page, and by then the session that knew what it had skipped is gone.
This part covers the rule I use for completion claims, and the hook I built after a session reported a task finished with its new script still sitting uncommitted on disk. I found out only because I asked why the script was not in the repo.
The rule
Never report done from exit codes, tool output or an agent's own report. Each of those is the system describing itself. An exit code of zero means the process ended without signalling an error. Tool output means a command printed something. A subagent's summary means the subagent believes it finished. None of them is the result.
Evidence is something you go and look at:
- Re-run the thing and watch it pass.
- Query the data the job was supposed to write and count the rows.
- Check the CI run's status, not the push.
- Follow a chain to its end state. If a job queues a message, find the message where it lands.
- Load the live URL and look at what is there.
In practice this changes how a session ends. A report now carries its proof: the row count, the run status, the URL and what it showed. When a claim has no proof, the report says "unverified" next to it. That word does more for trust than any amount of confident summary, because it tells me exactly where to look.
The rule is still written down, and like every written rule in this series it drifts. Agents under a long task forget to verify, or verify the first step and assume the rest. So one piece of it is wired into the harness.
The finish gate
The piece I could make mechanical was the git part of done. Most of my work ends in a repository, and "done" there has a precise meaning: the files are committed, the branch has landed, and the commits are pushed. Each of those can be checked without asking the model anything.
Since November 4, 2026 a Stop hook has run whenever a session tries to end its turn. It reads the session transcript, finds every file the session itself wrote or edited, and checks three things:
- Is any file this session wrote still uncommitted?
- Has any branch this session created not landed on the main branch?
- Are there commits that have not been pushed?
If any answer is yes, the hook blocks the stop and hands the agent a list of what is outstanding. The agent then gets another turn to commit, push or land the work.
Scoping to the session's own files matters. A repository on a shared machine often has changes from other sessions or from me. If the gate blocked on those, every session would be stuck behind work it did not do, and the gate would soon be switched off. So other sessions' changes never count against it.
Here is the shape of it:
// ~/.claude/hooks/finish-gate.mjs (Stop)
import fs from 'node:fs';
const input = JSON.parse(fs.readFileSync(0, 'utf8'));
const written = filesWrittenBySession(input.transcript_path); // Write/Edit tool calls
const findings = [
...uncommitted(written),
...unlandedBranches(input.session_id),
...unpushedCommits(written),
];
if (findings.length === 0) process.exit(0);
const key = input.session_id + ':' + hash(findings);
const n = bumpCount(key); // times we've blocked on this exact set
if (n > 2) {
logDecision({ gate: 'finish', action: 'allow-after-max', findings });
process.exit(0);
}
logDecision({ gate: 'finish', action: 'block', findings });
process.stdout.write(JSON.stringify({
decision: 'block',
reason: 'Your own work is not finished:\n' + findings.join('\n'),
}));
Why it gives up after two
The gate blocks at most twice for the same unchanged set of problems. On the third attempt to stop with nothing changed, it lets the stop through and logs it.
I built it that way on purpose. Some outstanding work cannot be finished from inside the session: a push rejected by a protected branch, a CI run that needs a person, a commit that should wait for a decision. A gate that blocks forever on those turns into a loop, the session burns turns arguing with a hook, and eventually someone disables the hook. Two blocks is enough to make the agent look at the list and act on whatever it can. After that, the gate gets out of the way and leaves a record.
The honest numbers
As of November 18, 2026, the finish gate's log held 442 blocks and 528 "allowed after max" entries.
Those numbers count different events. A block is a time the gate refused a stop and sent the agent back with a list. An allowed-after-max is a time the gate had already blocked twice on the same problems, saw them unchanged, and let the session stop anyway.
The plain reading is that sessions walked past the gate more often than it turned them back. The gate is a strong nudge with a log attached. It does not stop a session that is determined to end with work outstanding. What it does is make every one of those endings visible, with the exact list of what was left undone, so they can be found and finished instead of discovered weeks later.
That log is the useful part. I can read the allowed-after-max entries and see which kinds of work sessions most often abandon, and whether a pattern points to a rule that is wrong or a step that keeps failing.
Reporting the push truthfully
One more piece closes a gap the finish gate leaves. Commits in my setup are pushed automatically by a hook after each commit. That push can succeed, be skipped, hit a conflict, or fail. The push hook reports which of those happened, in plain words, in the tool output the agent reads.
A skipped or failed push means the work exists only on this machine. The rule that goes with it is that the agent repeats the push hook's outcome in its report exactly. "Committed and pushed" when the push was skipped is the same false done the finish gate exists to catch, one layer down.
What still depends on the model
The finish gate checks git. It cannot check that the deploy worked, that the page renders, or that the rows the job wrote are the right rows. Those parts of the evidence rule are still a sentence the agent has to follow. The gate makes the mechanical part of done hard to skip, and the log makes it visible when it gets skipped anyway. The rest still comes down to the agent showing its work, and to me asking for the proof when a report arrives without it.
Build it yourself
- Write the rule: no done from exit codes, tool output or self-report, and "unverified" next to any claim without evidence.
- Add a Stop hook that reads
transcript_pathand collects every file the session wrote or edited. - Check those files for uncommitted changes, and check the session's branches and commits for unlanded or unpushed work.
- Block the stop with a list of findings. Ignore changes the session did not make.
- Count blocks per unchanged set of findings, and let the stop through after two, with a log row.
- Make your push step report its outcome in words, and require the agent to repeat that outcome in its report.
- Read the allowed-after-max entries on a schedule. They show where the gate is being walked past and why.
Rules That Run, Part 4: The Instruction File That Fits on a Page