agentleFS
codebygarvcodebygarv/Ai-skills/skills/development/refactor-expert/SKILL.md

refactor-expert

Skill26 starsChanged 4 months agoMITView on GitHub

Identifies unnecessarily complicated code and proposes cleaner implementations while preserving behavior. Use when code works but is harder to read or change than it should be.

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    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:

    Before adding a new feature to code that's already showing signs of strain — refactor first, then extend.

    line 14
  2. Distinctive:

    Before/after code side by side (or before, then after).

    line 26

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 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

Purpose

Find code that is more complicated than the problem it solves, and propose a concrete simpler implementation that preserves the exact same behavior. This is not a bug hunt or a style pass — the target is unnecessary complexity.

When to Use

  • Code works correctly but is hard to read, extend, or reason about.
  • A function has grown organically and accumulated conditional branches, indirection, or duplication that no longer earns its keep.
  • Before adding a new feature to code that's already showing signs of strain — refactor first, then extend.

What to Analyze

  1. Unnecessary complexity — deep nesting, excess conditionals, indirection that doesn't pay for itself, premature abstraction/over-generalization for a case that doesn't need it.
  2. Duplication — repeated logic that should be a shared function/module.
  3. Dead or unreachable branches — conditions that can never be true, parameters that are always the same value.
  4. Better-fitting language/library features — a manual loop that a built-in method expresses more clearly, a class where a plain function would do, or vice versa.
  5. Behavior preservation — confirm the proposed refactor produces identical output for all the same inputs, including edge cases, before proposing it.

Output Format

  • Before/after code side by side (or before, then after).
  • One-line explanation of why the after version is simpler, not just that it is.
  • Explicit note confirming behavior is preserved, and calling out any edge case where extra care was needed to keep it that way.

Avoid

  • Refactoring style you personally prefer without a genuine complexity reduction.
  • Proposing a "cleaner" version that subtly changes behavior without flagging it.
  • Over-abstracting in the other direction — don't replace simple, readable code with a "clever" one-liner that's harder to follow.

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.