code-refactoring
БесплатноБез исполняемых скриптовНе проверенTurn a cleanup packet into one behavior-preserving refactor brief. Use when simplifying a messy function/component/service, freezing behavior before touching…
от akillness★ 63 звезды на GitHubОб этом скилле
Code Refactoring
Use this skill when the job is to improve structure without changing intended behavior.
The center of the skill should stay small and repeatable:
- identify the cleanup packet you actually have,
- choose one refactor mode,
- make the behavior guardrail explicit,
- stage the work in reviewable slices,
- verify and route remaining work honestly.
Read these support docs before handling unfamiliar cleanup work:
- references/intake-packets-and-route-outs.md
- references/refactor-modes.md
- references/handoff-boundaries.md
- references/safe-refactor-checklist.md
When to use this skill
- A function, component, service, script, or module is too tangled and needs structural cleanup without a behavior change.
- A legacy area needs a freeze-first cleanup because the current behavior is fragile or poorly understood.
- The same API, naming, or structure change repeats across many files and needs a codemod / migration brief.
- A diff mixes cleanup with too much semantic work and needs to be split into smaller reviewable slices.
- The user asks to refactor, decompose, deduplicate, rename safely, stage a cleanup, or plan a behavior-preserving migration.
When not to use this skill
- The main job is proving why behavior is wrong, reproducing a failure, or isolating a regression →
debugging - The main job is deciding whether a concrete diff / PR is safe to merge →
code-review - The main job is choosing org-wide validation depth, benchmark policy, or release gates →
testing-strategies - The main job is finding the bottleneck from traces, flamegraphs, CWV reports, or profiler output →
performance-optimization - The main job is finding symbols, call sites, or impact scope before any cleanup tactic is chosen →
codebase-search
Instructions
Step 1: Start from the cleanup packet
Use references/intake-packets-and-route-outs.md.
Choose the packet the user already has:
- one messy file / component / service
- a fragile legacy area with weak confidence in current behavior
- a repeated migration pattern across many files
- a cleanup-heavy diff that needs reshaping before review
- only a vague desire to “find all the places first”
Output the intake briefly:
## Cleanup Packet
- Current artifact:
- Why it is enough (or not enough):
- Missing evidence to collect next:
Rule: do not force a giant refactor plan when the immediate need is only search, diagnosis, review, or performance evidence.
Step 2: Choose one primary refactor mode
Pick exactly one primary mode from references/refactor-modes.md.
Primary modes:
local-safe-refactorbehavior-freeze-firstrepetitive-migration-codemoddiff-shaping-cleanup
Quick selector:
| Signal | Mode |
|---|---|
| One file or narrow module, clear intent, at least one fast guardrail exists | local-safe-refactor |
| Fragile legacy area, hidden invariants, weak test trust | behavior-freeze-first |
| Same API or structure repeats across many files | repetitive-migration-codemod |
| Cleanup is mixed into a risky review diff and needs smaller slices | diff-shaping-cleanup |
Rule: one primary mode, optional secondary note. Do not mix every cleanup tactic into one answer.
Step 3: Freeze the behavior guardrail
Before broad edits, decide how you will prove intent stayed the same.
Guardrail sources can include:
- existing unit / integration / end-to-end tests
- typecheck and linter
- characterization tests or captured examples
- fixture snapshots or golden outputs
- screenshots / preview captures for UI work
- before/after sample input-output tables
- manual smoke steps when automation is thin
Minimum rule:
- Local cleanup → at least one fast verification path
- Fragile legacy cleanup → freeze behavior first
- Repeated migration → pilot on a small representative sample first
- Diff reshaping → separate mechanical cleanup from semantic follow-up
If the user mainly needs help designing the entire validation program, route to testing-strategies.
Step 4: Build the smallest credible cleanup plan
Keep the plan reviewable.
Preferred slices:
- rename / move / extract work
- duplicated or dead-code cleanup
- mechanical migration or codemod rollout
- semantic follow-up only if still needed
- verification + handoff
For each slice, capture:
- goal
- behavior to preserve
- evidence / guardrail
- risk edge
- whether another skill owns the next step
Rules:
- Prefer a sequence of boring diffs over one heroic rewrite.
- Keep structural cleanup and semantic behavior changes separate when possible.
- For migrations, define source pattern, target pattern, known exceptions, and rollback path before scaling up.
Step 5: Use the right mode
Установить code-refactoring в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadGrepGlobBashWriteВложенные файлы
FAQ
Что делает скилл code-refactoring?
Turn a cleanup packet into one behavior-preserving refactor brief. Use when simplifying a messy function/component/service, freezing behavior before touching fragile legacy code, splitting a cleanup-heavy diff into reviewable slices, or planning a repeated migration / codemod without changing intended behavior. Route diagnosis to debugging, review judgment to code-review, validation-program design to testing-strategies, bottleneck-led tuning to performance-optimization, and pure symbol inventory to codebase-search.
Как установить скилл code-refactoring?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл 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