‹ 首页

refactor

@darkroomengineering · 收录于 昨天 · 上游提交 昨天

Behavior-preserving restructuring of code that is NOT in your current diff — extract modules, rename across files, untangle abstractions, pay down tech debt. For tightening just-changed code use `/zero-tech-debt` instead. Triggers "refactor X", "reorganize this module", "restructure", "extract Y from Z", "pay down tech debt".

适合你,如果希望在不改变行为的前提下改善代码结构

/ 通过 npx 安装 校验哈希
npx oh-my-skill add darkroomengineering/cc-settings/refactor
/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- darkroomengineering/cc-settings/refactor
/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify darkroomengineering/cc-settings/refactor
安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
40GitHub stars
~640上下文体积 · 单文件
索引托管

怎么用

商店整理自技能原文 · 版本 fa04efc · 表述以原文为准
它做什么

当你要求重构代码时,Claude会自动协调多个子助手完成分析、规划、实现、测试和审查,最终输出一份包含变更内容、文件列表、测试结果和改进建议的摘要。

什么时候触发

当你提到“重构”、“重组”、“提取”等代码重构关键词,且操作的不是你当前正在编辑的代码时触发。

装好后可以这样说
Claude将分析并重新组织代码模块。
Claude会提取并封装独立功能。
技能原文 SKILL.md作者撰写 · MIT · fa04efc

Refactoring Workflow

Before starting work, create a marker: mkdir -p ~/.claude/tmp && echo "refactor" > ~/.claude/tmp/heavy-skill-active && date -u +"%Y-%m-%dT%H:%M:%SZ" >> ~/.claude/tmp/heavy-skill-active

You are in Maestro orchestration mode. Delegate immediately.

Workflow
  1. Explore - Spawn explore agent to analyze current code
  2. Plan - Spawn planner agent to design refactoring approach
  3. Implement - Spawn implementer agent to refactor
  4. Test - Spawn tester agent to verify behavior unchanged
  5. Review - Spawn reviewer agent to check quality
  6. Learn - Store patterns discovered during refactoring
Agent Delegation

Spawn explore and planner first — they accept thin prompts because they discover what they need from the codebase:

Agent(explore, "Analyze the code to refactor: $ARGUMENTS. Identify patterns, issues, dependencies.")
Agent(planner, "Design refactoring approach based on analysis. Keep behavior unchanged.")

Then assemble the implementer prompt from the actual planner output. Implementer runs in an isolated worktree with no access to prior agent results, so paste the real plan — not "according to plan":

  • The user's refactor target ($ARGUMENTS) verbatim
  • The planner's step-by-step plan, including file paths and each move/rename/extract operation
  • Any "preserve behavior" invariants the planner called out
  • The test command that must remain green
  • Scope: "only the files in the plan; do not touch anything else"

Now spawn:

Agent(implementer, "<the assembled briefing above — all five items inline>")
Agent(tester, "Verify refactored code behaves identically to original.")
Agent(reviewer, "Review refactoring for quality and completeness.")

Refactors are a top source of subtle regressions — behavior that "shouldn't change" quietly does. When the Codex bridge is available, run a cross-model review in parallel with the reviewer:

Agent(codex-verifier, "Cross-model review of the refactor diff. Confirm behavior is preserved; report findings by severity.")

The bridge is gated and fails open: if Codex is unavailable, the reviewer agent alone is fine.

If the codex-verifier spawn fails, or it reports that Bash was stripped (forked skill contexts), run bun "$HOME/.claude/src/scripts/codex-run.ts" review directly instead — never skip the cross-model pass.

Output

Return a summary:

  • What changed: Brief description
  • Files modified: List of files
  • Tests passing: Verification status
  • Improvements: What's better now
  • Learnings: Patterns worth remembering
按 MIT 许可原样转载,未经改动 · 在 GitHub 查看 →

评论

登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。