Published on , Aurélien Vandaële

How to verify that a Claude Code subagent really did what it reports

Don't trust the report, check the trail. A subagent returns only a summary, and that summary can be wrong. In my chain, every coding agent must return the SHA of its commit. A script then checks in git that the commit exists, starts from the right place, contains the tests and carries no AI attribution. If it fails, I don't resume that agent: I start a fresh one.

The problem: a summary is not evidence

The Claude Code documentation says it in one sentence: the subagent does the work in its own context and returns only the summary. The orchestrator, meaning the main conversation, sees neither the commands that ran nor their output. It sees a text that says “done”.

That text is wrong in both directions. Agents announced they had finished when they had stopped to wait for a command running in the background: nothing was produced, I tell that story in the article on my postmortem loop. Another returned the single word “placeholder” as its whole answer, with its fix staged but never committed. The other way round, two agents stopped midway while their work was actually done, just not committed: it read as lost, and was nearly redone.

In all three cases, the truth was in git. Nobody had looked.

The method: git as the only evidence

My chain has one agent write the tests, a second write the code, and a third review (details in the article on tests written before the code). Before each coding agent, the orchestrator records the starting commit. The agent must return a short contract, including a SHA: line that can never be “placeholder”. Then the orchestrator runs the check:

verify.sh <starting-commit> <claimed-sha> --expect-tests
verify.sh <starting-commit> <claimed-sha> --prev <sha-before-the-fix>

The script runs seven checks, all with plain git commands:

  • The claimed SHA exists. Otherwise, nothing was committed.
  • It differs from the starting commit. Otherwise, no commit was made.
  • After a fix, it differs from the SHA before the fix (the --prev option). An amend creates a new SHA: an unchanged SHA means nothing happened.
  • It descends from the starting commit and is reachable from `HEAD`. Otherwise, history was rewritten or the commit lives on another branch.
  • No commit message carries `Co-Authored-By: Claude` or “Generated with Claude”. I forbid it, and one agent had added it to four commits in a row.
  • With `--expect-tests`, the commit contains at least one test file.
  • The working tree is clean. Otherwise, the script lists the files left behind, without failing.

The rule that matters most is what happens on failure: the failing agent is not resumed. Its context holds a false belief, it is convinced it committed. A fresh agent is started. After two failures, the orchestrator does the work itself, marks those commits as written outside the chain, and warns the final reviewer that they are not trustworthy.

A real case: 78 green tests, and the wrong tests in the commit

On 24 August, on one of my apps, the coding agent reported 78 of 78 tests green and a full check with no error. Both were true, but in its working tree. It had added only its two source files to the commit. The tests written by the previous agent, deliberately left uncommitted so they could be handed over, were not in it.

So the commit held 322 lines of a new component with the old test file. Anyone checking out that commit would have run 61 stale tests against new code.

At the time, the script did not look at whether the commit contained a test file. It printed “ok”. The only signal was its last line: the working tree is not clean. Two things changed since. The coding agent's brief names the test files to commit explicitly. And the --expect-tests option fails the check when a task has tests and the commit contains none.

The AI attribution follows the same logic. A hook blocks it at commit time. The script looks for it again afterwards, in the messages actually recorded: the hook reads the command, the script reads the history. And since it is code, the script has its own tests: 11 cases.

What the script lets through

  • A commit that is not its own. On 26 October, another Claude Code session was committing on the same branch. While my agent had its fix staged, the other session made a commit that swept it in along with its own files. My agent then reported that commit as its own. The script passed: new SHA, tests present, no AI attribution. Only the final reviewer noticed that the commit title had nothing to do with the task. Comparing the commit's title and files with what the task expects is logged in my ledger, not done yet. Meanwhile, the real protection is one worktree per session, covered in the article on parallel sessions.
  • Quality. The script proves that work exists, not that it is good. Tests that pass on wrong code are the job of the reviewer, who gets the diff and never the conversation.
  • A shortcut that does nothing. The agent also returns a fingerprint of the tree it checked, to avoid rerunning the whole suite when nothing changed. That fingerprint includes files that are never committed, so in a repo that has some, it never matches: the full check reruns for nothing. That is wasted time, not a missed error, and it is still open.

How to start

You don't need my plugin. You need three things: ask for a SHA in the agent's answer format, record HEAD before starting it, and look at git afterwards. The minimum:

BASE=$(git rev-parse HEAD)   # before starting the agent
# the agent returns SHA=<sha>
git rev-parse --verify --quiet "$SHA^{commit}" || echo "nothing was committed"
git merge-base --is-ancestor "$BASE" "$SHA" || echo "history rewritten"
git merge-base --is-ancestor "$SHA" HEAD || echo "commit not on this branch"
git diff --name-only "$BASE..$SHA"   # what the agent really changed
git status --porcelain               # what it left behind

Claude Code also offers a SubagentStop hook event, which fires when a subagent finishes and receives the text of its final response. I run the check from the orchestrator instead, which recorded the task's starting commit before starting the agent.

Then add a check each time an agent misleads you in a new way. Most of the checks in my script trace back to a specific incident in my ledger.

Article written with the help of AI, from my daily practice and my projects.

The whole notebook