TL;DR
The CLAUDE.md file is Claude Code's persistent brain, but a poor configuration undermines the quality of generated responses. Here are the most frequent mistakes when setting up the memory system, with concrete fixes for each pitfall. Avoid these issues to get the most out of your AI assistant's contextual memory.
The CLAUDE.md file is Claude Code's persistent brain, but a poor configuration undermines the quality of generated responses. Here are the most frequent mistakes when setting up the memory system, with concrete fixes for each pitfall. Avoid these issues to get the most out of your AI assistant's contextual memory.
The CLAUDE.md memory system is the central mechanism that allows Claude Code to retain persistent instructions between work sessions. Many developers configuring Claude Code for the first time make at least one error in their CLAUDE.md file, according to community feedback.
SFEIR Institute trainings
Claude Code Training
1 day · Fundamentals
AI-Augmented Developer
2 days · Intermediate
How does the memory hierarchy work in Claude Code?
Claude Code loads memory files according to a precise order. Each level has a different scope. Understanding this architecture prevents you from placing your instructions in the wrong location. All discovered files are concatenated and combined into context, so none is silently discarded.
| Level | File | Scope | Load order (broadest to most specific) |
|---|---|---|---|
| User | ~/.claude/CLAUDE.md | All your projects | First (broadest) |
| Project (root) | ./CLAUDE.md | The current project | After user |
| Project (local) | ./CLAUDE.local.md | The project, to be added to .gitignore (for personal notes) | After project root |
| Modular rules | .claude/rules/*.md | Launched at startup, or conditional when a paths: glob is set | With or after project files |
| Auto Memory | ~/.claude/projects/ | Per project, auto-managed | Loaded into context each session |
All files are concatenated; instructions read closer to the working directory appear last, but none is silently discarded. Check the complete CLAUDE.md memory system guide for a detailed overview.
In practice, many conflicts stem from a poor understanding of this loading. Always check which files are loaded before adding an instruction.
Key takeaway: all CLAUDE.md files are concatenated from general (user) to specific (project), with the more specific instructions appearing last.
What are the critical errors in a CLAUDE.md file?
The errors documented below are ranked by frequency and severity. Each error reduces the relevance of Claude Code's responses and can cause inconsistent behavior. Browse this list and fix the issues identified in your files.
The 8 main errors that degrade Claude Code's memory:
- CLAUDE.md file too large (wasted context)
- Vague instructions without concrete examples
- Contradictory rules between hierarchy levels
- Missing
.claude/rules/file for conditional rules - CLAUDE.md versioned with sensitive data
- Unsupervised Auto Memory accumulating noise
- Bad Markdown format breaking the parsing
- Missing project-level CLAUDE.md
To learn more about best practices, check the memory system configuration tutorial which details each step. Specifically, fix the errors marked "Critical" below first.
Key takeaway: focus first on critical errors, which have the most impact on response quality.
How to avoid mistake #1: CLAUDE.md file too large?
Severity: Critical
An overly long CLAUDE.md file wastes context unnecessarily and dilutes your critical instructions. The longer the file, the less reliably instructions at the end are followed.
Incorrect:
# CLAUDE.md - My Project
## Architecture
[... 80 lines describing each folder...]
## Code Conventions
[... 60 lines of style rules...]
## Available Commands
[... 40 lines of npm scripts...]
## Deployment
[... 50 lines of procedures...]
## Review Rules
[... 30 lines of guidelines...]
# Total: ~260 lines - critical instructions are diluted and less reliably followed
Correct:
# CLAUDE.md - My Project (compact)
## Architecture
- src/: source code, React + TypeScript components
- api/: Next.js App Router routes
> Details: see .claude/rules/architecture.md
## Conventions
- TypeScript strict, no any
- Naming: camelCase functions, PascalCase components
> Details: see .claude/rules/conventions.md
## Commands
- `npm run dev`: local server (port 3000)
- `npm test`: Jest tests
- `npm run build`: production build
# Total: ~30 lines - everything is loaded
Move details into dedicated .claude/rules/ files to keep your CLAUDE.md under 100 lines. You will find ready-to-use templates in the CLAUDE.md memory system tips.
Key takeaway: keep the CLAUDE.md under 100 lines and delegate the rest to modular rules.
Why do vague instructions degrade Claude Code's responses?
Severity: Critical
Claude Code interprets your instructions literally. A vague directive produces inconsistent results from one session to the next. Precise instructions are followed far more consistently than vague ones.
Incorrect:
# CLAUDE.md
- Write good code
- Be careful about errors
- Use best practices
- Be concise
Correct:
# CLAUDE.md
- TypeScript strict: never use `any`, use `unknown` + type guards
- Error handling: try/catch on every API call, log with Winston
- Tests: each public function has a Jest unit test (coverage > 80%)
- Responses: max 3 paragraphs unless explicitly requested
Formulate each rule with an action verb, a scope, and a measurable criterion. You will get reproducible results. If in doubt about wording, check the installation and first launch checklist for validated examples.
| Instruction Type | Reliability | Example |
|---|---|---|
| Vague ("do well") | Low | "Write good code" |
| Precise without metric | Medium | "Use TypeScript strict" |
| Precise with metric | High | "Test coverage > 80%" |
Key takeaway: an instruction without a measurable criterion is an instruction that gets ignored.
How to resolve conflicts between memory levels?
Severity: Warning
Contradictory rules between ~/.claude/CLAUDE.md and ./CLAUDE.md cause unpredictable behaviors. Claude Code applies the more specific file, but partial overlaps create confusion.
Incorrect:
# ~/.claude/CLAUDE.md (user level)
- Always write comments in English
- Use tabs for indentation
# ./CLAUDE.md (project level)
- Write comments in French
# No mention of indentation -> silent conflict on tabs
Correct:
# ~/.claude/CLAUDE.md (user level)
- Comments in English (default, unless project override)
- Indentation: 2 spaces (default)
# ./CLAUDE.md (project level)
- OVERRIDE: comments in French for this project
- OVERRIDE: tab indentation (team convention)
Explicitly document overrides in the project file. Add the "OVERRIDE" prefix to signal that a rule replaces a global directive. The permissions and security system follows the same priority logic.
Memory conflicts are a common cause of unexpected results. Audit your two files side by side with this command:
diff ~/.claude/CLAUDE.md ./CLAUDE.md
Key takeaway: prefix "OVERRIDE" in the project file for every rule that contradicts the user level.
Why should you use modular rules .claude/rules/?
Severity: Warning
Files in .claude/rules/ allow conditional rule loading. Not using them forces all content into the main CLAUDE.md, which bloats it and dilutes critical instructions (see mistake #1).
Incorrect - everything in CLAUDE.md:
# CLAUDE.md (180 lines)
## When working on tests
- Use Jest with ts-jest
- Mock API calls with msw
- Minimum 80% coverage
## When working on CSS
- Use Tailwind CSS v4.0
- No custom CSS except base components
- Follow the Figma design system
Correct - modular rules:
# .claude/rules/testing.md
---
description: "Rules for test files"
paths: ["**/*.test.ts", "**/*.spec.ts"]
---
- Framework: Jest + ts-jest
- Mocking: msw for network calls
- Minimum coverage: 80%
# .claude/rules/styling.md
---
description: "CSS and design rules"
paths: ["**/*.css", "**/*.tsx"]
---
- CSS Framework: Tailwind CSS v4.0
- No custom CSS except base components
- Design system reference: Figma link
Rules with a paths: glob only load when you work on the corresponding files. Claude Code discovers all markdown files in .claude/rules/ recursively, so keep each rule focused on a single topic for easier maintenance. For fine-grained access management, check the common permissions and security errors guide.
| Approach | CLAUDE.md Lines | Loading | Dilution Risk |
|---|---|---|---|
| Everything in CLAUDE.md | 180+ | Systematic | High (file too long) |
| Modular rules | 40-60 | Conditional | None |
| Optimized hybrid | 60-80 | Hybrid | Low |
Key takeaway: move any rule specific to a file type into .claude/rules/ with the right paths: pattern.
How to protect sensitive data in CLAUDE.md?
Severity: Critical
Versioning a CLAUDE.md containing tokens, API keys, or passwords exposes your secrets in the Git history. Even after deletion, the data remains in previous commits.
Incorrect:
# CLAUDE.md (versioned in git)
- OpenAI API Key: sk-proj-abc123...
- Database: postgres://admin:password@prod.db:5432
- Slack Token: xoxb-123456789
Correct:
# CLAUDE.md (versioned - NO secrets)
- API keys are in .env (not versioned)
- Run `cp .env.example .env` then fill in the values
# .claude/settings.local.json (ignored by Git - local secrets OK)
- My dev token: use $DEV_TOKEN from .env
- Staging endpoint: https://staging.internal.company.com
Use .claude/settings.local.json (for local, non-versioned settings) for information specific to your local environment. Add this file to your .gitignore. Committed secrets are a frequent source of data leaks.
# .claude/settings.local.json is already ignored by default
# Use .claude/settings.local.json for local settings
For other Git-related security errors, check the common Git integration errors. The .claude/settings.local.json (for local, non-versioned settings) file is designed to never leave your machine.
Key takeaway: secrets in .claude/settings.local.json (for local, non-versioned settings) (gitignored), shared instructions in CLAUDE.md (versioned).
What problems does unsupervised Auto Memory cause?
Severity: Warning
Claude Code's Auto Memory system writes automatically to ~/.claude/projects/. Without supervision, this file accumulates obsolete notes, duplicates, and incorrect information that pollute the context.
Incorrect - unsupervised MEMORY.md:
# MEMORY.md (auto-generated, never cleaned)
- The project uses React 17 (noted 2024-03-15)
- The project uses React 18 (noted 2024-09-22)
- The project uses React 19 (noted 2025-06-01)
- Bug: the test user.test.ts fails (noted 2024-05-10)
- Preference: always use yarn
- Preference: always use pnpm
Correct - regularly audited MEMORY.md:
# MEMORY.md (reviewed February 2026)
## Tech Stack
- React 19.1 + Next.js 15.2 (verified Feb. 2026)
- Package manager: pnpm (team convention)
## Confirmed Conventions
- Tests: Vitest (migration from Jest completed Dec. 2025)
- Lint: Biome v1.9
Audit your MEMORY.md every 2 weeks. Delete entries older than 3 months without verification. In practice, an unsupervised MEMORY.md accumulates obsolete and duplicate entries over time.
To manage context size globally, check the common context management errors. Claude Code loads MEMORY.md into context at each session, so every unnecessary line consumes tokens.
Key takeaway: schedule a biweekly audit of your MEMORY.md and delete unverified entries.
How to fix a Markdown format that breaks parsing?
Severity: Minor
Claude Code parses CLAUDE.md as standard Markdown. Incorrect formatting (poorly indented lists, unclosed code blocks, headings without spaces) prevents correct loading of instructions.
Incorrect:
#CLAUDE.md
-No space after the dash
- Level 1 list
-Poorly indented sub-list (4 spaces instead of 2)
code
unclosed block, missing triple backtick
- Orphan rule after broken block
Correct:
markdown
- Space after the dash
- Level 1 list
- - Sub-list (2-space indentation)
echo "properly closed block"
- Readable rule after closed block
**Validate** your Markdown with a linter before committing. Use `markdownlint` in your CI to automatically detect formatting errors. The [installation troubleshooting guide](/en/claude-code/claude-code-installation-and-first-launch/troubleshooting/) covers other common parsing issues.
bash
npx markdownlint-cli2 CLAUDE.md
Malformed Markdown is an easy mistake to make and a frequent cause of instructions that fail to load.
Key takeaway: **run** a Markdown linter on your CLAUDE.md with every modification.
## Why is the absence of a project CLAUDE.md a problem?
**Severity: Warning**
Without a CLAUDE.md file at the project root, Claude Code falls back on your global user preferences. You lose all project-specific customization: code conventions, build commands, architecture.
| Situation | Claude Code Behavior | Response Quality |
|-----------|----------------------------|---------------------|
| No CLAUDE.md | Uses only `~/.claude/CLAUDE.md` | Generic |
| Minimal CLAUDE.md (10 lines) | Basic project context | Adequate |
| Optimized CLAUDE.md (50-80 lines) | Complete project context | Precise |
**Create** a minimal CLAUDE.md as soon as you initialize each project:
bash
claude # Launch Claude Code in the project
touch CLAUDE.md
markdown
Project
- Name: my-app
- Stack: Next.js 15.2, TypeScript 5.7, Tailwind CSS v4.0
Commands
pnpm dev: local serverpnpm test: run testspnpm build: production build
Conventions
- TypeScript strict, zero
any - React components: functional + hooks only
Specifically, even a 10-line CLAUDE.md takes only a few moments to write and noticeably improves the relevance of Claude Code's responses. The [essential slash commands](/en/claude-code/claude-code-essential-slash-commands/errors/) also let you interact with memory directly from the terminal.
At SFEIR Institute, trainers recommend creating the CLAUDE.md as the first step of any new project using Claude Code.
Key takeaway: spending just a few moments to create a minimal CLAUDE.md delivers a clear gain in response relevance.
## How to structure a maintainable CLAUDE.md over time?
Here is how to organize your file so it remains useful over the months. **Adopt** a structure with short sections, each with a clear objective. Maintainability is what distinguishes an effective CLAUDE.md from a file abandoned after 2 weeks.
markdown
Context (5 lines max)
- Stack, Node.js 22 version, framework, language
Essential Commands (10 lines max)
- dev, test, build, lint, deploy
Strict Conventions (10-15 lines)
- Non-negotiable code rules with measurable criteria
What Claude must NOT do (5 lines)
- Explicit prohibitions: no console.log in prod, no any
**Limit** each section to its indicated number of lines. **Delegate** everything else to `.claude/rules/`. You will get a stable file that never exceeds 50 lines.
The [Claude Code](/en/training/claude-code-training) training from SFEIR Institute covers in 1 day the complete setup of the memory system, with hands-on labs on file hierarchy and modular rules. To go further, the [AI-Augmented Developer](/en/training/ai-augmented-developer) training deepens over 2 days the integration of Claude Code into a professional development workflow, including advanced context management.
Experienced developers will appreciate the [AI-Augmented Developer - Advanced](/en/training/ai-augmented-developer-advanced) training, which dedicates 1 day to advanced optimization techniques like prompt engineering in memory files.
To discover other optimization techniques, browse the [memory system tips](/en/claude-code/claude-code-memory-system-claude-md/tips/) and the [step-by-step tutorial](/en/claude-code/claude-code-memory-system-claude-md/tutorial/).
Key takeaway: a well-structured 50-line CLAUDE.md outperforms a long and unorganized file.
## What are the indicators of a healthy memory system?
**Regularly check** these metrics to ensure your configuration is working. A healthy memory system is measured by the consistency of Claude Code's responses from one session to the next.
| Indicator | Healthy Threshold | Critical Threshold | Corrective Action |
|------------|-----------|----------------|-------------------|
| CLAUDE.md lines | < 100 | > 200 | Externalize to rules/ |
| rules/ files | 3-10 | > 50 | Merge related rules |
| MEMORY.md age | < 30 days | > 90 days | Audit and clean |
| Detected conflicts | 0 | > 2 | Add OVERRIDEs |
| Exposed secrets | 0 | >= 1 | Migrate to .claude/settings.local.json |
**Run** this command for a quick diagnostic:
bash
wc -l CLAUDE.md && ls .claude/rules/ 2>/dev/null | wc -l && wc -l ~/.claude/projects/*/memory/MEMORY.md 2>/dev/null ```
In practice, teams that audit their Claude Code memory every month see significant improvement in response relevance over a quarter. SFEIR Institute integrates this audit into its trainings to instill this habit in developers.
Key takeaway: measure your memory system with these 5 indicators and correct as soon as a critical threshold is reached.
Recent articles about Claude

Claude Managed Agents: Anthropic's Platform for Production Agent Deployment
Anthropic launches Managed Agents: a cloud platform for deploying AI agents in production. Secure sandbox, checkpointing, multi-agent, autonomous sessions lasting hours. Notion, Rakuten, Asana and Sentry already use it.

Claude Code Dream & Auto Dream: Automatic Memory Consolidation
After 20 sessions, Auto Memory notes become a mess. Auto Dream solves this by automatically consolidating Claude Code's memory: deduplication, stale entry removal, relative-to-absolute date conversion.

Claude Code Auto Mode: Autonomy Without the Risk
Auto Mode in Claude Code eliminates permission interruptions while keeping a safety net. A classifier analyzes every action before execution and blocks destructive operations. The sweet spot between approving everything and letting everything through.
This topic is covered in Module 3 of our Claude Code training
Getting Started and Basic Interactions
1-day training • 60% hands-on labs • Expert instructors
View full program