refactor
БесплатноБез исполняемых скриптовНе проверенRefactor and optimize [code]
от 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 --porcelainat exit must list only files the picked item named — that is this command's scope guarantee, and unlike/branch-reviewit is not expected to be empty..claude/is gitignored, so also hash the files there before you start and again before you report:
and show the comparison: in ledger mode onlyfind .claude/remember -maxdepth 1 -type f -exec md5sum {} + | sort -k2fix-ledger.mdmay differ; in duplicates mode nothing may differ.last-review.mdis/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.
- 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 --porcelainnon-empty → stop, say what is uncommitted. Onmain→git switch -c chore/fix-ledger. - Ledger missing or has zero bullets → say so and stop. Nothing to do.
- 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. - Fix only surviving
nitbullets (tags:/branch-review's ledger header; untagged =nit), one bullet per change, under the constraints below. Delete each bullet as its fix lands. Survivingchangeandideabullets are listed in the report ("left: change" / "left: idea") and left untouched — the worker cannot ask. Anitthat turns out to need a behaviour change is retaggedchangein place. The orchestrator then asks the user, perchange/ideaitem: 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). - 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'sledger: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 - Hand it back; do not chain it. Say plainly: commit, then run
/branch-reviewon 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
Установить refactor в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadEditGrepGlobBash(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), без исполняемых скриптов.
Похожие скиллы
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