refactor-simplify
Skill2 starsChanged 7 months agoMITView on GitHub
Reduce complexity, eliminate anti-patterns, and improve structural clarity in existing code. Use when requesting "clean up this", "make it more readable", or "reduce cyclomatic complexity". Do NOT use for feature additions, security hardening, or performance profiling without explicit refactoring scope.
In this repository20 other files it gives its agents.
- api-design-standardizerSkill
- api-documentation-generatorSkill
- cloud-infrastructure-architectSkill
- cobol-to-javaSkill
- code-reviewSkill
- compliance-policy-auditorSkill
- database-performance-auditorSkill
- data-cleanupSkill
- incident-post-mortem-generatorSkill
- kaggle-notebook-generatorSkill
- meeting-transcriberSkill
- pdf-extractSkill
- python-structure-generatorSkill
- python-type-hinterSkill
- github-repo-structure-builderSkill
- security-vulnerability-scannerSkill
- sql-query-optimizerSkill
- unit-test-generatorSkill
- user-story-generatorSkill
- web-researchSkill
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 7 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 21
Do NOT use for adding new business logic, fixing runtime bugs, or optimizing performance without structural cleanup
- Distinctive: line 22
Do NOT use when the user explicitly requests "keep it as-is, just add comments"
- Distinctive: line 30
IF deep nesting → extract guard clauses, early returns, or strategy patterns.
- Distinctive: line 31
IF duplicated logic → extract reusable functions or utility modules.
- Distinctive: line 32
IF large functions → decompose into single-responsibility units.
- Distinctive: line 33
IF implicit state → make dependencies explicit via parameters or DI.
- Very specific: line 39
Ensure refactored code produces identical outputs for identical inputs.
- Distinctive: line 61
If the code is already well-structured and no meaningful simplification exists, respond with:
- Very specific: line 71
If the user's request conflicts with framework conventions (e.g., forcing procedural style in OOP), warn: "⚠️ Proposed simplification …
≈ “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 & Simplify
Focused transformation workflow targeting readability, modularity, and long-term maintainability.
🎯 When to Use
- User shares deeply nested, overly long, or highly coupled code
- User asks to "simplify this", "extract methods", or "improve readability"
- Code exhibits duplicated logic, magic numbers, or inconsistent naming
- Do NOT use for adding new business logic, fixing runtime bugs, or optimizing performance without structural cleanup
- Do NOT use when the user explicitly requests "keep it as-is, just add comments"
🧠 Core Workflow
Step 1 — Measure Complexity Identify high-complexity areas: functions > 30 lines, nesting > 3 levels, cyclomatic complexity > 10, or tightly coupled classes. Log exact metrics.
Step 2 — Apply Structural Simplification
- IF deep nesting → extract guard clauses, early returns, or strategy patterns.
- IF duplicated logic → extract reusable functions or utility modules.
- IF large functions → decompose into single-responsibility units.
- IF implicit state → make dependencies explicit via parameters or DI.
Step 3 — Enforce Consistency Standardize naming (variables, functions, classes), align formatting, remove dead code, and replace magic numbers/strings with named constants or enums.
Step 4 — Validate Behavioral Equivalence
Ensure refactored code produces identical outputs for identical inputs. IF public interfaces must change → wrap in compatibility layer and explicitly mark @deprecated.
Step 5 — Output & Diff Return before/after comparison, list of applied transformations, and any required follow-up actions (e.g., updating call sites).
📋 Output Format
Section 1 — Refactor Report
{
"status": "success | partial | error",
"complexity_before": {"lines": 0, "nesting_depth": 0, "functions_extracted": 0},
"complexity_after": {"lines": 0, "nesting_depth": 0, "functions_extracted": 0},
"changes_applied": ["early_returns", "extract_method", "remove_duplication"],
"breaking_changes": false
}Section 2 — Refactored Code
Provide the cleaned code block. Add // REFACTOR: or # REFACTOR: comments above modified sections. Keep structure flat and intent explicit.
⚠️ Fallback Behavior If the code is already well-structured and no meaningful simplification exists, respond with:
{
"status": "partial",
"message": "Code already meets modern readability standards. No structural refactoring required.",
"suggestion": "Consider adding type annotations, documentation, or test coverage instead."
}If the user's request conflicts with framework conventions (e.g., forcing procedural style in OOP), warn:
"⚠️ Proposed simplification conflicts with detected framework paradigms. Proceed only if intentional."
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.

