Before You Add a Rule to CLAUDE.md, Ask What Will Go Wrong
This post was written with AI assistance.
I recently added three rules to my CLAUDE.md, hoping Claude would write better code, but they gave me more trouble than help.
The rules
src/. That includes line comments, block comments and JSDoc. Say what the code means through names, types and test titles; spec IDs belong in test names, not comments.They read well, and I did not test what Claude actually understood by them.
What happened
| Rule | What I meant | What Claude did |
|---|---|---|
| No dead code | Remove leftovers | Deleted everything not currently used: structural abstractions, prebuilt UI components, full API signature exports, default handlers that exist for architectural completeness |
| No comments | Remove noise | Removed every comment, including linter directives and the ones that explain architecture |
| Failing test first | Test-drive the logic | On CSS, docs and refactors, wrote pointless tests or got stuck |
The pattern is the same each time. Claude follows the rule literally, and a literal reading has no room for the exceptions I had in my head. "Unused" is not the same as "not needed". "No comments" does not mean // eslint-disable-next-line should go. "Test first" makes little sense for a CSS tweak or a rename.
The fix: ask what will go wrong
Asking Claude before the rule goes in:
I'm about to add this rule to CLAUDE.md:
"<the rule>"
What will go wrong with it? Where will it be misread, over-applied, or conflict with something else?Claude is good at this. It lists the exact failures and help me to rewrite the rule. For example:
src/. Use names, types and test titles instead. Keep linter directives and comments that record a constraint the code cannot express.Why negative feedback works better
This is my guess: asking "is this a good rule?" invites Claude to agree. Asking "what will go wrong?" pushes Claude to look for the ways the rule breaks and to suggest better alternatives.
Takeaway
A rule in CLAUDE.md is code for the model. Treat it like code: before it ships, try to break/test it. Ask Claude what will go wrong, fix the rule, then add it.