Running into this?

I asked my agent to remove something; instead of removing it, it added another converter on top: the value is converted to another form, then right back to the form it started in

For a layer to stay, I have my agent write down what forces it from the outside, with file and line: an outside source that delivers the value in that shape, a measured speed difference, or an outside caller that needs it. Another function we wrote ourselves expecting it doesn't count as a reason. A layer whose reason can't be written is deleted together with its inverse, and the callers take the original value directly.

beforebackground mechanisms that say what they protect: 1 of 73 (Oct 20)
after57 of 133 · cached copies stayed only when they gave the same output faster than the path without them (5 of 5)
for every converter and wrapper the removed value passes through, have your agent write its outside reason with file:line; delete the ones without one from that path, and show the output didn't change on the same input
Text for your agent · 24 lines
Situation: you told your agent to remove or simplify something. Instead of removing it, it added another layer on top: a converter, right after it the inverse, a compatibility wrapper, or a function marked "old" and left in place. The code works, but the value changes shape several times before it reaches the place it's used, and every new request brings one more layer.

Why: to avoid breaking existing calls, the agent picks the safest move: it puts an adapter in front of whatever it touches. A rule written as "don't add compatibility layers" often doesn't stop it: anthropics/claude-code#2901 is the same complaint from someone who had written the rule out explicitly. The agent can't remove a layer without asking why it exists; and when asked, the only reason for most layers turns out to be another function in the same project, not something forced from outside. In my setup on Oct 20, 72 of 73 background mechanisms didn't say what they protected.

Do:
(Replace <value> with the name in the code of the thing you had removed. Run the commands at the root of the git repo.)
1. Find the value's path: every function it passes through from where it enters from outside to where it's used. If the value enters from more than one place (an argument, an API response, a file), each entry is its own path.
   git grep -nEi '<value>'
   In those lines, find the definition and the calls of every function the value passes through, by its name: git grep -nw '<function name>'. Write each path on one line: entry (file:line) → layer → layer → use (file:line). The function that reads the value from outside is the entry; a function that prints, stores or computes with it is the use; only the ones in between are layers.
2. Next to each path, write with file:line the shape read at its entry (the unit an API returns, the format of a file being read, a field the user types) and the shape its use gives to the outside (the unit printed on screen, a file written, a published interface someone else calls). If the two differ, one converter stays at that path's boundary and its outside reason is those two lines; if they're the same, a layer on that path can only have a measured speed difference as its outside reason.
3. Save the output before deleting: run the command that produces the project's output using this value (the tests or the program itself).
   <output command> > "$(git rev-parse --git-dir)/before.txt" 2>&1
   Test that the command runs these paths: at every use file:line you wrote in step 1, deliberately multiply the value by 1000 and run step 5's line → diff prints a difference (if it doesn't, pick a command that really prints the value), then undo: git checkout -- <use files>
4. Delete every layer whose outside reason can't be written from that path: callers take the original value directly. Don't write a comment, a "removed" note, or a line in your instructions file for the deleted layer: the history stays in git.
5. Run the same command again and compare the two outputs:
   G=$(git rev-parse --git-dir); <output command> > "$G/after.txt" 2>&1; diff "$G/before.txt" "$G/after.txt" && echo "same output"
6. If step 5 printed "same output", commit once; if it printed a difference, one of the deleted layers had an outside reason: undo with git checkout -- <files you changed>, write its reason in step 2 and run again from step 4.
   git add -A && git commit -m "<value>: removed <names of the deleted layers>, no outside reason"

Check:
- Step 5's line prints "same output".

Don't:
- Don't mark the layer "deprecated" and leave it in place: the agent will call it again.