agentleFS
bsafronovbsafronov/prosto-skills/skills/.experimental/refactor-code/SKILL.md

refactor-code

Skill0 starsChanged 3 months agoApache-2.0View on GitHub

Implement an agreed structural code change while preserving observable behavior. Use when extraction, consolidation, or responsibility moves must keep existing behavior equivalent. Do not use for an unresolved interface decision alone, bug correction, new feature behavior, or a staged compatibility transition.

9 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use optimize-performance.

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.
  • gologo13Skill

    optimize-performance

    Analyze the current code for performance bottlenecks and provide optimization recommendation...; keywords: api, performance. Use only on explicit request; skip in routine implementation discussions.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

1 rule. 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 9 edited versions we read keep these.

  • 1

    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:

    Stop when the requested structure exists and the relevant before/after behavior agrees.

    line 34

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

Change the requested structure with evidence that its callers still observe the same behavior.

  • Define equivalence at the affected boundary: results and identity, side effects, ordering, errors, resource lifetime, and compatibility where the change touches them. Existing quirks remain behavior unless their correction is also in scope; an apparently cleaner result can still be a regression.
  • Establish that boundary's behavior before changing its implementation. Reuse meaningful coverage; add characterization only where an exposed risk lacks proof. A pre-existing failure or unavailable check limits the baseline: record it, preserve the evidence, and use an independent observation where possible. A green run only after editing cannot establish before/after equivalence.
  • Move the chosen responsibility while keeping callers' obligations intact. Preserve ordering and failure paths through extractions, including work that must not occur after failure. Keep useful behavior tests tied to the public boundary; replace an implementation-coupled assertion only with evidence that its behavior remains covered. Split genuinely independent moves when each can be verified; keep a coupled edit together when intermediate states cannot work.
  • Repeat the same behavioral observations after the move, and verify the chosen structural boundary is now real rather than an unused wrapper. Treat a changed observation as a discrepancy to explain, not a reason to update expectations. Report the affected guarantees and any equivalence that remains unproved.

Stop when the requested structure exists and the relevant before/after behavior agrees. An unresolved contract choice can compose with interface design; an independently requested correction or feature remains a separate behavior change. Small cleanup inside an already green test-first slice does not require another Skill. This Skill owns preservation across structural change, not test-first sequencing, diagnosis, or mixed-version rollout.

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.