Skip to main content
skill CX Codex

refactor · parcadei — Claude Code skill: what it does, how to install

Runs refactoring through analysis, planning, implementation, review and test validation. Use it when restructuring code while preserving behaviour.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add parcadei/Continuous-Claude-v3 --skill refactor -a claude-code
Open on GitHub

What refactor does

The skill coordinates five subagents: phoenix examines the code and risks, plan-agent writes a step-by-step plan, and kraken makes the changes. plan-reviewer then checks the diff, while arbiter runs tests, type checks and linting.

It treats refactoring as small, reversible steps with tests after each change. A rename or simple restructure uses a shorter sequence of analysis, implementation and validation. Architecture changes can repeat implementation and review across phases.

The workflow expects adequate test coverage before work starts. --coverage-check requires coverage above 80%, so check that threshold before relying on this mode. Use --dry-run to create a plan without edits, or --step-by-step to pause for approval after each change.

What it helps with

  • extract code into a separate module
  • build a safe refactoring plan
  • check that behaviour stays unchanged
  • stop changes when tests fail
  • identify risk areas and test coverage gaps

Example prompts for the agent

  • Run /refactor and extract the validation logic into a separate module.
  • Use /refactor --dry-run to plan a restructure of src/validation.
  • Run /refactor --step-by-step for this rename and restructure.

How to install refactor

1Skills CLI (Vercel)

npx skills add parcadei/Continuous-Claude-v3 --skill refactor -a claude-code

2Manually: put the files in place

~/.claude/skills/refactor/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/refactor/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about refactor

How do I install refactor in Claude Code?

Run npx skills add parcadei/Continuous-Claude-v3 --skill refactor -a claude-code, then run npx skills add parcadei/Continuous-Claude-v3 --skill refactor -a claude-code again. The skill file is at ~/.claude/skills/refactor/SKILL.md.

What does refactor do?

It runs a refactoring workflow with analysis, planning, implementation, review and final validation. The sequence uses phoenix, plan-agent, kraken, plan-reviewer and arbiter.

Which flags does refactor support?

--dry-run produces a plan without making changes. --step-by-step pauses after each change for approval, while --coverage-check requires coverage above 80%.

Source text

SKILL.md · MIT
---
name: refactor
description: Code refactoring workflow - analyze → plan → implement → review → validate
---

# /refactor - Refactoring Workflow

Safe refactoring with review gates.

## When to Use

- "Refactor X"
- "Clean up this code"
- "Extract this into a module"
- "Improve the architecture of Y"
- Large-scale code restructuring
- Technical debt reduction

## Workflow Overview

```
┌──────────┐    ┌────────────┐    ┌──────────┐    ┌──────────┐    ┌───────────┐
│ phoenix  │───▶│   plan-    │───▶│  kraken  │───▶│plan-reviewer│───▶│ arbiter  │
│          │    │   agent    │    │          │    │          │    │           │
└──────────┘    └────────────┘    └──────────┘    └──────────┘    └───────────┘
  Analyze         Plan             Implement       Review          Verify
  current         changes          refactor        changes         tests pass
```

## Agent Sequence

| # | Agent | Role | Output |
|---|-------|------|--------|
| 1 | **phoenix** | Analyze current code, identify improvement areas | Analysis report |
| 2 | **plan-agent** | Create safe refactoring plan | Step-by-step plan |
| 3 | **kraken** | Implement the refactoring | Code changes |
| 4 | **plan-reviewer** | Review changes for correctness | Review report |
| 5 | **arbiter** | Verify all tests still pass | Test report |

## Refactoring Principles

1. **Tests first**: Ensure adequate test coverage before refactoring
2. **Small steps**: Each change should be independently verifiable
3. **Behavior preserved**: No functional changes during refactor
4. **Reviewable**: Changes should be easy to review

## Execution

### Phase 1: Analyze

```
Task(
  subagent_type="phoenix",
  prompt="""
  Analyze for refactoring: [TARGET_CODE]

  Identify:
  - Current pain points
  - Code smells
  - Improvement opportunities
  - Risk areas
  - Test coverage gaps
  """
)
```

### Phase 2: Plan

```
Task(
  subagent_type="plan-agent",
  prompt="""
  Plan refactoring: [TARGET_CODE]

  Analysis: [from phoenix]

  Create:
  - Step-by-step refactoring plan
  - Each step should be:
    - Small and focused
    - Independently testable
    - Reversible
  - Identify files affected
  - Risk mitigation strategy
  """
)
```

### Phase 3: Implement

```
Task(
  subagent_type="kraken",
  prompt="""
  Implement refactoring: [TARGET_CODE]

  Plan: [from plan-agent]

  Requirements:
  - Follow plan exactly
  - Run tests after each step
  - Stop if tests fail
  - NO behavior changes
  """
)
```

### Phase 4: Review

```
Task(
  subagent_type="plan-reviewer",
  prompt="""
  Review refactoring: [TARGET_CODE]

  Changes: [git diff from kraken]

  Check:
  - Behavior preserved
  - No unintended changes
  - Code quality improved
  - Patterns consistent
  """
)
```

### Phase 5: Validate

```
Task(
  subagent_type="arbiter",
  prompt="""
  Validate refactoring: [TARGET_CODE]

  - Run full test suite
  - Verify no regressions
  - Check type errors
  - Run linting
  """
)
```

## Refactoring Types

### Extract Module
```
phoenix → plan-agent → kraken → plan-reviewer → arbiter
```

### Rename/Restructure
```
phoenix → kraken → arbiter  (simpler, skip detailed planning)
```

### Architecture Change
```
phoenix → plan-agent → [kraken → plan-reviewer] × N phases → arbiter
```

## Example

```
User: /refactor Extract the validation logic into a separate module

Claude: Starting /refactor workflow...

Phase 1: Analyzing current structure...
[Spawns phoenix]
Found: Validation logic spread across 4 files
- form.ts (lines 45-120)
- api.ts (lines 200-280)
- user.ts (lines 15-45)
- order.ts (lines 88-130)

Phase 2: Planning extraction...
[Spawns plan-agent]
Plan:
1. Create src/validation/index.ts
2. Extract common validators
3. Update imports one file at a time
4. Run tests after each change

Phase 3: Implementing...
[Spawns kraken]
Completed all 4 steps, tests green after each

Phase 4: Reviewing changes...
[Spawns plan-reviewer]
✅ All behavior preserved
✅ DRY improved (removed 45 duplicate lines)
✅ New structure consistent

Phase 5: Final validation...
[Spawns arbiter]
✅ 312 tests passing, 0 regressions

Refactoring complete!
```

## Safety Flags

- `--dry-run`: Plan but don't implement
- `--step-by-step`: Pause after each change for approval
- `--coverage-check`: Require >80% coverage before proceeding

© parcadei · MIT · parcadei/Continuous-Claude-v3

Similar skills

Everything for Code review and refactoring →

refactor by other authors comes first.

refactor official github This skill reshapes existing code without changing its external behavior. Use it for gradual cleanup of large functions, duplication, weak types, and code smells. 22,321installs refactor smallnest Restructures code safely based on Martin Fowler's catalog without altering external behavior. Fixes code smells through small, verifiable steps. CX Codex +1 518installs refactor pproenca A skill with 43 refactoring rules drawn from Martin Fowler's catalog and Clean Code. Useful when you want the agent to restructure code by a fixed set of rules instead of guessing. CX Codex +1 641installs refactor luongnv89 Walks the agent through six refactoring phases: code analysis, test check, code smell hunt, plan, incremental edits and review. CX Codex +1 ★ 45,153repo stars refactor tartinerlabs A refactoring skill that flags dead code, deep nesting and weak patterns, then applies the fixes when you ask. CX Codex +1 376installs review-and-refactor official github Reviews project code against local instructions and refactors parts that need changes. Use it before review or when cleaning up an existing codebase. 11,056installs refactor-method-complexity-reduce official github Refactors a chosen method by moving complex logic into helpers. Use it when nested conditions or branching make a method hard to follow. 9,992installs refactor-code davila7 A slash command that walks Claude through 17 refactoring steps, from analysis and tests to performance checks and review prep. 4,890installs refactor-safely tirth8205 Plans a refactor from a dependency graph, lists edits before a rename and checks the impact radius before large changes. CX Codex +1 1,100installs code-refactoring-refactor-clean sickn33 Analyzes code smells and plans stepwise refactoring based on SOLID and clean code principles. Helps clean tangled modules before introducing new features. CX Codex +1 1,200installs ce-simplify-code EveryInc Simplifies code after implementation while keeping its behavior, and removes tests or comments with little value. Use it before review or for a repository audit. CX Codex +1 3,400installs

From the same set69

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor