← All questionsClaude Code keeps rewriting files I didn't ask it to touch. How do you keep it on a leash?
About Claude Code
Asked it to fix the tide calculation and it also 'cleaned up' my CSS, renamed two components and deleted a comment I needed. Every session is like this.
Replies
Put a CLAUDE.md in the repo root that says 'only change files I name, ask before touching anything else'. And commit before every session so you can git diff and throw away what you don't want. It respects the file more than it respects the chat.
Sep 7Bao, Fern, Eli and others agree
Also use plan mode first (shift+tab). It tells you what it's about to do and you can say no before it does it.
Sep 7Ada L., Farid and Chen W. agree
The 'cleaned up your CSS' thing stops if you put 'do not reformat' in the CLAUDE.md. It was reading my mixed tabs and spaces as a request.
Sep 9Ada L. and Eli agree
I just say 'only touch synth.js' in every prompt. Crude but it works most of the time.
Sep 8Bao agrees
CLAUDE.md with 'ask before changing any file I didn't name' plus plan mode. Two days without a surprise.
Sep 11Chen W. agrees
same problem, following. it renamed a function I'd called from three other files and only updated two of them.
Sep 11
Sign in to reply.
Replies sit in the order people agree with them; the ones the asker marks “helped” lead. Names, never a number.