跳到正文
cccskills
免费在 GitHub 公开

refactor

Refactor existing code through analysis, planning, implementation, review, and testing. Use small, verifiable changes to extract modules, reorganize code, or improve architecture while preserving existing behavior and checking for regressions.

中文简介正在准备中。当前显示英语简介。

原文查看原文说明

Code refactoring workflow - analyze → plan → implement → review → validate

查看安装方法

适用场景

  • Extracting shared logic into a separate module
  • Reorganizing code while preserving behavior
  • Improving architecture in stages
  • Planning changes without implementing them

包含的文件(1)

  • SKILL.md4.5 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

/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

#AgentRoleOutput
1phoenixAnalyze current code, identify improvement areasAnalysis report
2plan-agentCreate safe refactoring planStep-by-step plan
3krakenImplement the refactoringCode changes
4plan-reviewerReview changes for correctnessReview report
5arbiterVerify all tests still passTest 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

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Coordinate background agents through saved files, keeping lengthy work transcripts out of the main conversation. It defines how to pass results between agents, monitor progress, and verify completed work with tests.

中文简介正在准备中。当前显示英语简介。

  • Keeping long agent transcripts out of the main conversation
  • Passing research and plans between agents through files
  • Checking for stalled background agents
parcadei/Continuous-Claude-v339462026年1月27日 更新

Delegate implementation, file reading, and testing to separate agents, then bring concise summaries back to the main conversation. The rules explain when delegation helps and when a small edit is better handled directly.

中文简介正在准备中。当前显示英语简介。

  • Implementing a feature across multiple files
  • Completing a specific phase of an implementation plan
  • Delegating feature development and testing
parcadei/Continuous-Claude-v339462026年1月27日 更新

Organize implementation work across research, planning, validation, implementation, and review agents. Each stage passes files to the next, while implementation starts with failing tests and the main conversation coordinates the workflow.

中文简介正在准备中。当前显示英语简介。

  • Dividing implementation work among specialized agents
  • Checking a plan against research before implementation
  • Writing failing tests before implementing changes
parcadei/Continuous-Claude-v339462026年1月27日 更新

Connect Agentica SDK agents to Claude Code CLI through a proxy, an intermediary server. Use setup and debugging guidance to address file permissions, streamed responses, result formatting, and agents reporting success without performing the requested operations.

中文简介正在准备中。当前显示英语简介。

  • Connecting Agentica agents to Claude Code tools
  • Investigating file write and edit permission errors
  • Debugging streaming and REPL response formats
parcadei/Continuous-Claude-v339462026年1月27日 更新

Consult Agentica APIs when building workflows where multiple AI agents cooperate. This reference covers eleven coordination patterns, agent tracking, shared state, handoffs, and ways to combine results, with pointers to detailed API specifications.

中文简介正在准备中。当前显示英语简介。

  • Choose a coordination pattern for multiple agents
  • Check pattern constructors and methods
  • Implement custom coordination patterns
parcadei/Continuous-Claude-v339462026年1月27日 更新

Write clearer instructions for Agentica and REPL agents by specifying roles, file operations, and output formats. Includes templates for dividing research, coordinating specialists, reviewing solutions, and passing results between agents through files.

中文简介正在准备中。当前显示英语简介。

  • Clarifying instructions for reading and editing files
  • Dividing research among multiple agents
  • Passing findings and plans between agents
parcadei/Continuous-Claude-v339462026年1月27日 更新

查看 parcadei 的全部技能

报告此技能的问题