Agent skill

Refactor Planner

by WrongStack in WrongStack/WrongStack

A skill your agent uses when planning a multi-file refactor, code modernization, or technical debt resolution.

MITAuto-check passedDevelopment

Install Refactor Planner

skills CLI
$ npx skills add WrongStack/WrongStack --skill refactor-planner -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install WrongStack/WrongStack refactor-planner --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/WrongStack/WrongStack.git skills-src && mkdir -p .claude/skills && cp -r skills-src/packages/core/skills/refactor-planner .claude/skills/refactor-planner && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
refactor-planner
GitHub stars
370
Token cost
~3.3k tokens
SKILL.md length
1,438 words
Files
2
Skills in repo
38
Repo updated
First seen
Licence
MIT

At a glance

A skill your agent uses when planning a multi-file refactor, code modernization, or technical debt resolution.

  • Works in 6 steps: Always build a dependency graph before… → Always include a rollback strategy —… → Never skip Phase 1 (low-risk quick wins)… → …
  • Planning a multi-file refactor
  • SKILL.md covers Overview, Rules, Workflow and Building the dependency graph, plus 11 more sections
  • Calls pnpm and git

What it does

Refactor Planner is an agent skill from WrongStack/WrongStack. Use this skill when planning a multi-file refactor, code modernization, or technical debt resolution. Trigger on the explicit vocabulary — "refactor", "technical debt", "modernize", "clean up", "restructure", "decompose" — and on the task shape, which is how it usually arrives: "this file is 2000 lines", "split this up", "extract X into its own module", "there's a circular dependency", "migrate from X to Y", "this is getting unmaintainable", "everything imports everything". This skill produces a phased PLAN with…

Its SKILL.md is about 3.3k tokens, which your agent loads only when the skill is triggered. The skill folder holds 1 other file (for example `SKILL.save.md`).

It sits in Development, covering Refactoring, Technical debt and Legacy modernization. The repository describes itself as: An AI coding agent that reads your code, edits files, runs commands, and reasons through bugs — across a terminal REPL, a full-screen TUI, and a browser UI, while you keep your… The licence is MIT.

When your agent uses it

  • Planning a multi-file refactor
  • Code modernization
  • Technical debt resolution
  • The explicit vocabulary — refactor

Example prompts

  • “refactor”
  • “technical debt”
  • “modernize”
  • “/refactor-planner”

Workflow steps

6 steps, taken from the first numbered list in SKILL.md.

  1. Always build a dependency graph before planning — assumptions cause wasted work.
  2. Always include a rollback strategy — every refactor can fail.
  3. Never skip Phase 1 (low-risk quick wins) — momentum matters.
  4. Never over-phase — if a task takes <1h, merge it with related tasks.
  5. Rate each module by: cyclomatic complexity, test coverage, fan-out, public API surface.
  6. Never ignore team constraints — parallelization only works if reviewers exist.

What it can do on your machine

Read from SKILL.md and the folder at commit 57f6018. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • pnpm
    • git

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use pnpm and git, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Refactor Planner loads about 3.3k tokens when it runs. Until then it costs about 179 tokens; SKILL.md has 1,438 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~179
When it runs · the whole SKILL.md, loaded when a task matches
~3.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from WrongStack/WrongStack at commit 57f6018, republished under its MIT licence (© WrongStack). 1,438 words, ~3,290 tokens.

Download SKILL.mdSave it as .claude/skills/refactor-planner/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
refactor-planner
description
Use this skill when planning a multi-file refactor, code modernization, or technical debt resolution. Trigger on the explicit vocabulary — "refactor", "technical debt", "modernize", "clean up", "restructure", "decompose" — and on the task shape, which is how it usually arrives: "this file is 2000 lines", "split this up", "extract X into its own module", "there's a circular dependency", "migrate from X to Y", "this is getting unmaintainable", "everything imports everything". This skill produces a phased PLAN with a dependency graph, risk scores, and a rollback strategy — it does not perform the refactor. Use it before touching code, and when a refactor already in flight has lost its ordering.
version
2.0.0
required-capabilities
filesystem.read, code.inspect, work.plan

Refactor Planner

Overview

Analyzes code structure and produces a phased refactoring plan with risk assessment, dependency ordering, and rollback strategy. Use for multi-file refactors, breaking up large modules, changing public APIs, addressing technical debt, or migrating to new patterns.

This skill plans; it does not execute. The deliverable is the phased plan. Do not start editing modules while planning — a half-done refactor with no graph behind it is the exact failure this skill exists to prevent. Hand the finished plan to the executing agent, phase by phase.

Rules

  1. Always build a dependency graph before planning — assumptions cause wasted work.
  2. Always include a rollback strategy — every refactor can fail.
  3. Never skip Phase 1 (low-risk quick wins) — momentum matters.
  4. Never over-phase — if a task takes <1h, merge it with related tasks.
  5. Rate each module by: cyclomatic complexity, test coverage, fan-out, public API surface.
  6. Never ignore team constraints — parallelization only works if reviewers exist.

Workflow

1. Analyze:  Build dependency graph, identify coupling
2. Score:    Rate each module by size, complexity, test coverage
3. Plan:     Order tasks by risk, dependency, payoff
4. Document: Phased markdown plan with checkpoints

Building the dependency graph

Rule 1 and the anti-pattern list both call this the most important part, so do it from evidence, not from intuition.

Derive it from the code. When the codebase index is available, the codebase-impact-analysis tool returns a symbol's production callers and affected tests, the codebase-incoming-calls and codebase-outgoing-calls tools give both edge directions, and the codebase-repo-map tool shows which files are hubs. Without the index, grep the actual import / require / from statements across the target set. Directory layout, file naming, and the mental model in someone's head all lie; the import statements don't.

Arrow convention: A → B means A depends on B. B is the leaf. This is the one thing the graph must be unambiguous about, because it decides the entire ordering.

Refactor leaves first, right to left. Changing a leaf ripples up to its dependents, so a leaf changed late invalidates everything already done above it. In this graph:

text
config.ts → logger.ts → path-resolver.ts
     ↓           ↓
  secret-vault.ts    session-store.ts
     ↓                    ↓
     └────────→  agent.ts  ←←←

path-resolver.ts is safe to touch first; config.ts is the most expensive.

Also record the reverse edges. Fan-out (what a module imports) drives its own risk; the dependents list (who imports it) drives blast radius. Both belong in the score — a 40-line file imported by twelve modules is riskier to change than a 600-line file nobody imports.

Cycles come first

A cycle means there is no valid ordering, so every plan built over one is fictional. Find cycles during the analyze step and list them explicitly. Breaking them is Phase 1 work even when it looks like Phase 2 work, because nothing downstream can be sequenced until they're gone.

Typical breaks: extract the shared piece into a new leaf both sides import, invert one direction with an interface or callback, or move the coupling into a composition root that wires both.


Risk criteria

FactorLow RiskMedium RiskHigh Risk
Cyclomatic complexity<1010-20>20
Test coverage>80%50-80%<50%
Fan-out (imports)<55-15>15
Public API surfaceunchangedmodifiedremoved

Score every module in scope; the mix of factors, not any single one, sets the phase. A high-complexity module with 90% coverage is safer to change than a simple one with none — the tests are what tell you the refactor preserved behavior.

Risk assessment checklist

One record per module in scope:

json
{
  "module": "src/auth/session.ts",
  "size": 450,
  "cyclomatic": 12,
  "testCoverage": 65,
  "fanOut": 8,
  "publicAPI": true,
  "dependencies": ["core", "providers"],
  "dependents": ["cli", "tui", "webui"]
}
Coverage below 50% changes the first task

A refactor is only safe to the degree that something can tell you behavior didn't change. When a module scores <50% coverage, its first Phase 1 task is writing characterization tests — tests that pin down what the code does today, bugs included, before anything moves. This isn't scope creep; without it every later phase is unverifiable and the rollback strategy is the only safety net left.


Phase structure

Good refactors have 3 phases:

Phase 1: Low Risk / High Payoff
  - No behavior change
  - Tests already pass
  - Quick wins

Phase 2: Medium Risk (test heavily)
  - Some behavior may change
  - Significant test coverage needed
  - May need rollback plan

Phase 3: High Risk (full regression)
  - Behavior changes expected
  - Integration tests required
  - Coordinate with team

Two notes on using this well:

  • Each phase ends green. A phase boundary is a checkpoint: tests pass, the branch is mergeable, and the work could stop there permanently without leaving the codebase worse. If a phase can't end in that state, it's split wrong.
  • Phase 3 is redesign, not refactoring. Refactoring preserves behavior by definition; once behavior changes, the safety argument changes with it. Call that out in the plan so reviewers and QA know which parts need behavioral review rather than a diff read.
Estimates

Estimate from fan-out and coverage, not from line count — a small change in a widely-imported module costs more than a large one in a leaf. Keep the <1h merge rule (rule 4). Mark anything you're guessing at with a ? rather than inventing false precision; an honest range beats a confident wrong number when someone schedules against it.


Patterns

Do
text
// ✅ Good — graph derived from imports, direction stated, cycles named
// A → B means A imports B. Refactor right to left.
// CYCLE: config.ts ↔ logger.ts — break before sequencing anything else.
text
// ✅ Good — phase boundary is a real checkpoint
// End of Phase 1: pnpm test green, no circular deps in src/core, mergeable.
Don't
json
// ❌ Bad — no dependency graph
// "Refactor the auth layer" — with no graph, order is guessed

// ❌ Bad — no rollback strategy
// "We'll figure it out if something breaks" — plan for failure

// ❌ Bad — unverifiable exit criterion
// "Code is cleaner and easier to maintain" — nothing to check

Rollback strategy

Every phase needs one, and it has to match the phase's risk:

  • Phase 1 — reversible commits. One commit per task, nothing squashed until the phase is green: git checkout if tests fail.
  • Phase 2 — feature flag around the changed path so the old one still exists and can be re-enabled without a deploy.
  • Phase 3 — blue-green deployment, or whatever your release process offers for reverting behavior in production.

The test of a rollback plan is whether someone who wasn't in the planning session could execute it under pressure. "Revert the commits" is a plan only if the commits are actually separable.

Show full SKILL.md (575 more words)Show less

Exit criteria

Make each one mechanically checkable — a command that exits zero, or a number that can be measured. "Code is cleaner" is not an exit criterion, and a phase without a checkable exit never formally ends.

✅ pnpm test passes; no circular deps in src/core; Context interface < 20 methods ❌ Code is more maintainable; the module is better factored; complexity reduced


Phased plan output

text
## Refactor Plan — <target>

### Phase 1: Low Risk / High Payoff
| # | Task | Module | Risk | Est. Time |
|---|------|--------|------|-----------|
| 1 | Extract `ToolExecutor` interface | core/tool-executor.ts | low | 2h |
| 2 | Decouple `SessionStore` from Agent | core/session-store.ts | low | 4h |

### Phase 2: Medium Risk (test heavily)
| # | Task | Module | Risk | Est. Time |
|---|------|--------|------|-----------|
| 3 | Break circular dep: Config ↔ Logger | core/config.ts | medium | 6h |

### Dependency Graph
```
config.ts → logger.ts → path-resolver.ts
     ↓           ↓
  secret-vault.ts    session-store.ts
     ↓                    ↓
     └────────→  agent.ts  ←←←
```

### Rollback Strategy
- Phase 1: `git checkout` if tests fail
- Phase 2: Feature flag, can disable
- Phase 3: Blue-green deployment

### Exit Criteria
- [ ] All Phase 1 tasks pass `pnpm test`
- [ ] No circular deps in `src/core`
- [ ] `Context` interface < 20 methods

<nextsteps>
1. Extract ToolExecutor interface in core/tool-executor.ts
2. Decouple SessionStore from Agent in core/session-store.ts
3. Break circular dep between Config and Logger in core/config.ts
</nextsteps>

State the arrow convention alongside the graph, and if any cycles exist, list them directly under it — a reader who assumes the arrows point the other way will execute the plan backwards.


Anti-patterns

  • Don't plan without analyzing — assumptions cause wasted work
  • Don't skip rollback strategy — every refactor can fail
  • Don't over-phase — if a task takes <1h, merge it
  • Don't ignore team constraints — parallelization only works if reviewers exist
  • Don't skip the dependency graph — the most important part
  • Don't start refactoring while planning — the plan is the deliverable
  • Don't plan around a cycle — break it first, or the ordering is fiction
  • Don't refactor untested code blind — characterize it first
  • Don't write exit criteria nobody can check — they never close

Large targets

Above roughly 15 modules, scoring and graphing serially burns the session before the plan exists. Hand the analysis to the multi-agent fan-out pattern: one worker per chunk of 5–10 modules, each returning the same risk-assessment JSON shape, leader merges them into one graph. Read that skill for sizing and briefing rules first. The planning stays with the leader — only the measurement parallelizes.


Out of scope

  • Don't start refactoring while planning. A half-done refactor with no graph behind it is the failure this skill exists to prevent. Plan first, hand the plan to the executing agent phase by phase.
  • Don't write code or apply edits. This skill produces a plan, not a diff. If the user wants the refactor done, the executing agent picks it up; this skill's deliverable is the phased plan.
  • Don't skip the dependency graph. Ordering without a graph is guessing. Imports are the truth; build the graph from import statements, not from directory layout or someone's mental model.
  • Don't ignore cycles. A cycle means no valid ordering. List cycles explicitly, schedule their breaking first. A plan over a cycle is fiction.
  • Don't refactor modules under 50% coverage blind. Phase 1 of any such module is characterization tests, not the refactor itself. The safety argument is "behavior preserved" — without tests, there is no safety net.
  • Don't over-phase. Tasks under 1h merge with related tasks. A 12-phase plan for a 3-day refactor is process for process's sake.
  • Don't write exit criteria that aren't checkable. "Code is cleaner" is not an exit criterion. pnpm test passes is. If a phase has no checkable exit, it never formally ends.

Skills in scope

  • bug-hunter — for finding bugs exposed by the refactor
  • git-flow — for committing each phase properly
  • multi-agent — for parallel analysis of multiple modules
  • output-standards — for standardized <nextsteps> formatting

Before delivering the plan

  • Graph derived from actual imports or the codebase index, with the arrow convention stated
  • Cycles found, listed, and scheduled first
  • Every module in scope scored on all four risk factors
  • Modules under 50% coverage get characterization tests as their first task
  • Tasks ordered leaves-first; nothing depends on work scheduled later
  • Nothing under 1h stands alone (rule 4)
  • Each phase ends green, mergeable, and abandonable
  • Rollback strategy per phase, executable by someone who wasn't here
  • Every exit criterion is a command or a number
  • No code was modified while producing this plan

© WrongStack, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file in packages/core/skills/refactor-planner of WrongStack/WrongStack.

  • SKILL.md
  • SKILL.save.md

Open the folder on GitHubat commit 57f6018

Compare with similar skills

Refactor Planner next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Refactor Planner compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Refactor Planner this skillWrongStack/WrongStack370—~3.3kAutomated safety check: PassMIT
Code Refactoring Workflowluongnv89/claude-howto42k—~3.1kAutomated safety check: PassMIT
Fowler-Style Refactoringlhfer/claude-howto-zh-cn2.3k—~156Automated safety check: PassMIT
Refactoring Skill (Vietnamese)luongnv89/claude-howto42k—~3.1kAutomated safety check: PassMIT
Legacy ModernizerJeffallan/claude-skills12k—~1.6kAutomated safety check: PassMIT
Moai Workflow Dddmodu-ai/moai-adk1.2k—~3.6kAutomated safety check: PassApache-2.0

Similar skills

  • Code Refactoring Workflow

    luongnv89/claude-howto

    Guides systematic, test-backed refactoring in the style of Martin Fowler, moving through research, planning and small incremental changes with your approval at each phase.

    42k GitHub stars~3.1k tokensUpdated 8 days ago
    DevelopmentAuto-check passed
  • Fowler-Style Refactoring

    lhfer/claude-howto-zh-cn

    基于 Martin Fowler 方法论做系统化重构。Use when users ask to refactor code, improve structure, reduce technical debt, clean up legacy code, or improve maintainability.

    2.3k GitHub stars~156 tokensUpdated 2 mo ago
    DevelopmentAuto-check passed
  • Refactoring Skill (Vietnamese)

    luongnv89/claude-howto

    Vietnamese edition of a systematic refactoring skill based on Martin Fowler's book, working in approved phases with small, test-backed changes.

    42k GitHub stars~3.1k tokensUpdated 8 days ago
    DevelopmentAuto-check passed
  • Legacy Modernizer

    Jeffallan/claude-skills

    Plans incremental migrations of aging systems with the strangler fig pattern, using dependency maps, rollback plans, characterization tests and gradual traffic shifts.

    12k GitHub stars~1.6k tokensUpdated 4 days ago
    DevelopmentAuto-check passed
  • Moai Workflow Ddd

    modu-ai/moai-adk

    Domain-Driven Development workflow specialist using ANALYZE-PRESERVE-IMPROVE cycle for behavior-preserving code transformation.

    1.2k GitHub stars~3.6k tokensUpdated today
    DevelopmentAuto-check passed
  • Guided journey from a working codebase grown slow and tangled to one measurably fast, cleanly bounded, and readable.

    2.4k GitHub stars~7.4k tokensUpdated 27 days ago
    DevelopmentAuto-check passed

More from WrongStack/WrongStack

All 38 skills in this repo
  • Design Craft

    WrongStack/WrongStack

    Design or substantially improve user-facing interfaces with a product-specific visual direction, content hierarchy, and rendered critique.

    370 GitHub stars~2k tokensUpdated today
    Auto-check passed
  • Design Critique

    WrongStack/WrongStack

    A skill your agent uses to audit an interface that already exists and say precisely why it looks generated, templated, or unfinished — a scored rubric across composition, typography, color, states…

    370 GitHub stars~3k tokensUpdated today
    Auto-check passed
  • Mailbox Bridge

    WrongStack/WrongStack

    A skill your agent uses when external coding agents (Claude Code, Aider, custom scripts) need to participate in the project's shared WrongStack mailbox, or when a user asks to "expose the mailbox"…

    370 GitHub stars~3.9k tokensUpdated today
    Auto-check passed
  • Multi Agent

    WrongStack/WrongStack

    A skill your agent uses whenever work can be split across multiple AI agents running in parallel, or when orchestrating leader/worker patterns in WrongStack.

    370 GitHub stars~3.6k tokensUpdated today
    Auto-check passed
  • Web Platform Baseline

    WrongStack/WrongStack

    Use this skill before asserting that a CSS, HTML or accessibility capability is available, unavailable, or the right tool — it carries dated, refreshable platform facts and refuses to let stale…

    370 GitHub stars~1.6k tokensUpdated today
    Auto-check passed
  • Wrongstack Mailbox

    WrongStack/WrongStack

    A skill your agent uses when the user wants to communicate with WrongStack's shared project mailbox from outside WrongStack — read messages sent by WrongStack agents, send replies, broadcast to all…

    370 GitHub stars~3.5k tokensUpdated today
    Auto-check passed

Categories

Questions about Refactor Planner

What does Refactor Planner do?

A skill your agent uses when planning a multi-file refactor, code modernization, or technical debt resolution. Refactor Planner is an agent skill from WrongStack/WrongStack. Use this skill when planning a multi-file refactor, code modernization, or technical debt resolution.

When should I use Refactor Planner?

Refactor Planner fits situations like: planning a multi-file refactor; code modernization; technical debt resolution; the explicit vocabulary — refactor.

How do I install Refactor Planner in Claude Code?

Run `npx skills add WrongStack/WrongStack --skill refactor-planner -a claude-code`. Or copy the skill folder (packages/core/skills/refactor-planner in WrongStack/WrongStack) into .claude/skills/refactor-planner in your project. Claude Code loads it when a task matches its description.

How do I install Refactor Planner in Codex?

Run `npx skills add WrongStack/WrongStack --skill refactor-planner -a codex`. Or copy the skill folder (packages/core/skills/refactor-planner in WrongStack/WrongStack) into .agents/skills/refactor-planner in your project. Codex loads it when a task matches its description.

Can I use Refactor Planner in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add WrongStack/WrongStack --skill refactor-planner -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/refactor-planner, .gemini/skills/refactor-planner, .github/skills/refactor-planner and .opencode/skills/refactor-planner in your project.

What does Refactor Planner need to run?

Going by SKILL.md and its folder, Refactor Planner needs the command-line tools its instructions call (pnpm and git).

Does Refactor Planner access the network?

SKILL.md contains no URLs. Its commands use git, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Refactor Planner safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Refactor Planner use?

Refactor Planner is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Refactor Planner use?

About 3.3k tokens (SKILL.md is roughly 13k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Refactor Planner?

Skills that share tags, products or a category with Refactor Planner: Code Refactoring Workflow (luongnv89/claude-howto, 42k stars), Fowler-Style Refactoring (lhfer/claude-howto-zh-cn, 2.3k stars), Refactoring Skill (Vietnamese) (luongnv89/claude-howto, 42k stars) and Legacy Modernizer (Jeffallan/claude-skills, 12k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Refactor Planner?

WrongStack (a GitHub organization) maintains it in WrongStack/WrongStack, which has 370 GitHub stars. The repository holds 38 skills in this directory. The repository was last updated on October 7, 2026.

Source: WrongStack/WrongStack on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.