๐Ÿ“„

Context Files and Memory

Persistent knowledge that survives between sessions. Without context, Claude is a brilliant stranger. With context, Claude is a colleague who has worked with you for months.

Conceptยท6 sectionsยท1 min read

01What Context Means for AI

Without Context

Every session

Starts from zero. You explain your project, preferences, and conventions again and again.

Claude is

A brilliant stranger

Advice quality

Generic, needs constant clarification

With Context

Every session

Continues from where you left off. Claude knows your codebase, remembers preferences, follows conventions.

Claude is

A colleague who has worked with you for months

Advice quality

Personalized, informed by your situation

Context in Claude Code comes from three sources: CLAUDE.md files (explicit instructions), personal context files (your knowledge base), and MEMORY.md (automatic cross session learning).

02CLAUDE.md: Project Instructions

Your standing instructions

CLAUDE.md is a Markdown file that Claude reads at the start of every session. Think of it as a set of standing instructions that shape every interaction.

Step 1: ~/.claude/CLAUDE.md (Global)

Applied to every project on your machine. Good for personal preferences, writing style rules, and tool defaults.

Step 2: ./CLAUDE.md (Project root)

Shared with your team via git. Contains build commands, code conventions, architecture notes.

Step 3: ./.claude/CLAUDE.md (Project specific, private)

Not committed to git. Your personal overrides for this project.

Step 4: ./src/CLAUDE.md, ./api/CLAUDE.md (Subdirectory)

Loaded when Claude works in those directories. Good for module specific context.

Each level adds to the previous. If there is a conflict, the more specific file wins. The hierarchy lets you share team conventions while keeping personal preferences private.

03What to Put in CLAUDE.md

The best CLAUDE.md files are concise and actionable. Claude reads every word, so bloated instructions dilute the important ones.

โšก
Commands

Build, test, lint, deploy. The exact commands Claude should run. No guessing required.

๐ŸŽจ
Code Style

TypeScript strict mode, functional components, error handling patterns, import conventions.

๐Ÿ—๏ธ
Architecture

Frontend framework, API layer, database, auth. The structural decisions that shape everything.

โš ๏ธ
Pitfalls

Things Claude cannot infer by reading code. Webhook verification quirks, import restrictions, edge cases.

What to avoid

Do not paste your entire architecture document. Do not include information Claude can discover by reading files. Focus on things Claude cannot infer: commands, conventions, warnings, and preferences.
## Commands
Build: `npm run build`
Test: `npm test`
Lint: `npm run lint`

## Code Style
TypeScript strict mode, no `any` types
Functional components with hooks

## Preferences
Conventional commits format
Always ask before running git push

04Personal Context Files

Beyond CLAUDE.md, you can build a personal knowledge base that Claude references. This is useful when you want Claude to know about you across all projects.

๐Ÿ‘ค
about.md

Bio, current role, focus areas. Who you are and what you do.

๐Ÿ› ๏ธ
skills.md

Technical and non technical skills. What you bring to the table.

๐Ÿ’ผ
experience.md

Work history, key achievements. Context for career related tasks.

โš™๏ธ
preferences.md

Coding style, writing tone, tool choices. How you like things done.

๐Ÿ“
projects/

Detailed breakdowns of each active project. The agent reads whichever is relevant.

๐Ÿ“š
knowledge/

Learnings organized by topic. Domain expertise captured over time.

The key benefit: when you ask Claude to write a cover letter, update your resume, or draft a bio, it pulls from accurate, up to date information instead of guessing.

05Auto Memory (MEMORY.md)

Claude Code automatically maintains a memory file for each project at ~/.claude/projects/<project>/memory/MEMORY.md. This file is populated with patterns Claude notices across sessions and persists between conversations.

Good For

Patterns

Stable patterns and conventions Claude has observed

Insights

Debugging insights: "Module X fails silently when Y is null"

Preferences

User preferences that emerge over time

Not Ideal For

Patterns

Temporary state or one off decisions

Insights

Speculative conclusions from limited data

Preferences

Information that belongs in CLAUDE.md (put it there instead)

You can read and edit MEMORY.md directly. If Claude has learned something wrong, correct it. If something important is missing, add it. You are always in control.

06The Four Layers

Step 1: CLAUDE.md (Instructions)

What Claude should DO. Commands, rules, conventions, warnings. Loaded automatically at session start. Prescriptive.

Step 2: Context Files (Knowledge)

What Claude should KNOW. Your background, skills, project details, domain knowledge. Referenced on demand. Descriptive.

Step 3: MEMORY.md (Learning)

What Claude has OBSERVED. Patterns, preferences, insights accumulated across sessions. Loaded automatically. Observational.

Step 4: MCP Connections (External)

What Claude can ACCESS. Notion pages, documentation, knowledge bases, file systems. Queried when needed. Dynamic.

Start with CLAUDE.md

It gives you the highest return for the least effort. A well written CLAUDE.md transforms the quality of every interaction. Add the other layers as your workflow matures.