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.
In this repository12 other files it gives its agents.
- api-consistency-checkSkill
- architecture-drift-checkSkill
- design-reviewSkill
- jml-completeness-checkSkill
- jml-conformance-checkSkill
- jml-designSkill
- jml-test-generationSkill
- new-classSkill
- static-analysisSkill
- test-coverage-reviewSkill
- update-backlogSkill
- update-readmeSkill
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
- Distinctive: line 14
After implementing a complex class
- Distinctive: line 15
When a class exceeds ~300 lines
- Distinctive: line 16
When the user asks for "refactor", "clean up", or "improve this class"
- Distinctive: line 62
If no issues are found in a category, skip it entirely.
≈ “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.
Files
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.
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
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.

