agentleFS
alabenkhlifaalabenkhlifa/dayjob/skills/refactor/SKILL.md

refactor

Skill1 starsChanged 29 days agoMITView on GitHub

Use when the user wants to refactor, clean up, tidy, or simplify existing code without changing what it does — quick wins (unused imports, magic numbers, duplication) or a deeper restructure.

196 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use ascii-diagram, debug-fix 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.
  • SethGammonSkill

    ascii-diagram

    Generate perfectly aligned ASCII diagrams — architecture, flow, sequence, box-and-arrow. Uses a programmatic character-grid approach so alignment is guaranteed by math, not token prediction. Includes post-render verification.

    Also in 4 projects that use this

  • zebbernSkill

    debug-fix

    Find and fix a bug or issue — from any source (GitHub issue, error message, user report, or observed behavior)

    Also in 4 projects that use this

  • parcadeiSkill

    agent-context-isolation

    Agent Context Isolation

    Also in 3 projects that use this

  • parcadeiSkill

    agentica-infrastructure

    Reference guide for Agentica multi-agent infrastructure APIs

    Also in 3 projects that use this

  • +8 more from parcadei

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 169 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 git status --short first.

    line 21
  2. Distinctive:

    No tests cover the target → say so and offer to add characterization tests first.

    line 30
  3. Distinctive:

    Never change behavior or a public API (exports, function signatures, CLI flags) without the user's approval.

    line 37
  4. Distinctive:

    Never edit, skip, or delete a test to make it pass.

    line 38
  5. Distinctive:

    Run the full test suite (and build) once more, then report:

    line 42
  6. Distinctive:

    No file changes in auto mode until the user picks a mode.

    line 54
  7. Distinctive:

    No file changes while other files have uncommitted changes, until the user says how to handle them.

    line 55

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

Make code easier to read and change without changing what it does. Prove it with the tests, before and after.

1. Scope and mode

Target: the file or folder the user named. If none, ask.

Modes:

  • easy — unused imports and variables, magic values → named constants, duplicated blocks → one function, dead code.
  • hard — split long functions, clearer names, extract modules or interfaces, reuse existing helpers, simplify conditionals and loops.
  • auto (no mode given) — read the target, list 3–5 concrete opportunities with path:line, recommend easy or hard, and ask which to apply. Do not change any file until the user picks.

2. Baseline

Run git status --short first. If files other than the target have uncommitted changes, stop: name them and ask which the user wants:

  • commit them first;
  • refactor in a separate worktree off the base branch (git worktree add <sibling folder> -b refactor/<slug> <base>);
  • continue here, with the refactor mixed into those changes.

Change no file until the user answers. A new branch alone does not separate them: uncommitted changes move with it.

Find the test and build commands (package.json, Makefile, README, CI config) and run them before changing anything. Record the result.

  • No tests cover the target → say so and offer to add characterization tests first. Ask before going on.
  • Tests already failing → stop and report; don't refactor on a red baseline.

3. Change in small steps

  • One kind of change at a time; run the tests after each group.
  • Match the surrounding style. Reuse helpers that already exist.
  • Never change behavior or a public API (exports, function signatures, CLI flags) without the user's approval.
  • Never edit, skip, or delete a test to make it pass. Adding tests is fine.

4. Verify and report

Run the full test suite (and build) once more, then report:

Mode:    <easy | hard>
Changes:
- <path:line> — <what changed> — <why it is better>
Tests:   <command> — <result before> → <result after>
Skipped: <ideas you did not do, and why (risky, changes behavior, out of scope)>

Rules

  • No file changes in auto mode until the user picks a mode.
  • No file changes while other files have uncommitted changes, until the user says how to handle them.
  • Tests before and after; never claim green without running them.
  • Behavior and public API stay the same unless the user approves.
  • Tests are never weakened to pass.

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.