Published: March 30, 2026

The Complete Guide to CLAUDE.md

CLAUDE.md is a markdown configuration file that Claude Code reads at the start of every session. It gives Claude persistent memory about your project: your tech stack, coding conventions, architecture decisions, and workflow rules. Think of it as a README for your AI coding assistant. Instead of repeating instructions every conversation, you write them once in CLAUDE.md and Claude follows them automatically.

If you use Claude Code for development, CLAUDE.md is the single most impactful file you can add to your project. A well-written CLAUDE.md eliminates repetitive prompting, enforces consistent code style across sessions, and turns Claude from a generic assistant into a teammate that actually understands your codebase. This guide covers everything: what to include, where to put it, how the loading hierarchy works, real examples, and common mistakes to avoid.

What is CLAUDE.md?

CLAUDE.md is a plain markdown file that Claude Code (Anthropic's CLI coding agent) reads automatically every time it starts a new session in your project. The file contains instructions, context, and rules written in natural language. Claude treats its contents as high-priority system context, similar to how a new developer would read a project's contributing guide before writing their first pull request.

The concept is simple but powerful. Without CLAUDE.md, you start every Claude Code session from scratch. Claude has no memory of your preferences, your project's architecture, or the conventions your team follows. You end up repeating the same instructions: "Use TypeScript strict mode," "We use Tailwind, not CSS modules," "Always write tests for new functions." CLAUDE.md eliminates that friction entirely.

Once you add a CLAUDE.md file to your project, Claude Code reads it before processing your first prompt. Every instruction in the file shapes how Claude writes code, responds to questions, and makes decisions throughout the session. It is persistent, versioned (since you commit it to git), and shared across your entire team.

Why You Need a CLAUDE.md File

The benefits compound quickly once you start using CLAUDE.md. Here is what changes:

Consistency across sessions

Without CLAUDE.md, Claude might use different patterns in different sessions. One day it writes React class components, the next day functional components. One session it uses CSS modules, the next it uses styled-components. CLAUDE.md locks in your preferences so the output stays consistent every time.

No more repeating yourself

If you find yourself typing the same instructions at the start of every session, that is a sign you need CLAUDE.md. Write it once, and Claude remembers it for every future interaction in that project.

Team alignment

When CLAUDE.md is committed to your repo, every developer on the team gets the same Claude behavior. Junior developers, senior developers, and contractors all get code output that follows the same conventions. It is like an enforced style guide that Claude actually follows.

Faster onboarding

New team members can read your CLAUDE.md to quickly understand the project's architecture, conventions, and key commands. It doubles as lightweight documentation that is always up to date because you maintain it for Claude anyway.

Better code quality

By encoding architectural decisions and code review standards into CLAUDE.md, you catch issues before they happen. Claude will follow your patterns for error handling, testing, type safety, and project structure without being asked.

Ad Space Reserved for Google AdSense

Where to Put Your CLAUDE.md

CLAUDE.md supports three placement levels, each with a different scope. You can use all three simultaneously; they merge together when Claude Code starts.

1. Global (all projects)

~/.claude/CLAUDE.md

This file applies to every project you open with Claude Code. Use it for personal preferences that span all your work: your preferred language, formatting opinions, communication style, or global permissions. For example, if you always want TypeScript strict mode regardless of project, put that here.

2. Project root (single project)

/your-project/CLAUDE.md

This is the most common placement. It sits alongside your package.json, pyproject.toml, or Cargo.toml. It contains project-specific instructions: the tech stack, architecture overview, key commands, and coding conventions. This is the file you commit to git and share with your team.

3. Subdirectory (folder-specific)

/your-project/src/CLAUDE.md /your-project/api/CLAUDE.md /your-project/packages/auth/CLAUDE.md

Subdirectory CLAUDE.md files add context specific to that part of the codebase. In a monorepo, you might have one CLAUDE.md in packages/api/ with backend-specific rules and another in packages/web/ with frontend conventions. These only load when Claude is working on files within that directory.

How CLAUDE.md Gets Loaded

Understanding the loading hierarchy helps you decide what goes where. When Claude Code starts a session, it follows this order:

  1. Global CLAUDE.md loads first from ~/.claude/CLAUDE.md. This sets your baseline personal preferences.
  2. Project root CLAUDE.md loads next. Its instructions layer on top of (and can override) the global file.
  3. Subdirectory CLAUDE.md files load as Claude navigates into specific folders. These add folder-specific context on top of everything above.

All three levels combine into a single context that Claude uses throughout the session. There is no conflict resolution needed in most cases because each level typically covers different concerns. Your global file handles personal style, the project root handles architecture, and subdirectory files handle folder-specific details.

If instructions genuinely conflict (for example, your global file says "use spaces" but the project file says "use tabs"), the more specific file wins. Project-level overrides global, and subdirectory-level overrides project-level.

What to Include in CLAUDE.md

A good CLAUDE.md covers the information that actually changes how Claude writes code. Here are the key sections with examples you can copy and adapt.

Project overview

Start with a two to three sentence summary of what the project is, who it is for, and what stage it is in. This gives Claude the high-level context it needs to make appropriate decisions.

# Project Overview
TensorFeed.ai is an AI news aggregator and data hub.
Built with Next.js 14 (App Router), deployed on Cloudflare Pages.
Currently in production with 40+ pages and growing.

Tech stack

List your core technologies. This prevents Claude from suggesting incompatible tools or libraries.

## Stack
- Framework: Next.js 14 (App Router, static export)
- Language: TypeScript (strict mode)
- Styling: Tailwind CSS
- Database: Cloudflare Workers KV
- Hosting: Cloudflare Pages
- Auth: Firebase Auth
- Testing: Vitest + React Testing Library

Architecture notes

Document the decisions that are not obvious from the code alone. This is especially valuable for patterns that Claude might otherwise override with "better" alternatives.

## Architecture
- All pages are server components by default
- Only add 'use client' when truly needed (interactivity, hooks)
- API routes proxy to Cloudflare Workers (not Next.js API routes)
- Static export means no SSR; all data fetching is client-side
- KV operations are batched to stay under 100k/day free tier limit

Common commands

Give Claude the commands it needs to build, test, and deploy your project.

## Commands
- Dev server: npm run dev
- Build: npm run build
- Type check: npx tsc --noEmit
- Lint: npm run lint
- Deploy: git push origin main (auto-deploys via Cloudflare Pages)
- Worker deploy: cd worker && npx wrangler deploy

Code style rules

These are the rules that matter most for consistency. Focus on conventions that Claude might not infer from existing code.

## Code Style
- TypeScript strict mode, never use `any` types
- React functional components with hooks (no class components)
- Tailwind CSS for all styling (no CSS modules, no styled-components)
- Semantic HTML: use article, nav, aside, main, section
- Include ARIA labels on all interactive elements
- Handle loading states with skeleton loaders
- Handle errors gracefully with fallback UI

Workflow rules

Define how Claude should behave when completing tasks. This covers the "process" side rather than the code side.

## Workflow
- Always commit and push after completing changes
- Run the type checker before committing
- Add new pages to sitemap.xml
- Every new page needs a unique title tag and meta description
- Every new API endpoint must be documented in /developers

Permission rules

By default, Claude Code asks for permission before running commands or modifying files. You can reduce friction by pre-authorizing routine operations.

## Permissions
- Always allow file creation and editing without asking
- Always allow npm, git, and build commands without asking
- Only ask permission for genuinely destructive operations
  (deleting databases, revoking keys, force-pushing to main)
Ad Space Reserved for Google AdSense

What NOT to Include

A bloated CLAUDE.md is almost as bad as no CLAUDE.md. When the file gets too long, key instructions get diluted and Claude is more likely to miss them. Here is what to leave out:

  • Things Claude already knows. You do not need to explain what React is or how TypeScript generics work. Claude has extensive knowledge of programming languages, frameworks, and tools.
  • Linter and formatter configuration. Claude reads your .eslintrc, .prettierrc, and tsconfig.json files directly. Duplicating those rules in CLAUDE.md adds noise without adding value.
  • Overly detailed instructions. Rules like "always put a blank line after imports" are better handled by your formatter. CLAUDE.md should cover architectural and behavioral rules, not micro-formatting.
  • Frequently changing data. API keys, version numbers, or deployment URLs that change often will make your CLAUDE.md a maintenance burden. Reference these from config files or environment variables instead.
  • Entire API documentation. Claude can read your source files. Instead of pasting your full API spec into CLAUDE.md, point Claude to the file: "API docs are in /docs/api.md."

CLAUDE.md vs AGENTS.md

If you have explored AI coding tools beyond Claude Code, you may have seen AGENTS.md mentioned alongside tools like Cursor, Windsurf, Zed, and OpenCode. Here is how the two files compare.

FeatureCLAUDE.mdAGENTS.md
Supported byClaude Code (Anthropic)Cursor, Zed, OpenCode, others
FormatMarkdown (free-form)Markdown (free-form)
PlacementGlobal, project root, subdirectoriesProject root, subdirectories
PurposeProject context and coding rulesProject context and coding rules
StandardAnthropic-specificOpen community standard

The content format is nearly identical. If your team uses multiple AI coding tools, the simplest approach is to maintain both files with the same content. Some developers create one file and symlink the other. Others maintain a single AGENTS.md and a minimal CLAUDE.md that points to it.

Claude Code reads CLAUDE.md by default. It does not currently read AGENTS.md unless you configure it to. If you only use Claude Code, CLAUDE.md is all you need.

Real-World CLAUDE.md Examples

The best way to learn is by reading real files from real projects. We have compiled full, annotated examples for common project types. Here is a preview of each.

Next.js Web App

App Router, Tailwind CSS, server components, Vercel deployment. Covers page creation checklists, SEO requirements, and static export constraints.

View full example →

Python Backend

FastAPI, SQLAlchemy, Alembic migrations, pytest. Includes virtual environment setup, database conventions, and deployment workflows.

View full example →

React Native Mobile App

Expo, Firebase, React Navigation. Covers platform-specific code, EAS Build commands, and testing on simulators vs devices.

View full example →

Cloudflare Workers

Wrangler, Workers KV, Durable Objects. Covers KV operation limits, Worker size constraints, and environment-specific configuration.

View full example →

Each example includes inline annotations explaining why specific rules are included. Visit the full examples page to see them all.

CLAUDE.md Template Generator

Do not want to start from a blank file? Our interactive CLAUDE.md generator asks a few questions about your project (framework, language, hosting, testing tools) and produces a ready-to-use CLAUDE.md file. You can copy the output directly into your project or use it as a starting point to customize.

Build your CLAUDE.md in 60 seconds

Answer a few questions and get a production-ready CLAUDE.md file for your project.

Open the Generator
Ad Space Reserved for Google AdSense

Best Practices

  • Keep it between 40 and 80 lines. Long enough to cover important context, short enough that every line carries weight. If your file exceeds 100 lines, break it into project root and subdirectory files.
  • Prune regularly. Review your CLAUDE.md every few weeks. Remove rules that Claude now follows naturally, update outdated information, and add rules for new patterns you have introduced.
  • Use emphasis sparingly. If you mark everything as CRITICAL or IMPORTANT, nothing stands out. Reserve bold, caps, and emphasis for the one or two rules that truly matter most.
  • Test by observing Claude's behavior. After adding a new rule, use Claude Code on a few tasks and see if the rule is being followed. If not, rephrase the instruction to be more direct and specific.
  • Commit it to version control. Your project CLAUDE.md belongs in git. It is part of your project's configuration, just like tsconfig.json or .eslintrc. Track changes, review in PRs, and keep it in sync with your codebase.
  • Use /init to bootstrap. If you are starting fresh, run /init inside Claude Code. It analyzes your project structure and generates a starter CLAUDE.md that you can refine.
  • Write for a new teammate, not for a machine. The best CLAUDE.md files read like something you would give a new developer joining the team. Natural language works better than rigid syntax or JSON-like formatting.

Common Mistakes

Over-documenting everything

A 300-line CLAUDE.md with every possible rule is counterproductive. Claude's attention to any single instruction decreases as the total context grows. Focus on the 20% of rules that affect 80% of code output.

Duplicating linter rules

Claude already reads your ESLint, Prettier, and TypeScript config files. Restating those rules in CLAUDE.md wastes space and creates a maintenance burden when configs change. Only include style rules that are not captured by your existing tooling.

Never updating the file

Your CLAUDE.md should evolve with your project. When you adopt a new library, change your deployment pipeline, or introduce a new convention, update CLAUDE.md. Stale instructions are worse than no instructions because they actively mislead Claude.

Being too vague

"Write good code" or "follow best practices" tells Claude nothing actionable. Be specific: "Use React Query for all API calls" or "Every component must have a loading and error state." Specific instructions produce specific results.

Including secrets or credentials

Since CLAUDE.md gets committed to git, never put API keys, passwords, or sensitive URLs in it. Reference environment variables instead: "Database URL is in the DATABASE_URL env var."

Frequently Asked Questions

What is a CLAUDE.md file?

CLAUDE.md is a markdown configuration file that Claude Code reads automatically at the start of every session. It acts as persistent project memory, giving Claude context about your codebase, coding style, architecture decisions, and workflow preferences without you needing to repeat yourself.

Where should I put my CLAUDE.md file?

You can place CLAUDE.md at three levels: globally at ~/.claude/CLAUDE.md (applies to all projects), at your project root alongside package.json or similar config files (applies to that project), or in subdirectories for folder-specific instructions. All three levels merge together when Claude Code starts a session.

How long should a CLAUDE.md file be?

Aim for 40 to 80 lines. Shorter files risk missing important context, while longer files dilute the signal. Focus on information that actually changes how Claude behaves. If a rule does not affect code output, it probably does not belong in CLAUDE.md.

What is the difference between CLAUDE.md and AGENTS.md?

CLAUDE.md is specific to Claude Code (Anthropic). AGENTS.md is an open standard supported by multiple AI coding tools including Cursor, Zed, and OpenCode. They serve the same purpose: giving AI context about your project. Some teams include both files to support multiple tools.

Does CLAUDE.md work with Claude on the web (claude.ai)?

No. CLAUDE.md is only read by Claude Code, the command-line coding agent. The web interface at claude.ai uses Projects with custom instructions instead, which serve a similar purpose but are configured through the UI rather than a file.

Should I commit CLAUDE.md to version control?

Yes, absolutely. Your project-level CLAUDE.md should be committed to git so that every team member and CI environment gets the same instructions. The global ~/.claude/CLAUDE.md is personal and stays on your machine.

How do I create a CLAUDE.md file quickly?

The fastest way is to run the /init command inside Claude Code, which generates a starter CLAUDE.md based on your project structure. You can also use our interactive generator at tensorfeed.ai/claude-md-generator to build one from a template, or copy one of our examples at tensorfeed.ai/claude-md-examples.

Continue Learning