claude-md

A reference for writing CLAUDE.md files, which give Claude Code project context and working instructions. It covers what information to include, how files are discovered, and how more specific files override broader ones.

In plain words
What is it for?
Use it to document a project's purpose, structure, technology, build and test commands, deployment process, and directory-specific guidance for Claude Code.
Why use it?
Claude Code may follow the wrong commands or miss important project context when its instruction files are incomplete or misplaced. This guide helps make those instructions clear and discoverable.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/nedcodes-ok/cursorrules-collection/claude-md
Clone the repo
git clone --depth 1 https://github.com/nedcodes-ok/cursorrules-collection
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 812 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00812
Opus 5 $0.00000 $0.00406
Sonnet 5 $0.00000 $0.00162
Haiku 4.5 $0.00000 $0.00081

Measured 2d ago against content hash f5579870eca7, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

claude-md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

  • claude-md — 100% identical, 0 lines differ
rules-mdc/ai-tools/claude-md.mdc · 46 lines

How it starts

The opening of the file, as written. The whole thing — 46 lines — stays where its author put it; the contents beside it link to each section on GitHub.

CLAUDE.md Rules

CLAUDE.md is loaded into every Claude Code session. It's your one chance to onboard the model to your codebase before each conversation.

What Goes In CLAUDE.md

  • WHAT: tech stack, project structure, key directories. In monorepos, list the apps, shared packages, and what each one does. Claude doesn't explore on its own until prompted
  • WHY: purpose of the project, what the different parts do, business context that affects technical decisions ("we use polling instead of websockets because our infra doesn't support persistent connections")
  • HOW: build commands, test commands, lint commands, deploy process. If your project uses pnpm instead of npm, say so here or Claude will guess wrong

Discovery Hierarchy

  • ~/.claude/CLAUDE.md — global, applies to every project
  • CLAUDE.md at project root — project-specific, overrides global
  • CLAUDE.md in subdirectories — more specific, stacks with parent files
  • Claude concatenates all found files, root to leaf. Later files override earlier ones for conflicting guidance

What Makes CLAUDE.md Get Ignored

  • Claude Code wraps CLAUDE.md with a system reminder saying "this context may or may not be relevant to your tasks." If your file is full of situational hotfixes and edge cases, Claude is more likely to skip the whole thing
  • Keep instructions broadly applicable to tasks you'll run. "Always run tests after changes" stays relevant. "When modifying the payment webhook handler, remember the Stripe API changed in v2024-06" only matters for one specific task
  • Shorter, focused files get followed more reliably than 2000-line dumps. If you hit diminishing returns, split into subdirectory CLAUDE.md files

Patterns That Work

  • Build/test/lint commands at the top — these are universally relevant and anchor the file as useful context
  • Project map with directory descriptions: src/api/ does X, src/workers/ does Y, shared/ contains Z
  • Explicit tool preferences: package manager, test runner, formatter, deployment method
  • Coding conventions that differ from defaults: "we use tabs not spaces," "we use Zustand not Redux," "error responses use Problem Details format"

Read the full file on GitHub · 46 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 46 lines · 0 tokens per session scan A f5579870eca7

Subscribe to this mod's changes

claude-md is a cursor rule published in the GitHub repository nedcodes-ok/cursorrules-collection (37 stars, last pushed 6mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 812 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.