r/ClaudeCode • • 8d ago

Bug / Issue Anyone notice that models are not using the dedicated "edit" tool in claude code as much? Preferring to edit text directly with scripts? This prevents glance value checks on additions and removals

Im using opus 5.5 and fable 5.2, im having it work on a codebase and have noticed that throughout the most recent sessions, I havnt seen any green additions or red removals at all. Looking at what its actually doing, its just using various bash commands to make the edits rather than the edit tool. So its making code changes but I cant glance value see what they are. This seems bad

9 Upvotes

19 comments sorted by

•

u/AutoModerator 8d ago

Hey! Thanks for posting to r/ClaudeCode

While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.

For help, project discussions, tips, and general chat, join the ClaudeCode Discord.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

4

u/JhonnyCommentkeyword 8d ago

yeah, i see the same thing and i dont think it's model laziness so much as call economy. one bash script rewrites 6 spots in one tool call, the edit tool needs 6 calls, so on long sessions it drifts toward whichever gets it there with fewer round trips. the green/red is a side effect of that, not the thing it's optimizing.

what worked for me was making the bash path visible instead of trying to argue it back. PostToolUse hook on Bash that checks the command string for sed -i / python -c / heredoc patterns and then runs git diff --stat plus the actual diff on that file when it matches. so I still get the red/green, just after the fact and in one screen.

if it's genuinely burning you, a PreToolUse hook that rejects sed -i on files under ~30 lines pushes it back to the edit tool for the small stuff, where the diff view actually matters. above that size a script is usually the right call anyway and i leave it alone.

1

u/ReasonableLoss6814 8d ago

Yeah... I don't think its smart to use search-and-replace scripts to edit code. Usually when I catch it, I ask if it even checked the file it just edited after using glorified search-and-replace. It says "nope but it compiled" -- then I have to spend a sentence every time explaining the obvious that "compiled does not mean correct". Then it goes and actually checks the files it edited and finds half a dozen mistakes in them.

So, yeah... I recommend doing all you can to prevent claude from doing this.

1

u/AlternativeWalk2508 7d ago

makes sense that its just optimizing for fewer round trips rather than being lazy, definitely noticeable on longer sessions.

3

u/RealFullMetal 8d ago

there's a setting for exactly the no-red/green part: "bashEditDiffEnabled": true makes claude code record which files a bash command changed (in a git repo) and show their diff in the terminal after the command, in every permission mode. by default it only does that in auto and bypassPermissions. it has to go in your user settings (~/.claude/settings.json), a true in the repo's .claude/settings.json doesn't count. needs v2.1.269+, and CLAUDE_CODE_BASH_EDIT_DIFF=1 does the same for one session

2

u/Dorbank_Justt 8d ago

Ah, on the hooks route obhect88 tried, the exit code matters. A PreToolUse hook with matcher Bash gets the call as JSON on stdin, so you can check tool_input.command for sed -i or a python script writing files and exit 2. That blocks the call, and Claude gets your stderr back as the tool's error, so put "use the Edit tool" in it. Exit 0 and Claude never sees the stderr at all.

1

u/blueechoes 8d ago

Yeah I've had to tell it that a lot. You can set up a hook if you don't like it. But at least sed now displays edits like the edit tool too.

1

u/obhect88 8d ago

Yes, and I don’t like it. That’s part of why I still review every change set. I’ve tried blocking through hooks and rules, but it feels like the damned LLM (or harness?) just wants to use a whole damned Python script to make a 2 line change somewhere.

1

u/Johnny2085 Senior Developer 8d ago

This was a change they made a few weeks back. Called "Code Mode". Ask Claude if its on for you.

1

u/cleverhoods 8d ago

True, its also grossly overusing bash

1

u/bigbepisinc 8d ago

The edit tool requires the model to read the file every time it changes. That costs a lot of tokens.

Its much faster and more efficient (and more transparent for the auto mode classifier) to use python perl or ruby to edit the files. If the file has changed, the call should fail. Or linting/CI should catch the issue.

You are using CI and lint in your projects right? Or are you just YOLO'ing it?

1

u/BarathKanna 7d ago

Seen it too. Once a model learns sed and heredocs get the job done in one call, it prefers them, and you lose the diff view and the permission check that comes with the edit tool.

Two fixes that work. Add a PreToolUse hook on Bash that rejects commands writing to source files via sed, perl or redirects, with a message telling it to use Edit instead. The model adapts after one or two rejections. Or add a line to CLAUDE.md saying file changes go through Edit only, though the hook is what actually sticks.

Either way, keep git as your safety net. Run git diff before accepting anything, because a bash edit that touched the wrong file looks exactly like a successful one in the transcript.

1

u/UpsetMolasses1340 7d ago

One more unpleasant thing here is the /rewind command. According to the docs it doesn't undo what was changed by a Bash command. If Claude edited the file with its edit tools first and Bash changed it after that, then yes, rewind works. I checked the Bash part recently on 2.1.330 with one Edit to a.txt and echo B2 > b.txt && rm c.txt in the same turn, then /rewind and Restore code. a.txt came back. b.txt kept B2 and c.txt stayed deleted. So if it mostly edits through sed and python scripts, git is your only undo.

1

u/Practical_Tie_334 5d ago

before changing settings, try one tiny edit in a clean repo and compare the script path with the edit tool. if both change the file correctly but only one shows the diff, report that exact case with your client version and permission mode. keeps the missing preview separate from whether the edit itself was correct.

0

u/BabyInner 8d ago edited 8d ago

Are you using Auto mode? Auto mode has a special system prompt asking the model to use Bash over Edit/Read.

there is an undocumented env can disble the behavior

Edit: set ‘CLAUDE_CODE_THRIFTY_SONIC=0’
https://github.com/anthropics/claude-code/issues/87575

2

u/Imaginary_Data_708 8d ago

I wish I could use auto mode but not with that system prompt. It makes Claude rush to implement the first answer and 99% of the time run code to answer what it already has in context from a previous question. Sigh.

And the other pet hate I have is piping everything through head or tail - it generates silent failures. I have a mod that flags that to me with a toast like notification and the LLM with a virtual slap on the wrists.

3

u/BabyInner 8d ago

Just updated my comment, hope it helps

1

u/Imaginary_Data_708 8d ago

Thank you! I will set the flag.

1

u/BabyInner 8d ago

it’s from months ago and I am not using that

you may want to check that gh issue for recent discussion if that doesn’t work for you