Refactoring your whole codebase file-by-file takes forever.
You make the same change ten times, wait for tests to pass ten times, debug the same edge case across ten PRs.
Claude Code’s /batch command breaks that pattern.
Instead of one refactor running sequentially, /batch decomposes your task into 5-30 independent units and runs them in parallel. Each unit gets its own Claude instance, its own git worktree, its own PR. When they finish, you merge them all at once. Typical speedup: 10x faster than file-by-file.
Here’s the flow:
First, identify your refactoring scope. Large codebases usually have clusters of files that follow the same pattern. An old API client library used in 15 places. A deprecated utility function scattered across the backend. A style migration across all React components. Find them with grep, a glob, or your own knowledge of the codebase.
Pass your refactoring prompt to /batch. Tell it what you’re changing and why. Claude decomposes the work: one unit per file, or one per logical scope if they’re naturally grouped. It shows you the plan before executing anything. Read it. Does each unit stand alone? Can a reviewer merge one without waiting for another? If yes, approve.
From there, /batch takes over. Each unit spins up in its own worktree. Claude runs your refactoring prompt independently on each one. Tests run. Changes go into a PR. No waiting for one unit to finish before the next starts.
Watch the PRs come in. Merge when tests pass. Done.
One gotcha: units must be independently mergeable. If unit B depends on unit A’s result, /batch isn’t the right tool. For that kind of sequential work, run the refactors one at a time. Another gotcha: each unit needs its own passing test suite. If your tests are flaky, fix that before starting /batch or you’ll spend more time debugging than you saved.
For codebases with hundreds of files, /batch is a productivity multiplier. It’s especially useful for migrations, deprecations, and style updates where the change is the same everywhere but independent per-file.
——
Book your free AI clarity call, NOW!
https://buff.ly/TpWy277
——
Repost this. Thanks.
