Exercise 1: Subagents for Parallel UI Audits¶
Your app has multiple templates. Reading every file in your main session burns context. Subagents work in their own context window and return only a summary.
Lab: Lab 04 overview
Visual identity
The Lab 04 starter is a fresh codebase. Before the exercises below, ask Claude to re-apply your visual identity: "Apply our visual identity from CLAUDE.md to @src/templates/play.html and @src/static/style.css."
Theory: Subagents
What it is. Specialized AI assistants in their own context window. Claude delegates matching tasks to them.
Built-in subagents:
| Agent | Model | Purpose |
|---|---|---|
| Explore | Haiku (fast) | Read-only codebase search |
| Plan | Same as parent | Research for plan mode |
| General-purpose | Same as parent | Multi-step read + write tasks |
You can also create custom subagents in .claude/agents/.
Gotcha. Subagents cannot spawn other subagents, the parent orchestrates everything.
Key commands: /agents (list), /context (check usage savings)
Further reading: Create custom subagents
Hands-on¶
Part 1: Baseline¶
- Start Claude, run
/context. Note the number.
Part 2: Subagent Audit¶
- Ask:
- Run
/context. The Messages line will be higher than your Part 1 baseline — the subagent's summary was added to the conversation — but far smaller than if you had read every template file inline. As a rough guide, a subagent audit of a handful of templates might move context from ~8% to ~13%, versus a much larger jump when reading the files directly. The saving: you pay for the summary, not the source.
Part 3: Parallel Subagents¶
- Spawn two at once:
Part 4: Inline Comparison¶
- Run
/compactand note the context count before clearing. - Fresh session (
/exitand relaunch), same audit inline (no subagent). - Run
/context. Compare. - Discuss: when would you use subagents vs. inline?
Checkpoint
- [x]
ui-audit.mdexists with theme-specific findings - [x] Parallel reports were received and merged
- [x] Context difference is quantified