agentleFS
bt2gobt2go/claude-skills/skills/refactor-safely/SKILL.md

refactor-safely

Skill0 starsChanged 3 months agoMITView on GitHub

Use when the user wants to clean up, restructure or rename code without changing its behaviour.

19 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use audit-test-suite, change-data-safely and 9 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

  • Codagent-AISkill

    implement-change

    Implements an approved change in one continuous session, with tiered test runs. Use when asked to implement a change from its approved definition, or to invoke codagent:implement-change.

    Also in 5 projects that use this

  • +6 more from yaohuangguan

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 7 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 17 edited versions we read keep these.

  • 7

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run the suite before touching anything and record the result.

    line 14
  2. Distinctive:

    Run the suite after every move.

    line 16
  3. Distinctive:

    Update all call sites in the same move.

    line 17
  4. Distinctive:

    Keep the diff to the target area.

    line 18
  5. Distinctive:

    No behaviour change and no new feature inside a refactor commit.

    line 23
  6. Distinctive:

    No formatting sweep across untouched files.

    line 24
  7. Distinctive:

    If a change turns out to need behaviour edits, stop and say so before continuing.

    line 25

“Common” is measured: kept by at least 6 in 10 of the 17 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Refactor safely

Change the shape of the code. Do not change what it does.

Procedure

  1. Confirm the goal in one sentence and confirm behaviour must stay identical.
  2. Find the safety net: existing tests that cover the code. If there are none, write a characterisation test first.
  3. Run the suite before touching anything and record the result. This is your baseline.
  4. Make one mechanical move at a time: extract, inline, rename, move, or change signature.
  5. Run the suite after every move. A red suite means you stop and undo the last move.
  6. Update all call sites in the same move. Never leave a half renamed symbol.
  7. Keep the diff to the target area. Unrelated tidying belongs in another commit.
  8. Finish by rereading the diff for accidental behaviour changes: reordered side effects, changed defaults, dropped error handling.

Rules

  • No behaviour change and no new feature inside a refactor commit.
  • No formatting sweep across untouched files.
  • If a change turns out to need behaviour edits, stop and say so before continuing.

Output format

Goal: <one sentence>
Baseline: <test command and result>
Moves: <numbered list, each with the file touched>
Final: <test command and result>
Behaviour risk: <bullets, or "none identified">

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.