agentleFS
ksed8ksed8/cc-loopkit/.claude/skills/refactor/SKILL.md

refactor

Skill1 starsChanged 4 months agoMITView on GitHub

Clean up dead code, reduce duplication, and simplify structure without changing behavior. Use when refactoring, removing dead code, reducing duplication, or simplifying structure without changing behavior.

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

Files
SKILL.md

Refactor & Cleanup

Improve the internal structure of the selected code without changing its observable behavior. All tests must pass before and after.

Before Starting

  • Confirm the test suite is passing.
  • Note the current coverage baseline.
  • Identify the scope: single function, file, or module?

Refactoring Targets

Dead Code Removal

  • Unused variables, imports, functions, and exports
  • Commented-out code blocks (delete, don't leave as comments)
  • Feature flags that are permanently enabled/disabled
  • Unreachable branches

Duplication Reduction

  • Repeated logic that can be extracted into a shared utility
  • Copy-pasted blocks differing only in a parameter (extract with that parameter)
  • Inline constants that appear in multiple places (extract to named constants)

Structure Improvements

  • Functions over 50 lines → break into smaller, named steps
  • Files over 800 lines → extract cohesive sub-modules
  • Nesting deeper than 4 levels → extract early-return guards or helper functions
  • Mixed concerns in one function → split into focused single-responsibility functions

Naming

  • Rename variables/functions whose names don't match their behavior
  • Replace magic numbers and strings with named constants
  • Align naming with the domain language used elsewhere in the codebase

Constraints

  • No behavior changes — refactoring is purely structural.
  • One concern at a time — do not mix refactoring with feature work or bug fixes.
  • Keep tests green — run the suite after each meaningful change.
  • Don't add abstractions preemptively — extract only what has already proven to be duplicated (rule of three).

Output

After refactoring, summarize:

  • What was removed (dead code, duplication)
  • What was extracted (new utilities, constants)
  • What was renamed and why
  • Coverage before / after (should not decrease)

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.