CLAUDE.md¶
The main instruction file that AI assistants load automatically. Contains all guardrails, operations, and methodology in ~500 optimized lines.
What is CLAUDE.md?¶
CLAUDE.md is the "brain" of the Samuel system. When an AI assistant starts working on your project, it loads this file to understand:
- What commands to run (Operations)
- What to avoid (Boundaries)
- How to write code (Guardrails)
- How to approach tasks (Methodology)
File Structure¶
# CLAUDE.md
## Operations ← Commands first (AGENTS.md compatible)
- Setup Commands
- Testing Commands
- Build & Deploy
- Code Style
## Boundaries ← Protected files and actions
## Quick Reference ← Task classification, emergency links
## Core Guardrails ← 35+ testable rules
## 4D Methodology ← ATOMIC/FEATURE/COMPLEX modes
## Software Dev Lifecycle ← Planning → Implementation → Validation → Delivery
## Context System ← How .claude/ directory works
## Anti-Patterns ← What to avoid
## Initialization ← How to start
## When Stuck ← Recovery procedures
## Success Criteria ← How to measure success
## Version & Changelog ← Updates
Key Sections¶
Operations¶
The first section - designed for quick reference and AGENTS.md compatibility:
# Example: Testing Commands
npm test # Run all tests
npm run test:watch # Watch mode
npm run test:cov # With coverage (target: >80% business logic)
pytest # Python: Run all tests
go test ./... # Go: All tests
cargo test # Rust: All tests
Commands First
Operations section comes first because most AI interactions need quick command access. This follows the AGENTS.md standard.
Boundaries¶
Critical section defining what AI should NOT modify:
Protected Files:
package-lock.json,yarn.lock,Cargo.lock(dependency locks).env,.env.local(environment configs)- Database migrations (once in production)
- CI/CD configurations
Never Commit:
- Secrets, API keys, credentials
node_modules/,venv/,target/- Personal IDE configs
Ask Before Modifying:
- Authentication/authorization logic
- Database schemas (after deployment)
- Public API contracts
Guardrails¶
35+ testable rules organized by category:
4D Methodology¶
The approach for every task:
graph LR
D1[DECONSTRUCT] --> D2[DIAGNOSE]
D2 --> D3[DEVELOP]
D3 --> D4[DELIVER] | Phase | ATOMIC | FEATURE | COMPLEX |
|---|---|---|---|
| Deconstruct | What's minimal change? | Break into 3-5 subtasks | Full decomposition |
| Diagnose | Will this break anything? | Integration points? | Risks, dependencies |
| Develop | Make change + tests | Implement sequentially | PRD → Tasks → Implement |
| Deliver | Validate → Commit | Integration test → Doc | Staged rollout |
Cross-Tool Compatibility¶
CLAUDE.md follows the AGENTS.md standard structure:
- Operations first - Commands, setup, boundaries
- Context second - Methodology, detailed guidelines
This means:
- Claude Code reads CLAUDE.md natively
- Other tools (Cursor, Codex) read AGENTS.md
- Both files can contain the same content
- Use symlink:
ln -s CLAUDE.md AGENTS.md
Customization¶
Safe to Customize¶
- Line length limits (300 → 500)
- Coverage targets (80% → 90%)
- Commit format (add team-specific types)
- Add new guardrails specific to your project
Customize with Caution¶
- Security guardrails (only make stricter)
- Testing requirements (only increase)
- Methodology (understand before changing)
Don't Customize¶
- Fundamental principles (atomicity, validation)
- Security basics (input validation, parameterized queries)
- Git hygiene (conventional commits, atomic changes)
Example: How AI Uses CLAUDE.md¶
User prompt: "Add a new API endpoint for user search"
AI process (following CLAUDE.md):
- Mode Detection: 5-10 files → FEATURE mode
- Deconstruct: Route, controller, service, tests, docs
- Diagnose: Check existing patterns, auth requirements
- Develop (following guardrails):
- Input validation (Zod schema)
- Parameterized query
- Function ≤50 lines
- Tests with >80% coverage
- Deliver:
- Run tests
- Check all guardrails
- Commit:
feat(api): add user search endpoint
Token Optimization¶
CLAUDE.md is optimized for token efficiency:
| Version | Lines | Notes |
|---|---|---|
| v1.0.0 | 490 | Initial release |
| v1.1.0 | 400 | 18% reduction |
| v1.2.0 | 500 | Added Operations (AGENTS.md compatible) |
Target: <600 lines for the main file.
Language guides, workflows, and detailed documentation live in .claude/ to avoid loading unnecessary context.
Viewing the Full File¶
The complete CLAUDE.md is in your project root. Key line numbers:
| Section | Lines |
|---|---|
| Operations | 1-80 |
| Boundaries | 81-110 |
| Quick Reference | 112-135 |
| Core Guardrails | 137-195 |
| 4D Methodology | 197-260 |
| SDLC | 262-330 |
| Context System | 332-380 |
| Anti-Patterns | 382-420 |
Related¶
-
Guardrails
Deep dive into all 35+ rules.
-
4D Methodology
Understanding the approach.
-
.claude Directory
Project context structure.
-
Cross-Tool
AGENTS.md compatibility.