Memory & Compact Commands
/memory persists notes; /compact frees context (with risks).
Why Memory and Compact Matter
Claude Code runs inside a finite context window. As a session grows, two pressures appear: you want some notes to survive every session, and you want the running conversation to stay small enough to reason well.
Two commands handle these jobs:
/memory— editsCLAUDE.mdso instructions persist across sessions./compact— compresses the current context to free space, at the cost of detail.
This lesson is from Domain 5 (Context Management & Reliability) and Domain 3 (Claude Code Config). Knowing exactly what each command does — and what it costs — is an exam favorite.
/memory Edits CLAUDE.md
/memory opens your CLAUDE.md for editing. Whatever you write there is loaded into context at the start of every session — it is durable, not tied to one conversation.
Use it for stable facts the model should always know: project conventions, build commands, architectural rules, coding standards. Think of CLAUDE.md as your project's long-term memory; /memory is just the editor that opens it.
# In an interactive Claude Code session:
/memory
# Opens CLAUDE.md in your editor so you can add durable instructions
# e.g. "Always run `yarn build` before committing."All lessons in this course
- What Is Claude Code
- Interactive vs Headless
- The Read / Edit / Write Loop
- Memory & Compact Commands