refactor
Refactor code using Martin Fowler's patterns. Improves readability, moves behavior closer to data, removes unnecessary abstractions.
от rakovi4★ 54 звезды на GitHub
Установить refactor в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
/refactor
Dispatch one independent refactor-agent per coherent scope. The worker applies
all applicable refactoring checks; scope partitioning controls parallelism, not
checklist coverage. Load .claude/templates/workflow/quality-execution.md for
ownership, scheduling, evidence reuse, inspection modes, and result joining.
Usage
/refactor— analyze and refactor the current scope/refactor {Target}— analyze and refactor a named target
Dispatch
- Resolve the target, tests, helpers, and relevant collaborators. Load shared
coding detail, frontend rules where relevant, and active technology bindings.
Map responsibilities using
.claude/templates/refactoring/scan-checklist.md. - Dispatch
refactor-agentwith the scope manifest, input revisions, applicable context, and execution mode. The worker must be independent of the primary implementation/test author and load every applicable M, D, and T check. It must not nest fan-outs. For large scopes, partition by cohesive capability, assign each partition all applicable clusters, and name an owner for cross-capability checks. Shared writes have one owner. Partitioned dispatches are read-only initially; gather every partition and cross-capability result before granting fixes. - Default unpartitioned standalone/task mode is scan-and-fix: scan the complete scope,
resolve findings one refactoring at a time, verify, and return the completed
result using
refactor-agent.md. A small scope uses this same route. - Stage 2 may dispatch inspect on the stable joined candidate alongside coverage. It returns findings without edits; this is not a completed gate. After coverage-driven changes are verified and behavior is published, the coordinator explicitly dispatches fix, granting owned paths and passing current revisions and invalidations. Reuse the inspector when available; otherwise pass its evidence to a new independent worker. Revalidate affected checks, apply fixes, and await verification before completing the gate.
- A worker retained from
/test-reviewmay run/refactoronly after the coordinator publishes the reviewed tests and explicitly dispatches this skill. Keep the two named phases and results distinct; never auto-run the next phase. GREEN scope reuse followsquality-execution.md; every file and check remains accounted for, including cross-file effects.
Optional cluster fan-out is a coordinator choice only when scope size and
available capacity justify it without delaying ready independent scopes. Dispatch
refactor-mechanics-agent, refactor-design-agent, and
refactor-duplication-agent before awaiting any; gather every result, then grant
one owning refactor-agent the fixes. Workers never nest this fan-out.
Available Templates
Shared principles and responsibility-specific patterns (.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 decompositionreplace-comment-with-code.md- Preserve essential information elsewhere and delete every source commentextract-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
Additional presentation and fixture patterns (.claude/templates/refactoring/)
extract-component.md- Extract JSX block into field/section componentextract-shared-ui.md- Move reusable component toapp/components/ui/extract-test-fixture.md- Extract MSW response fixtures, stub helpers, assertion helpers
Constraints
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл refactor?
Refactor code using Martin Fowler's patterns. Improves readability, moves behavior closer to data, removes unnecessary abstractions.
Как установить скилл refactor?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл refactor запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
AnthropicCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
discernment-nudge
AnthropicAfter you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
data-consolidate
AnthropicJoins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
inspection-to-capa
AnthropicRuns the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…