Skip to content
X

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 Code has 3 types of memory. Understanding the characteristics of each is the starting point for Context Engineering.

TypeStorage locationCharacteristicsCan I control it?
CLAUDE.mdFilePersists across sessionsYes (I write it myself)
Auto-memoryAuto-generated fileClaude automatically saves important informationIndirectly (check and edit with /memory)
Context windowConversation onlyValid only during the current sessionYes (reset with /clear)

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 directory

Example 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 Code

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:

/memory

Example 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 ECS

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:

  1. Reset the conversation with /clear — run this before switching to a new topic
  2. 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 rules

CLAUDE.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.md

Lines starting with @ import the contents of that file. This is useful when you want different team members to manage different rule files by role.


If you want to learn by doing, check out the tutorial.

Hands-on tutorial for this level →

Level 5: Architect — Multi-step Systems and Sub-agents