CLAUDE.md is a dedicated Markdown configuration file used by Claude Code, Anthropic’s command-line AI coding tool, to give the AI agent persistent memory and project specific instructions. Placed in the root directory of a project codebase, it functions as an “onboarding manual” that Claude reads automatically at the start of every terminal session. This entirely eliminates the frustrating loop of re-explaining your technical stack, folder structures, or coding rules every time you open a new chat.
Core Functions Of CLAUDE.md
- Persistent Instructions: Injects stable rules and project criteria into the model’s background context before you type your first prompt.
- Operational Guidelines: Feeds Claude essential project context, including precise terminal commands, build steps, and architectural workflows, so it can work safely and autonomously in your local environment.
- Team Standardization: Storing it in your repository allows the configuration to be version controlled via Git, ensuring every developer, and every asynchronous AI agent on the team, follows identical development standards.
Memory Hierarchy
Claude Code processes rules recursively through a structured hierarchy, allowing you to layer your guidelines:
- Global (~/.claude/CLAUDE.md): Configured in your home directory to enforce personal preferences or default standards across every repository you open on your machine.
- Project Root (./CLAUDE.md): Defines the high level, unique constraints of a specific repository.
- Subdirectories (./src/components/CLAUDE.md): Scoped rules nested in localized directories that Claude actively surfaces only when modifying files within that specific subtree.
You can learn what is the difference between Claude Code and Claude Cowork using guide for beginners.
Key Sections To Include
A standard CLAUDE.md file should be kept highly concise, ideally under 200 lines or 500 words, to save token limits and keep the AI strictly focused. Effective files usually contain:
- Project Overview: A 2-sentence summary detailing what the application does and its core constraints.
- Tech Stack: Exact languages, core libraries, and databases deployed (e.g., TypeScript, Next.js, Prisma), alongside explicitly banned alternatives.
- Common Commands: Verbatim terminal strings for building, running tests, linting, and starting the local server.
- Coding Conventions: Explicit style specifications like naming rules or design constraints (e.g., “Always write unit tests for the auth module” or “Use functional components over classes”).
- Domain Vocabulary: A glossary mapping complex business jargon or obscure acronyms directly to the underlying code definitions.
You can learn how to use Claude Projects using step by step guide.

How To Generate CLAUDE.md file?
You do not need to write this file manually. Running the initialization command in your project directory commands Claude to scan your repository structure and automatically generate a custom blueprint for you:
claude /init
(Note: Treat the generated markdown as a rough first draft and refine the rules to match your exact team standards.)
CLAUDE.md vs AGENTS.md
While CLAUDE.md and AGENTS.md serve the exact same conceptual purpose, acting as a “README for AI assistants” to prevent fragmented code style, their biggest difference lies in ecosystem locking versus universal portability.
The core differences break down across four main pillars:
Ecosystem Adoption vs. Universal Portability
- CLAUDE.md: This is a proprietary, vendor specific configuration designed by Anthropic explicitly for Claude Code. It natively integrates with Claude’s terminal commands (like claude /init).
- AGENTS.md: This is an open, tool agnostic standard governed under the Agentic AI Foundation. Backed by an industry coalition including OpenAI, Google, Sourcegraph, and Harness, it is designed as a single source of truth that works universally across OpenAI Codex, GitLab Duo, Cursor, Windsurf, and Kilo Code.
Resolution Mechanics and File Naming
- CLAUDE.md: Claude Code looks strictly for CLAUDE.md. It handles complex codebases via a tree based lookup, inheriting a global file (~/.claude/CLAUDE.md) and merging it downward into localized repository subdirectories.
- AGENTS.md: Tools look for AGENTS.md or AGENT.md. It features a built-in override mechanism. For instance, if you are actively testing different instructions without modifying the core repository file, tools will check for a file named AGENTS.override.md first, which takes immediate precedence.
File Schema and Strictness
Both standards rely on plain Markdown rather than strict JSON/YAML to keep them highly readable for humans. However, their structural design differs slightly:
- CLAUDE.md: Has no formal rigid spec but heavily emphasizes a tight token footprint (recommending files stay under 200 lines) so that the AI retains space for execution.
- AGENTS.md: Features a generalized open specification. The formal spec defines a structured set of composable primitives. It explicitly outlines standard sections that an agent must look for, such as project boundaries, precise linter constraints, and human in the loop safety hooks.
Comparison Summary
| Feature | CLAUDE.md | AGENTS.md Standard |
| Primary Owner | Anthropic | Agentic AI Foundation (OpenAI, Google, etc.) |
| Supported Tools | Claude Code exclusively | Cursor, Windsurf, Codex, GitLab Duo, Kilo Code |
| Override File | Not natively standardized | Supported via AGENTS.override.md |
| Core Philosophy | Deep integration with Claude’s local tools | Open source portability across multiple LLM vendors |
The Developer’s Best Practice
If you use multiple AI coding tools or work in an open source team where developers use different AI assistants, supporting separate claude.md and gemini.md files will quickly cause configuration drift.
To get the best of both worlds, maintain AGENTS.md as your universal source of truth, then create a symbolic link in your project root so Claude Code can read it too:
ln -s AGENTS.md CLAUDE.md
How To Use CLAUDE.md For Correcting Repeat Mistakes?
To eliminate recurring logic bugs or styling blunders, structure your CLAUDE.md as an explicit anti-pattern ledger rather than a passive list of generic coding rules. Claude Code processes negative constraints far more strictly when they are framed as explicit “never” directives.
Structure an “Anti-Pattern Ledger” Section
Add an explicit section to your CLAUDE.md titled ### Anti-Patterns & Past Mistakes. Instead of telling the AI what to do, tell it exactly what it has previously broken. Group these entries into three fields:
- The Symptom: The recurring bug or wrong pattern.
- The Trigger: The specific file, module, or package that triggers the mistake.
- The Correction: The exact code pattern required to fix it.
Format with Explicit “Never” Directives
Generic suggestions like “Please remember to use strict typing” are frequently ignored over long chat histories. Use definitive, absolute syntax that triggers Claude’s guardrails:
### Anti-Patterns & Past Mistakes
* **Never use** `useEffect` for data fetching in `/src/routes/dashboard`. Use `react-query` hooks instead.
* **Do not modify** `schema.prisma` without running `npx prisma format` immediately after.
* **Avoid treating** `userId` as an integer. It is a UUID string in this project.
Add Auto Verification Commands
Force the AI agent to self correct before it considers a task complete. Map your common repeating mistakes to local automated scripts or linter flags in the commands section:
### Verification Checklist
* Run `npm run lint:types` after modifying any API endpoint to catch explicit typing regressions.
* Run `npm test -- --findRelatedTests` on the modified file to ensure no breaking changes were introduced.
Dynamically Update the File via CLI
You do not need to open the markdown file to update it manually when a mistake happens. The moment you catch Claude making a repeating mistake in your terminal session, use the command line to update its memory permanently:
claude "Add a rule to CLAUDE.md: Never use inline styles in components under /src/ui. Always use Tailwind utility classes."
This immediately rewrites the file, ensuring that the very next command you run, and all future terminal sessions, incorporate the correction.
