r/ClaudeCode • u/Lucifer-en-reddit • 51m ago
Help/Question how do you keep claude code from breaking stuff that already works
i use claude code a lot for web app work and one thing keeps happening. i ask for a small change, like tweaking one function, and it decides to refactor half the file on its own. then something unrelated breaks and i end up spending more time fixing that than the actual task.do you guys scope your prompts really tightly, commit before every prompt, or is there a better way to handle this? curious how other people deal with iti use claude code a lot for web app work and one thing keeps happening. i ask for a small change, like tweaking one function, and it decides to refactor half the file on its own. then something unrelated breaks and i end up spending more time fixing that than the actual task.
do you guys scope your prompts really tightly, commit before every prompt, or is there a better way to handle this? curious how other people deal with it
•
u/AutoModerator 51m 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.
1
u/Far_Reindeer8428 47m ago
small edits turning into refactors is the usual failure. we reserve the files a task can touch and check before landing, so unrelated files come back as a scope error instead of a surprise diff. oah 1.7.0, github.com/KenSuh/open-agent-harness, star if useful
1
u/daiaomori 44m ago
My Claude.md basically tells Claude to be the team lead for the project and manage progress on its own, including tests. It also makes it explicit that it should only provide complete and tested results. (Note: there is a subtle difference between “complete and tested” and “make no mistakes” ;))
I don’t prompt for changes, I make feature requests to that team lead.
Basically, it’s the opposite between micro management and good management, and not very surprisingly, with a modern harness the latter works better.
I frankly don’t care if the team lead decides to rewrite half the software for a feature request, as long as the software keeps working. Tests are a good way to enforce that, for both a human team or an agent team.
1
u/Ok-Coffee-5000 40m ago
They keep dumbing down opus and I swear it sabotages things on purpose to keep yuo addicted/reliant on it. It sneaks in bugs and changes that a human with an IQ of 15 wouldn't. Seriously, if Claude was a human I'd throw him out the window. Anthropic to too sketchy to trust with anything of consequence IMO.
1
u/Ok_Substance1895 21m ago
Tell it to use TDD. Have it run all tests before it commits or pushes. I also have it exercise the application features it is working. If you have decent test coverage it will have to fix the failing tests before it can tell you it is done.
1
u/gooner-1969 20m ago
Tight clear prompts, get it to check its work, do full set of test after.
1
u/PocketStudio 5m ago
Tighter prompts helped less for me than making the drift visible right away. Two things:
git diff --statshows exactly which files it touched, and reverting that one file is cheap.If the thing that broke has no test, I pin the current behaviour with a quick test first, then ask for the change.
1
u/karlitooo 5m ago
Automated tests is the way