ワンクリックで
refactor
Refactor code using Martin Fowler's patterns. Improves readability, moves behavior closer to data, removes unnecessary abstractions.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Refactor code using Martin Fowler's patterns. Improves readability, moves behavior closer to data, removes unnecessary abstractions.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
| name | refactor |
| description | Refactor code using Martin Fowler's patterns. Improves readability, moves behavior closer to data, removes unnecessary abstractions. |
Scatter–gather: three parallel read-only detectors scan for smells, then a single serial fixer applies refactorings one at a time. Detectors never edit — only the fixer writes, and it re-scans cascades after each change, so the "one refactoring at a time" invariant is preserved.
/refactor # Analyze current code for smells
/refactor Email # Create Email value object
/refactor UserService # Refactor specific file
.tsx)..claude/templates/refactoring/scan-checklist.md
and returns a candidate table:
refactor-mechanics-agent — cluster M (size, complexity, variables, dead code)refactor-design-agent — cluster D (domain modeling, behavior placement, type safety)refactor-duplication-agent — cluster T (sibling/cross-class duplication, tests, frontend).claude/agents/refactor-agent.md
(the serial fixer). It merges, dedups, orders highest-impact-first, applies
ONE refactoring at a time (loading the template from the Code Smells Routing
Table), runs tests, and re-scans cascades inline — repeating until clean.If the target is small with few methods/concerns, skip the fan-out and run a
single refactor-agent pass over the whole checklist — the detector
orchestration + merge overhead can exceed the single-agent cost on tiny files.
.claude/templates/refactoring/)scan-checklist.md - Scan hub: detector clusters + output format (links the three below)scan-mechanics.md - Cluster M checks (structural mechanics)scan-design.md - Cluster D checks (design + domain judgment)scan-duplication.md - Cluster T checks (duplication, tests, frontend)code-smells-routing-table.md - Smell → fix → template map (serial fixer)value-object.md - Replace primitive with value objectreplace-string-with-enum.md - Replace string constants with domain enumcomputed-field.md - Remove persisted field, replace with computed methodtest-base-class.md - Extract shared test setupfactory-method.md - Replace constructor with factoryencapsulate-conditional.md - Move conditionals to data classparameterize-helper.md - Add parameters to test helpersinline-test-params.md - Simplify test→statement data flowreplace-map-with-dto.md - Replace Map.of() with typed DTOrest-response-dto.md - Wrap in REST DTO for snake_case conversionmove-to-data.md - Move behavior, serialization, factories to data ownersimplify-expressions.md - Static imports, method references, inline variablesflatten-control-flow.md - Flatten conditionals, Optional patterns, child delegationextract-method.md - Named computations, guards, long method decompositionextract-class.md - Split large class by concern, extract superclass for shared infraadapter-query.md - Extract typed AdapterQuery for Specification/CriteriaQuery logicsubselect-read-model.md - Consolidate multiple repositories into single query with ORM relationships.claude/templates/refactoring/)extract-component.md - Extract JSX block into field/section componentextract-shared-ui.md - Move reusable component to app/components/ui/extract-test-fixture.md - Extract MSW response fixtures, stub helpers, assertion helpersReview the latest work unit with fresh, unnarrowed eyes and surface any problem it contains as follow-ups. Use after a work-unit commit, or when the user runs /agent-review.
Continue working on a story or task by reading progress.md, executing the next work unit, and updating progress. Use when user wants to resume story/task work or mentions /continue command.
Run a Selenium test in visible (non-headless) mode with slowdown so the user can watch it. Use when user wants to demo or visually watch a Selenium test or mentions /demo command.
Preview the planned design for a scenario before writing tests. Shows domain model changes, usecase patterns, and key design choices. Use before red-usecase to get user approval on the implementation approach. If the user rejects the design, offers to discuss inline or escalate to /architecture for a full ADR.
Write a journey summary capturing noteworthy moments (predictions, decisions, surprises, mistakes, quirks). Runs automatically the moment the agent observes something worth noting during work, and manually before /clear or /compact as a final sweep. Idempotent — skips entries already recorded. Use when the agent observes a noteworthy moment, before clearing context, or when the user mentions /handoff.
Re-explain the last thing in plain words. Use ONLY when the user explicitly types /plain or asks to "explain that simply / in plain words / like I'm not an expert". Never invoke on your own initiative — this is a manual button the user presses when something was hard to follow.