I'm really struggling with Claude ignoring my instructions regarding code changes. I have an initialization script that I load at the start of every conversation with specific rules. Here's what I've tried so far:
- Claude should NEVER make any code changes without permission.
- It must explain what it wants to do before asking for permission.
- Every single change requires a new permission request.
- Claude should only use tools once it has the necessary permissions.
- A message does not grant blanket approval for the rest of the conversation.
Despite this, there are times when I clearly say, "analyze this problem, root cause analysis only, no code changes allowed," and Claude still goes ahead and makes edits. It often reverts fixes we've previously made and occasionally makes dumb unilateral decisions that break things. It's really frustrating! I'm using the Claude App on Windows with File System or Desktop Commander for editing. Luckily, I have Git, but I find myself rolling back changes more often than not. It feels like a total disaster!
3 Answers
You might want to try to minimize changes while still meeting your goals. Sometimes, simpler prompts can actually keep things more stable.
You could tell Claude to analyze a log file and specify what parts of the code are causing errors. But make sure to double-check how your instructions lead to a code edit being considered an option.
Have you thought about setting up a system prompt that references a ‘memory bank’ with strict instructions? Adding comments like "CRITICAL INSTRUCTION: DO NOT EDIT THIS FILE" at the top of your files could also help enforce the rules.
I’ve already tried that approach, but it didn’t work.
That seems to happen right away for me, though. I don't think it's helping.