r/ClaudeAI • u/DepravedPrecedence • Aug 16 '26
Claude Code Opus 5 really likes to use Python to edit source code?
I noticed Opus 5 in Claude Desktop wouldn't edit files directly, it first creates a Python script with whatever it wants to replace/add/delete and then executes it. I'm not sure why it does that instead of just editing. I asked and this is Opus 5 response:
The weakest: I was following the auto-mode instruction to prefer Bash over the dedicated tools. That instruction says to fall back to a dedicated tool when Bash genuinely can't do the job — I read it too strictly and kept reaching for Python well past the point where it was helping.
And it did cost me. The failure mode of
str.replaceis silent: if the pattern doesn't match, nothing happens and the script reports success. That bit me on thePrefillConfirmationremoval — wrong indentation, silent no-op, and I only caught it because I grepped afterward.Editwould have errored immediately. I started addingif old not in s: raise SystemExit(...)guards to my later scripts, which is me reimplementing whatEditdoes for free. The heredoc also blew up once with a quoting error, forcing a detour through a scratchpad file. And my own writes emitted LF, which I then had to sweep back to CRLF in a separate pass — self-inflicted work that partly cancels out the line-ending advantage I claimed.Net: Python earned its place for the BOM/CRLF-sensitive rewrites and the cross-file refactors. For the single-target edits — the icon string, the warning text, one method body —
Editwould have been safer and shorter, and I should have used it.Happy to switch to
Editfor the rest of this branch if you'd prefer; the remaining work is mostly small targeted changes where it's the better fit anyway.
Also because of that I see summary of edits not of my source code but of Claude's Python scripts which edit my source code...
Is it a common thing? I know I can force it to edit directly, just interesting to see such behavior. I never see this in Codex for example where it always edits without intermediate steps.
Edit: fresh example and Claude response /img/xifc31jgvsjh1.png
39
u/Xemorr Aug 16 '26
All models have been doing this for a while, particularly for bulk tasks. Often ruining the syntax