agentleFS
drafaeldrafael/coding-harness/skills/refactor-code/SKILL.md

refactor-code

Skill1 starsChanged 7 months agoMITView on GitHub

Change existing code through narrow, behavior-preserving, test-backed simplification without speculative architecture or scope growth. Use for requests to refactor, clean up, restructure, or simplify code. Use explain-code instead when the user only wants an explanation of the current structure.

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

Show its rules and text

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 9 edited versions we read keep these.

  • 17

    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:

    Prefer less code, fewer concepts, and clearer control flow over abstraction, extensibility, or pattern use.

    line 13
  2. Distinctive:

    Keep the change within the requested boundary.

    line 14
  3. Distinctive:

    Do not combine refactoring with dependency upgrades, formatting sweeps, security programs, performance rewrites, or unrelated cleanup.

    line 17
  4. Distinctive:

    Do not change valid behavior, add arbitrary limits, or harden against theoretical threats under the label of refactoring.

    line 18
  5. Distinctive:

    Read the implementation, callers, tests, and repository conventions.

    line 24
  6. Distinctive:

    Run the smallest relevant existing tests before editing.

    line 28
  7. Distinctive:

    Add characterization tests only when changed behavior is otherwise unprotected or ambiguous.

    line 29
  8. Distinctive:

    Prefer rename, inline, delete, simplify, or local extraction before new types or architecture.

    line 34
  9. Distinctive:

    Use existing project primitives and dependencies.

    line 35
  10. Distinctive:

    Run focused validation after each meaningful step.

    line 36
  11. Distinctive:

    If the work requires several new production modules, a generalized framework, a lifecycle/ownership protocol, or subsystem redesign, stop …

    line 39
  12. Distinctive:

    If two attempts fail or remain unverified, revert to the last known-good state and reassess the actual boundary instead of layering more …

    line 40
  13. Distinctive:

    Run the appropriate broader validation.

    line 43
  14. Distinctive:

    Update documentation only where the refactor changed an actual contract or operating procedure.

    line 45
  15. Distinctive:

    Add resilience, retries, caching, feature flags, monitoring, rollout machinery, or migration compatibility without a current requirement.

    line 53
  16. Distinctive:

    Add production hooks solely for tests.

    line 55
  17. Distinctive:

    Commit, format the whole repository, update snapshots, or change generated files unless requested or required by repository policy.

    line 56

“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

Focused Refactoring

Refactor for a specific, demonstrated benefit while preserving external behavior. Load applicable language/framework skills and repository instructions first.

Principles

  • Prefer less code, fewer concepts, and clearer control flow over abstraction, extensibility, or pattern use.
  • Keep the change within the requested boundary. Ask before crossing packages, processes, layers, or public APIs.
  • A new abstraction needs multiple current consumers or a clear existing contract. Hypothetical reuse does not count.
  • Small duplication is preferable when sharing would create coupling or obscure behavior.
  • Do not combine refactoring with dependency upgrades, formatting sweeps, security programs, performance rewrites, or unrelated cleanup.
  • Do not change valid behavior, add arbitrary limits, or harden against theoretical threats under the label of refactoring.

Workflow

  1. Establish the target
    • Identify the concrete readability, duplication, complexity, or maintenance problem.
    • Read the implementation, callers, tests, and repository conventions.
    • State the smallest viable change and what behavior must remain unchanged.
  2. Establish evidence
    • Run the smallest relevant existing tests before editing.
    • Add characterization tests only when changed behavior is otherwise unprotected or ambiguous; do not build an exhaustive test framework first.
    • For performance work, require a measurement or an obviously material hot-path problem.
  3. Refactor incrementally
    • Make one coherent, reversible change at a time.
    • Prefer rename, inline, delete, simplify, or local extraction before new types or architecture.
    • Use existing project primitives and dependencies.
    • Run focused validation after each meaningful step.
  4. Control scope
    • If the work requires several new production modules, a generalized framework, a lifecycle/ownership protocol, or subsystem redesign, stop and ask for approval with a simpler alternative and regression risk.
    • If two attempts fail or remain unverified, revert to the last known-good state and reassess the actual boundary instead of layering more machinery.
  5. Finish cleanly
    • Run the appropriate broader validation.
    • Review the complete diff for behavior changes and remove dead experiments, unnecessary APIs, speculative limits, unused dependencies, duplicate paths, and one-consumer abstractions.
    • Update documentation only where the refactor changed an actual contract or operating procedure.

Prohibited Defaults

Do not automatically:

  • Apply design patterns, polymorphism, services, repositories, factories, or dependency injection merely to appear cleaner.
  • Eliminate every instance of duplication.
  • Add resilience, retries, caching, feature flags, monitoring, rollout machinery, or migration compatibility without a current requirement.
  • Rewrite working library behavior with application-owned approximations.
  • Add production hooks solely for tests.
  • Commit, format the whole repository, update snapshots, or change generated files unless requested or required by repository policy.

Success means the resulting code is easier to understand and has equal or lower conceptual complexity—not merely more modular files.

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.