Skip to content
Development
Skill

/safe-refactor

Use when code needs restructuring without changing observable behavior.

From plugin
agent-powerups
8114 skills46 agents54 commands

Claude Code

$ npx -y skills add yeaight7/agent-powerups --skill safe-refactor --agent claude-code

SKILL.md

safe-refactor.SKILL.md
name: safe-refactor
description: Use when code needs restructuring without changing observable behavior.

Purpose

Restructure code in small, safe steps while preserving all externally observable behavior. Prevents refactor regressions where behavior silently changes.

When to Use

  • Code needs structural improvement but its public API must remain unchanged.
  • Naming, organization, or duplication needs cleanup after a feature is complete.
  • Technical debt needs reduction without introducing risk.

Do not use this skill if there are no existing tests — write tests first.

Inputs

  • Code to refactor.
  • Existing test suite (required).
  • Optional: specific goals (extract function, rename module, remove duplication).

Workflow

1. **Confirm behavior** — Run the test suite. All tests must pass before starting. 2. **Plan** — List the structural changes. Check each for API impact. 3. **Refactor in small steps** — One change at a time, each independently reversible. 4. **Avoid interface changes** — Do not alter public APIs, exported types, or CLI behavior unless explicitly intended. 5. **Validate after each step** — Re-run targeted tests after each meaningful change.

Output

Changed:
- <structural change 1>
- <structural change 2>

Behavior unchanged because: <reasoning>

Validated by: <test commands run>

Verification

  • [ ] Tests pass before starting
  • [ ] Each step is small and independently reversible
  • [ ] No unintended API or interface changes introduced
  • [ ] Tests pass after each meaningful step
  • [ ] Final test suite fully green

Failure Modes

  • **Missing tests** — Stop. Write tests before refactoring. Behavior cannot be verified otherwise.
  • **Silent API change** — If a refactor touches public interfaces, stop and confirm this is intentional.
  • **Bundled unrelated changes** — Keep each step focused. Mixed changes make rollback and blame impossible.
Read more
@yeaight7
Ships withagent-powerups

Curated power-ups for coding agents: skills, slash commands, MCP configs, hooks, AGENTS.md templates, and workflows for serious software engineering. Claude Code, Codex, Antigravity CLI, Cursor and more

8114 skills46 agents
Get the whole plugin

Stars on GitHub

Momentum

stars in total
8
Star history of yeaight7/agent-powerups on GitHub, a chart by star-history.com

Other skills on agent-powerups.

More skills from other plugins.

brainstorming
Auto-invoked

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…

@obra@obraInstall Skill
ask-matt

ask-matt

Ask which skill or flow fits your situation. A router over the skills in this repo.

skills10d309k
@mattpocock@mattpocockInstall Skill
accessibility
Auto-invoked

accessibility

Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels,…

ecc11d293k
@affaan-m@affaan-mInstall Skill
compiler-commit

compiler-commit

Use when you want to verify compiler changes and commit with the correct convention. Runs tests, lint, and format, then commits…

react1d252k
@facebook@facebookInstall Skill

Questions about safe-refactor.

Which coding agents can use safe-refactor?
safe-refactor installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.