# The AI said it added one line. The branch had zero changes.

> Source: <https://dev.to/uehara/the-ai-said-it-added-one-line-the-branch-had-zero-changes-1e98>
> Published: 2026-12-06 03:04:41+00:00

**Recommendation:** When running coding agents unattended with `claude --print`, have the parent commit and verify the branch after delegation rather than ending its turn waiting on a subagent notice.
More in the playbook "Designing agent systems": <https://wpnews.pro/playbooks/agent-architecture>

GitHub returned a 422 and refused to open the pull request. The branch had no commits on it. Yet the AI that produced that branch had just reported: "Added one line." And when our system ran git in the working copy, git agreed: `M docs/README.md 1 insertion`.

Both were true. The line existed. It just never left the working copy.

The AI was not lazy, and it was not joking. Trace what it did step by step and it turns out to have followed the rule to delegate almost too faithfully. This is the story of where that one line went.

We build a system that hands work to AI agents. A local LLM decides which agent gets a job, and Claude Code does the implementing. The system clones the target repo, creates a work branch, starts Claude Code with no person attached, and lets it work. When the AI has finished and committed its work, the system pushes the branch and opens a pull request on GitHub. The goal is that a person only has to look at the finished pull request and decide whether to merge it.

On our other repos, this loop already worked end to end. So we tried the next step: asking the system to work on itself.

The first task was deliberately tiny, just enough to see the loop go all the way around:

Add one line to docs/README.md linking DOGFOODING-LOG.md

DOGFOODING-LOG.md is the trial-run log for the system: every run, what we asked, what broke, how we fixed it, and whether it passed. The task was to link it from the docs README. It was hard to imagine a way to fail.

The repo has a CLAUDE.md, the rules file Claude Code reads before it starts working. The rule was headed "main session = coordinator". Translated from the original Japanese, it said the main session launches specialist agents (task-decomposer, implementer, qa, reporter and so on) directly and in series through the Task tool; delegation is mandatory, and the main session must not bypass implementer and implement the work itself.

`implementer` is the name of the subagent that does the editing. The parent conversation sorts the work by type and coordinates, and specialist child AIs edit the files.

The rule was thorough. It even covered small fixes: a LIGHT_EDIT is delegated to a single implementer.

LIGHT_EDIT is the work type for a light edit. Adding one line to a README is exactly that. Even for a one-line change, the parent does not write it; it calls one implementer.

The AI that picked up the task read the rule first, and obeyed it. Its own words, from the log:

Delegating to implementer... waiting for the completion notice

It did not write the README itself. It handed the work to a child AI. Up to that point, it did what the rule asked. Waiting for a notice, though, was not something the rule said.

The catch: this AI was running unattended, one shot.

In an interactive Claude Code session, the conversation keeps going after the parent hands work to a child. When the child finishes, a notice arrives, and the parent picks up from there.

A one-shot run (`claude --print`) does not work like that. The AI answers once, and that is the end. The moment it wrote "waiting for the completion notice" and returned its answer, its turn was over. Nobody was left to wait, and nobody was left to receive the notice.

When the parent's turn ends, whatever was supposed to come next, "look at the result, then commit", never happens. In an unattended run, committing the change in the working copy is part of the AI's job. It never got that far, and the system moved on to its next step.

This is the strange part. The AI reported "Added one line."

When the AI's turn ends, our system runs `git status --porcelain` and `git diff --stat HEAD` in the working copy itself, and records the output as the change summary. The AI does not write it; git counts it. And git said `M docs/README.md` and `1 insertion`.

`M` marks a file that has been modified in the working copy and not yet committed. `1 insertion` is one added line. So docs/README.md in the working copy really did have one new line. The report and git's summary were both telling the truth about the working copy.

The only thing missing was a commit.

Next, the system pushed the work branch. A push sends commits to GitHub. Changes still sitting in the working copy stay on the machine.

Getting a change to GitHub with git takes three steps. Edit the file in the working copy. Turn that edit into a commit on the branch with `git add` and `git commit`. Send the commit to GitHub with `git push`. Our one line had stopped at step one. The system ran step three as usual. With no commit to send, what reached GitHub was a branch identical to main.

