refactoring
БесплатноБез исполняемых скриптовНе проверенRefactoring assessment and behavior-preserving patterns for code with a passing baseline and proportionate preservation evidence. Use when the user asks to…
Об этом скилле
Refactoring
Refactoring is the final step of each fast RED-GREEN-REFACTOR increment when restructuring is applicable. Assess it after GREEN establishes a passing behavior-test baseline. Do not run the automated mutation harness before or after each refactor; mutation testing verifies the completed phase once the work is otherwise ready for a PR.
Because automated mutation evidence is intentionally deferred, the baseline's strength is not yet mutation-harness-verified during refactoring. Keep each refactor small, strictly behavior-preserving, and green under the existing oracles; the final gate validates the accumulated result.
This skill safely implements a bounded, behavior-preserving improvement. Use improve-codebase-architecture to discover and rank architecture candidates, then codebase-design to design a selected module contract before returning here for implementation. If the slice participates in a selected whole-path reduction program, whether as a transition or terminal reduction, reduce-system-complexity governs the ledger and gate state; use this skill only as a secondary refactoring assessment when applicable.
When to Refactor
- Assess after GREEN or another passing proportionate preservation baseline
- Run the applicable tests yourself before you assess, before your first edit, and before any reply that declines to edit. Declining a request, or classifying every candidate Skip, is still an assessment, and an assessment that rests on no test run rests on nothing
- Before the first edit, list every candidate change and label each one Critical, High, Nice or Skip
- Whether you changed everything, one thing, or nothing, the final reply must carry that labelled list, Skip items included, as one line per candidate —
Critical: <what and why>,High: <what and why>,Nice: <what and why>,Skip: <what and why>— closed by aDecision: <what you did or did not do>line. A summary of what changed is not an assessment, and neither is an unlabelled recommendation. An unstated assessment is an unmade assessment - When every candidate is Skip, say so in those words and change nothing
- Only refactor if it improves the code
- Establish a verified, recoverable baseline before refactoring; commit only with explicit user approval
Establish a Recoverable Baseline - WHY
Having a working baseline before refactoring:
- Allows reverting if refactoring breaks things
- Provides safety net for experimentation
- Makes refactoring less risky
- Can show clear separation in git history when the user authorizes commits
If the baseline cannot be restored safely without creating a commit, stop and ask for approval rather than committing implicitly.
Workflow:
- BASELINE: Applicable tests pass and/or the conserved behavior and guarantees have proportionate evidence
- CHECKPOINT: Record the baseline and preservation evidence. Create a baseline commit only when the user explicitly approves it
- REFACTOR: Improve structure in small steps under the
tddskill's canonical fast-feedback policy. From a clean baseline, prefer a proven repository-owned graph-complete watcher; use diff-selected Vitest watch only when the installed version/configuration has passed the canonical clean-start live proof, otherwise repeat the affected one-shot. In monorepos use the root graph so transitive consumers remain eligible - VERIFY: Keep focused and affected tests plus other proportionate evidence green after each step; do not rerun the full suite after every edit
- CHECKPOINT: Present the verified refactor together with the labelled
Critical:/High:/Nice:/Skip:assessment lines and the closingDecision:line; a summary of what changed does not close this step. Commit it only after explicit user approval - PRE-PR GATE: When the phase is otherwise ready for a PR, run mutation testing once for the accumulated scope where meaningful, or record explicit
N/Aplus proportionate alternate evidence; address valuable survivors within that gate
Complete Slices
Deliver small complete changes around one bounded owner or behavior path. Update affected contracts, adapters, and consumers together; a horizontal migration of all handlers followed by all services usually leaves half-converted paths. Keep existing behavioral oracles as preservation evidence, and identify separately any tests needed for a new mechanism. When claiming simplification, show what wrapper, repeated decision, translation, or dependency was removed; extraction alone may improve comprehension without reducing mechanism. Add compatibility scaffolding only for a demonstrated rollout constraint, with an owner and removal condition; use reduce-system-complexity for a whole-path reduction claim.
Priority Classification
| Priority | Action | Examples |
|---|---|---|
| Critical | Fix now | Behavior-changing mutation, divergent copies of one business rule, control flow that obscures a high-risk path |
| High | This se |
Установить refactoring в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл refactoring?
Refactoring assessment and behavior-preserving patterns for code with a passing baseline and proportionate preservation evidence. Use when the user asks to clean up, tidy, simplify, restructure, deduplicate, collapse, or merge look-alike code in a selected area, or after GREEN establishes the passing baseline for a TDD increment. Mutation testing verifies the accumulated result later at the end-of-phase PR-readiness gate. Covers recoverable-baseline discipline, when refactoring adds value vs when to skip it, and priority classification; commits always require explicit user approval. For any slice in a selected whole-path reduction program—transition or terminal—use reduce-system-complexity as the governing skill; refactoring may be secondary when applicable. For repository-wide architecture discovery use improve-codebase-architecture; for a module contract use codebase-design. Do NOT use for insufficiently evidenced code or adding behavior.
Как установить скилл refactoring?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл refactoring запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic