7 Anti-Patterns That Ruin Your CLAUDE.md
CLAUDE.md is loaded into the context window at the start of every conversation. A 700-line CLAUDE.md burns roughly 8,000–10,000 tokens out of Claude Code’s 200K-token context window. That may look small on paper, but once you add your prompts, source files, and conversation history, that budget disappears fast. The more bloated your CLAUDE.md, the less room remains for actual engineering work.
This post groups 7 pitfalls I have hit in production into three areas: how you write rules, where you put them, and how you maintain them. Each section pairs bad examples with concrete fixes, followed by a quick-reference cheat sheet.
Three Principles for Writing Rules: Short, Actionable, Specific
Three of the seven anti-patterns come down to poorly written rules: writing too much (Anti-Pattern 1), forbidding without guiding (Anti-Pattern 2), and staying too abstract (Anti-Pattern 7). Here are the three principles that fix them.
Principle 1: Keep It Under 200 Lines
Dumping every coding standard, historical decision, and architecture write-up into CLAUDE.md looks thorough, but Claude has to re-read all of it on every single session. A CLAUDE.md under 200 lines costs roughly 2,000–3,000 tokens—a healthy overhead. Once it passes 500 lines, trim it.
Move project background and architecture decision records into separate docs, and leave a one-line pointer in CLAUDE.md such as “See docs/adr/ for architecture decisions.” Claude will look them up when it needs them.
1 | # Recommended CLAUDE.md structure (~100 lines) |
Principle 2: Pair Prohibitions with Direction
The problem with writing only “don’t do A” is that Claude knows to avoid A, but not whether you want B or C. Write “Don’t use fmt.Println,” and Claude might switch to log.Println when you actually wanted your project’s custom logger.
Pair every prohibition with the expected alternative:
1 | # Bad: prohibitions only |
Principle 3: Make Rules Concrete Enough to Execute
Rules like “keep code clean” or “follow best practices” tell Claude nothing. “Clean” and “high quality” mean completely different things to different engineers. Claude might assume adding 10 lines of comments to every function equals high quality, while you only want comments where intent is non-obvious.
Replace abstract slogans with executable instructions:
1 | # Abstract -> Concrete |
The litmus test is simple: can Claude execute the rule directly without guessing? If yes, it is a good rule.
Scope Boundaries: Global vs. Project vs. Hooks
Anti-Pattern 3 (putting project rules in the global CLAUDE.md) and Anti-Pattern 6 (putting Hook-worthy rules in CLAUDE.md) are the same mistake in two forms: putting a rule in the wrong layer.
Separating Global, Project, and Hook Layers
| Layer | File Path | Scope | Best For | Examples |
|---|---|---|---|---|
Global CLAUDE.md |
~/.claude/CLAUDE.md |
All projects | Personal habits, language preferences | “Reply in English”, “Prefer non-interactive commands” |
Project CLAUDE.md |
Repo root CLAUDE.md |
Current project | Project-specific conventions, layout, naming | “Use Gin for the API”, “Database is PostgreSQL” |
| Hooks | .claude/settings.json |
Current project | Mandatory, non-negotiable enforcement | “Build must pass before commit”, “Block rm -rf“ |
A classic mistake is writing “Database is PostgreSQL” in your global CLAUDE.md. Switch over to your blog repo, and Claude will still try to apply PostgreSQL conventions there.
Hard Constraints (Hooks) vs. Soft Constraints (CLAUDE.md)
Rules in CLAUDE.md rely on Claude remembering and choosing to follow them—and it won’t always remember. Anything that must happen every time, such as “run hexo generate to verify the build before every commit,” belongs in a Hook.
Here is the real configuration format in .claude/settings.json:
1 | { |
A simple rule of thumb: if breaking the rule causes real damage—a broken build, data loss, or a security vulnerability—enforce it with a Hook. If it is about style or preference, CLAUDE.md is enough.
Maintenance Traps: Unedited Generation and Stale Rules
Anti-Pattern 4 (letting Claude generate CLAUDE.md untouched) and Anti-Pattern 5 (never updating it afterward) are two halves of the same problem: a bad starting point followed by neglect.
Unedited Generation: Wrong from Day One
If you open an empty repo and ask Claude to “write a CLAUDE.md for me,” you will get generic boilerplate—“follow Go best practices,” “write clear comments,” “use standard error codes.” In my Go backend project, we don’t use standard HTTP error codes; we have a custom domain error-code scheme. The generated CLAUDE.md missed it completely.
The value of CLAUDE.md is not how neat the formatting looks—it is how accurately it captures your real mental model of the project. Let Claude draft the initial file if you want, then review it line by line and rewrite anything that does not match reality.
Stale Rules: Outdated Guidance Actively Misleads
Writing CLAUDE.md at project kickoff and ignoring it for months lets the codebase drift away from its instructions. A rule that says “All APIs return JSON” turns toxic once some endpoints move to Protobuf. Stale rules are worse than no rules at all—they actively steer Claude in the wrong direction.
When to update CLAUDE.md:
1 | # Triggers for updating CLAUDE.md |
Follow a consistent loop whenever Claude misbehaves: check whether CLAUDE.md covers it → if not, add a concrete rule → if it already does and Claude still ignores it, either the rule is too vague or it needs to become a Hook.
Cheat Sheet
| Anti-Pattern | Symptom | Fix | Where It Belongs |
|---|---|---|---|
| Kitchen-sink file | 700 lines packed with every rule | Keep under 200 lines; include only daily essentials | Project CLAUDE.md |
| Prohibitions only | List of “don’t” rules with no direction | Pair every prohibition with the right alternative | Project CLAUDE.md |
| Project rules in global config | Framework names in ~/.claude/CLAUDE.md |
Keep global habits global; put project rules in the repo | Global vs. Project |
| Unedited AI-generated file | Using Claude’s generated draft as-is | Review line by line and tailor to actual codebase | Project CLAUDE.md |
| Write once, never update | Untouched for months while code evolves | Review monthly and patch rules as issues surface | Project CLAUDE.md |
Hook rules in CLAUDE.md |
Pre-commit checks written as prose | Enforce mandatory checks with Hooks | .claude/settings.json |
| Overly abstract rules | “Follow best practices” | Rewrite as concrete, executable instructions | Project CLAUDE.md |
Minimal viable CLAUDE.md template (copy and customize):
1 | # Project Name |
A strong CLAUDE.md is not measured by how much ground it covers, but by whether every rule is accurate, specific, and immediately actionable. Nail those three first, and grow the rest incrementally as you maintain the project.




