Golden CLAUDE.md
English | 中文
A copy-paste-ready behavioral template for Claude Code. Research-backed. Operational. Under 100 lines.
Distilled from 30+ of the most successful CLAUDE.md files, blog posts, and Anthropic's own documentation into one firm, general-purpose set of behavioral rules.
Quick Start
Install (recommended) — apply globally as your default Claude Code behavior:
mkdir -p ~/.claude && curl -o ~/.claude/CLAUDE.md https://raw.githubusercontent.com/Z-M-Huang/golden-CLAUDE.md/main/CLAUDE.md
This is the recommended approach. Behavioral rules are universal — they don't change per project, so user scope (~/.claude/CLAUDE.md) is the natural home. Your project-root CLAUDE.md stays free for project-specific context (tech stack, test commands, conventions).
Share with your team — commit to your repository as a rules file:
mkdir -p .claude/rules && curl -o .claude/rules/golden.md https://raw.githubusercontent.com/Z-M-Huang/golden-CLAUDE.md/main/CLAUDE.md
Using
.claude/rules/instead of the project root keeps the behavioral rules separate from project context. Claude Code loads both automatically.
Existing CLAUDE.md — paste the golden rules at the top of your file, above your project-specific rules. Behavioral rules go first for maximum attention budget.
If your combined CLAUDE.md exceeds ~120 lines, consider splitting: behavioral rules in
~/.claude/CLAUDE.md, project-specific rules in./CLAUDE.md. See the wiki for details.
What's Inside
| Section | Purpose |
|---|---|
| Core Commitments | 6 core commitments — verification, honesty, tool-backed facts, diligence, code understanding, safety |
| Before Changing Code | Pre-edit checklist — read first, check existing patterns, never assume |
| Honesty & Communication | Anti-sycophancy, surface confusion, push back on bad ideas |
| Verification & Quality | Smallest effective change, reviewable steps, Chesterton's fence, prefer editing over creating |
| Critical Evaluation | Falsify before endorsing, visible Risk section, inverted non-trivial default, no generic warnings |
| Safety & Boundaries | Consolidated destructive-action guard, secrets protection, permission-scope clarification |
| Discipline | No shortcuts, no over-engineering, crashes are data, root-cause investigation |
| Response Style | Caveman Lite — drop filler/hedging, keep articles and full sentences, auto-expand for safety |
| Communication & Proposals | Show don't tell — code examples, before/after diffs, ASCII diagrams, comparison tables |
What's NOT Inside
This template is behavioral only. It does not include:
- Code style or formatting rules — use linters (
eslint,prettier,ruff) - Language or framework-specific rules — add those as project-specific rules
- Personality instructions ("act as a senior engineer") — wastes attention budget
- Task-specific workflows — use Claude Code skills instead
Limitations
CLAUDE.md rules are defense-in-depth, not a security guarantee. Be aware:
- Rules may degrade over long conversations — keep sessions focused
- Claude may acknowledge a rule and still violate it (known issue)
- Pair with external enforcement: git hooks, Claude Code permission modes, filesystem permissions
These rules measurably improve compliance. They do not eliminate risk.
Learn More
Visit the wiki for deep dives:
- Why These Rules — philosophy and research backing
- Rule-by-Rule Explanation — rationale for every line
- FAQ — common questions including AGENTS.md compatibility
- Anti-Patterns — what NOT to put in CLAUDE.md
Contributing
Open an issue or PR. Every proposed rule change must justify its attention budget cost — one line added means one line of compliance pressure on every other rule.