agentleFS
rpraharajrpraharaj/ai-sdlc/skills/refactor-safely/SKILL.md

refactor-safely

Skill0 starsChanged 16 days agoMITView on GitHub

Behavior-preserving cleanup — lock behavior with tests, refactor mechanically, re-run the same tests. Use when the user asks to refactor, clean up, simplify, or restructure without changing behavior.

19 other projects use a version of this, 1 of them edited.

Adopted by

Most recently taken up by

Used with

Projects with it also use audit-test-suite, change-data-safely and 8 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • yaohuangguanSkill

    audit-test-suite

    Find where an existing test suite is weak and decide what to test next, ranked by risk. Use this when asked to add missing tests, find gaps, raise coverage, assess test quality or see which areas are thin, even if the request only mentions a coverage percentage.

    Also in 3 projects that use this

  • yaohuangguanSkill

    change-data-safely

    Change a database schema or stored data without breaking running code or losing data. Use this for any migration, new or changed column, backfill, bulk update, delete, index, or change to a stored format, including in small projects. Data mistakes are often impossible to undo.

    Also in 3 projects that use this

  • SauravSrivastavSkill

    debug-failure

    Diagnose a failing test, command, or runtime behavior using evidence and produce a minimal verified fix.

    Also in 3 projects that use this

  • NVIDIASkill

    debug-issue

    Use when the user asks to debug, investigate, or fix a GitHub issue or supplies a repository bug report.

    Also in 5 projects that use this

  • +6 more from yaohuangguan

The file

Files
SKILL.md

Refactor safely

Change structure, not behavior. If they also want new behavior, stop and send that part to shape-work / implement-change.

Is this the right skill?

SignalDo this instead
New behavior in the same asksplit — this skill is structure only
Tests are red before you startdebug
Delete-list onlylean-review first

Required inputs

  • Named unit (files, package, endpoint)
  • AGENTS.md Test command

Human decisions (do not invent)

  • Mixing a feature into the refactor (do not)

Procedure

  1. Pin behavior with existing tests. If coverage is too thin, add characterization tests via write-tests first. Run them — that green run is the baseline. If they are red, this is debug.
  2. List mechanical steps. Climb engineering-bar Minimum path. No new framework, cache, or feature flags. Never delete trust-boundary checks to look smaller.
  3. One cluster of moves, then re-run the same tests. Stay in the named unit plus callers.
  4. Re-run characterization tests, then repo Test / Lint / Typecheck if known. If a conditional’s meaning changed, revert that part.

Output

  • Path: the structural diff
  • Template: references/refactor-report.md

Quality bar

  • Baseline tests were green before the moves
  • Same tests green after
  • Diff is structural
  • No mixed feature work

Done

Fill the report. Next: ready-to-merge if they want it shipped.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.