refactor

GitHub

提供安全的代码重构工作流,包含分析、计划、实施、审查和验证五个阶段。通过多智能体协作确保重构过程中行为不变、测试通过且代码质量提升,适用于清理代码、提取模块及降低技术债务等场景。

.claude/skills/refactor/SKILL.md parcadei/Continuous-Claude-v3

Trigger Scenarios

重构指定代码 清理代码结构 提取模块 改善架构设计 大规模代码重组 减少技术债务

Install

npx skills add parcadei/Continuous-Claude-v3 --skill refactor -g -y
More Options

Non-standard path

npx skills add https://github.com/parcadei/Continuous-Claude-v3/tree/main/.claude/skills/refactor -g -y

Use without installing

npx skills use parcadei/Continuous-Claude-v3@refactor

指定 Agent (Claude Code)

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

安装 repo 全部 skill

npx skills add parcadei/Continuous-Claude-v3 --all -g -y

预览 repo 内 skill

npx skills add parcadei/Continuous-Claude-v3 --list

SKILL.md

Frontmatter
{
    "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

Version History

  • d07ff4b Current 2026-08-20 12:50

Same Skill Collection

.claude/plugins/braintrust-tracing/skills/trace-claude-code/SKILL.md
.claude/skills/agentica-claude-proxy/SKILL.md
.claude/skills/agentica-infrastructure/SKILL.md
.claude/skills/agentica-prompts/SKILL.md
.claude/skills/agentica-sdk/SKILL.md
.claude/skills/agentica-server/SKILL.md
.claude/skills/archive/leann-search/SKILL.md
.claude/skills/ast-grep-find/SKILL.md
.claude/skills/braintrust-tracing/SKILL.md
.claude/skills/cli-reference/SKILL.md
.claude/skills/commit/SKILL.md
.claude/skills/compound-learnings/SKILL.md
.claude/skills/continuity_ledger/SKILL.md
.claude/skills/create_handoff/SKILL.md
.claude/skills/dead-code/SKILL.md
.claude/skills/debug-hooks/SKILL.md
.claude/skills/debug/SKILL.md
.claude/skills/describe_pr/SKILL.md
.claude/skills/discovery-interview/SKILL.md
.claude/skills/explore/SKILL.md
.claude/skills/firecrawl-scrape/SKILL.md
.claude/skills/fix/SKILL.md
.claude/skills/github-search/SKILL.md
.claude/skills/help/SKILL.md
.claude/skills/hook-developer/SKILL.md
.claude/skills/implement_plan_micro/SKILL.md
.claude/skills/implement_plan/SKILL.md
.claude/skills/implement_task/SKILL.md
.claude/skills/loogle-search/SKILL.md
.claude/skills/math-help/SKILL.md
.claude/skills/math-router/SKILL.md
.claude/skills/math-unified/SKILL.md
.claude/skills/math/abstract-algebra/fields/SKILL.md
.claude/skills/math/abstract-algebra/groups/SKILL.md
.claude/skills/math/abstract-algebra/rings/SKILL.md
.claude/skills/math/category-theory/categories-functors/SKILL.md
.claude/skills/math/category-theory/limits-colimits/SKILL.md
.claude/skills/math/category-theory/natural-transformations/SKILL.md
.claude/skills/math/complex-analysis/analytic-functions/SKILL.md
.claude/skills/math/complex-analysis/contour-integrals/SKILL.md
.claude/skills/math/complex-analysis/residues/SKILL.md
.claude/skills/math/functional-analysis/banach-spaces/SKILL.md
.claude/skills/math/functional-analysis/hilbert-spaces/SKILL.md
.claude/skills/math/functional-analysis/operator-theory/SKILL.md
.claude/skills/math/graph-number-theory/graph-algorithms/SKILL.md
.claude/skills/math/graph-number-theory/modular-arithmetic/SKILL.md
.claude/skills/math/graph-number-theory/prime-numbers/SKILL.md
.claude/skills/math/information-theory/channel-capacity/SKILL.md
.claude/skills/math/information-theory/entropy/SKILL.md
.claude/skills/math/information-theory/source-coding/SKILL.md

Metadata

Files
0
Version
d07ff4b
Hash
af9428c6
Indexed
2026-08-20 12:50

- 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-26 22:09
浙ICP备14020137号-1 $방문자$