Exercise 2: Context Management¶
Learn to control what Claude reads, and what it forgets, so your sessions stay fast and focused.
Lab: Lab 01 overview
Theory: Context Window & @ References
What it is. Claude operates within a context window, a fixed amount of text it can "see" at once. Every file read, every command output, every message takes up space.
Why it matters. A sloppy prompt that reads 15 files eats 10x more context than a precise prompt with @ references pointing to 2 files.
Three tools:
@references, focus Claude on specific files:/context, shows token usage breakdown/compact, compresses conversation history to reclaim space
Gotcha. /compact summarizes, it does not delete. Use /rewind to revisit specific earlier decisions.
Further reading: Common workflows docs
Hands-on¶
Part 1: Without @ References¶
- Fresh session — run
/clearnow to start clean. Ask: - Watch which files Claude reads.
- Run
/contextand note the token usage.
Part 2: With @ References¶
- Fresh session (
/clearor restart). - Same task with references:
- Run
/context, compare. Should be noticeably smaller.
Part 3: /compact During a Long Task¶
- Give a bigger task:
- Wait for Claude to finish, then run
/compact. Run/contextand verify the history is compressed before telling Claude to continue. - Tell Claude to continue. Verify it picks up where it left off.
Checkpoint
- [x] Validation is in place
- [x] You ran
/contexttwice and observed the difference - [x] You used
/compactand Claude continued successfully