Agent Skillsmohitagw15856/pm-claude-skills › refactoring-plan

refactoring-plan

GitHub

用于规划安全、增量式的代码重构,避免破坏性行为。通过先建立测试安全网,再制定一系列保持行为不变的小步骤,确保每次提交都通过测试,将重构与功能开发分离,降低大爆炸式重写的风险。

skills/refactoring-plan/SKILL.md mohitagw15856/pm-claude-skills

触发场景

代码结构混乱难以维护 需要清理代码以便添加新功能 代码耦合度高或重复逻辑多 希望在不改变现有行为的前提下优化架构

安装

npx skills add mohitagw15856/pm-claude-skills --skill refactoring-plan -g -y
更多选项

不安装直接使用

npx skills use mohitagw15856/pm-claude-skills@refactoring-plan

指定 Agent (Claude Code)

npx skills add mohitagw15856/pm-claude-skills --skill refactoring-plan -a claude-code -g -y

安装 repo 全部 skill

npx skills add mohitagw15856/pm-claude-skills --all -g -y

预览 repo 内 skill

npx skills add mohitagw15856/pm-claude-skills --list

SKILL.md

Frontmatter
{
    "name": "refactoring-plan",
    "description": "Plan a safe, incremental refactor of messy code without changing behavior. Use when code needs restructuring, is hard to change, has grown tangled, or you want to clean it up before adding a feature. Produces a sequenced plan of small behavior-preserving steps, the safety net (tests\/characterization) to add first, and the target structure — refactoring as a series of green commits, not a risky big-bang rewrite."
}

Refactoring Plan Skill

Refactoring means improving structure without changing behavior — and the danger is doing it in one big risky sweep. This skill plans the opposite: a safety net first, then a sequence of small, behavior-preserving steps, each leaving the code green and committable. It separates refactoring from feature work, so you're never doing both at once.

Required Inputs

Ask for these only if they aren't already provided:

  • The code & the pain — what's being refactored and why (hard to change, duplicated, slow, untestable).
  • Test coverage — what tests exist around it (and the framework). If none, that's step zero.
  • The goal — the target structure or what you want to make easy next (e.g. "so I can add payment provider #2").
  • Constraints — what must not change (public API, behavior, performance), time budget.

Output Format

Refactoring plan: [target]

Why & goal — the current pain in one line, and what "better" enables.

Safety net (do first) — the tests that must exist before touching anything. If coverage is thin, add characterization tests that pin current behavior (even bugs) so you'd notice any change. Don't refactor untested code blind.

Target structure — a short sketch of where you're going (the shape, the seams, the names).

Steps (small & sequenced) — each step is behavior-preserving and independently committable:

# Step Refactoring move Stays green by Commit after
1 (extract function / rename / introduce interface / move) run tests

Order them so risk drops early and each step is reversible.

Definition of done — behavior identical (tests still green), the goal structure reached, no feature changes smuggled in.

Quality Checks

  • A safety net (existing or characterization tests) is established before any change
  • Every step is behavior-preserving and independently committable
  • Steps are small and sequenced so the code is green throughout
  • Refactoring is kept separate from behavior/feature changes
  • The target structure is explicit and tied to what it makes easier next

Anti-Patterns

  • Do not refactor and add features in the same commit — separate them
  • Do not start without tests — add characterization tests first if coverage is thin
  • Do not plan a big-bang rewrite — sequence small, reversible steps
  • Do not change behavior and call it refactoring — behavior must stay identical
  • Do not skip running tests between steps — that's the whole safety mechanism

Based On

Refactoring discipline (Martin Fowler): behavior-preserving transformations, characterization tests, small steps.

版本历史

  • a38bc30 当前 2026-07-05 11:42

同 Skill 集合

exports/openclaw/360-feedback-template/SKILL.md
exports/openclaw/401k-plan-decoder/SKILL.md
exports/openclaw/ab-test-planner/SKILL.md
exports/openclaw/ab-test-readout/SKILL.md
exports/openclaw/accessibility-audit/SKILL.md
exports/openclaw/account-plan/SKILL.md
exports/openclaw/acquirer-red-team/SKILL.md
exports/openclaw/ad-copy/SKILL.md
exports/openclaw/aeo-optimizer/SKILL.md
exports/openclaw/agenda-or-cancel/SKILL.md
exports/openclaw/agent-design-review/SKILL.md
exports/openclaw/agent-hiring-panel/SKILL.md
exports/openclaw/agent-observability-spec/SKILL.md
exports/openclaw/agent-severance/SKILL.md
exports/openclaw/agent-spec/SKILL.md
exports/openclaw/agm-in-a-box/SKILL.md
exports/openclaw/ai-ethics-review/SKILL.md
exports/openclaw/ai-eval-plan/SKILL.md
exports/openclaw/ai-feature-prd/SKILL.md
exports/openclaw/ai-product-canvas/SKILL.md
exports/openclaw/air-quality/SKILL.md
exports/openclaw/altitude-shifter/SKILL.md
exports/openclaw/ambiguity-resolver/SKILL.md
exports/openclaw/analyst-relations-brief/SKILL.md
exports/openclaw/announcement-card/SKILL.md
exports/openclaw/api-docs-writer/SKILL.md
exports/openclaw/api-test-plan/SKILL.md
exports/openclaw/api-versioning-strategy/SKILL.md
exports/openclaw/apology-letter/SKILL.md
exports/openclaw/architecture-decision-record/SKILL.md
exports/openclaw/architecture-diagram/SKILL.md
exports/openclaw/archive-strategy/SKILL.md
exports/openclaw/assumption-bounty/SKILL.md
exports/openclaw/assumption-mapper/SKILL.md
exports/openclaw/async-update-format/SKILL.md
exports/openclaw/auto-repair-estimate-decoder/SKILL.md
exports/openclaw/autopilot-charter/SKILL.md
exports/openclaw/behavior-intervention-plan/SKILL.md
exports/openclaw/benefits-decoder/SKILL.md
exports/openclaw/bennett-time-audit/SKILL.md
exports/openclaw/bid-tender-review/SKILL.md
exports/openclaw/board-deck-narrative/SKILL.md
exports/openclaw/board-game-designer/SKILL.md
exports/openclaw/board-minutes/SKILL.md
exports/openclaw/board-pre-read/SKILL.md
exports/openclaw/bom-cost-review/SKILL.md
exports/openclaw/bookkeeping-categorization/SKILL.md
exports/openclaw/boolean-search-builder/SKILL.md
exports/openclaw/brag-doc/SKILL.md
exports/openclaw/brainstorming/SKILL.md

元信息

文件数
0
版本
e4def4c
Hash
3eebe3bb
收录时间
2026-07-05 11:42

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-01 10:50
浙ICP备14020137号-1 $访客地图$