Back to Learn
Getting Started
5 min read

What is CLAUDE.md and Why You Need It

clauderules.net

The Problem CLAUDE.md Solves

Every time you start a new Claude Code session, Claude has no memory of your previous conversations. It doesn't know your project's naming conventions, your preferred libraries, or the architectural decisions your team made six months ago.

Without CLAUDE.md, you spend the first few minutes of every session re-explaining your stack. You correct the same mistakes repeatedly. Teammates get different behavior from Claude because they haven't set up the same context.

What CLAUDE.md Is

CLAUDE.md is a Markdown file that Claude Code reads automatically at the start of every session. Place it at the root of your project, commit it to git, and every session — for every developer on your team — starts with Claude already knowing your codebase. For a quick sense of what these files look like in real projects, browse Next.js CLAUDE.md examples.

CLAUDE.md
# My Project

## Tech Stack
- Next.js 15, TypeScript strict mode
- Prisma + PostgreSQL
- Tailwind CSS

## Rules
- Always use named exports
- Never use `any` type
- Prefer `const` over `let`
- Use Zod for all runtime validation

How Claude Processes It

Claude reads CLAUDE.md before your first message in every session. The contents are injected into Claude's context as a system-level instruction, giving it persistent knowledge of your project without consuming your conversation turns.

You can also have CLAUDE.md files in subdirectories — Claude reads them when it navigates into those directories, enabling per-module rules.

What to Put In It

Focus on project-specific knowledge Claude cannot infer from reading your code:

  • Tech stack and versions
  • Coding conventions and style preferences
  • Common commands (build, test, deploy)
  • Architectural constraints ("never use X")
  • File and directory structure
  • Business domain context

To see how teams encode these for specific stacks, browse CLAUDE.md rules by language.

Start with 10–20 lines covering your stack and top 3 conventions. Expand from there as you notice Claude making mistakes you could prevent.

Frequently asked questions

What is CLAUDE.md?+

CLAUDE.md is a Markdown file that Claude Code reads automatically at the start of every session. It encodes project-specific knowledge — your tech stack, naming conventions, architectural decisions, coding rules — directly into your repository so Claude always has context without you re-explaining it each time. Place it at the root of your project, commit it to git, and every session for every developer on your team starts with Claude already knowing your codebase. It's the lightest-weight way to give Claude persistent project knowledge.

Does Claude read CLAUDE.md automatically every session?+

Yes. Claude reads CLAUDE.md before your first message in every Claude Code session. The contents are injected into Claude's context as a system-level instruction, so the rules apply persistently throughout the conversation without consuming your conversation turns. You don't need to paste it in or remind Claude — it just works. You can also place CLAUDE.md files in subdirectories; Claude reads them when it navigates into those directories, enabling per-module rules layered on top of the project root file.

Where should I put my CLAUDE.md file?+

Put your project's main CLAUDE.md at the root of the repository, alongside your README and package.json, and commit it to git. This way every team member and every CI environment gets identical Claude behavior. For per-module conventions, you can place additional CLAUDE.md files in subdirectories — Claude reads them when it navigates into those areas, layered on top of the root file. For your personal cross-project defaults, a separate file lives at ~/.claude/CLAUDE.md (or the platform equivalent).

What kinds of things should I put in CLAUDE.md?+

Focus on project-specific knowledge Claude cannot infer from reading your code. Good candidates include: tech stack and exact versions, coding conventions and style preferences, common commands like build/test/deploy, architectural constraints such as "never use X here", file and directory structure, and business-domain context. Avoid restating general programming best practices — Claude already knows those. Start with 10–20 lines covering your stack and top three conventions, and expand from there as you notice Claude making preventable mistakes.

Does CLAUDE.md consume tokens from my context window?+

Yes. Every byte of CLAUDE.md consumes context tokens, so a 10,000-word file leaves less room for actual code and conversation. Aim to keep it under 500 lines, prefer bullet points over prose paragraphs, and reference longer documents rather than inlining them — for example, "see docs/api-conventions.md for the full guide" plus a few key points. The most effective CLAUDE.md files are dense and specific rather than long and exhaustive.

What problem does CLAUDE.md solve?+

Without CLAUDE.md, every new Claude Code session starts with no memory of your project — Claude doesn't know your naming conventions, preferred libraries, or the architectural decisions your team made months ago. You spend the first few minutes re-explaining your stack, you correct the same mistakes session after session, and different teammates get inconsistent behavior because they haven't set up the same context. CLAUDE.md fixes this by giving Claude persistent, version-controlled project knowledge that applies to every session for every developer.

Get the Claude Code Starter Pack

Top CLAUDE.md rules for Next.js, TypeScript, Python, Go, and React — delivered free to your inbox.