Command Palette

Search for a command to run...

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

refactor

БесплатноБез исполняемых скриптовНе проверен

Refactor and optimize [code]

hamr0от hamr0★ 28 звёзд на GitHub

Об этом скилле

Refactor $ARGUMENTS. A targeted refactor includes the performance pass below — it is on by default, not a separate command.

Guardrails

  • Spawn a worker, mid tier stated explicitly (an omitted tier inherits the parent's; never a vendor model name). Run inline if your tool has no subagent mechanism.
  • Escalate, never assume. Anything you cannot decide, cannot verify, or that this spec does not cover → stop and report it to the orchestrator. Never improvise, never widen scope, never fix a side issue you noticed (for workers this overrides the Surgical dev rule).
  • The worker does the work itself — no sub-spawning. Every edit it reports and every test run it cites is one it made or ran with its own tool calls.
  • The HITL gates below belong to the orchestrator, not the worker. When one trips — a failing test, a crossed public API boundary, a change bigger than the bullet asked for — the worker stops there and hands the situation back, with the options and its reasoning but no choice made. The orchestrator asks.
  • Edit only the picked item (a surviving ledger bullet or a picked duplicate group). Ledger mode's scope is the bullets that survive revalidation, one change per bullet — not the neighbouring code, not the formatting, not a second finding noticed on the way past. Anything else goes back to the orchestrator to become a new bullet.
  • Prove the blast radius with two checks, because neither sees what the other does. git status --porcelain at exit must list only files the picked item named — that is this command's scope guarantee, and unlike /branch-review it is not expected to be empty. .claude/ is gitignored, so also hash the files there before you start and again before you report:
    find .claude/remember -maxdepth 1 -type f -exec md5sum {} + | sort -k2
    
    and show the comparison: in ledger mode only fix-ledger.md may differ; in duplicates mode nothing may differ. last-review.md is /branch-review's to write.

Ledger mode — $ARGUMENTS empty or plain-text guidance

Plain text that is not duplicates and names no file, directory or function (e.g. "fix all nits, nothing on vibes") is ledger mode; pass the text to the worker as guidance on which surviving bullets to take. Work through .claude/remember/fix-ledger.md, the non-blocking findings /self-review and /branch-review have accumulated. Everything below (goals, constraints, verification, HITL gates) still applies; this section only says what to refactor and how to close each item.

  1. Tree must be clean and not on main. The orchestrator runs this check before spawning the worker, so a dirty tree costs no worker; the worker then re-runs it as its own first act. git status --porcelain non-empty → stop, say what is uncommitted. On main → git switch -c chore/fix-ledger.
  2. Ledger missing or has zero bullets → say so and stop. Nothing to do.
  3. Revalidate every bullet first, fix nothing yet. For each: git grep -F "<snippet>" -- <path>. No hit → delete the bullet and list it as "cleaned by other work". Hit → re-read the surrounding code; if the finding no longer holds, delete the bullet with a one-line reason. What survives is the work list.
  4. Fix only surviving nit bullets (tags: /branch-review's ledger header; untagged = nit), one bullet per change, under the constraints below. Delete each bullet as its fix lands. Surviving change and idea bullets are listed in the report ("left: change" / "left: idea") and left untouched — the worker cannot ask. A nit that turns out to need a behaviour change is retagged change in place. The orchestrator then asks the user, per change/idea item: keep (stays in the ledger), drop (the orchestrator deletes the bullet) or spec it (it becomes its own task on its own branch after this run — never built in ledger mode, whose diff must have NO behavior changes).
  5. Run the tests as described below. Then report: fixed / dropped / left with the reason per left item, ending with N nits, K changes, I ideas remaining, counted as /branch-review's ledger: line is (N = total − K − I):
    grep -c '^- ' .claude/remember/fix-ledger.md
    grep -cE '@ [0-9a-f]{7,40} · change$' .claude/remember/fix-ledger.md
    grep -cE '@ [0-9a-f]{7,40} · idea$' .claude/remember/fix-ledger.md
    
  6. Hand it back; do not chain it. Say plainly: commit, then run /branch-review on this branch. Say it, never run it: they are two separate calls and both are the user's — "commit", "yes" or "go" authorizes the commit and nothing after it.

Duplicates mode — $ARGUMENTS is duplicates [path]

Merges functions that do the same job. [path] bounds the search, else the repo. Everything else here (constraints, verification, HITL gates) still applies, and so do ledger mode's step 1 (tree clean, not

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

Установить refactor в Claude Code и Claude Desktop

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

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

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

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

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

Read
Edit
Grep
Glob
Bash(npm test:*)
Bash(npx jest:*)
Bash(npx vitest:*)
Bash(pnpm test:*)
Bash(yarn test:*)
Bash(pytest:*)
Bash(python:*)
Bash(go test:*)
Bash(cargo test:*)
Bash(make test:*)
Bash(git diff:*)
Bash(git grep:*)
Bash(git status:*)
Bash(git rev-parse:*)
Bash(git switch:*)

FAQ

Что делает скилл refactor?

Refactor and optimize [code]

Как установить скилл refactor?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл refactor запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

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

Сравнить refactor с