Part 3 is where study-buddy gets big enough to hurt. Two jobs land at once: migrate everything in src/components/ from JavaScript to TypeScript, and figure out why some decks lose cards after sync. That's more than one chat should carry, so this part covers scaling out (ultracode, /batch) and keeping a long session sane (/compact, /rewind, /clear, /context). Facts are Anthropic's; every prompt is illustrative.
TL;DR
- ultracode in a prompt makes Claude write a dynamic workflow that fans subagents out in the background; /effort ultracode does it for every substantive task.
- /batch splits a big change into 5 to 30 independent units, shows you the plan, then runs one background subagent per unit in its own worktree.
- /compact summarizes the conversation to free context; give it focus instructions so the right details survive.
- /rewind restores code, conversation or both from a checkpoint, but Bash changes and most subagent edits slip past it. Keep using git.
- Workflows can burn meaningfully more tokens. Try a small slice first. 💸
ultracode: let Claude write the orchestra
A dynamic workflow is a JavaScript script, written by Claude, that orchestrates many subagents in the background while your session stays responsive. The script holds the loop, branching and intermediate results, so Claude's context only needs the final answer. In our terms it's a harness built on the fly; our harness vs loop vs graph engineering post explains that layer.
Two ways in. Put the keyword ultracode in a prompt you type (or ask for a workflow in your own words), or run /effort ultracode so Claude plans a workflow for every substantive task in the session, which uses more tokens and hits limits sooner. Starting with claude --effort ultracode also sets effort to xhigh.
ultracode figure out why some study-buddy decks lose cards after sync:
have agents test competing hypotheses, cross-check each other, and
report the root cause with evidence.Fine print: the keyword only works in a prompt you type yourself (the interactive prompt, the IDE panel, a Remote Control client, or SDK input stamped human), not from claude -p, unstamped SDK prompts, scheduled tasks, or webhook and PR comments. Approval depends on your permission mode: Auto asks on the first launch only, Manual and accept-edits ask every run, bypass and -p never ask.
Once it's running, /workflows lists runs and shows progress (phases, agent counts, tokens, time). Keys: p pauses or resumes, x stops, s saves it as a command in .claude/workflows/ or ~/.claude/workflows/.
- Large workflow warning
- 25 agents · 1.5M tokensAn advisory warning above either projected figure.
- Default size guideline
- medium (<10)Agents per run; small (<5) on Pro, from v2.1.271.
- Limits
- 16 · 1,000Concurrent agents by default · agents per run.
From Anthropic's dynamic workflows docs.
On Pro, turn on "Dynamic workflows" in /config first (Part 1's version table has the full plan list). To switch them off, use the /config toggle, "disableWorkflows": true in settings, or CLAUDE_CODE_DISABLE_WORKFLOWS=1.
When is it worth the tokens? Thariq Shihipar and Sid Bidasaria point at migrations, deep research, verification, root-cause investigation and large-scale triage, especially where one agent drifts into laziness, grades its own homework (self-preferential bias) or wanders off the goal. They also say plainly that workflows "are not needed for every task". Their gut check: "does it really need more compute?"
/batch: one migration, many worktrees
/batch <instruction> is the bundled skill for large changes across a codebase, run in parallel. The docs' own example is /batch migrate src/ from JavaScript to TypeScript. Ours has the same shape, scoped tighter:
/batch migrate src/components/ from JavaScript to TypeScript- 01
Research
Reads the codebase to understand the job.
- 02
Split
Breaks it into 5 to 30 independent units.
- 03
Plan
Shows you the plan.
- 04
You approve
Nothing runs until you say so.
- 05
Fan out
One background subagent per unit, each in an isolated worktree.
- 06
Test and publish
Each one implements its unit, runs tests and publishes its change.
It needs a git repo or a WorktreeCreate hook (outside git, v2.1.281 or later). Read the plan before approving: two units that edit the same shared types file aren't independent, and that's cheaper to fix in the plan than in merge conflicts. Prefer doing it by hand? The best-practices page loops claude -p over a file list with --allowedTools, tested on 2 or 3 files first.
01Can you describe the change and check it inside one normal session?
YES → One focused task, no orchestra neededNO ↓
02Is it the same kind of edit across many files that don't depend on each other?
YES → /batchNO ↓
03Does it need many agents to investigate, cross-check or verify before anyone edits?
YES → ultracodeNO ↓
Shrink it: run one focused task on a small slice, then scale up
For study-buddy: the component migration is textbook /batch (same edit, independent files). The sync bug is ultracode (competing hypotheses to test and cross-check). The fix it points to is probably one focused task.
/compact: shrink the chat, keep the plot
From Anthropic's best practices: "Claude's context window fills up fast, and performance degrades as it fills." /compact [instructions] frees context by summarizing the conversation so far, and the optional instructions tell it what to focus on. It also runs automatically near the context limit, so steer it before that happens.
/compact Keep the list of components already converted to TypeScript,
the type errors still failing in DeckList, and the test command.To make it permanent, the docs suggest a CLAUDE.md line like "When compacting, always preserve the full list of modified files and any test commands". For side questions that shouldn't enter the history, there's /btw.
Our habit before compacting or clearing: ask Claude for a short handoff note and keep it outside the chat.
## Handoff (illustrative)
Goal: src/components/ fully TypeScript, build green
Done: Button, FlipCard, DeckCard, QuizTimer
Open: DeckList (prop types), StatsChart (untyped chart data)
Check: npm run build && npm test
Hands off: src/lib/sync (root-cause run still going)/rewind: undo, with fine print
Every prompt that starts a turn creates a checkpoint; /rewind (or /checkpoint, /undo, or Esc twice on an empty input) opens the menu. The 100 most recent checkpoints keep file snapshots, survive a resume, and are deleted about 30 days after the last save (cleanupPeriodDays).
| Menu option | Code | Conversation | Reach for it when |
|---|---|---|---|
| Restore code and conversation | Restored | Restored | The last few turns were a wrong turn, full stop |
| Restore conversation | Unchanged | Restored | The code is fine but the chat went sideways |
| Restore code | Restored | Unchanged | You want the files back but keep what was discussed |
| Summarize from here | Unchanged (files on disk untouched) | Compressed from this point forward; earlier messages kept | A long detour you want squashed |
| Summarize up to here | Unchanged (files on disk untouched) | Earlier messages compressed; later ones kept intact | Old context you still need, only shorter |
| Never mind | Unchanged | Unchanged | You panicked. It's fine. |
The /rewind menu, on loop
01ESC ESC
pick a checkpoint
Every prompt that started a turn made one.
02OPTION 1
restore code + conversation ⏪
Full time travel.
03OPTION 2
restore conversation only 💬
The files stay as they are.
04OPTION 3
restore code only 📁
The chat stays as it is.
05OPTIONS 4–5
summarize from / up to here 🗜️
Like a targeted /compact. Add context if you want.
06OPTION 6
never mind 🫡
Back to work.
Menu options from Anthropic's checkpointing docs.
/clear vs /compact, and /context
🗜️ /compact
same task, less context
Summarizes the conversation so far and keeps going.
Use it mid-task when the context is getting heavy.
🧹 /clear
new task, empty context
Starts a new conversation (aliases /reset and /new). Project memory stays.
Use it between unrelated tasks. The old chat is still reachable via /resume, or, in the same running session, the rewind menu's previous-session entry.
From Anthropic's commands reference and best practices.
The best practices name the "kitchen-sink session" as a failure pattern; the fix is /clear between unrelated tasks. Not sure how full you are? /context [all] draws your context usage as a coloured grid, with optimization suggestions and capacity warnings. Want your own guard rails around long sessions? Our Claude Code mods guide covers extending Claude Code itself.
The whole series
- Part 1: Audit your prompts with /claude-api prompt-audit
- Part 2: /effort, /simplify and /frontend-design
- Part 3: ultracode, /batch, /compact and /rewind (this post)
- Part 4: build-eval and hillclimb for your Claude app
Next up: Part 4 stops guessing and starts measuring, with /claude-api build-eval and hillclimb on a Claude-powered app.
