CloudCodeTree LogoCloudCodeTree
AI NewsTutorialsAbout
CloudCodeTree Logo
CloudCodeTree
  • AI News
  • Tutorials
  • About
← Back to AI News
One Slash Command, Hundreds of Worktree Agents: /batch for Repo-Wide Code Migrations

One Slash Command, Hundreds of Worktree Agents: /batch for Repo-Wide Code Migrations

Chris Harper

2 min read

Jul 30, 2026 · 20:05 UTC

AI
Workflow
Claude Code
Best Practices

Type /batch migrate from lodash to native and Claude Code proposes a per-module plan, fans out one worktree agent per unit, and each opens a draft PR automatically.

/batch is a built-in Claude Code slash command that turns any repo-wide mechanical task into a supervised parallel migration. Every run follows the same flow:

  1. Research — Claude scans your repo, understands what needs changing, and enumerates independent work units
  2. Plan for approval — it proposes 5–30 units ("migrate /src/auth/**", "migrate /src/api/**") and waits for your OK before touching a single file
  3. Fan out — one isolated worktree agent per unit; each gets its own branch, works without interfering with others, runs its scope's tests
  4. Draft PRs — each agent opens a draft PR when done; you get N focused, independently reviewable branches waiting

Common use cases

/batch migrate from lodash to native Array/Object methods
/batch add TypeScript types to all untyped function parameters
/batch rename DB columns from camelCase to snake_case
/batch replace deprecated axios calls with fetch
/batch add JSDoc to all exported functions

What makes it safe

Each agent works in an isolated git worktree — a separate directory backed by the same .git folder. One agent touching /src/auth/ cannot see or break /src/api/. If one agent's branch fails tests, only that unit's PR is red; the others merge normally.

The plan-approval step is the key: you review the decomposition before any file changes. If Claude missed a module or split things wrong, say so and it re-plans.

When to reach for it vs. writing a workflow script

/batch is best for mechanical changes with a clear per-file or per-module unit of work, where tests can verify each unit independently. For migrations where the transform itself is uncertain, verify the pattern manually on one file first — then /batch to apply the confirmed transform at scale.

Anthropic runs their own large-scale migrations this way: the AI code migration blog post describes a 1M-line Zig-to-Rust port completing in under two weeks using exactly this parallel worktree pattern.

Sources: What is /batch — ClaudeLog · /simplify and /batch commands — claudefa.st · How Anthropic runs large-scale code migrations — Anthropic