agentleFS
a365ngaya365ngay/CogniRouter/skills/senior-refactoring/SKILL.md

senior-refactoring

Skill2 starsChanged 5 days agoMITView on GitHub

Use when restructuring, cleaning up, simplifying, or modernizing existing code without changing behavior, including extracting functions or modules, removing duplication or dead code, reducing coupling, renaming, upgrading legacy patterns, or paying down technical debt in small safe steps.

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    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:

    Ensure tests cover current behavior.

    line 16
  2. Distinctive:

    Never mix refactoring with behavior changes or bug fixes in the same step.

    line 20
  3. Distinctive:

    Keep public APIs, serialized formats, database schemas, and event contracts stable unless the change explicitly includes a migration path.

    line 22
  4. Distinctive:

    Remove dead code only after proving it is unused (search, logs, feature flags).

    line 23
  5. Distinctive:

    Do not introduce abstractions for hypothetical future needs.

    line 24
  6. Distinctive:

    Run the full relevant test suite, linters, and type checks before and after.

    line 29

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “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

Senior Refactoring

Role

Improve structure while preserving behavior exactly, in small verified steps that are easy to review and revert.

Before Editing

  1. Define the goal of the refactor (readability, testability, removing duplication, enabling a feature) and the boundary of code in scope.
  2. Find all callers and usages, including reflection, dynamic imports, configuration, templates, and public API consumers.
  3. Ensure tests cover current behavior. If they do not, add characterization tests first that pin today's outputs, including odd ones.

Refactoring Rules

  • Never mix refactoring with behavior changes or bug fixes in the same step; note discovered bugs separately.
  • Move in small steps (rename, extract, inline, move, replace conditional) and run tests after each. Prefer IDE or tool-assisted refactors for renames and moves.
  • Keep public APIs, serialized formats, database schemas, and event contracts stable unless the change explicitly includes a migration path.
  • Remove dead code only after proving it is unused (search, logs, feature flags). Delete rather than comment out.
  • Do not introduce abstractions for hypothetical future needs; the result should be simpler than the start.
  • Preserve formatting and conventions of the codebase; avoid large formatting-only diffs mixed with logic moves.

Testing and Verification

Run the full relevant test suite, linters, and type checks before and after. Compare behavior on representative inputs when tests are thin. Keep commits small so each can be reviewed and reverted on its own.

Review Checklist

  • Is behavior provably unchanged (tests green before and after, no contract changes)?
  • Is the result simpler and easier to change?
  • Were all usages updated, including dynamic and external ones?
  • Is the diff reviewable, with no unrelated changes?

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.