0Pricing
Claude Architect · Lesson

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 — edits CLAUDE.md so 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

  1. What Is Claude Code
  2. Interactive vs Headless
  3. The Read / Edit / Write Loop
  4. Memory & Compact Commands
← Back to Claude Architect