orchestrate-batch-refactor
БесплатноБез исполняемых скриптовНе проверенRuns a large refactor or migration across many files by splitting it into units that cannot collide, mapping the code with read-only subagents, dispatching…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
Orchestrate Batch Refactor
Overview
A change that touches a hundred files is slow in one context window and dangerous when several agents edit at once. The way through is to act as an orchestrator: keep the requirements, the plan and the verification in the main session, hand the reading and the mechanical editing to subagents, and make collisions impossible by giving every file exactly one owner. Subagents start with an empty context and return only a summary, so the quality of the result depends on two artefacts this skill defines: the plan and the brief each worker receives.
Instructions
1. Decide whether to orchestrate
| Situation | Approach |
|---|---|
| Fewer than about ten files, or one tightly coupled module | Do it in the main session |
| A purely syntactic change (rename a symbol, change an import path) | Use a codemod, the compiler or the language server's rename; review the diff. No subagents needed |
| Many files, each edit needs judgment, units can be checked on their own | Orchestrate with parallel workers |
| Many files but every edit depends on the previous one (a type that ripples outward) | Orchestrate in sequence: one worker at a time, or do it yourself |
Parallel work costs more tokens than a single run, so use it for speed and context relief, not by default.
2. Fix the scope and the baseline
Ask the user: what must change, what must stay identical (public API, behaviour, wire formats, database schema), what is out of scope, whether the work lands as one commit series or one pull request, and whether workers may commit.
Look up yourself:
git status --short # start from a clean tree; stash or commit nothing yourself, ask
git grep -l "fetchJson(" -- 'packages/*/src' | wc -l # how many files
git grep -c "fetchJson(" -- 'packages/*/src' | sort -t: -k2 -nr | head # where the weight is
Find the project's checks in package.json, Makefile, pyproject.toml or the CI workflow, run them once, and record the result and the duration. A baseline that already fails must be reported before any edit, otherwise later failures cannot be attributed.
3. Map the code with read-only subagents
Split the scope into areas that follow the repository's own seams (packages, services, top-level directories) and send one read-only explorer per area, in parallel. Give each the pattern to look for and this return format:
AREA: packages/billing
FILES AFFECTED: 31 (list with occurrence counts)
VARIANTS: forms the pattern takes here, one example each (file:line)
SHARED FILES: files that other areas also import or would need to edit
HIDDEN USES: re-exports, string-based lookups, generated code, config, mocks, docs
TESTS: which suites cover these files and the command to run only them
RISKS: anything that cannot be changed mechanically, with the reason
4. Know how your agent delegates
| Read-only explorer | Worker that edits | Parallelism | Isolation between workers | |
|---|---|---|---|---|
| Claude Code | built-in Explore |
general-purpose, or a custom agent in .claude/agents/ |
Several Agent calls in one turn; 20 running at once by default | isolation: worktree in the agent's frontmatter gives each worker its own git worktree |
| Codex | built-in explorer |
built-in worker, or a TOML agent in .codex/agents/ |
Ask in words ("spawn one agent per unit and wait for all"); cap with agents.max_concurrent_threads_per_session |
Same checkout and sandbox as the parent; rely on disjoint file lists |
| Cursor | built-in Explore | custom agent in .cursor/agents/ |
Several Task calls in one message | Shared checkout unless you ask for "each in its own environment", which gives each a worktree and branch |
| Gemini CLI | codebase_investigator |
generalist |
Subagents cannot call other subagents; plan for one delegation at a time | Shared checkout |
Facts that shape the plan:
- A subagent does not see the conversation. Whatever it needs (rule, file list, commands, constraints) must be in its brief.
- In a shared checkout, two workers editing one file overwrite each other. Disjoint ownership is the protection.
- Claude Code worktrees branch from the repository's default branch, not from your current work, unless
worktree.baseRefis set to"head"in settings. A worker in a fresh worktree will not see an uncommitted foundation change. - Each finished subagent returns its report into the main context. Ask for short, structured reports.
5. Write one plan
Merge the explorer reports into a single plan and show it to the user before any worker edits.
# Refactor plan: fetchJson callbacks → http.get promises
Invariants: public exports of every package unchanged; no behaviour change; retry and timeout semantics identical
Baseline: pnpm -r typecheck (ok, 48 s) · pnpm -r test (ok, 612 tests, 3 min 10 s)
| Unit | Objective | Owns | Depends on | Check | Done when |
|------|-----------|------|
Установить orchestrate-batch-refactor в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл orchestrate-batch-refactor?
Runs a large refactor or migration across many files by splitting it into units that cannot collide, mapping the code with read-only subagents, dispatching one worker per unit in dependency order, and verifying everything in the main session before reporting. Includes the decision of when not to parallelize, a plan format with file ownership, a worker brief, and how subagents and worktrees behave in Claude Code, Codex, Gemini CLI and Cursor. Use when the user says "refactor this across the whole repo", "migrate all call sites", "split this up between subagents", "run the migration in parallel", "batch refactor", or "this change touches a hundred files".
Как установить скилл orchestrate-batch-refactor?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл orchestrate-batch-refactor запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic