Orchestrate Batch Refactor
Overview
Use this skill to run high-throughput refactors safely.
Analyze scope in parallel, synthesize a single plan, then execute independent work packets with sub-agents.
When to Use
- When a refactor spans many files or subsystems and needs clear work partitioning.
- When you need dependency-aware planning before parallel implementation.
Inputs
- Repo path and target scope (paths, modules, or feature area)
- Goal type: refactor, rewrite, or hybrid
- Constraints: behavior parity, API stability, deadlines, test requirements
When to Use Parallelization
- Use this skill for medium/large scope touching many files or subsystems.
- Skip multi-agent execution for tiny edits or highly coupled single-file work.
Core Workflow
- Define scope and success criteria.
- List target paths/modules and non-goals.
- State behavior constraints (for example: preserve external behavior).
- Run parallel analysis first.
- Split target scope into analysis lanes.
- Spawn
explorer sub-agents in parallel to analyze each lane.
- Ask each agent for: intent map, coupling risks, candidate work packets, required validations.
- Build one dependency-aware plan.
- Merge explorer output into a single work graph.
- Create work packets with clear file ownership and validation commands.
- Sequence packets by dependency level; run only independent packets in parallel.
- Execute with worker agents.
- Spawn one
worker per independent packet.
- Assign explicit ownership (files/responsibility).
- Instruct every worker that they are not alone in the codebase and must ignore unrelated edits.
- Integrate and verify.
- Review packet outputs, resolve overlaps, and run validation gates.
- Run targeted tests per packet, then broader suite for integrated scope.
- Report and close.
- Summarize packet outcomes, key refactors, conflicts resolved, and residual risks.
Work Packet Rules
- One owner per file per execution wave.
- No parallel edits on overlapping file sets.
- Keep packet goals narrow and measurable.
- Include explicit done criteria and required checks.
- Prefer behavior-preserving refactors unless user explicitly requests behavior change.
Planning Contract
Every packet must include:
- Packet ID and objective.
- Owned files.
- Dependencies (none or packet IDs).
- Risks and invariants to preserve.
- Required checks.
- Integration notes for main thread.
Use references/work-packet-template.md for the exact shape.
Agent Prompting Contract
- Use the prompt templates in
references/agent-prompt-templates.md.
- Explorer prompts focus on analysis and decomposition.
- Worker prompts focus on implementation and validation with strict ownership boundaries.
Safety Guardrails
- Do not start worker execution before plan synthesis is complete.
- Do not parallelize across unresolved dependencies.
- Do not claim completion if any required packet check fails.
- Stop and re-plan when packet boundaries cause repeated merge conflicts.
Validation Strategy
Run in this order:
- Packet-level checks (fast and scoped).
- Cross-packet integration checks.
- Full project safety checks when scope is broad.
Prefer fast feedback loops, but never skip required behavior checks.
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
1---2name: orchestrate-batch-refactor3description: Plan and execute large refactors with dependency-aware work packets and parallel analysis.4license: MIT5---6
7# Orchestrate Batch Refactor
8
9## Overview
10
11Use this skill to run high-throughput refactors safely.
12Analyze scope in parallel, synthesize a single plan, then execute independent work packets with sub-agents.
13
14## When to Use
15- When a refactor spans many files or subsystems and needs clear work partitioning.
16- When you need dependency-aware planning before parallel implementation.
17
18## Inputs
19
20- Repo path and target scope (paths, modules, or feature area)
21- Goal type: refactor, rewrite, or hybrid
22- Constraints: behavior parity, API stability, deadlines, test requirements
23
24## When to Use Parallelization
25
26- Use this skill for medium/large scope touching many files or subsystems.
27- Skip multi-agent execution for tiny edits or highly coupled single-file work.
28
29## Core Workflow
30
311. Define scope and success criteria.
32 - List target paths/modules and non-goals.
33 - State behavior constraints (for example: preserve external behavior).
342. Run parallel analysis first.
35 - Split target scope into analysis lanes.
36 - Spawn `explorer` sub-agents in parallel to analyze each lane.
37 - Ask each agent for: intent map, coupling risks, candidate work packets, required validations.
383. Build one dependency-aware plan.
39 - Merge explorer output into a single work graph.
40 - Create work packets with clear file ownership and validation commands.
41 - Sequence packets by dependency level; run only independent packets in parallel.
424. Execute with worker agents.
43 - Spawn one `worker` per independent packet.
44 - Assign explicit ownership (files/responsibility).
45 - Instruct every worker that they are not alone in the codebase and must ignore unrelated edits.
465. Integrate and verify.
47 - Review packet outputs, resolve overlaps, and run validation gates.
48 - Run targeted tests per packet, then broader suite for integrated scope.
496. Report and close.
50 - Summarize packet outcomes, key refactors, conflicts resolved, and residual risks.
51
52## Work Packet Rules
53
54- One owner per file per execution wave.
55- No parallel edits on overlapping file sets.
56- Keep packet goals narrow and measurable.
57- Include explicit done criteria and required checks.
58- Prefer behavior-preserving refactors unless user explicitly requests behavior change.
59
60## Planning Contract
61
62Every packet must include:
63
641. Packet ID and objective.
652. Owned files.
663. Dependencies (none or packet IDs).
674. Risks and invariants to preserve.
685. Required checks.
696. Integration notes for main thread.
70
71Use [`references/work-packet-template.md`](references/work-packet-template.md) for the exact shape.
72
73## Agent Prompting Contract
74
75- Use the prompt templates in [`references/agent-prompt-templates.md`](references/agent-prompt-templates.md).
76- Explorer prompts focus on analysis and decomposition.
77- Worker prompts focus on implementation and validation with strict ownership boundaries.
78
79## Safety Guardrails
80
81- Do not start worker execution before plan synthesis is complete.
82- Do not parallelize across unresolved dependencies.
83- Do not claim completion if any required packet check fails.
84- Stop and re-plan when packet boundaries cause repeated merge conflicts.
85
86## Validation Strategy
87
88Run in this order:
89
901. Packet-level checks (fast and scoped).
912. Cross-packet integration checks.
923. Full project safety checks when scope is broad.
93
94Prefer fast feedback loops, but never skip required behavior checks.
95
96## Limitations
97- Use this skill only when the task clearly matches the scope described above.
98- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
99- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.