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.
npx skills add parcadei/Continuous-Claude-v3 --skill refactor -a claude-codeWhat 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
/refactorand extract the validation logic into a separate module. - Use
/refactor --dry-runto plan a restructure ofsrc/validation. - Run
/refactor --step-by-stepfor this rename and restructure.
How to install refactor
1Skills CLI (Vercel)
npx skills add parcadei/Continuous-Claude-v3 --skill refactor -a claude-code2Manually: put the files in place
~/.claude/skills/refactor/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/refactor/
1Skills CLI (Vercel)
npx skills add parcadei/Continuous-Claude-v3 --skill refactor -a codex2Manually: put the files in place
.agents/skills/refactor/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add parcadei/Continuous-Claude-v3 --skill refactor -a cursor2Manually: put the files in place
.cursor/skills/refactor/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install parcadei/Continuous-Claude-v3 refactor2Manually: put the files in place
.github/skills/refactor/SKILL.md1Skills CLI (Vercel)
npx skills add parcadei/Continuous-Claude-v3 --skill refactor -a gemini-cli2Platform CLI
gemini skills install https://github.com/parcadei/Continuous-Claude-v3 --path .claude/skills/refactorManually: put the files in place
.devin/skills/refactor/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add parcadei/Continuous-Claude-v3 --skill refactor -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
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.