writingmaclulich.com

Your AI agents keep patching the same files. Git history shows which ones

The argument in 50 seconds, with music. The numbers are Rigby’s (my harness for AI coding agents) to 5 November 2026, and the last scene is Neuma (a product I’m building) on 6 November.

Five changes that make your AI agents redesign what they keep patching

  1. Count fix commits per file, and call two in 30 days a hotspotIn my setup, 46 of 127 source files were already past that line.
  2. Interrupt the agent at a hotspot and ask for a redesignMy disk cleanup took 21 fixes before I stepped in. Now the hook steps in at two.
  3. Make the warning quiet enough to be heardMine fires once per file per session. The first version fired 689 times in a day.
  4. Tell an unattended agent how to decideMy hook says only deletions here, and an agent working with nobody watching committed one: 33 lines out, 5 in.
  5. Ask for a redesign that shrinks the codeMy cleanup came out 12 lines shorter, and a 413-line test-skipping script was deleted for pytest’s own cache.
The numbers are mine: Rigby to 5 November 2026, and Neuma on 6 November.

Agents fix the bug in front of them

This is for you if your AI coding agents keep fixing the same files and each fix looks fine in review. I run mine with Rigby, my own harness that runs several of them at once, and the story starts with a disk that filled up.

Ask an agent to fix a bug and it fixes that bug. It rarely asks why the same file keeps needing fixes, so each fix adds one more special case.

Rigby’s disk cleanup is where this caught up with me, when the disk it was meant to protect filled up.

My 4 TB disk was 98% full, and one project’s agent checkouts held 589 GB of it

Dropbox local copies1,317 GB
One project’s agent checkouts589 GB
LM Studio models315 GB
Docker304 GB
5 November 2026, 107 GB free. Dropbox, local models and Docker are mine, not the harness’s.

The disk cleanup took 38 commits in 60 days across six files, 21 of them fixes

38
commits to the cleanup in 60 days
21
of them fixes, 29 counting each file a fix touched
6
files
Git history of the harness, the 60 days to 5 November 2026, before the redesign. Corrected 12 November 2026: first published as 47 commits and 29 fixes, which counted each fix once for every file it touched. How I found it

Each fix handled the case in front of it. The last one left fourteen build folders, most at 30 GB, on a nearly full disk.

The rule against this was already written down, in a skill and a playbook. The agents kept patching anyway, and in the end I had to tell them to stop and redesign it.

Now I don’t rely on a written rule to stop it. Git history already holds the evidence.

Count fix commits per file to find hotspots

Write fixes as fix: commits and a file’s fix count is one git query over the last 30 days.

46 of Rigby’s 127 source files had two or more fixes in 30 days

2
fixes in 30 days marks a hotspot
46 of 127
files past that line
6
fixes on the busiest cleanup file
Its Rust and Python source, 5 November 2026. A fix is a commit whose message starts with fix: or fix(scope):.

I call two fixes in 30 days a hotspot, and a hook now checks every file an agent edits against that line.

Interrupt at two fixes, ask for a redesign

So the check lives where the edit happens. When an agent touches a hotspot, it gets the file’s recent fixes and a request for a redesign instead of one more patch.

29 band-aids before I stepped in. Now the hook steps in at two

Band-aids on the cleanup’s files before I stepped in29
Fixes to a file before the hook steps in2
Rigby’s disk cleanup over the 60 days to 5 November 2026. The 29 counts each file a fix touched, which is the 21 fixes above. The reminder counts fix commits per file over 30 days.

Editing a hotspot now interrupts the agent and asks for a redesign, with no one watching

  1. The agent edits a hotspotAny file with two fixes in 30 days
  2. It sees the evidenceThe three most recent fixes, from git
  3. It’s told the mechanism is the bugDelete and replace, don’t add a case
  4. It proposes before it patches“This would be fix 7”, and the replacement

What the agent sees, simplified

lib/rigby/idle_builds.py has 6 fix commits in the last 30 days:
the mechanism is the bug.
Recent fixes:
  fix(housekeeping): what the hourly sweep reclaims is reported as a defect
  fix(worktrees): a worktree's test stacks go with it
  fix(idle-builds): enforce build-output limits on every rig and show what is kept
Only deletions here; replace the mechanism with the native tool.
Before another patch here, tell the user this would be fix 7
and propose the replacement; net state must not grow.

It’s a hook that runs after every file edit, for Claude Code and Codex agents. It never blocks the edit, because a gate would be the same band-aid shape it warns about.

Make the warning quiet enough to be heard

Getting the warning quiet enough to be heard took longer than getting it to fire.

The first version fired 689 times in a day. Now it speaks once per file per session

689
times the first version fired in a day
Once
per file per session is how often it speaks now
The first version’s count. Part 2 has the full account.

Fire once per file per session, and again only on a new fix, or the warning becomes noise.

Tell an unattended agent how to decide

In my setup, the user an agent reports to is usually my lead agent, which plans and merges the work, not me. So the reminder carries its own rule for the answer: only deletions here, and net state must not grow.

On 6 November a Neuma agent stopped at fix 21 and deleted code instead, with nobody watching

  1. 07:27, it edits a hotspotThe calendar sync: 20 fixes in 30 days
  2. The hook steps in“The mechanism is the bug”
  3. 07:29, it answers“This would be fix 21”, and a replacement
  4. 07:49, it commits a deletion33 lines out, 5 in
Sydney time. A Codex worker on a task from my lead agent; I sent neither of them a message that morning. Committed, not yet merged to main.

What it answered, simplified

sync.rs has 20 fixes in 30 days, so this would be fix 21.
My replacement proposal: remove its early refusal and route the
failure through the existing sync path, which already records
that the account needs reconnecting.

That’s the loop with nobody in it. My lead agent handed out the task, the hook caught the patch, and the worker chose the deletion.

It doesn’t always land. Earlier that morning the same agent patched another hotspot anyway, adding 88 lines, because the guide the reminder pointed to wasn’t in that checkout. Part 2 is how that got fixed.

If your reminder points at a guide, make sure it exists in every checkout your agents work in.

Ask for a redesign that shrinks the code

For my cleanup it was one rule: while free disk is under a floor, remove the least recently used worker checkout.

One rule replaced the trimming: 4 constants and 3 functions out, 2 functions in

−4
constants
−3
functions removed
+2
functions added
−12
lines of engine code, 189 added and 201 removed
Installed on 6 November. Engine code only.

The band-aid you’ve probably met is in the tests. Neuma’s deploy gate had a script that remembered which tests had passed, so the next run could skip them.

Neuma’s test-skipping script took 39 fixes, then was deleted for pytest’s own cache

39
fixes to the script, 32 of them in its last 30 days
413
lines in the script, all deleted
1,421
lines out in the commit that replaced it, 353 in
Neuma’s deploy gate, from July to 3 November 2026. The fixes are commits on the script itself.

Before: a receipt for every pass, simplified

# after a gate phase passes, write a receipt
write_receipt(phase, git_tree, environment)   # PASS, on this exact tree
# next run: skip the phase while a receipt matches
if receipt_matches(phase, git_tree, environment, max_age="24h"):
    skip(phase)

After: pytest’s own cache, simplified

# pytest already keeps a cache of what happened last run
pytest    # reruns what failed, what changed and what never ran

pytest already did most of that job. So the reminder asks for exactly that: less code, and the tool that already owns the job.

How far to trust it

It caught one on its own, and missed one the same morning

  1. One catch, one missThe same agent, one morning: a patch of 88 lines anyway, then a deletion. And I asked for the cleanup’s redesign myself
  2. A reminder, not a gateBy design, because a gate that blocks edits is the same band-aid shape it warns about
  3. Too new to measureThe cleanup’s redesign and the hook’s newest version went live on 6 November. The Neuma deletion isn’t merged yet

What to copy

You can build this with git history and one hook

  1. Write fixes as fixesConventional commits make them countable
  2. Pick a lineMine is two fixes to a file in 30 days
  3. Show the evidenceThe last few fixes, not a generic warning
  4. Ask before the patchThe fix number and a replacement, before any code
  5. Fire oncePer file per session, or it becomes noise

The query is one line of git. It lists every file with two or more fixes in the last 30 days, busiest first, and a fix that touches several files counts once for each.

Fix commits per file, last 30 days

git log --since="30 days ago" --no-merges -E \
  --grep='^fix(\(.+\))?:' --name-only --pretty=format: \
  | grep . | sort | uniq -c | sort -rn | awk '$1 >= 2'

When an agent edits one of those files, print the reminder above with that file’s name, its fix count and its three most recent fixes, once per file per session.

How it works

Find the hotspot, interrupt once, ask for a redesign

  1. Count fixes per filegit log, last 30 days, messages starting fix
  2. Mark hotspotsTwo or more fixes
  3. Interrupt on editOnce per file per session, again on a new fix
  4. Ask for a redesignFix number, replacement, no net growth

The detection is one git log query inside a hook that runs after each edit.

Part 2 is how I got it quiet. It also covers the second hook, which catches my agents when they merge.