The branch pointed at the same commit as main: zero commits ahead. When the system tried to open the pull request, GitHub answered 422: there are no commits between main and this branch.

The AI said one line. Git's summary said one line. GitHub said zero. All three were right. The line was in the working copy and not on the branch. They were simply looking at different places.

The other funny part: every step on the system's side worked. Cloning its own repo with a token, creating the work branch, pushing: all of that succeeded in this run. It proved the system could reach its own repo. The branch it delivered just happened to be empty.

At this point we could have decided "no subagents in unattended runs". But when we checked, that was not the problem.

Even in a one-shot run, a subagent works correctly if the parent waits for it on the spot. The child works in its own context, its file changes stay in the working copy, and its result comes back to the parent. We ran it on the machine that does the work and confirmed exactly that. The hunch that "delegating should be fine" was right.

The rule itself said "in series". What tripped was not the delegating; it was the waiting. This AI chose to run the child in the background and wait for a notice, inside a run where no notice could ever arrive.

On other repos, the same system had never stalled this way. The reason is simple: their CLAUDE.md files had no "delegate" rule, so the AI opened the files and edited them itself.

Only when it worked on this repo did it read this repo's rules, and carry a rule written for interactive sessions into an unattended run. The rule and the AI that followed it lived in the same repo. It tripped over its own rules exactly when we asked it to improve itself.

While the system worked on other repos, this mismatch stayed hidden; it surfaced only when the system worked on itself. The trial-run log records it as the eighth mismatch found (Gap#8), with what happened, why, and the fix. Most facts in this post are quoted from that log.

Every AI that works in a repo reads its CLAUDE.md: the one chatting with a person and the one running alone, without distinction. From the reader's side, a rule is a rule.

The fix had two parts. When starting the AI unattended, we add one sentence saying, in effect, that it may delegate to subagents but must wait for their result before moving on. And if the branch has zero commits ahead of main, the system does not push or open a pull request; it skips delivery and records in words what happened. Delegation itself was not banned. Only the waiting was fixed.

The first sentence is not an edit to the repo's CLAUDE.md. It is appended to the instructions only when the AI is started unattended. Its key parts read "you MUST run any sub-agent SYNCHRONOUSLY" and "NEVER run a sub-agent in the background or 'wait for a completion notification'", and it also asks the AI to check that every change is committed before finishing. The CLAUDE.md rule stayed as it was; we only added how to wait in an unattended run.

The second lets the system notice zero lines before GitHub has to say so. Until then, the only signal of an empty branch was GitHub's 422, and that 422 told us only that a pull request could not be opened. After the fix, the system counts the commits ahead of main before pushing, and if there are none it skips opening the pull request and records a message saying the actor (the AI working inside the system) did not commit any change, with the branch identical to its base.

Then we asked for the same task again. This time the AI added exactly one line to the README, committed it, the branch had a diff, and a pull request was opened: #1, the first pull request in that repo. The diff was exactly one line.

The second-run AI committed its line itself. Working copy to branch, branch to GitHub: the line that stopped at step one the first time made it through all three steps.

We asked for the same task once more in the next check, and got PR #2. That AI did not touch the docs README; it appended the link to the end of an existing sentence in the top-level README.md. The "one line" that never left the working copy the first time had now arrived in two places.

Each pull request carries a short English summary of the task that the system writes before the work starts. The request said "docs/README.md", but the first sentence of both summaries said "the `README.md` file": the `docs/` had dropped out. In the second-run pull request, the steps and limits still said `docs/README.md`, and the AI wrote to the docs README. In the third-run pull request, the `docs/` was missing from the steps and limits too, and the AI wrote to the top-level README.

Both pull requests were then closed without being merged. The task had only ever been a way to see the loop go all the way around.

So today, neither README on main links to DOGFOODING-LOG.md. Counting from the day the AI reported "Added one line", the number of link lines that made it into the README is still zero.

First in a working copy, then in two closed pull requests. That one link has been written three times, and it has yet to reach main once.

`claude --print` works this way
