Scaling Workflows
Part 4: Scaling Workflows
4.1 /batch — Codebase-Wide Migrations
text
/batch migrate all API routes from Express to Hono
/batch replace all uses of lodash with native equivalents
/batch add type annotations to all untyped function parameters
/batch standardize all API error responsesHow it works:
- Research and Plan:
/batchexplores affected files, decomposes into 5–30 independent units - Spawn Workers: One agent per unit in an isolated git worktree
- Each worker: implement → run /simplify → run tests → commit → open PR
- Merge independently — failure in one unit doesn't affect others
Prerequisites: Git repository required (uses worktrees for isolation). Add .claude/worktrees/ to .gitignore.
4.2 Agent Teams — Coordinated Parallel Work
Enable:
json
// In settings.json
"env": { "CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1" }Usage:
text
Create an agent team for the payment integration:
- API agent: implement Stripe webhook handlers in services/payments/
- Frontend agent: build the checkout flow in apps/web/checkout/
- Test agent: write integration tests covering the full payment flow
Use Sonnet for each teammate to manage costs.Display modes:
- In-process (default in non-tmux): Shift+Up/Down to switch between teammates
- Split panes (in tmux/iTerm2): Each teammate in its own pane
- Auto: Detects tmux → split panes, otherwise in-process
Team hooks:
TeammateIdle: Fires when a teammate is about to go idle. Exit 2 to reassign work.TaskCompleted: Fires when a task is marked complete. Exit 2 to enforce quality gates.
Best practices:
- 3–5 teammates is the sweet spot
- Enable delegate mode to prevent the lead from doing implementation
- Assign clear file ownership per agent
- Token costs scale linearly with team size
- Use subagents for quick focused work; Agent Teams for coordination-heavy work
4.3 /loop — Recurring Monitoring
text
/loop 5m check the deploy status and report any errors
/loop 10m run the test suite and summarize failures
/loop 30m scan for new TODO comments added since last checkSession-level cron. Stays active while the session is open. Disable with CLAUDE_CODE_DISABLE_CRON.
4.4 /simplify — Post-Implementation Review
Run after finishing any feature, before opening a PR:
text
/simplify
/simplify focus on memory efficiency
/simplify focus on error handlingSpawns 3 parallel agents:
- Code Reuse Agent: Scans for duplicated patterns, checks for existing utilities
- Code Quality Agent: Looks for dead code, unclear logic, style issues
- Efficiency Agent: Profiles for unnecessary allocations, redundant loops, batch opportunities
Findings are aggregated and fixes applied automatically. You review the diff.