Use case
Refactoring
TL;DR
A refactor across several packages is the easiest job to run in parallel: one spec, applied to separate parts of the codebase. Commit the spec once, open one pane per package, and point an agent in each pane at it. Every pane has its own worktree and branch, so the agents never touch each other's files. Review and commit each package on its own, in a fraction of the time.
The most repetitive agent task is also the easiest to parallelize: the same spec, a different scope. “Switch every logger call to the new structured logger” across packages A to E is five identical jobs on five separate parts of the code. Five panes, five agents, a fifth of the wall time.
Why it fits panes
One package per agent means no shared state while they work.
With one package per agent, each works in isolation, with nothing shared while they run and no chance of two agents writing the same file. The only coordination is at merge, by which point each package is already clean.
A refactor also has a clear definition of done: a before-and-after pattern the agent can check. Write the spec once; the agents do the mechanical work; you review the diffs.
Walkthrough
Commit the spec, one pane per package, review and commit each.
- 1Write
refactor.mdat the repo root: the before-and-after pattern, which folders to touch, and what to avoid. The more precise it is, the less the agent improvises. Commit it, so every new worktree has a copy. - 2Create a pane per package with Ctrl+N, named after the package, such as
refactor/pkg-authandrefactor/pkg-billing. Each gets its own worktree and branch. - 3In each pane, start your agent and point it at
refactor.mdand its package. Same spec, different folder. - 4Watch progress from the sidebar; move between panes with Ctrl+Tab. A notification tells you when an agent finishes or gets stuck.
- 5Review each pane's Changes with Ctrl+Shift+B and commit it with Ctrl+Shift+K. If packages share a boundary, rebase the next branch on the previous one first.
Variation: best of N
Unsure of the approach? Run several attempts and keep the best.
If you're not sure how a refactor should go, run several agents on the same package from the same base branch and compare. In Pane's Create Pane dialog, set Panes to 2 to 5 and it makes that many worktrees at once. Review each diff, keep the one you like, and archive the rest. It costs more tokens but helps when the task is ambiguous.
When this breaks
Shared interfaces and global side effects need an order.
- → Shared interfaces. If the refactor changes a type or function every package imports from a shared library, do the library first, merge it, then rebase each package branch on top.
- → Packages that import each other. If package B imports package A and both change in parallel, B's agent works against the old A. Sequence them, or plan a rebase after A lands.
- → Global side effects. Database migrations, code generation and similar steps should run one branch at a time.
See also parallel features and Pane vs Emdash.
Sources
- Corrections
- If anything here is wrong or out of date, tell us and we'll fix it and update the date at the top. Open an issue on GitHub
- Sources
frequently asked questions
By Parsa Khazaeepoul, co-founder of Pane. .