refactor-plan
Skill3 starsChanged 6 months agoMITView on GitHub
Multi-agent refactor planning — files + goal in, ordered step plan with risk per step out. Wraps `jutsu swarm refactor-plan <path>... --goal "<goal>"` to run claude / codex / antigravity with three angles (claude=architectural decomposition, codex=stepwise risk, antigravity=pattern consistency). Designed to feed into `planning-and-task-breakdown` for execution. Use when the user says "plan this refactor", "how do I restructure", "step plan to extract X", or invokes /refactor-plan.
11 other projects use a version of this.
Adopted by
Most recently taken up by
- Aboudjem/ui-ux-suitetheir own version, first seen Nov 8, 2026
- GangJaeYu/harness_loop_full_koreantheir own version, first seen Oct 29, 2026
- github/awesome-copilottheir own version, first seen Oct 25, 2026
- BuilderIO/agent-nativetheir own version, first seen Oct 17, 2026
- hyperledger-cacti/cactitheir own version, first seen Oct 9, 2026
- Cosmian/kmstheir own version, first seen Oct 8, 2026
Other versions11 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 11
- github/awesome-copilot★ 41ksame name
- BuilderIO/agent-native★ 7.6ksame name
- hyperledger-cacti/cacti★ 412same name
- Cosmian/kms★ 372same name
- Aboudjem/ui-ux-suite★ 8same name
- GangJaeYu/harness_loop_full_korean★ 4same name
- DingGao1124/skills★ 2same name
- GA14-hub/claude-code-kit-ja★ 1same name
- khanashes/claude-skills★ 0same name
- ReaperOAK/ForgeOS★ 0same name
1 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository26 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- code-simplificationSkill
- dcgSkill
- editorial-reviewSkill
- journalSkill
- readme-updateSkill
- security-and-hardeningSkill
- session-retroSkill
- autopilotSkill
- blunder-huntSkill
- brainstormSkill
- convergence-detectSkill
- deslopSkill
- dispatch-parallelSkill
- doc-reviewSkill
- dreamSkill
- incremental-implementationSkill
- planning-and-task-breakdownSkill
- polishSkill
- pr-reviewSkill
- scope-checkSkill
- security-auditSkill
- spec-driven-developmentSkill
- unstuckSkill
- verification-before-completionSkill
The file
We split this skill into the rules it gives an agent
4 rules. 0 are common, 2 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 8 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 39
Before the first invocation in a repo:
- Very specific: line 84
--goal is required: If the user can't articulate the goal in one line, the refactor isn't well-defined yet — go back to brainstorm.
- Distinctive: line 86
Cite line ranges: Every step references existing code by file:line.
- Very specific: line 97
Default --max-cost $1.00. With 3 agents in --quick mode, typical refactor-plan runs ~$0.10–0.40 depending on file size.
“Common” is measured: kept by at least 6 in 10 of the 8 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
refactor-plan
Three angles on the same refactor:
| Lens | Agent | Looks for |
| Architectural decomposition | claude | The right new shape — abstractions, boundaries, test seams |
| Stepwise risk | codex | Order that minimizes regression — small reversible steps first |
| Pattern consistency | antigravity | Existing repo patterns the refactor should follow, not invent around |
Synthesizer takes all three step proposals, clusters by what-changes, sorts low-risk-first, surfaces ordering disagreements as callouts. Output is an ordered plan with per-step risk + files-touched.
When to invoke
# Single-file refactor
jutsu swarm refactor-plan handlers/users.go --goal "extract auth check into middleware"
# Multi-file (concatenated review — agents reason cross-file)
jutsu swarm refactor-plan cmd/server/handlers.go cmd/server/router.go \
--goal "split monolithic handler module into per-resource services"
# High-stakes — debate + filter
jutsu swarm refactor-plan db/migrations.go --goal "split into per-table migration files" --full --strict
# Iterate on synth prompt without re-spending
jutsu swarm refactor-plan --replay <key>The --goal flag is REQUIRED. Missing-goal invocation hard-errors with a usage hint. Goal text counts against the 200 KB InputFiles cap (negligible in practice).
First-run consent
Before the first invocation in a repo:
jutsu swarm refactor-plan --grant-consentPersists allow-multi-model: true to .kaijutsu/refactor-plan.yaml. Files + goal go to remote model providers; explicit consent required.
Reading the output
### Plan
1. **Step 1 — Extract auth check into separate function** (recommended, agreement 3/3)
- What: Move lines 42-58 from handlers/users.go into a new authMiddleware function.
- Why: Single responsibility; isolates auth from request handling.
- Risk: Low. No behavior change. Tests in handlers_test.go cover the path.
- Files touched: handlers/users.go:42-58
2. **Step 2 — Wire middleware into router** (recommended, agreement 2/3)
- ...
### Ordering disagreements
- claude wanted Step 4 before Step 3; codex argued Step 3's reversibility
makes it lower-risk to ship first. Going with codex's order.
### Speculative additions
- Optional: extract a TokenValidator interface for easier mocking.
Defer unless tests need it.The disagreement table (rendered separately) shows which agent proposed each step. 1/N rows are usually the speculative bucket — interesting but not required.
Composes
This skill chains naturally:
brainstorm— pick the refactor approach (if not yet decided)refactor-plan— turn that approach into ordered steps with riskplanning-and-task-breakdown— convert the steps into shippable vertical slices with per-task acceptance- Implementation in a separate session, slice by slice
Each tool gets its own multi-agent pass at the appropriate level of detail.
Hard rules
- --goal is required. If the user can't articulate the goal in one line, the refactor isn't well-defined yet — go back to
brainstorm. - Read-only on inputs. refactor-plan never modifies files; it produces a plan markdown the user reads + executes manually (or via planning-and-task-breakdown → implementation).
- Cite line ranges. Every step references existing code by file:line. Plans without citations are aspirational, not actionable.
- Don't run on the WHOLE repo. The 200 KB cap exists because cross-file refactors only synthesize well over a focused subset. If the refactor touches 30 files, narrow to the core 5-10 the agents need to reason about, then plan the rest based on the pattern.
When NOT to use
- Single-line behavioral fixes — overkill.
- Pure stylistic refactors (renames, formatting) —
polishis the right primitive. - Refactors that need to read external dependencies (third-party source) — refactor-plan is sandboxed; supply the relevant external code as input files OR brainstorm the approach instead.
Cost
Default --max-cost $1.00. With 3 agents in --quick mode, typical refactor-plan runs ~$0.10–0.40 depending on file size. --full (debate round) adds ~50%. --strict (lie-to-them filter on synthesis) adds another synthesis call.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

