agentleFS
TrarothTraroth/claude-dev-framework/skills/refactor-class/SKILL.md

refactor-class

Skill1 starsChanged 7 months agoMITView on GitHub

Refactor an existing class in the project to improve readability, maintainability, and structure without changing its observable behaviour. Use this skill after a class has grown significantly or when the user asks for refactoring.

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    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:

    After implementing a complex class

    line 14
  2. Distinctive:

    When a class exceeds ~300 lines

    line 15
  3. Distinctive:

    When the user asks for "refactor", "clean up", or "improve this class"

    line 16
  4. Distinctive:

    If no issues are found in a category, skip it entirely.

    line 62

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

Refactor Class

When to run

  • After implementing a complex class
  • When a class exceeds ~300 lines
  • When the user asks for "refactor", "clean up", or "improve this class"

Refactoring checklist

Focus on structural improvements without altering behaviour.

1. Method structure

  • Long methods identified and simplified
  • Repeated code extracted into private helper methods
  • Complex logic split into smaller methods
  • Method names clearly describe behaviour

2. Class structure

  • Fields grouped logically
  • Declaration order follows project standards
  • Responsibilities clearly separated

3. Encapsulation

  • Fields use the most restrictive visibility possible
  • Internal structures are not unnecessarily exposed
  • Defensive copies added where required

4. Duplication

  • Duplicate logic detected
  • Reusable helper methods introduced

5. Invariants

  • Refactoring does not break class invariants
  • Mutation methods remain consistent

Output format

Report findings grouped by category. For each finding, state:

  • The method or area concerned
  • The improvement suggested
  • The risk level (safe / requires testing)

If no issues are found in a category, skip it entirely.

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.