Level 4: Context Engineer — Design Memory and Context
Once you’ve mastered custom commands, the next challenge becomes visible: when a session ends, Claude doesn’t remember “what we talked about last time.” By actively designing memory, you can make Claude’s behavior consistent across sessions.
Target audience: Anyone who is comfortable with custom commands and wants to deeply understand how Claude’s memory works.
Estimated learning time: Read 20min + Practice 30min
Claude’s 3 Types of Memory
Section titled “Claude’s 3 Types of Memory”Claude Code has 3 types of memory. Understanding the characteristics of each is the starting point for Context Engineering.
| Type | Storage location | Characteristics | Can I control it? |
|---|---|---|---|
| CLAUDE.md | File | Persists across sessions | Yes (I write it myself) |
| Auto-memory | Auto-generated file | Claude automatically saves important information | Indirectly (check and edit with /memory) |
| Context window | Conversation only | Valid only during the current session | Yes (reset with /clear) |
CLAUDE.md Hierarchy
Section titled “CLAUDE.md Hierarchy”CLAUDE.md can be placed in multiple locations. Lower-level files are loaded in addition to higher-level settings.
~/.claude/CLAUDE.md ← Applied to all projects (user settings)
your-project/
├── CLAUDE.md ← Applied to this entire project
└── src/api/
└── CLAUDE.md ← Applied additionally only to this directoryExample of a User-Level CLAUDE.md (~/.claude/CLAUDE.md)
Section titled “Example of a User-Level CLAUDE.md (~/.claude/CLAUDE.md)”Write settings you want to apply across all projects:
# User Settings
## My Style
- Keep explanations concise, prioritize code examples
- Explain error messages in plain English
- Write commit messages in English (e.g., `feat: add user endpoint`)
- Present only one recommendation (show multiple options only when I ask)
## Development Environment
- OS: macOS
- Shell: zsh
- Editor: VS CodeHow Auto-memory Works and How to Check It
Section titled “How Auto-memory Works and How to Check It”Auto-memory is a mechanism where Claude automatically saves information it judges as “important” during a conversation as a memo. For example, if you tell it once that “this project uses pytest for testing,” it will remember that in subsequent sessions.
Use the /memory command to check current memory:
/memoryExample output:
## Project Memory (CLAUDE.md)
A REST API server built with Python + FastAPI
...
## Auto Memory
- Tests are written with pytest + pytest-asyncio
- Database migrations use Alembic
- Production environment runs on AWS ECSUsing the Context Window Efficiently
Section titled “Using the Context Window Efficiently”As a conversation grows longer, the context window (the amount of information Claude can process at once) fills up. There are two ways to handle this:
- Reset the conversation with
/clear— run this before switching to a new topic - Move important information to CLAUDE.md — write anything you want available in the next session to a file
The basic design principle is to use the context window for “detailed information discussed only in this session,” and write anything you want to persist into CLAUDE.md.
Splitting Rules with .claude/rules/ (@ Import Syntax)
Section titled “Splitting Rules with .claude/rules/ (@ Import Syntax)”When your project’s CLAUDE.md gets long, you can split it into the .claude/rules/ folder for easier management.
your-project/
├── CLAUDE.md ← Only @imports go here
└── .claude/
└── rules/
├── coding-style.md ← Coding conventions
├── git-workflow.md ← Commit and PR rules
└── testing.md ← Test writing rulesCLAUDE.md content (imports only):
# your-project
A REST API server built with Python + FastAPI.
@.claude/rules/coding-style.md
@.claude/rules/git-workflow.md
@.claude/rules/testing.mdLines starting with @ import the contents of that file. This is useful when you want different team members to manage different rule files by role.
Hands-On Tutorial
Section titled “Hands-On Tutorial”If you want to learn by doing, check out the tutorial.
Hands-on tutorial for this level →