Writing a Good CLAUDE.md
Guidelines for crafting an effective CLAUDE.md file, emphasizing brevity, universal applicability, and progressive disclosure to maximize Claude Code's instruction-following capacity.
Key Insight
LLMs are stateless—they have no memory between sessions. CLAUDE.md is the primary file that enters every conversation, making it the highest leverage point for configuring Claude Code.
Core Principles
Less is More
Frontier LLMs can reliably follow 150-200 instructions. Claude Code's system prompt already contains ~50 instructions, leaving limited capacity for your custom file. Keep it under 300 lines (HumanLayer keeps theirs under 60).
Universal Applicability
Since CLAUDE.md appears in every session, content should be broadly useful. Avoid task-specific instructions that distract from unrelated work.
Progressive Disclosure
Store detailed instructions in separate markdown files and guide Claude to relevant documents as needed, rather than cramming everything into one file.
What to Include
Cover the WHY, WHAT, and HOW:
- Why: Project purpose and context
- What: Technical stack and structure
- How: Development workflows and commands
What to Avoid
- Code style guidelines: Use linters and formatters instead
- Auto-generated content: Don't use
/init—this high-leverage file deserves careful manual crafting - Task-specific instructions: Keep those in separate files
Notable Quote
"CLAUDE.md is the highest leverage point of the harness...you should spend some time thinking carefully about every line."
Related
See 12-factor-agents for broader principles on AI agent design, and context-efficient-backpressure for practical context management techniques.
Linked References (16)
- 12 Factor Agents
- 2025: The Year in LLMs
- Awesome list of Claude Code tips, tricks, gotchas
- Beast Mode 3.1: AI-Powered VS Code Chat Agent
- Claude Code 2.1: Skills, Slash Commands, and Subagents Converge
- Claude Code Best Practices
- Building a Conversation Search Skill for Claude Code
- Context-Efficient Backpressure for Coding Agents
- Context Engineering for AI Systems
- Set Up a Context Engineering Flow in VS Code
- Don't Outsource Your Thinking: Key Takeaways on Claude Code
- md-ai
- Self-Improving Skills in Claude Code
- Teaching Claude Code My Obsidian Vault
- Understanding Claude Code's Full Stack: MCP, Skills, Subagents, and Hooks Explained
- Vue 3 Testing Pyramid: A Practical Guide with Vitest Browser Mode