Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

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от 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:

  1. identify the cleanup packet you actually have,
  2. choose one refactor mode,
  3. make the behavior guardrail explicit,
  4. stage the work in reviewable slices,
  5. verify and route remaining work honestly.

Read these support docs before handling unfamiliar cleanup work:

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-refactor
  • behavior-freeze-first
  • repetitive-migration-codemod
  • diff-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:

  1. rename / move / extract work
  2. duplicated or dead-code cleanup
  3. mechanical migration or codemod rollout
  4. semantic follow-up only if still needed
  5. 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

Полный SKILL.md на GitHub

Установить code-refactoring в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Read
Grep
Glob
Bash
Write

Вложенные файлы

SKILL.toonevals/evals.jsonreferences/handoff-boundaries.mdreferences/intake-packets-and-route-outs.mdreferences/refactor-modes.mdreferences/safe-refactor-checklist.md

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), без исполняемых скриптов.

Похожие скиллы

Сравнить code-refactoring с