<< Home | Work
Stopped Claude from going rogue and ignoring instructions
| Area | Work |
| AI used | Claude Code |
| Source | r/ClaudeCode |
| Posted | 2026-03-01 |
The move
Create a CLAUDE.md file in your project root to define strict coding constraints.Steps
- Create a file named CLAUDE.md in your project root directory.
- List specific constraints like 'no refactoring unless asked' or 'no extra comments'.
- Define preferred coding patterns or architectural styles.
- Place additional CLAUDE.md files in subdirectories for folder-specific rules.
Prompt for your AI
Act as a senior developer. Follow these strict rules for all code changes: [Insert rule 1, e.g., No refactoring unless explicitly requested]. [Insert rule 2, e.g., Always follow existing codebase patterns]. [Insert rule 3, e.g., Keep solutions simple and avoid unnecessary abstractions].
What happened
The user struggled with Claude Code constantly adding unwanted docstrings and refactoring working code. By creating a simple CLAUDE.md file with specific rules, the AI began following instructions consistently. This approach also works by placing specific rule files in different subdirectories for monorepos.Watch out
Overly restrictive rules might prevent the AI from suggesting necessary improvements. Ensure rules are updated if your project's coding standards change.Give it to your agent
Read https://howtheyuse.ai/p/stopped-claude-from-going-rogue-and-ignoring-instructions.md and help me do this.