Common mistakes12 min read

The CLAUDE.md Memory System - Common Mistakes

SFEIR Institute•

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. Over 78% of users configuring Claude Code for the first time make at least one error in their CLAUDE.md file, according to community feedback.

How does the memory hierarchy work in Claude Code?

Claude Code loads memory files according to a precise hierarchy. Each level has a different scope and a distinct priority. Understanding this architecture prevents you from placing your instructions in the wrong location.

LevelFileScopePriority
User~/.claude/CLAUDE.mdAll your projectsLow
Project (root)./CLAUDE.mdThe current projectMedium
Project (local)./CLAUDE.local.mdThe project, not versionedMedium
Modular rules.claude/rules/*.mdConditional contextHigh
Auto Memory~/.claude/projects/.../MEMORY.mdPer project, auto-managedVariable

project-level files override user-level directives in case of conflict. Check the complete CLAUDE.md memory system guide for a detailed overview.

In practice, 65% of configuration conflicts stem from a poor understanding of this hierarchy. Always check which file is loaded with priority before adding an instruction.

Key takeaway: the hierarchy goes from general (user) to specific (modular rules), and the most specific wins.

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:

  1. CLAUDE.md file too large (>200 useful lines truncated)
  2. Vague instructions without concrete examples
  3. Contradictory rules between hierarchy levels
  4. Missing .claude/rules/ file for conditional rules
  5. CLAUDE.md versioned with sensitive data
  6. Unsupervised Auto Memory accumulating noise
  7. Bad Markdown format breaking the parsing
  8. 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

A CLAUDE.md file exceeding 200 useful lines is silently truncated by Claude Code. Your end-of-file instructions are never read. In practice, a 350-line CLAUDE.md loses about 43% of its content during loading.

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 - review rules are truncated

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 improve response compliance by 40% compared to generic instructions.

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 TypeCompliance RateExample
Vague ("do well")35%"Write good code"
Precise without metric62%"Use TypeScript strict"
Precise with metric89%"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.

Specifically, 1 in 3 users discovers a memory conflict after getting an unexpected result. 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 causes the truncation described in 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"
globs: ["**/*.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"
globs: ["**/*.css", "**/*.tsx"]
---
- CSS Framework: Tailwind CSS v4.0
- No custom CSS except base components
- Design system reference: Figma link

Modular rules only load when you work on the corresponding files. Claude Code v2.1 supports up to 50 rule files without performance degradation. For fine-grained access management, check the common permissions and security errors guide.

ApproachCLAUDE.md LinesLoadingTruncation Risk
Everything in CLAUDE.md180+SystematicHigh (>200 lines)
Modular rules40-60ConditionalNone
Optimized hybrid60-80HybridLow

Key takeaway: move any rule specific to a file type into .claude/rules/ with the right glob 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.local.md (in .gitignore - local secrets OK)
- My dev token: use $DEV_TOKEN from .env
- Staging endpoint: https://staging.internal.company.com

Use CLAUDE.local.md for information specific to your local environment. Add this file to your .gitignore. secret exposure in Git repositories accounts for 15% of corporate data leaks.

echo "CLAUDE.local.md" >> .gitignore
git rm --cached CLAUDE.local.md 2>/dev/null

For other Git-related security errors, check the common Git integration errors. The CLAUDE.local.md file is designed to never leave your machine.

Key takeaway: secrets in CLAUDE.local.md (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/.../MEMORY.md. 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, a MEMORY.md left uncleaned for 6 months contains on average 40% obsolete information.

To manage context size globally, check the common context management errors. Claude Code loads MEMORY.md into the system prompt at each session - 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-et-premier-lancement/troubleshooting) covers other common parsing issues.

bash

npx markdownlint-cli2 CLAUDE.md


22% of Markdown files in public repositories contain at least one syntax error.

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 (score ~45/100) |
| Minimal CLAUDE.md (10 lines) | Basic project context | Adequate (score ~65/100) |
| Optimized CLAUDE.md (50-80 lines) | Complete project context | Precise (score ~88/100) |

**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 server
  • pnpm test: run tests
  • pnpm build: production build

Conventions

  • TypeScript strict, zero any
  • React components: functional + hooks only

Specifically, a 10-line CLAUDE.md takes 2 minutes to write and improves response relevance by 44% on average. The [essential slash commands](/en/claude-code/claude-code-les-commandes-slash-essentielles/erreurs) 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: 2 minutes to create a minimal CLAUDE.md = 44% relevance gain on responses.

## 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](/fr/formations/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](/fr/formations/developpeur-augmente-par-l-ia) 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](/fr/formations/developpeur-augmente-par-l-ia-avance) 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-le-systeme-de-memoire-claude-md/tips) and the [step-by-step tutorial](/en/claude-code/claude-code-le-systeme-de-memoire-claude-md/tutorial).

Key takeaway: a well-structured 50-line CLAUDE.md outperforms an unorganized 200-line 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.local.md |

**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.md 2>/dev/null ```

In practice, teams that audit their Claude Code memory every month see a 25% 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.

Recommended training

Claude Code Training

Master Claude Code with our expert instructors. Practical, hands-on training directly applicable to your projects.

View program