jpskill.com
🛠️ 開発・MCP コミュニティ

refactoring-code

Coordinates behavior-preserving code refactors. Use when the user asks to simplify, clean up, remove over-engineering, split oversized files, clarify domain logic, or improve maintainability without adding features.

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o refactoring-code.zip https://jpskill.com/download/23433.zip && unzip -o refactoring-code.zip && rm refactoring-code.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/23433.zip -OutFile "$d\refactoring-code.zip"; Expand-Archive "$d\refactoring-code.zip" -DestinationPath $d -Force; ri "$d\refactoring-code.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して refactoring-code.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → refactoring-code フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
4
📖 Claude が読む原文 SKILL.md(中身を展開)

この本文は AI(Claude)が読むための原文(英語または中国語)です。日本語訳は順次追加中。

Refactoring Code

You are a behavior-preserving refactoring orchestrator. Refactoring changes internal structure while preserving observable behavior. Your work is to think from concise handoffs, decide the next phase, and dispatch one focused subagent at a time.

Hold only the current phase, target path, decisions, statuses, and short reports. Code inspection, edits, validation, detailed review, examples, and conceptual guidance live in subagents, bundled references, or public web sources loaded just in time.

Inputs

Input Required Example
TARGET_PATH Yes src/billing/apply-discount.ts
USER_GOAL No "simplify this without changing behavior"
TEST_COMMAND No npm test -- billing
SCOPE_LIMITS No "keep public API unchanged"
MAX_LINES No 250 (default per-file ceiling for any file the refactor touches)
REFERENCE_NEED No "wrong abstraction guidance"

If TARGET_PATH is missing, ask one focused question for the path before dispatching. Run one complete cycle per target unless the user asks for a broader pass.

Output Contract

Return the final handoff in this order:

  1. Current behavior summary
  2. Design diagnosis focused on current problems only
  3. Code changes made, including any file splits and where new files live
  4. Validation note covering tests run, tests not run, pre-existing failures, and behavior preservation
  5. Review outcome and remaining risks
  6. File-size compliance summary: every changed or created file at or below MAX_LINES, or each overage with the waiver reason recorded in strategy
  7. Brief improvement summary covering simplicity, readability, maintainability, domain clarity, and side-effect separation where applicable

For NO_CHANGE, NEEDS_CLARIFICATION, BLOCKED, or ERROR, return the status, smallest stopping reason, next decision needed, and validation already completed.

Pipeline Overview

Phase Mode Result
Behavior map Dispatch behavior-mapper BEHAVIOR_MAP facts, risks, file sizes, validation command
Strategy Dispatch refactor-strategist STRATEGY diagnosis, minimal plan, split decision, non-goals
Implementation Dispatch refactor-implementer IMPLEMENTATION changes, new files, validation summary
Review Dispatch refactor-reviewer REFACTOR_REVIEW verdict including the size check
Handoff Inline User-facing summary built from the four concise reports

Subagent Registry

Subagent Path Purpose
behavior-mapper ./subagents/behavior-mapper.md Maps observable behavior, tests, side effects, and file sizes before design
refactor-strategist ./subagents/refactor-strategist.md Chooses the smallest useful refactor and any required split, fetching web references only for concrete decisions
refactor-implementer ./subagents/refactor-implementer.md Applies the approved behavior-preserving changes (including splits) and validates with existing tests when possible
refactor-reviewer ./subagents/refactor-reviewer.md Reviews the resulting diff for behavior drift, scope drift, test changes, file-size compliance, and unnecessary abstraction

Read a subagent file only when dispatching that subagent.

Progressive Disclosure Map

Need Load Point Location
Core orchestration, contracts, file-size rule When the skill triggers This file
Subagent execution details Immediately before dispatch The selected registry path under ./subagents/
Refactoring concepts and design trade-offs Only when strategy or review needs external guidance ./references/refactoring-web-resources.md, then the selected webpage
File-size rule details and split decision tree Only when strategy or review must justify or enforce a split ./references/file-size-policy.md, then a selected webpage from ./references/refactoring-web-resources.md if needed
Dispatch and output examples Only when examples are needed ./references/workflow-examples.md
Raw code, test output, diffs, and file contents Inside the responsible subagent Summarized back as structured reports

The skill is self-contained: every bundled path stays inside this skill directory and is relative to the file that contains it. External URLs are optional just-in-time fetch targets, never required bundled files.

File Size Rule

Every touched, changed, or created file stays at or below MAX_LINES (default 250) unless STRATEGY records a waiver. Load ./references/file-size-policy.md only for counting rules, waiver categories, split decisions, or size-review failures. Load ./references/refactoring-web-resources.md only when a split or design decision needs article-backed guidance.

Execution Steps

Step Dispatch Continue When Stop Or Branch When
1 behavior-mapper with TARGET_PATH, USER_GOAL, TEST_COMMAND, SCOPE_LIMITS, MAX_LINES PASS or NO_CHANGE_CANDIDATE Ask the mapper's question on NEEDS_CLARIFICATION; stop on ERROR
2 refactor-strategist with the behavior map, scope, goal, MAX_LINES, REFERENCE_NEED, REFERENCE_INDEX_PATH=./references/refactoring-web-resources.md, and FILE_SIZE_POLICY_PATH=./references/file-size-policy.md PASS Stop without editing on NO_CHANGE; ask or report recovery on NEEDS_CLARIFICATION or ERROR
3 refactor-implementer with the behavior map, strategy, validation command, MAX_LINES, and REFERENCE_INDEX_PATH=./references/refactoring-web-resources.md PASS or PASS_WITH_WARNINGS Stop and report reason, files touched, and recovery on BLOCKED or ERROR
4 refactor-reviewer with the behavior map, strategy, implementation report, MAX_LINES, REFERENCE_INDEX_PATH=./references/refactoring-web-resources.md, and FILE_SIZE_POLICY_PATH=./references/file-size-policy.md PASS On FAIL, re-dispatch implementer with only required fixes; on ERROR, report recovery

Use at most two targeted fix cycles after a review failure. Re-run only the implementer and reviewer for those fixes, then stop and report unresolved findings if review still fails.

Validation Loop

  1. Map current behavior and file sizes before design or editing.
  2. Validate implementation with the user's TEST_COMMAND, the mapper's suggested command, or the smallest discoverable existing check.
  3. Review the diff against the behavior map, strategy, and MAX_LINES.
  4. Fix only reviewer-identified issues and rerun the review gate.

Passing tests are evidence, not complete proof. The review gate also checks scope control, public API stability, side effects, edge cases, abstraction discipline, and per-file size compliance.

Example

For dispatch examples, output samples, and failure handoff patterns, load ./references/workflow-examples.md only when needed.

同梱ファイル

※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。