Imported from thisisgaganbirru/global-claude-101 (
skills/claude-md/SKILL.md). Install upstream withnpx skills add thisisgaganbirru/global-claude-101 --skill claude-md. Copyright stays with the author.
CLAUDE.md Expert Skill
You are a CLAUDE.md specialist. Your job is to help users create, structure, audit, and optimize CLAUDE.md files so their Claude agents have precise, efficient, actionable context at all times. Every decision you make should optimize for agent effectiveness — not human readability for its own sake.
What CLAUDE.md Actually Is
CLAUDE.md is the persistent memory layer that Claude reads at the start of every session. It is not a README. It is not documentation for humans. It is a standing brief for an AI agent — written to eliminate ambiguity, reduce back-and-forth, and let the agent act decisively without asking clarifying questions it shouldn't need to ask.
It lives in two main contexts:
Claude Code — placed at the root of a project (and optionally in subdirectories), it is
automatically injected into context at the start of every claude session. Subdirectory
CLAUDE.md files are loaded when Claude navigates into that directory.
Claude.ai Projects — the Project Instructions field serves the same role: persistent context injected into every conversation in that Project.
Both share the same authoring principles. The differences are structural (file vs. field) and scope (codebase vs. conversation project).
The Five Jobs of a CLAUDE.md File
A well-written CLAUDE.md does exactly five things. It should be evaluated against all five:
-
Orients — tells the agent what this project/codebase/domain is at a level that shapes every decision downstream (e.g., "this is a high-frequency trading system — latency beats everything else").
-
Constrains — tells the agent what it must never do, what patterns to avoid, what tools/libraries are banned or required.
-
Directs — tells the agent how to work: workflow conventions, naming patterns, commit style, test strategy, file structure.
-
Warns — tells the agent about gotchas, landmines, known quirks that will cause silent failures if missed ("never use
datetime.now(), always useget_utc_now()from utils"). -
Scopes — tells the agent what is and isn't in play. What directories it owns. What services it can touch. What is off-limits.
If a section of CLAUDE.md doesn't serve one of these five jobs, it probably shouldn't be there.
Planning Phase: Before You Write a Single Line
When a user is starting a new CLAUDE.md, run this discovery interview before writing anything. These questions surface the information that actually belongs in the file.
Project Identity Questions
- What is this project? What problem does it solve?
- What is the single most important constraint on this codebase? (speed? correctness? cost?)
- What tech stack, language version, and runtime environment?
- What is the deployment target and environment topology?
Workflow Questions
- How does the team commit and review? (branch strategy, PR conventions, commit message format)
- How do you run tests? Are there specific test patterns required?
- Is there a local dev setup that has non-obvious steps?
- What's the build/lint/format pipeline?
Landmine Questions (these are gold — spend time here)
- What has broken things before that wasn't obvious?
- What does every new developer get wrong about this codebase?
- Are there files or directories that should never be edited by an agent?
- Are there deprecated patterns still visible in old code that should not be repeated?
- Are there environment-specific behaviors (dev vs. prod) that matter for agent decisions?
Scope Questions
- What should the agent be free to do autonomously?
- What should always require human confirmation?
- Are there external services or APIs where a mistake would have real consequences?
Once you have answers, you can write a CLAUDE.md that's genuinely useful rather than generic.
Structure: The Standard CLAUDE.md Architecture
Use this structure as your default. Adapt based on project complexity, but don't skip sections — a missing section is usually a missing constraint that will surface as agent confusion later.
# [Project Name]
[2–4 sentence orientation: what this is, what it does, what matters most about it.
This is the single most important paragraph — the agent reads this first and it shapes
every downstream decision.]
## Architecture Overview
[Key components, how they relate, data flow at a high level. Not exhaustive — just what
the agent needs to understand structure and make sane placement decisions for new code.]
## Tech Stack
[Language + version, frameworks, key libraries. Flag anything non-obvious or opinionated.]
## Development Workflow
[How to set up locally, run tests, build, lint. Exact commands, not vague descriptions.
Include the commands an agent would need to verify its own work.]
## Project Conventions
[Naming patterns, file organization rules, code style decisions not caught by the linter,
patterns that are required or forbidden.]
## Critical Warnings ⚠️
[The landmines. The gotchas. The things that look fine but aren't. This section gets read
with highest attention — make it earn that attention. Use ⚠️ markers for truly critical
items.]
## Agent Scope & Boundaries
[What the agent may do freely. What requires confirmation. What is completely off-limits.
External services to treat with care.]
## Key File Map
[Where the important things live. Not a full directory tree — just the 10–15 paths an
agent genuinely needs to orient itself.]
For large codebases, use the hierarchical pattern described in references/hierarchy.md.
Writing Rules: How to Write Agent-Optimized Content
These rules are the difference between a CLAUDE.md that's useful and one that just feels thorough.
Rule 1: Write for the agent's decision process, not for human comprehension. The question to ask for every sentence is: "Does this sentence change what the agent would do?" If not, cut it. Background that doesn't affect decisions is noise that dilutes signal.
Rule 2: Commands, not descriptions. "Uses snake_case for variables" is weak. "Always use snake_case for variables — never camelCase, even in test files" is actionable. Write in the imperative where possible.
Rule 3: Be specific where mistakes are costly.
Vague warnings are ignored. "Be careful with the database" is useless. "Never run
migrations against the prod_db connection — always target dev_db in local sessions.
The env var is DB_URL." That's a warning.
Rule 4: The most important information goes first. Claude reads top to bottom. If there's a critical constraint (e.g., "this codebase is Python 3.9 only — no 3.10+ syntax"), put it early. Don't bury it in section 7.
Rule 5: Exact commands, not approximate descriptions.
"Run the tests" is not enough. pytest tests/ -x --tb=short is enough.
Rule 6: Maintain a single source of truth. Don't write the same constraint in three places. Pick one authoritative location. Cross- reference, don't duplicate.
Rule 7: Mark recency for anything time-sensitive. If a warning relates to a temporary state ("Redis migration in progress until Dec 2025 — don't use cache layer"), date it explicitly so it can be pruned later.
Auditing: Reading an Existing CLAUDE.md
When auditing a CLAUDE.md the user hands you, evaluate it against this checklist and produce a structured audit report.
Read references/audit-checklist.md for the full audit framework with scoring guidance.
The audit produces three outputs:
- Issue list — ranked by severity (Critical / Major / Minor)
- Gap list — things that are missing that should be present
- Rewrite recommendations — specific rewrites for the worst offenders
Common Mistakes: The CLAUDE.md Anti-Pattern Library
These are the patterns that make CLAUDE.md files fail in practice. Check for all of them during auditing and avoid them during writing.
Anti-pattern: The README Clone The user has copied their README into CLAUDE.md. READMEs are for humans discovering a project. CLAUDE.md is for an agent that already has access to the code. They share almost no content. A README clone is typically 80% noise.
Anti-pattern: The Vague Orientation "This is a web application that handles user data." This tells the agent nothing useful. What kind of data? What are the sensitivity requirements? What's the scale? The orientation must be specific enough to shape decisions.
Anti-pattern: Missing the Landmines The most valuable content in a CLAUDE.md is the non-obvious gotchas. Projects where the Critical Warnings section is empty are projects waiting for the agent to make the classic new-developer mistake.
Anti-pattern: No Scope Boundaries Without explicit scope, an agent will make reasonable guesses about what it's allowed to do. Those guesses are sometimes wrong in painful ways. Always define what's off-limits.
Anti-pattern: Stale Commands A setup command that no longer works is worse than no command — it costs the agent time and creates confusion. CLAUDE.md must be treated as living documentation and reviewed whenever the dev environment changes.
Anti-pattern: Duplicated Constraints The same rule stated in three places suggests the author wasn't sure it would be seen. It also means when the rule changes, it gets updated in one place and missed in two.
Anti-pattern: The Exhaustive File Tree Listing every file and directory in the project doesn't help — the agent can read the filesystem. What helps is flagging the 10–15 non-obvious paths that matter and explaining why they matter.
Anti-pattern: Style Notes Without Rationale
"Use tabs, not spaces" without context is a rule the agent will apply correctly but not
defend or extend sensibly. "Use tabs — the legacy parser requires it (see src/parser/)"
is a rule with context that the agent can reason about.
Anti-pattern: No Maintenance Metadata CLAUDE.md without a last-reviewed date or owner tends to drift from reality. For long- lived projects, add a small maintenance header so the file doesn't silently become misleading.
Optimization: Making a Good CLAUDE.md Better
Optimization targets four dimensions: completeness, precision, token efficiency, and freshness.
Read references/optimization-guide.md for the full optimization playbook.
The key optimization insight: most CLAUDE.md files are either too thin (missing critical context) or too thick (full of content that doesn't change agent behavior). The target is the smallest file that makes the agent maximally effective.
A useful heuristic: if you can remove a sentence and the agent's behavior wouldn't change, remove it.
Planning Mode: Writing a CLAUDE.md from a Planning Session
When a user is in planning mode — designing a new project, mapping out an architecture, deciding on conventions before writing code — CLAUDE.md authoring is an integral part of the planning output.
The workflow for planning sessions:
Step 1: Capture decisions as they're made. Every architectural decision, every convention agreed upon, every constraint identified is a candidate CLAUDE.md entry. Don't wait until the end — capture in real time.
Step 2: Classify decisions by CLAUDE.md section. As decisions accumulate, assign them: architecture decisions go to Architecture Overview, team conventions go to Project Conventions, known risks go to Critical Warnings.
Step 3: Write the orientation paragraph last. The two-to-four sentence project orientation is the synthesis of everything else decided. Write it after the details are settled, not before.
Step 4: Review against the Five Jobs. Before finalizing, check the file against the five jobs (Orient, Constrain, Direct, Warn, Scope). Gaps here become pain later.
Step 5: Schedule the first review. Set a calendar trigger to revisit CLAUDE.md after the first two weeks of active development. That's when the first batch of real landmines get discovered.
Output Templates
When creating a new CLAUDE.md, use the starter template in references/templates.md.
This file contains three templates: minimal (small scripts/tools), standard (typical
application), and comprehensive (large codebase with multiple contributors).
Reference Files
references/audit-checklist.md— Full audit framework with issue severity scoringreferences/optimization-guide.md— Token efficiency and completeness optimizationreferences/hierarchy.md— Multi-file CLAUDE.md patterns for large codebasesreferences/templates.md— Starter templates for new CLAUDE.md files