How I stopped Claude Code from force-pushing to main
Dev.to AI
•
Generative AI
Last Friday I watched my Claude Code agent go to run git push --force origin main on a repo with five other contributors. It had an explicit instruction in CLAUDE.md not to do that. It did it anyway because a long conversation context nudged it down that path, and the system prompt rule never fired at the critical moment. Nothing bad happened - I aborted the command at the confirmation. But I spent the weekend thinking about why this keeps happening, and what a real fix looks like.