agentleFS
hidekituxhidekitux/skills/skills/fix/refactor-code/SKILL.md

refactor-code

Skill0 starsChanged 2 months agoApache-2.0View on GitHub

Perform small, behavior-preserving code refactorings verified against a test baseline. Use when asked to refactor, restructure, clean up, or rename code under a defined task or Issue while keeping observable behavior unchanged, or when a debug or review step leaves related code debt. Requires a runnable test baseline before and after the change; never changes behavior, adds features, or fixes unrelated defects.

16 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use optimize-performance, debug-issue and 1 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.
  • 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

  • NVIDIASkill

    debug-issue

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

    Also in 3 projects that use this

  • SentrySkill

    security-review

    Finds exploitable application security vulnerabilities in code changes. Use for Warden security scans, appsec review, OWASP-style checks, authentication or authorization bugs, injection, XSS, SSRF, path traversal, secrets, unsafe crypto, webhook verification, open redirects, or sensitive data exposure.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 15 edited versions we read keep these.

  • 10

    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:

    Verify the before/after baseline results and the diff.

    line 14
  2. Distinctive:

    Keep exactly one item in progress.

    line 17
  3. Distinctive:

    Read repository instructions and the governing task or Issue before refactoring.

    line 21
  4. Distinctive:

    Stop and report when the task lacks a scoped boundary, the baseline cannot run, or the baseline does not pass before the change.

    line 24
  5. Distinctive:

    Do not expand the refactor into a larger rewrite or combine it with unrelated work.

    line 30
  6. Distinctive:

    Keep each change small and reviewable.

    line 35
  7. Distinctive:

    Run the project's test baseline before the change and record the result.

    line 39
  8. Distinctive:

    Run the same baseline after the change and record the result.

    line 40
  9. Distinctive:

    Never add features, fix defects, or open a Pull Request.

    line 46
  10. Distinctive:

    Use plain, active, evidence-backed prose in the final handoff.

    line 50

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

Todo List

  1. in progress: Resolve the refactor task, its in-scope files, and the project's test baseline command.
  2. Scope one small refactor and state the behavior that must be preserved.
  3. Make the mechanical changes on the in-scope files.
  4. Verify the before/after baseline results and the diff; record the evidence.
  5. Complete the list only when the baseline passes before and after and the handoff is reported.

Keep exactly one item in progress. Mark an item complete only after its stated evidence exists. Add or revise items when the agreed scope changes. Use the host's native Todo List when available; otherwise maintain this list as a Markdown checklist in the conversation.

Resolve and Guard

  • Read repository instructions and the governing task or Issue before refactoring.
  • Resolve the refactor target, its in-scope files, and the project's test command from the repository. Do not guess a target.
  • Refactors only: never change behavior, add features, or fix unrelated defects. Feature work and defect fixes belong to separate governed work (plan-issue and implement-issue); test design belongs to write-tests; defect fixing belongs to debug-code.
  • Stop and report when the task lacks a scoped boundary, the baseline cannot run, or the baseline does not pass before the change.

Scope the Refactor

  • Choose a single small refactor with a stated purpose, for example extracting a function, renaming an identifier, or simplifying a structure.
  • State the behavior that must be preserved and how the test baseline observes it.
  • Do not expand the refactor into a larger rewrite or combine it with unrelated work.

Make Mechanical Changes

  • Edit only the in-scope files and prefer the repository's existing patterns.
  • Keep each change small and reviewable; prefer many small verified steps over one large change.

Verify the Baseline

  • Run the project's test baseline before the change and record the result; the baseline must pass before refactoring starts.
  • Run the same baseline after the change and record the result.
  • Review the diff to confirm that only structure changed. A failing baseline or a behavior-changing diff stops the refactor and is reported.

Handoff

  • Report the refactor target, the changed files, the before/after baseline results, and the next owner: implement-issue integrates the refactor into the governed change; report to the requester when the refactor is not part of a governed change.
  • Never add features, fix defects, or open a Pull Request; those are separate phases.

Writing quality

Use plain, active, evidence-backed prose in the final handoff. Keep headings in sentence case and name the file, command, or output behind each repository claim.

Choose the plain word over an inflated or Latinate one: write use rather than utilize and is rather than serves as.

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.