# Claude Code Commands, Part 3: ultracode, /batch, /compact and /rewind

> Part 3 of our Claude Code commands series: ultracode workflows, /batch across worktrees, /compact with focus, and what /rewind can and can't undo.

Source: https://bytevancer.com/blog/claude-code-commands-part-3-ultracode-batch-compact-rewind · Published 2026-10-03 · ByteVancer · AI Engineering

**When one chat can't hold the job: ultracode and /batch to scale out, /compact and /clear to keep context sane, and /rewind for undo, plus everything it won't undo.**

> **Part 3 of 4: Claude Code commands, explained** — [Part 1: Audit your prompts with /claude-api prompt-audit](https://bytevancer.com/blog/claude-code-commands-part-1-prompt-audit) · [Part 2: /effort, /simplify and /frontend-design](https://bytevancer.com/blog/claude-code-commands-part-2-effort-simplify-frontend-design) · **Part 3: ultracode, /batch, /compact and /rewind (you're here)** · [Part 4: build-eval and hillclimb for your Claude app](https://bytevancer.com/blog/claude-code-commands-part-4-build-eval-hillclimb)

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](https://bytevancer.com/blog/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.

*Illustrative prompt for study-buddy. The keyword counts because we typed it ourselves.*
```text
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/.

**ultracode guardrails, by the numbers**
- **25 agents · 1.5M tokens** Large workflow warning — An advisory warning above either projected figure.
- **medium (<10)** Default size guideline — Agents per run; small (<5) on Pro, from v2.1.271.
- **16 · 1,000** Limits — Concurrent 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:

*Illustrative, modelled on the docs' example.*
```text
/batch migrate src/components/ from JavaScript to TypeScript
```

**What /batch does with that**
Research → Split → Plan → You approve → Fan out → Test and publish

1. **Research** — Reads the codebase to understand the job.
2. **Split** — Breaks it into 5 to 30 independent units.
3. **Plan** — Shows you the plan.
4. **You approve** — Nothing runs until you say so.
5. **Fan out** — One background subagent per unit, each in an isolated worktree.
6. **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.

**ultracode, /batch or just one task?**
- Can you describe the change and check it inside one normal session? → **One focused task, no orchestra needed**
- Is it the same kind of edit across many files that don't depend on each other? → **/batch**
- Does it need many agents to investigate, cross-check or verify before anyone edits? → **ultracode**
- Otherwise → **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.

*Illustrative focus instructions for the study-buddy migration.*
```text
/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.

*Our format, not an Anthropic one.*
```markdown
## 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 actions from Anthropic's checkpointing docs; the last column is our advice. Code options only appear when the checkpoint has tracked file changes.**
- **Restore code and conversation** — Code: Restored; Conversation: Restored; Reach for it when: The last few turns were a wrong turn, full stop
- **Restore conversation** — Code: Unchanged; Conversation: Restored; Reach for it when: The code is fine but the chat went sideways
- **Restore code** — Code: Restored; Conversation: Unchanged; Reach for it when: You want the files back but keep what was discussed
- **Summarize from here** — Code: Unchanged (files on disk untouched); Conversation: Compressed from this point forward; earlier messages kept; Reach for it when: A long detour you want squashed
- **Summarize up to here** — Code: Unchanged (files on disk untouched); Conversation: Earlier messages compressed; later ones kept intact; Reach for it when: Old context you still need, only shorter
- **Never mind** — Code: Unchanged; Conversation: Unchanged; Reach for it when: You panicked. It's fine.

**🎞️ The /rewind menu, on loop**
1. **ESC ESC** — pick a checkpoint — Every prompt that started a turn made one.
2. **OPTION 1** — restore code + conversation ⏪ — Full time travel.
3. **OPTION 2** — restore conversation only 💬 — The files stay as they are.
4. **OPTION 3** — restore code only 📁 — The chat stays as it is.
5. **OPTIONS 4–5** — summarize from / up to here 🗜️ — Like a targeted /compact. Add context if you want.
6. **OPTION 6** — never mind 🫡 — Back to work.

*Menu options from Anthropic's checkpointing docs.*

> **What /rewind can't undo** — File changes made by Bash commands (rm, mv, cp) aren't tracked. Most subagent edits aren't restored either, and every /batch unit runs as a subagent, so commit and lean on git. Edits made outside Claude Code aren't tracked, messages queued mid-turn aren't checkpointed, and symlinked or hard-linked files are skipped. In Anthropic's words, it's "not a replacement for version control".

## /clear vs /compact, and /context

**/compact or /clear?**

**🗜️ /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](https://bytevancer.com/blog/claude-code-mods) covers extending Claude Code itself.

## The whole series

1. [Part 1: Audit your prompts with /claude-api prompt-audit](https://bytevancer.com/blog/claude-code-commands-part-1-prompt-audit)
2. [Part 2: /effort, /simplify and /frontend-design](https://bytevancer.com/blog/claude-code-commands-part-2-effort-simplify-frontend-design)
3. **Part 3: ultracode, /batch, /compact and /rewind (this post)**
4. [Part 4: build-eval and hillclimb for your Claude app](https://bytevancer.com/blog/claude-code-commands-part-4-build-eval-hillclimb)

Next up: [Part 4](https://bytevancer.com/blog/claude-code-commands-part-4-build-eval-hillclimb) stops guessing and starts measuring, with /claude-api build-eval and hillclimb on a Claude-powered app.

## Frequently asked questions

**What does ultracode do in Claude Code?**
Including the keyword ultracode in a prompt you type asks Claude to write a dynamic workflow: a JavaScript script that orchestrates many subagents and runs in the background while your session stays responsive. /effort ultracode makes Claude plan a workflow for every substantive task in the session, which uses more tokens and hits limits sooner.

**Why doesn't the ultracode keyword work with claude -p?**
The keyword only works in a prompt you type yourself: the interactive prompt, the IDE panel, a Remote Control client, or SDK input stamped as human. It doesn't start a workflow from claude -p, an SDK prompt that isn't stamped human, a scheduled task, or a webhook or PR comment.

**What does /batch need to run?**
A git repo or a WorktreeCreate hook, because each unit runs in an isolated worktree; outside git it needs Claude Code v2.1.281 or later. /batch researches the codebase, splits the work into 5 to 30 independent units, shows a plan, and after you approve it runs one background subagent per unit that implements, tests and publishes its change.

**Does /rewind undo everything Claude did?**
No. Checkpoints don't track file changes made by Bash commands such as rm, mv or cp, most subagent edits, edits made outside Claude Code, or symlinked and hard-linked files. Anthropic says checkpointing is not a replacement for version control, so keep using git.

**Should I use /clear or /compact?**
Use /compact to free context while continuing the same task: it summarizes the conversation so far and accepts focus instructions. Use /clear between unrelated tasks: it starts a new conversation with empty context but keeps project memory, and the previous conversation stays reachable through /resume.

## Keep reading

- [Claude Code Commands, Part 2: /effort, /simplify and /frontend-design](https://bytevancer.com/blog/claude-code-commands-part-2-effort-simplify-frontend-design) — Part 2 of our Claude Code commands series: set /effort per model, clean up with /simplify (not /code-review), and brief /frontend-design properly.
- [Claude Code Commands, Part 4: build-eval and hillclimb for Your Claude App](https://bytevancer.com/blog/claude-code-commands-part-4-build-eval-hillclimb) — Part 4 of our Claude Code commands series: build an eval with /claude-api build-eval, check it's trustworthy, then hillclimb on held-out cases.
- [All ByteVancer engineering articles](https://bytevancer.com/blog)

## Got a migration that's too big for one chat?

We plan and run large codebase changes with AI agents in parallel, with worktrees, real tests and git as the safety net. See our [large-scale codebase migrations with AI agents](https://bytevancer.com/services/cloud-applications) or [talk to the team](https://bytevancer.com/contact).

## Sources

- [Claude Code docs — Commands reference (checked Oct 3, 2026)](https://code.claude.com/docs/en/commands)
- [Claude Code docs — Dynamic workflows (checked Oct 3, 2026)](https://code.claude.com/docs/en/workflows)
- [Thariq Shihipar & Sid Bidasaria — A harness for every task: dynamic workflows in Claude Code, claude.dev (Jun 2, 2026)](https://claude.dev/blog/a-harness-for-every-task-dynamic-workflows-in-claude-code/)
- [Claude Code docs — Checkpointing](https://code.claude.com/docs/en/checkpointing)
- [Claude Code docs — Best practices](https://code.claude.com/docs/en/best-practices)

---

*This is the Markdown copy of https://bytevancer.com/blog/claude-code-commands-part-3-ultracode-batch-compact-rewind — the page itself has the interactive charts and diagrams.*
