agentleFS
rafaelghifrafaelghif/antigravity-agents-core/.agents/skills/safe-refactor/SKILL.md

safe-refactor

Skill6 starsChanged 15 days agoMITView on GitHub

Restructures code in atomic behavior-preserving steps verified by characterization and regression tests. Use when refactoring code, eliminating duplication, or consolidating shared UI/helpers without changing external behavior.

33 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use surgical-patch, investigate-first and 10 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.
  • JuliusBrusseeSkill

    surgical-patch

    Fix bugs and small behavior changes at the narrowest responsible layer. Use when regression proof, preserved surrounding behavior, and task-relevant tests matter.

    Also in 10 projects that use this

  • JuliusBrusseeSkill

    investigate-first

    Diagnose ambiguous failures before editing. Use for unknown causes, intermittent behavior, performance regressions, or investigations needing evidence-ranked hypotheses.

    Also in 8 projects that use this

  • +10 more from JuliusBrussee

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 31 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Search all callers of target symbols (rg -n via run_command or search tool).

    line 22
  2. Very specific:

    Run the typechecker and test suite via run_command to verify a green baseline.

    line 23
  3. Very specific:

    Run typecheck and tests immediately after each transformation.

    line 28

“Common” is measured: kept by at least 6 in 10 of the 31 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

Safe Refactor

Restructure internal code and eliminate duplication while preserving 100% of observable external behavior at every step.

Decision tree

  1. Are you trying to change observable behavior and restructure code in the same step?
    • Yes → Separate into two passes/commits: land the behavior-preserving refactor first, then apply the behavioral change.
    • No → Proceed to step 2.
  2. Do passing automated tests cover the public seam of the code being refactored?
    • No → Write characterization tests at the public seam and confirm they pass before changing internals.
    • Yes → Proceed to workflow below.

Workflow

  1. Baseline & Caller Check:
    • Search all callers of target symbols (rg -n via run_command or search tool).
    • Run the typechecker and test suite via run_command to verify a green baseline.
  2. Atomic Transformations:
    • Extract duplicated UI/helpers/validators into existing shared modules.
    • Collapse shallow pass-through wrappers and replace boolean flag clusters with discriminated unions.
  3. Bracketed Verification:
    • Run typecheck and tests immediately after each transformation. If a step breaks and cannot be fixed cleanly, revert only your own edit (via edit_file or git stash push -- <file>, never git checkout -- .) and take a smaller step.

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.