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.
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.
1---2name: "orchestrate-batch-refactor"3description: "Plan and execute large refactor or rewrite efforts efficiently with parallel multi-agent analysis and implementation. Use when a user asks to refactor many files, split workstreams, analyze a target code area, and coordinate sub-agents with clear ownership and dependency-aware execution."4metadata:5 source: https://skillmd.com/skills/dimillian/orchestrate-batch-refactor6---78# Orchestrate Batch Refactor910## Overview1112Use this skill to run high-throughput refactors safely.13Analyze scope in parallel, synthesize a single plan, then execute independent work packets with sub-agents.1415## Inputs1617- Repo path and target scope (paths, modules, or feature area)18- Goal type: refactor, rewrite, or hybrid19- Constraints: behavior parity, API stability, deadlines, test requirements2021## When to Use Parallelization2223- Use this skill for medium/large scope touching many files or subsystems.24- Skip multi-agent execution for tiny edits or highly coupled single-file work.2526## Core Workflow27281. Define scope and success criteria.29 - List target paths/modules and non-goals.30 - State behavior constraints (for example: preserve external behavior).312. Run parallel analysis first.32 - Split target scope into analysis lanes.33 - Spawn `explorer` sub-agents in parallel to analyze each lane.34 - Ask each agent for: intent map, coupling risks, candidate work packets, required validations.353. Build one dependency-aware plan.36 - Merge explorer output into a single work graph.37 - Create work packets with clear file ownership and validation commands.38 - Sequence packets by dependency level; run only independent packets in parallel.394. Execute with worker agents.40 - Spawn one `worker` per independent packet.41 - Assign explicit ownership (files/responsibility).42 - Instruct every worker that they are not alone in the codebase and must ignore unrelated edits.435. Integrate and verify.44 - Review packet outputs, resolve overlaps, and run validation gates.45 - Run targeted tests per packet, then broader suite for integrated scope.466. Report and close.47 - Summarize packet outcomes, key refactors, conflicts resolved, and residual risks.4849## Work Packet Rules5051- One owner per file per execution wave.52- No parallel edits on overlapping file sets.53- Keep packet goals narrow and measurable.54- Include explicit done criteria and required checks.55- Prefer behavior-preserving refactors unless user explicitly requests behavior change.5657## Planning Contract5859Every packet must include:60611. Packet ID and objective.622. Owned files.633. Dependencies (none or packet IDs).644. Risks and invariants to preserve.655. Required checks.666. Integration notes for main thread.6768Use [`references/work-packet-template.md`](references/work-packet-template.md) for the exact shape.6970## Agent Prompting Contract7172- Use the prompt templates in [`references/agent-prompt-templates.md`](references/agent-prompt-templates.md).73- Explorer prompts focus on analysis and decomposition.74- Worker prompts focus on implementation and validation with strict ownership boundaries.7576## Safety Guardrails7778- Do not start worker execution before plan synthesis is complete.79- Do not parallelize across unresolved dependencies.80- Do not claim completion if any required packet check fails.81- Stop and re-plan when packet boundaries cause repeated merge conflicts.8283## Validation Strategy8485Run in this order:86871. Packet-level checks (fast and scoped).882. Cross-packet integration checks.893. Full project safety checks when scope is broad.9091Prefer fast feedback loops, but never skip required behavior checks.