safe-refactor
БесплатноБез исполняемых скриптовНе проверенRefactor in small, verified steps, with behavior locked by tests before any change. Use when asked to refactor, clean up, rename, extract or restructure code…
от aiskillstore★ 509 звёзд на GitHubОб этом скилле
Refactor without changing behavior
Goal: improve structure while behavior stays identical, proven after every step.
Before touching code
- State the goal and the boundary in two lines: what gets better (readability, duplication, testability) and what must not change (public API, output format, performance envelope). Confirm with the user if the boundary is unclear.
- Find the safety net. Locate the tests that cover the code. Run them and record the baseline (pass count, any pre-existing failures). Pre-existing failures are not yours to fix silently; list them.
- Close gaps. If the code to change has no tests, write characterization tests first: run the code with realistic inputs, record what it currently does (even if odd), and assert exactly that. Commit or save these before refactoring.
- Check the blast radius. Search for callers and dependents (
rg), including tests, scripts, docs and config that mention the names you will change. Public or exported symbols need a deprecation path or an explicit go-ahead.
During
- One kind of change per step: rename, or extract, or move, or inline. Never mix a refactor with a bug fix or a feature.
- After every step run the relevant tests plus type check or lint. If red, undo the step (
git restoreor revert your last edit) and try a smaller step. Do not debug forward through a broken refactor. - Keep diffs reviewable. Aim for steps a person can review in minutes. Prefer several small commits if the user wants commits.
- Do not "improve" while you are here: unrelated formatting, dependency bumps and style changes go in a separate list at the end.
- Preserve behavior including error messages, ordering, logging and edge cases, unless the user says otherwise.
Finish
Report: the steps taken, tests run and results, what you deliberately did not change, bugs or smells you noticed but left alone, and any behavior you are not sure is preserved (for example, code with no coverage that you could not exercise).
Stop and ask when
- Tests cannot be run, or the baseline is red for reasons you cannot explain.
- The change needs a public API break.
- You find a real bug in the code being moved. Report it; fix it as its own change.
Установить safe-refactor в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл safe-refactor?
Refactor in small, verified steps, with behavior locked by tests before any change. Use when asked to refactor, clean up, rename, extract or restructure code without changing behavior.
Как установить скилл safe-refactor?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл safe-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