The Complete Guide to CLAUDE.md Files for AI Development 2026
By Serenities AI · Updated February 23, 2026 · 20 min read
If you're using Claude Code in 2026 and you haven't set up a CLAUDE.md file, you're leaving serious productivity on the table. Every time you start a new session, Claude forgets your coding standards, your project conventions, your testing preferences — everything. You type the same instructions over and over. Your AI assistant makes the same mistakes you corrected yesterday. It's frustrating, and it's completely avoidable.
CLAUDE.md files solve this problem by giving Claude Code a persistent memory — a set of instructions, rules, and preferences that load automatically at the start of every session. Think of it as a configuration file for your AI coding partner. Once you set it up properly, Claude follows your team's conventions, respects your architecture decisions, and remembers how you like to work. This guide walks you through everything you need to know about CLAUDE.md files, from your first file to advanced multi-file setups.
What You'll Learn
In this guide, you'll learn:
- What CLAUDE.md files are and how they work inside Claude Code
- The complete memory hierarchy — all 6 types, where they live, and what they're for
- How to create your first project-level CLAUDE.md step by step
- How to set up user-level preferences that follow you across every project
- How to use project rules for modular, topic-specific configuration
- How auto memory and MEMORY.md work behind the scenes
- How to use @imports to organize large instruction files
- How CLAUDE.md compares to .cursorrules, AGENTS.md, and .windsurfrules
- Best practices, common mistakes, and real-world examples
What is CLAUDE.md?
CLAUDE.md is a Markdown file that you write and maintain with instructions, rules, and preferences for Claude Code to follow. It's part of Claude Code's memory system, and it's loaded into Claude's context at the start of every session. The concept is simple: instead of repeating yourself every time you open a new Claude Code session, you write your instructions once in a CLAUDE.md file, and Claude reads them automatically.
Claude Code is Anthropic's CLI-based AI coding tool. It uses Claude models (including Opus 4.6 and Sonnet 4.6) and includes features like Plan Mode, subagents, the /memory command, and auto memory. It's available through Claude Pro ($20/mo), Max (from $100/mo), or direct API usage.
When you place a CLAUDE.md file in your project root, Claude Code reads it before it does anything else. This means every interaction Claude has with your codebase is informed by the rules you've defined. You can specify coding standards ("use single quotes in TypeScript"), testing conventions ("always run npm test before committing"), architectural guidelines ("this project uses a hexagonal architecture pattern"), and communication preferences ("be concise, skip explanations unless asked").
The beauty of CLAUDE.md is that it's just a Markdown file. There's no special syntax to learn. No YAML configuration. No JSON schemas. You write natural language instructions in a .md file, and Claude follows them. You can use headings, lists, code blocks, tables — whatever makes your instructions clear and organized.
CLAUDE.md files can live in multiple locations, forming a hierarchy that ranges from organization-wide policies down to auto-generated project notes. This layered system means you can set broad standards that apply everywhere while still having project-specific and even personal preferences that override them when needed. More specific instructions always take precedence over broader ones.
It's also worth noting that CLAUDE.md isn't the only instruction file format in the AI coding ecosystem. If you've used Cursor, you may be familiar with .cursorrules. GitHub Copilot uses .github/copilot-instructions.md. Windsurf has .windsurfrules. And AGENTS.md is used by various AI agents including Codex and Claude Code itself. We'll compare all of these later in this guide, but the key point is: if you're using Claude Code, CLAUDE.md is the native, first-class way to configure it.
The CLAUDE.md Memory Hierarchy
Claude Code doesn't just read one CLAUDE.md file — it supports a full hierarchy of 6 different memory types. Each serves a different purpose, lives in a different location, and is shared with different people. Understanding this hierarchy is essential for setting up an effective configuration.
| Memory Type | Location | Purpose | Shared With |
|---|---|---|---|
| Managed Policy | macOS: /Library/Application Support/ClaudeCode/CLAUDE.mdLinux: /etc/claude-code/CLAUDE.md |
Organization-wide instructions set by IT/DevOps | All users in the org |
| Project Memory | ./CLAUDE.md or ./.claude/CLAUDE.md |
Team-shared project instructions | Team via source control |
| Project Rules | ./.claude/rules/*.md |
Modular, topic-specific instructions | Team via source control |
| User Memory | ~/.claude/CLAUDE.md |
Personal preferences across all projects | Just you (all projects) |
| Project Memory (Local) | ./CLAUDE.local.md |
Personal project-specific preferences | Just you (current project) |
| Auto Memory | ~/.claude/projects/<project>/memory/ |
Claude's automatic notes and learnings | Just you (per project) |
How the Hierarchy Works
When Claude Code starts a session, it loads all applicable CLAUDE.md files and combines their instructions. The critical rule to remember: more specific instructions take precedence over broader ones. If your organization's managed policy says "use 4-space indentation" but your project CLAUDE.md says "use 2-space indentation," the project instruction wins for that project.
There's also an important distinction in how files are loaded based on their position in the directory hierarchy:
- Files in the directory hierarchy above your working directory: loaded in full at launch
- Files in child directories: loaded on demand when Claude reads files in those directories
This on-demand loading is smart — it means a monorepo with 50 subdirectories won't bloat Claude's context with irrelevant instructions. When Claude starts working in your frontend/ directory, it picks up the frontend/CLAUDE.md at that point, not before.
For most individual developers, you'll use three of these six types: project memory (shared team instructions), user memory (your personal preferences), and auto memory (what Claude learns on its own). The others become relevant in team and enterprise settings. Let's walk through setting up each one.
Step 1: Create Your First Project CLAUDE.md
The project-level CLAUDE.md is where most developers start, and it's the most impactful one to get right. This file lives in your project root and gets committed to source control so your entire team benefits.
Create a file called CLAUDE.md in your project root directory:
# Project: My App
## Tech Stack
- Frontend: React 18 with TypeScript
- Backend: Node.js with Express
- Database: PostgreSQL with Prisma ORM
- Testing: Vitest for unit tests, Playwright for E2E
## Code Style
- Use TypeScript strict mode everywhere
- Prefer functional components with hooks
- Use named exports, not default exports
- Keep files under 300 lines — split if larger
## Architecture
- Follow feature-based folder structure: src/features/[feature]/
- Each feature has: components/, hooks/, utils/, types.ts
- Shared code goes in src/shared/
- API routes follow RESTful conventions
## Testing
- Every new function needs a unit test
- Run `npm test` before suggesting a commit
- Use `describe/it` blocks, not `test` blocks
- Mock external APIs, never hit real endpoints in tests
## Git Conventions
- Commit messages: type(scope): description
- Types: feat, fix, refactor, test, docs, chore
- Branch naming: feature/description, fix/description
## Important Files
- src/shared/api-client.ts — all API calls go through here
- src/shared/auth-context.tsx — authentication state
- prisma/schema.prisma — database schema (source of truth)
- .env.example — required environment variables
## Common Commands
- `npm run dev` — start development server
- `npm test` — run all tests
- `npm run db:migrate` — run Prisma migrations
- `npm run lint` — run ESLint + Prettier check
What Makes a Good Project CLAUDE.md
Notice the structure of the example above. It covers several key areas that Claude needs to know about:
Tech stack declaration. Claude can usually detect your tech stack from package.json or config files, but explicitly stating it prevents ambiguity. If you use React with TypeScript, say so — otherwise Claude might generate JavaScript snippets or suggest class components.
Code style rules. These are the rules Claude should follow when writing or modifying code. Be specific. "Write clean code" is useless. "Use named exports, not default exports" is actionable. Every rule should be something Claude can either follow or violate — if it can't be violated, it doesn't need to be stated.
Architecture guidelines. This is where you describe how your project is organized. Claude needs to know where new code should go, what patterns to follow, and how modules relate to each other. Without this, Claude might create a new utility file in the wrong directory or violate your architecture patterns.
Important files. Point Claude to the files that matter most. Your API client, your auth system, your database schema — these are the files Claude should reference (not rewrite) when making changes.
Common commands. Claude Code can run shell commands, so tell it which ones to use. If your test command is npm test, state it. If your build requires a specific environment variable, document it here.
Keep your CLAUDE.md focused and scannable. Use headings and bullet points. Avoid long paragraphs of explanation — Claude processes structured content more effectively than prose.
Step 2: Set Up User-Level CLAUDE.md for Personal Preferences
Your user-level CLAUDE.md lives at ~/.claude/CLAUDE.md and applies to every project you work on. This is where you put personal preferences that shouldn't be imposed on your team.
Create the file:
mkdir -p ~/.claude
nano ~/.claude/CLAUDE.md
Here's an example of a user-level CLAUDE.md:
# My Preferences
## Communication Style
- Be concise — skip explanations unless I ask for them
- When showing code changes, show only the relevant diff, not the entire file
- If something is ambiguous, ask me rather than guessing
- Use American English
## Coding Preferences
- I prefer early returns over nested if/else
- Use descriptive variable names — no single-letter variables except in loops
- Add JSDoc comments on exported functions
- Prefer `const` over `let` whenever possible
## Workflow
- Always run tests after making changes
- Show me what files you're about to modify before making changes
- When fixing a bug, explain the root cause first
- Suggest commit messages after completing a task
## Environment
- I use VS Code with Vim keybindings
- My terminal is iTerm2 on macOS
- I use pnpm, not npm or yarn
When to Use User Memory vs. Project Memory
The distinction is straightforward:
| Put in User Memory (~/.claude/CLAUDE.md) | Put in Project Memory (./CLAUDE.md) |
|---|---|
| Communication style preferences | Tech stack and dependencies |
| Personal coding style (early returns, etc.) | Team coding standards and linting rules |
| Your development environment details | Architecture and folder structure |
| Package manager preference | Build and test commands |
| Verbosity and explanation preferences | Git conventions and branch strategy |
A good rule of thumb: if a preference would confuse your teammates or conflict with their workflow, it belongs in user memory. If it's something the whole team should follow, it goes in the project CLAUDE.md.
There's also a middle ground: CLAUDE.local.md. This file lives in your project root but is not committed to source control (add it to .gitignore). Use it for personal preferences that are specific to one project — like local file paths, debug flags, or reminders about a feature you're actively developing.
Step 3: Use Project Rules (.claude/rules/*.md) for Modular Config
As your CLAUDE.md grows, it can become unwieldy. A single file with 500 lines of instructions covering testing, API design, database patterns, frontend conventions, and deployment is hard to maintain and hard for Claude to parse effectively.
Project rules solve this by letting you split your instructions into modular, topic-specific files inside .claude/rules/:
.claude/
rules/
testing.md
api-design.md
database.md
frontend.md
security.md
Each rule file focuses on one topic:
.claude/rules/testing.md:
# Testing Rules
## Unit Tests
- Use Vitest for all unit tests
- Co-locate test files: `component.test.ts` next to `component.ts`
- Aim for 80% coverage on business logic
- Mock all external dependencies
## Integration Tests
- Test API endpoints with supertest
- Use a test database, never the development database
- Seed test data in beforeAll, clean up in afterAll
## E2E Tests
- Use Playwright for all E2E tests
- Tests live in /e2e/ directory
- Always wait for network idle before assertions
- Use data-testid attributes for selectors, never CSS classes
.claude/rules/api-design.md:
# API Design Rules
## Endpoints
- Follow REST conventions: GET (read), POST (create), PUT (update), DELETE (remove)
- Use plural nouns: /api/users, /api/projects
- Nest related resources: /api/users/:id/projects
## Responses
- Always return JSON
- Success: { data: T, meta?: {} }
- Error: { error: { code: string, message: string } }
- Use appropriate HTTP status codes (201 for created, 404 for not found, etc.)
## Validation
- Validate all inputs with Zod schemas
- Return 400 with specific validation errors
- Never trust client-side validation alone
Why Rules Files Are Better Than One Giant CLAUDE.md
There are several advantages to this modular approach:
- Maintainability: It's easier for your team to update testing rules without risking accidental changes to API design rules.
- Ownership: Your frontend lead can own
frontend.mdwhile your backend lead ownsapi-design.md. - Code review: When someone changes a rules file, the diff is clear and focused — reviewers know exactly what changed.
- Scalability: New topics get new files. You don't need to decide where in a monolithic document something belongs.
All files in .claude/rules/ are loaded alongside your main CLAUDE.md. You don't need to import them — Claude Code picks them up automatically. They're committed to source control, so your whole team benefits.
Step 4: Understanding Auto Memory and MEMORY.md
Everything we've covered so far involves files you write and maintain. Auto memory is different — it's what Claude writes and maintains about your project. It's the AI's own notebook.
Auto memory is stored at ~/.claude/projects/<project>/memory/ and contains:
- MEMORY.md — the main entrypoint file
- Topic files — optional files like
debugging.md,api-conventions.md, etc.
What Claude Auto-Remembers
As you work with Claude Code, it automatically records things it learns about your project:
- Project patterns: Build commands, test conventions, code style patterns it discovers
- Debugging insights: Solutions to tricky problems you've worked through together
- Architecture notes: Key files, module relationships, how different parts of the codebase connect
- Your preferences: Communication style, workflow habits, how you like things done
For example, if you tell Claude "don't use any types in this project" during a session, Claude might save that to its auto memory so it remembers next time. If you spend 30 minutes debugging a tricky PostgreSQL connection issue, Claude might note the solution for future reference.
How Auto Memory Loads
There's an important detail about how auto memory is loaded: only the first 200 lines of MEMORY.md are loaded into the system prompt at session start. Topic files (like debugging.md or api-conventions.md) are not loaded at startup — they're read on demand when they become relevant.
This 200-line limit means Claude's auto memory is focused and efficient. It doesn't dump everything it's ever learned into context. The most important, most recent learnings go in MEMORY.md, while deeper reference material lives in topic files that get pulled in when needed.
Managing Auto Memory
You can interact with auto memory using the /memory command in Claude Code. This lets you view, edit, or clear Claude's auto-generated notes. If Claude has recorded something inaccurate or outdated, you can fix it directly.
You can also control auto memory with an environment variable:
CLAUDE_CODE_DISABLE_AUTO_MEMORY=0— force auto memory onCLAUDE_CODE_DISABLE_AUTO_MEMORY=1— force auto memory off
Most developers should leave auto memory on. It gets better over time as Claude learns your project. But if you're working on a sensitive project where you don't want Claude storing notes locally, you can disable it.
Auto Memory vs. Your CLAUDE.md
Think of it this way: your CLAUDE.md files are the constitution — the rules you define upfront. Auto memory is the case law — the learnings that accumulate through practice. Both inform Claude's behavior, but your explicit CLAUDE.md instructions always take priority when there's a conflict.
Step 5: Use @imports to Keep CLAUDE.md Organized
As your configuration grows, you might want to keep your main CLAUDE.md lean while pulling in detailed instructions from separate files. The @import syntax lets you do exactly this.
In any CLAUDE.md file, you can import additional files using the @path/to/file syntax:
# Project: My App
## Quick Overview
This is a React + Node.js application for project management.
## Instructions
@docs/coding-standards.md
@docs/api-reference.md
@docs/deployment-guide.md
@.claude/rules/security.md
When Claude Code processes this CLAUDE.md, it reads the imported files and includes their contents in context. This keeps your root CLAUDE.md clean and scannable — it serves as a table of contents that points to detailed docs elsewhere.
Import Path Rules
- Relative paths resolve relative to the file containing the import
- Absolute paths are also supported
So if your CLAUDE.md is at /project/CLAUDE.md and it contains @docs/standards.md, Claude looks for /project/docs/standards.md.
When to Use Imports vs. Rules Files
| Use @imports when... | Use .claude/rules/ when... |
|---|---|
| You have existing documentation you want Claude to read | You're writing Claude-specific instructions from scratch |
| The imported file is also used by humans (like an API reference) | The instructions are only for Claude |
| You want explicit control over what gets imported | You want everything in the rules folder to load automatically |
| You're importing from outside the .claude/ directory | You want team-reviewable, modular rule files |
Both approaches work well. Many projects use a combination: a lean CLAUDE.md that imports existing docs, plus a .claude/rules/ directory for Claude-specific instructions. The key is keeping things organized so that both you and Claude can find what you need.
One practical tip: don't go overboard with imports. Every imported file adds to Claude's context window, and context is a finite resource. Import what's genuinely useful — your coding standards, your API conventions, your architecture decisions. Don't import your entire documentation site.
CLAUDE.md vs .cursorrules vs AGENTS.md vs .windsurfrules
CLAUDE.md isn't the only instruction file format in the AI coding world. If you use multiple tools — or you're evaluating which tool to adopt — it helps to understand how these formats compare. For a deeper dive, check out our full comparison of .cursorrules vs AGENTS.md vs CLAUDE.md.
| Feature | CLAUDE.md | .cursorrules | AGENTS.md | .windsurfrules |
|---|---|---|---|---|
| Primary Tool | Claude Code | Cursor IDE | Various (Codex, Claude Code) | Windsurf IDE |
| Format | Markdown | Plain text / Markdown | Markdown | Plain text / Markdown |
| Memory Hierarchy | 6 levels (managed → auto) | Single file | Per-directory | Single file |
| Auto Memory | Yes (MEMORY.md + topic files) | No | No | No |
| @imports | Yes | No | No | No |
| Modular Rules | Yes (.claude/rules/) | No | Yes (per directory) | No |
| User-Level Config | Yes (~/.claude/CLAUDE.md) | Settings UI | No | Settings UI |
| Org-Level Config | Yes (managed policy) | No | No | No |
| Version Controlled | Yes | Yes | Yes | Yes |
Key Differences
CLAUDE.md has the deepest memory system. With 6 levels of hierarchy, @imports, modular rules, and auto memory, it's the most sophisticated instruction system available. No other tool offers anything close to the managed policy → project → user → auto memory pipeline.
.cursorrules is simpler but more limited. It's a single file in your project root. No hierarchy, no auto memory, no imports. It works well for small projects, but it doesn't scale to complex, multi-team codebases. If you're switching from Cursor to Claude Code, think of CLAUDE.md as .cursorrules with superpowers.
AGENTS.md is the most portable. Since it's used by multiple tools (including Codex and Claude Code), AGENTS.md is a good choice if your team uses different AI tools. It supports per-directory placement, which makes it useful in monorepos. However, it lacks the user-level and auto memory features of CLAUDE.md.
.windsurfrules is the most basic. Similar to .cursorrules — a single instruction file for the Windsurf IDE. If you're evaluating Windsurf vs. Claude Code, the instruction file system is one area where Claude Code has a clear advantage.
If you're experiencing issues with your AI agent not following instructions, our guide on fixing Claude Code ignoring instructions covers the most common problems and solutions.
Best Practices and Common Mistakes
Best Practices
1. Start small, iterate often. Don't try to write the perfect CLAUDE.md on day one. Start with your tech stack, 5-10 code style rules, and your most common commands. Add more rules as you discover what Claude gets wrong.
2. Be specific and actionable. Every instruction should be something Claude can clearly follow or violate. "Write good code" is meaningless. "Use early returns to avoid nesting deeper than 3 levels" is actionable.
3. Use examples. When a rule is nuanced, show an example of what you want and what you don't want:
## Error Handling
try {
const result = await fetchUser(id);
return result;
} catch (error) {
logger.error('Failed to fetch user', { userId: id, error });
throw new AppError('USER_FETCH_FAILED', 500);
}
try {
const result = await fetchUser(id);
return result;
} catch (error) {
console.log(error);
return null;
}
4. Point to important files. Claude can't read your mind about which files matter most. Explicitly list your key files — the ones Claude should reference but not refactor without asking.
5. Keep it under 500 lines. If your CLAUDE.md exceeds 500 lines, split it into .claude/rules/ files or use @imports. Long files waste context and bury important instructions.
6. Review and update quarterly. Your project evolves. Your CLAUDE.md should too. Set a quarterly reminder to review your instructions and remove anything outdated.
Common Mistakes
1. Being too vague. "Follow best practices" tells Claude nothing. Be specific about which practices matter to your team.
2. Contradicting yourself. If your CLAUDE.md says "use 2-space indentation" but your .prettierrc says 4 spaces, Claude gets confused. Align your instruction files with your tooling config.
3. Overloading context. Importing 20 documentation files into your CLAUDE.md wastes context tokens on information Claude might never need. Import selectively.
4. Forgetting CLAUDE.local.md in .gitignore. If you use CLAUDE.local.md for personal preferences, add it to .gitignore so you don't accidentally share your personal setup with the team.
5. Never updating auto memory. Claude's auto memory can accumulate stale or incorrect information over time. Use the /memory command periodically to review and clean up what Claude has learned.
6. Not using CLAUDE.md at all. This is the biggest mistake. If you're using Claude Code without a CLAUDE.md file, you're repeating yourself every session and getting inconsistent results. Even a 20-line CLAUDE.md makes a significant difference. Learn more in our guide on making AI coding agents follow your rules.
Real-World CLAUDE.md Examples
Let's look at practical CLAUDE.md files for different types of projects. These are patterns you can adapt for your own work.
Example 1: Full-Stack SaaS Application
# SaaS Dashboard
## Stack
- Next.js 14 (App Router)
- TypeScript strict
- Tailwind CSS + shadcn/ui components
- Supabase (auth, database, storage)
- Stripe for billing
## Architecture
- /app — Next.js app router pages
- /components/ui — shadcn/ui primitives (DO NOT modify)
- /components/features — feature-specific components
- /lib — utility functions and Supabase client
- /hooks — custom React hooks
- /types — shared TypeScript types
## Rules
- Use server components by default; add "use client" only when needed
- All database queries go through /lib/supabase.ts
- Never expose Supabase service key in client components
- Use Zod for all form validation
- Stripe webhooks: always verify signatures in /app/api/webhooks/stripe/
## Testing
- `pnpm test` for unit tests
- `pnpm test:e2e` for Playwright E2E tests
- Seed test data with /scripts/seed.ts
Example 2: Python Data Science Project
# ML Pipeline
## Stack
- Python 3.12
- pandas, scikit-learn, XGBoost
- MLflow for experiment tracking
- DVC for data versioning
## Conventions
- Type hints on all function signatures
- Docstrings in Google format
- Tests in /tests/ mirroring /src/ structure
- Notebooks in /notebooks/ are for exploration only — production code goes in /src/
## Data
- Raw data: /data/raw/ (never modify these files)
- Processed data: /data/processed/
- Models: /models/ (tracked by DVC, not git)
## Commands
- `make train` — run training pipeline
- `make test` — run pytest suite
- `make lint` — run ruff + mypy
- `mlflow ui` — view experiment dashboard on port 5000
Example 3: Monorepo with Multiple Packages
# Monorepo Root
## Structure
- /packages/api — Express REST API
- /packages/web — React frontend
- /packages/shared — shared types and utilities
- /packages/cli — command-line tool
## Rules
- Changes to /packages/shared/ must not break any dependent package
- Run `pnpm -r test` from root to verify all packages
- Each package has its own CLAUDE.md with package-specific rules
- Use workspace protocol for internal deps: "shared": "workspace:*"
## Git
- PR titles: [package-name] description
- Never commit directly to main
- All PRs need at least one test
@packages/api/CLAUDE.md
@packages/web/CLAUDE.md
Notice how the monorepo example uses @imports to pull in package-specific CLAUDE.md files. This lets you maintain a single source of truth at the root while each package has its own detailed instructions. Each subdirectory can also have its own CLAUDE.md that loads on demand when Claude works in that directory.
How Serenities AI Uses Instruction Files
At Serenities AI, we use instruction files extensively in our own development workflow. Our all-in-one platform (which combines Vibe, Flow, Base, and Drive) has built-in MCP support that works directly with Claude Code, and CLAUDE.md files are central to how we keep our AI-assisted development consistent across the team.
Our project CLAUDE.md defines our coding standards, architecture patterns, and deployment procedures. Each module (Vibe for frontend building, Flow for automation, Base for databases, Drive for file management) has its own set of rules in .claude/rules/. When a developer works on the Flow module, they automatically get Flow-specific instructions without being distracted by Vibe-specific rules.
We also use CLAUDE.md to enforce our API design patterns across all modules. Since Serenities AI integrates with tools like Claude Code through MCP, consistency in our API layer is critical — and CLAUDE.md helps us maintain that consistency without constant code reviews on styling and convention issues.
If you're building with Serenities AI (plans starting at Free, with paid tiers at $24, $49, $99, and $249/mo), you can leverage the same CLAUDE.md patterns in your own projects. The MCP integration means Claude Code can interact directly with your Serenities AI workspace, and your CLAUDE.md rules apply to those interactions just like they do to local code changes.
Frequently Asked Questions
Does CLAUDE.md work with other AI tools, or only Claude Code?
CLAUDE.md is specifically designed for Claude Code — Anthropic's CLI-based AI coding tool. Other tools have their own instruction file formats: Cursor uses .cursorrules, Windsurf uses .windsurfrules, and GitHub Copilot uses .github/copilot-instructions.md. However, AGENTS.md is a more portable format that works across multiple tools including Claude Code. If you use multiple AI tools, you might want to maintain both a CLAUDE.md (for Claude Code-specific features like auto memory and @imports) and an AGENTS.md (for cross-tool compatibility).
How big should my CLAUDE.md file be?
Keep your root CLAUDE.md under 500 lines. If it's growing beyond that, split instructions into .claude/rules/ files or use @imports to pull in separate documents. Remember that everything in CLAUDE.md uses context window tokens — overly large files waste context that could be used for actual code analysis. Focus on instructions that genuinely change Claude's behavior, not documentation that restates what's already obvious from your code.
Should I commit CLAUDE.md to source control?
Yes — your project-level CLAUDE.md and .claude/rules/ files should be committed to source control. These are team-shared instructions. However, CLAUDE.local.md should be added to .gitignore because it contains personal, project-specific preferences. Your user-level ~/.claude/CLAUDE.md is in your home directory and wouldn't be in a project repo anyway. Auto memory at ~/.claude/projects/ is also personal and local.
What's the difference between CLAUDE.md and the /memory command?
CLAUDE.md files are instructions you write for Claude. The /memory command lets you view and edit Claude's auto memory — the notes Claude generates automatically as it learns about your project. Both inform Claude's behavior, but they serve different purposes. Your CLAUDE.md is the authoritative rulebook; auto memory is Claude's supplementary notes. When they conflict, your CLAUDE.md instructions take precedence.
Can CLAUDE.md slow down Claude Code?
CLAUDE.md files are loaded into Claude's context window, so extremely large instruction sets can reduce the available context for actual work. In practice, a well-organized CLAUDE.md under 500 lines has no noticeable performance impact. The auto memory system is designed to be efficient too — only the first 200 lines of MEMORY.md are loaded at startup, and topic files are loaded on demand. The performance benefit of having clear instructions (fewer mistakes, less back-and-forth) far outweighs the minimal context cost.
Next Steps
You now have everything you need to set up a complete CLAUDE.md system for your projects. Here's what to do next:
- Create a basic CLAUDE.md in your most active project. Start with your tech stack, 10 code style rules, and your common commands. Commit it and share it with your team.
- Set up your user-level CLAUDE.md at
~/.claude/CLAUDE.mdwith your personal preferences — communication style, coding preferences, and environment details. - Try the /memory command after a few sessions to see what Claude has learned about your project automatically.
- Graduate to modular rules as your instructions grow. Move topic-specific rules into
.claude/rules/files. - Review our related guides for more depth:
If you're looking for a development platform that integrates seamlessly with Claude Code and supports CLAUDE.md-driven workflows, give Serenities AI a try. Our free tier gets you started immediately, and our MCP integration means Claude Code works with your Serenities workspace out of the box.
Start with one CLAUDE.md file today. Your future self — and your AI coding partner — will thank you.