Back to Guides
Problem-Solving

Why Claude Code Ignores Your CLAUDE.md Rules

You wrote the rules. Claude still writes the wrong code. Here's exactly what's breaking and how to fix it.

Last updated: 2026-07-01

The four reasons rules get ignored

(1) The rule is too vague -"write clean code" gives Claude nothing to act on. (2) The file is too long -Claude deprioritizes content after the first ~300 lines. (3) Conflicting instructions -if two rules contradict each other, Claude resolves it unpredictably. (4) Rules buried at the bottom -critical rules should be near the top, ideally in the first 100 lines.

Vague vs. concrete rules

Compare these: Vague: "Follow best practices for TypeScript." Concrete: "Never use `any`. If you must, add an ESLint disable comment with a written reason." Vague: "Organize your imports." Concrete: "Import order: 1) Node built-ins, 2) external libraries, 3) internal @/ paths, 4) relative paths. Blank line between each group." The more specific and example-driven your rules are, the higher compliance you get.

File length and rule prioritization

If your CLAUDE.md is longer than 400 lines, Claude begins to deprioritize rules in the lower half. The fix: move your most-violated conventions to the top section. Use a "Key Rules" or "Critical Constraints" block at the very top with your 5-10 non-negotiables. Let the rest of the file be reference documentation.

How to test if Claude is actually reading your rules

Start a fresh Claude Code session and ask: "Read my CLAUDE.md and tell me the three most important rules." If Claude can't summarize them accurately, your rules are either too vague or the file is too long/disorganized. Then ask Claude to write a small component and manually check each convention. Rule-by-rule testing reveals exactly which rules are being dropped.

CLAUDE.md structure that maximizes compliance

Put the highest-priority rules first in a clearly labeled section.

CLAUDE.md
# CLAUDE.md

## ⚡ Critical Rules -Never Break These
1. Named exports only. No default exports for components.
2. No `any` in TypeScript. No exceptions without a comment.
3. No `null` -use `undefined`.
4. Server Components are default. Add "use client" only when required.
5. No useEffect for data fetching -use Server Components.

## Stack
[Your stack details here]

## Folder Structure  
[Your folder structure here]

## Naming Conventions
[Naming rules here]

## Full Coding Standards
[Detailed standards below -less critical, more reference]

Generate a CLAUDE.md that Claude actually follows

standarx generates a structured CLAUDE.md with critical rules front-loaded and concrete examples for every convention.

Generate my rules file