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.replace is silent: if the pattern doesn't match, nothing happens and the script reports success. That bit me on the PrefillConfirmation removal — wrong indentation, silent no-op, and I only caught it because I grepped afterward. Edit would have errored immediately. I started adding if old not in s: raise SystemExit(...) guards to my later scripts, which is me reimplementing what Edit does 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 — Edit would have been safer and shorter, and I should have used it. Happy to switch to Edit for 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.

添加评论
点赞收藏
点踩分享查看原文
评论
?
参与讨论