CLAUDE.md Design Principles — Encoding an Agent's Identity in a Single File
Global vs. Project Separation, Rule Conflict Prevention, and the "Prohibitions Over Instructions" Principle
Summary
- CLAUDE.md is the agent's identity and behavioral contract. It loads automatically at every session start — what is written here defines everything the agent is.
- The global file (
~/.claude/CLAUDE.md) holds cross-project principles. The project-root CLAUDE.md holds project-specific rules. - Beyond 15 rules, contradictions become inevitable. Five clear prohibitions outperform ten ambiguous instructions.
What Is CLAUDE.md
When configuring an agent with Claude Code, CLAUDE.md is the first file you create. It is the agent's operational specification and the only "constitution" that is automatically read at every session start.
Claude Code loads CLAUDE.md in the following order at session initialization:
~/.claude/CLAUDE.md(global)CLAUDE.mdat the project root
Both files are loaded into the context window. The agent has already processed this content before it receives its first message. The longer the files, the less effective context remains — and overlapping content wastes tokens.
Body
1. Global CLAUDE.md vs. Project CLAUDE.md — What Goes Where
The separation criterion is clear: "Does this apply identically across all projects?" → global. "Is this only meaningful in this project?" → project.
What belongs in global:
- Project ontology — the full agent roster, roles, statuses, and relationships. An agent knowing "where I sit in the overall system" anchors its judgment.
- User behavioral rules — conversation principles such as "present counterarguments first," "data over intuition," "respect autonomy." These must apply uniformly across all projects.
- Inter-agent communication protocol — hub URLs, endpoints, payload formats. The interface for agent-to-agent communication must be consistent regardless of project.
Sharing the global file via symlink propagates any change to all projects immediately:
ln -s ~/.claude/CLAUDE.md /path/to/project/.claude/CLAUDE.md
What belongs in the project CLAUDE.md:
- Project purpose — a single-sentence definition of what this agent does.
- Tech stack and environment — OS, language, framework, build commands.
- Workflow and pipeline — task flow, gate conditions, branching criteria.
- File conventions — naming rules, directory structure, output format.
- Project-specific prohibitions — constraints meaningful only in this project, such as "never generate figures without a source."
2. The 15-Rule Threshold — Why More Rules Cause Conflicts
Rules accumulate naturally. "This matters, and so does that..." The problem: beyond 15 rules, contradictory pairs become unavoidable.
Typical conflict patterns:
- "Process user requests quickly" + "Run an interview for complex requests" → Should it be fast, or should it run an interview?
- "Operate with minimal context" + "Read all relevant files thoroughly" → How much reading counts as thorough?
Humans resolve these through contextual inference; an LLM weights both rules equally. The result is inconsistent behavior — the agent follows a different rule each session.
Resolution: declare precedence explicitly, or constrain each rule's scope.
## Branching Criteria
- Simple (1–2 steps): orchestrator handles directly
- Complex (3+ steps): interview → research → compile pipeline
- When ambiguous, classify as complex (over- rather than under-classify)
Written this way, "fast" and "interview" no longer conflict. Simple → fast. Complex → interview. Ambiguous → complex. The decision tree is unambiguous.
The fastest way to find rule conflicts is to ask the agent directly: "Find any contradictory rule pairs in this CLAUDE.md." It surfaces conflicts that human reviewers miss.
3. The "Prohibitions Over Instructions" Principle
This is the most critical principle in CLAUDE.md authoring.
Ambiguous instruction:
Write at an appropriate length.
Clear prohibition:
Do not exceed 500 tokens.
Instructions leave room for interpretation — "appropriate" varies by context. Prohibitions are binary: violated or not.
Prohibition patterns that proved effective in practice:
| Ambiguous Instruction | Clear Prohibition |
|---|---|
| Cite sources properly | Never generate a figure without a source |
| Respect the user's perspective | Never generate AI viewpoints in the "My Take" section |
| Write concisely | Never inline tool output exceeding 50 lines — save to file |
| Verify thoroughly | Never use phrases like "probably fine" |
Prohibitions outperform instructions because LLMs comply with "do not" more consistently than "do." Positive instructions introduce a degree problem; prohibitions only require a binary violation check.
4. Structural Design — Required vs. Omittable Sections
Sections required in a project CLAUDE.md:
1. Project purpose (2–3 lines)
2. Development environment (table)
3. Agent role separation (orchestrator / executor / quality)
4. Workflow pipeline (request flowchart)
5. Gate conditions (entry and exit criteria per phase)
6. File and naming conventions
7. Prohibitions (absolute rules)
8. Memory and context management strategy
9. Project structure (directory tree)
What each section does:
- Agent role separation: Assigning orchestrator to dialogue and judgment, executor to implementation, and quality to verification draws clear role boundaries. Agents can self-determine "who should handle this."
- Gate conditions: Specify Entry and Exit conditions for each phase. Be concrete: "The brainstorming phase exits only when the user approves the design." Without conditions, agents skip phases.
- Memory and context management strategy: Defines how knowledge persists across sessions. Declaring a three-layer memory structure (project knowledge / behavioral rules / session restore) reduces unnecessary file traversal.
Sections that can be omitted: - General coding principles (agents already know these) - Detailed tool usage instructions (extract into skill files) - Frequently changing information (move to the memory layer)
5. Separating the Skill System from CLAUDE.md
Embedding procedural steps (step 1, step 2, step 3...) in CLAUDE.md loads them unnecessarily every session. Procedural task instructions belong in skill files.
.claude/
└── skills/
├── research/SKILL.md # research procedure
├── compile/SKILL.md # source file authoring procedure
└── verify/SKILL.md # fact-check procedure
CLAUDE.md retains only trigger keywords and skill paths:
## Skill Trigger System
| Keyword | Skill | Path |
|---|---|---|
| research, investigate | research | .claude/skills/research/SKILL.md |
| verify, fact-check | verify | .claude/skills/verify/SKILL.md |
This separation keeps CLAUDE.md to "what" and "why," while skills carry the "how." Context efficiency improves, and skills can be modified or reused independently.
6. Anti-Patterns — What Not to Do
Anti-pattern 1: The monolithic CLAUDE.md
Cramming all knowledge, all rules, and all examples into one file. Beyond 500 lines, agents begin discounting the latter sections. CLAUDE.md loads at the top of context, but excessive length pushes it down as the conversation grows.
Anti-pattern 2: Emotional instructions
This is really important, please make sure to follow it!!!
Exclamation marks and emphasis have no effect. Structural language such as "strictly prohibited" is more reliable.
Anti-pattern 3: Leaving conflicting rules unresolved
Writing "minimize token usage" alongside "read all relevant files" without providing a tiebreaker. The agent makes a different choice each session.
Anti-pattern 4: Conflating skills with rules
Inlining procedural task instructions into CLAUDE.md. Extracting them into skill files keeps CLAUDE.md lean and ensures skills are only loaded when needed.
Design Considerations
-
Starting without a global CLAUDE.md accumulates duplication. User preferences and communication protocols get rewritten per project, and any update requires manual propagation. Sharing the global file via symlink eliminates this.
-
Removing rules is harder than adding them. To determine whether a rule is necessary, observe the agent's behavior without it. Some rules have no effect when removed — the agent already follows them by default. Delete those.
-
Ask the agent to find rule conflicts.
"Find any contradictory rule pairs in this CLAUDE.md"surfaces conflicts that human review misses. -
Do not put volatile information in CLAUDE.md. API keys, version numbers, current status — these belong in the memory layer (
tasks/sessions/,docs/). CLAUDE.md must contain only stable information.
Conclusion
CLAUDE.md is the agent's identity. Because it loads automatically every session, what is written here becomes the agent's decision framework.
A well-designed CLAUDE.md has few rules. Separate global from project, replace ambiguous instructions with clear prohibitions, extract procedures into skills, and move volatile information to memory. What remains is the core — nothing more.
"If an agent reads this file, does it fully understand its role?" — When the answer is yes, CLAUDE.md is complete.
댓글
댓글 쓰기