CLAUDE.md Mastery: Your AI's Operating System
CLAUDE.md is your AI's operating system, not documentation. Define orchestration, conversation management, and delegation patterns.
Most guidance about CLAUDE.md gets it wrong. The common advice treats CLAUDE.md as project documentation - a place to describe your tech stack, list commands, and explain directory structure. This fundamentally misunderstands what CLAUDE.md should be.
CLAUDE.md is your central AI's operating system. It defines how Claude operates, how conversations are managed, and how work gets delegated. Project-specific knowledge belongs in skills - modular, dynamically-loaded components that activate when relevant.
Two Paradigms: Onboarding vs. Orchestration
The Inferior Approach: Project Onboarding
The conventional wisdom says CLAUDE.md should "onboard Claude to your codebase" by answering WHAT (tech stack), WHY (project purpose), and HOW (commands to run). Some even recommend keeping files under 60 lines.
This approach has problems:
Priority saturation: CLAUDE.md content receives high priority in Claude's context window - the model treats these instructions as authoritative. When you stuff everything into one file, all of it competes for that elevated attention. Your React patterns fight with your API guidelines, even when you're working on database migrations. High priority everywhere means priority nowhere.
Context waste: If your CLAUDE.md describes React patterns for a React project, that context loads every session - even when you're working on database migrations or deployment scripts.
No behavioral control: Listing your tech stack doesn't tell Claude how to approach problems, when to delegate, or how to manage complex multi-step work.
Repetition across projects: Every new project needs a new CLAUDE.md explaining similar patterns, leading to inconsistent AI behavior across your work.
Static knowledge: Project documentation becomes outdated. Your API patterns from six months ago may not reflect current best practices.
The onboarding approach treats Claude as a contractor who needs to be briefed on each job. The orchestration approach treats Claude as an intelligent system that needs operational parameters.
The Superior Approach: Orchestration Layer
CLAUDE.md should define:
- Operational workflows - The sequence Claude follows for every request
- Context management strategy - How to conserve and allocate context effectively
- Delegation patterns - When to use sub-agents vs. handle directly
- Quality standards - Coding practices, error handling, security requirements
- Coordination protocols - How to manage parallel vs. sequential work
Project-specific knowledge - your tech stack, patterns, conventions - lives in skills that load dynamically when relevant. This separation provides:
- Consistent AI behavior across all projects
- Efficient context usage - domain knowledge loads only when needed
- Portable expertise - skills transfer between projects
- Maintainable knowledge - update a skill once, benefit everywhere
Structuring Your CLAUDE.md
Core Principles Section
Start with the fundamental behaviors you want from your AI. These should apply universally, regardless of what project or task you're working on.
This establishes behavioral patterns that govern every interaction - not project facts that may or may not be relevant.
Routing and Delegation Logic
Define when Claude should handle work directly versus delegate to specialists:
This routing logic ensures Claude makes intelligent decisions about work distribution rather than either doing everything itself or delegating unnecessarily.
Operational Protocols
Define how Claude should coordinate work, especially when parallelism is possible:
Coding Standards and Practices
Include universal coding principles that should govern all work:
The Rules Directory: Modular Instructions
As of Claude Code v2.0.64, you have another option for organizing instructions: the .claude/rules/ directory. This solves the priority saturation problem by letting you distribute high-priority instructions across targeted files.
Key insight from Anthropic: Rules files load with the same high priority as CLAUDE.md. The difference is you can scope when that priority applies using path targeting.
When Rules Beat CLAUDE.md
The rules directory shines when your instructions have domain boundaries:
Each file loads as project memory, but you can target rules to specific file patterns:
This rule only activates when Claude touches API files. Your API guidelines stay out of the way during frontend work.
The Instruction Priority Hierarchy
Think of it as layers combining priority level with loading behavior:
| Layer | Priority | Contains | Loads |
|---|---|---|---|
| CLAUDE.md | High | Operational workflows, routing logic | Always |
| Rules Directory | High | Domain-specific guidelines | Always (filtered by path) |
| Skills | Medium | Reusable procedures, cross-project expertise | On-demand |
| File contents | Standard | Code, documentation | When read |
Use CLAUDE.md for universal behavior that deserves constant high priority. Use rules for domain-specific instructions - they get high priority only when relevant files are in scope. Use skills for portable expertise - medium priority, loaded on-demand.
For a deep dive into path-targeted rules and migration strategies, see the Rules Directory guide.
Skills: Where Domain Knowledge Lives
Skills are the counterpart to your CLAUDE.md operating system. While CLAUDE.md defines how Claude operates, skills provide what Claude knows about specific domains.
The Skills Architecture
Anthropic describes the distinction clearly: "Projects say 'here's what you need to know.' Skills say 'here's how to do things.'"
Skills use progressive disclosure:
- Metadata loads first (~100 tokens) - enough to know when the skill is relevant
- Full instructions load when needed (<5k tokens)
- Bundled files/scripts load only as required
This architecture means you can have dozens of skills available without overwhelming context. Claude accesses exactly what it needs, when it needs it.
What Belongs in Skills
Technology patterns:
- Framework conventions (React patterns, API design)
- Database operations and migrations
- Testing strategies and utilities
Domain workflows:
- Payment processing integrations
- Authentication implementations
- Deployment procedures
Project-specific context:
- Codebase navigation guides
- Architecture documentation
- Team conventions
Example: Separating Concerns
Instead of putting this in CLAUDE.md:
Create a backend-api skill:
Your CLAUDE.md references the skill system:
Now the backend knowledge loads only during backend work, preserving context for everything else.
The Line Count Debate
Some popular guidance recommends keeping CLAUDE.md under 60 lines, claiming Claude "ignores" longer files. This advice misunderstands how Claude processes context.
The reality: Anthropic recommends skill files be 500 lines maximum. If a dynamically-loaded skill can effectively use 500 lines, your always-loaded CLAUDE.md can certainly use 200-400 lines for comprehensive operational instructions.
The key isn't brevity - it's relevance. A 60-line file full of project-specific details that don't apply to every task wastes more effective context than a 300-line file of universally-applicable operational protocols.
The sweet spot is 200-400 lines of:
- Operational workflows (always relevant)
- Routing logic (always relevant)
- Quality standards (always relevant)
- Coordination protocols (always relevant)
Not 60 lines of project facts that may or may not matter for any given task.
Framework Evolution
Your CLAUDE.md should include instructions for its own improvement:
This creates a self-improving system where Claude actively identifies opportunities to enhance the framework.
Why This Approach Works
Multi-Agent Orchestration
Modern Claude Code development increasingly involves sub-agents - specialized instances handling discrete tasks. Your CLAUDE.md defines how the central AI orchestrates these agents.
As Anthropic notes, Opus 4.5 is explicitly trained to manage teams of sub-agents. Your CLAUDE.md should leverage this by defining:
- When to delegate vs. handle directly
- How to construct sub-agent prompts
- How sub-agent results flow back to the main conversation
Context Economics
Context is finite. Every token of project-specific documentation in CLAUDE.md is a token unavailable for actual work. The orchestration approach optimizes context allocation:
- CLAUDE.md: Operational instructions (always needed)
- Skills: Domain knowledge (loaded on demand)
- Sub-agents: Fresh context for specialized work
Consistency Across Projects
When CLAUDE.md defines behavior rather than project facts, you get consistent AI assistance regardless of what you're working on. The same routing logic, quality standards, and coordination patterns apply whether you're building a React app or a Python CLI tool.
Quick Reference
Routing:
- Simple/bounded task → Direct execution
- Complex/multi-phase → Sub-agent delegation or session management
CLAUDE.md Contains:
- Operational workflows
- Context management strategy
- Routing and delegation logic
- Quality standards
- Coordination protocols
Skills Contain:
- Tech stack specifics
- Framework patterns
- Project conventions
- Domain workflows
Next Steps
-
Audit your current CLAUDE.md: Is it project documentation or operational instructions?
-
Extract domain knowledge to skills: Move tech stack, patterns, and conventions out of CLAUDE.md
-
Define your operational workflows: How should Claude approach every request?
-
Establish routing logic: When should Claude delegate vs. handle directly?
-
Set quality standards: What practices should govern all work?
Remember: CLAUDE.md isn't documentation for Claude to read - it's an operating system for Claude to run. Define behavior, delegate knowledge to skills, and build a system that improves itself over time.
Last updated on