Video: A CLAUDE.md That Follows
1. Video: A CLAUDE.md That Follows
The CLAUDE.md file is not an enforced configuration, meaning if you keep adding to one gigantic file, the less Claude is able to follow it correctly. Here's how you can keep your CLAUDE.md file tight and to follow your instructions much more reliably. Simply put, the longer the file gets, the more it has to compete with itself. First, is CLAUDE.md even the right tool for the job? A hard rule like never push to main belongs in a PreToolUse hook instead. The hook is designed to stop the push even when Claude does try to do it. The CLAUDE.md file doesn't just exist in your project file, there's three other places. One's your managed policy, then your user file, then your project file, and finally local. Claude loads every memory file together. Nothing gets dropped, and org-policy is always in play. Local is for what's just yours in this project. Say you're refactoring off the sprint and want Claude to hold your architectural decisions in mind. That goes in local, not the shared project file. To make your CLAUDE.md files easier to maintain, use the path-to-file syntax to split up your instructions. Just know what they buy you, though. Claude expands imported files inline at launch right alongside the file that references them. Imports help you organize a large CLAUDE.md file, but everything still loads up front and they don't reduce context. So we can make our CLAUDE.md file much shorter. Whether Claude obeys it comes down to phrasing, and most rules fail because they're pretty vague. First, be specific and checkable. Don't put things like, follow best practices. Do you even know what that means? Well, don't expect Claude to magically. Put new API routes in source API handlers, one per file. Well, that's explicit, so put that instead. Name the replacement. Don't use default exports. Leave the alternative open. Use name exports, not default exports. Close that potential misinterpretation. And then realize that emphasis is a budget. Important and you must raises a rule priority, but only relative to everything quieter around it. Spend them on the two or three rules that hurt when broken. The file also stays under revision. When Claude does the wrong thing, well, treat that as a bug report against your CLAUDE.md file. Tell it, add that to the CLAUDE.md file, and it'll write that rule for you. Treat your CLAUDE.md file like production code. If you can't justify a line, well, delete it. Move enforcement to hooks, organize with imports, and scope past specific conventions into your rules so that they load only when they apply. The leaner the file, the more of it Claude follows.2. Let's practice!
Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.