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
- BrOrlandi/my-claude-skillstheir own version, first seen Sep 22, 2026
- bsafronov/prosto-skillstheir own version, first seen Aug 31, 2026
- r2rka1/skillstheir own version, first seen Aug 18, 2026
- emaraschio/cursor-commandstheir own version, first seen Aug 7, 2026
- igmarin/rails-agent-skillstheir own version, first seen Jul 30, 2026
- chrisetheridge/skillstheir own version, first seen May 11, 2026
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.
gologo13Skilloptimize-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
Other versions9 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 9
- igmarin/rails-agent-skills★ 27same name
- BrOrlandi/my-claude-skills★ 21same name
- zbruhnke/claude-code-starter★ 17same name
- emaraschio/cursor-commands★ 9same name
- chrisetheridge/skills★ 4same name
- adolfoaranaes12/BMAD-ENHANCED★ 2same name
- r2rka1/skills★ 2same name
- bsafronov/prosto-skills★ 0same name
- gologo13/agent-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository26 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- architectSkill
- arenaSkill
- autopilotSkill
- blast-radiusSkill
- brainstormSkill
- clarifySkill
- code-reviewSkill
- debug-errorSkill
- diagram-designSkill
- explain-codeSkill
- java-coderSkill
- owasp-securitySkill
- pdfSkill
- pretty-mermaidSkill
- reflectSkill
- skill-hunterSkill
- teachSkill
- technical-writingSkill
- test-coverageSkill
- typesafe-aiSkill
- typescript-coderSkill
- unslopSkill
- write-testsSkill
- wrongSkill
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
- Distinctive: line 13
Prefer less code, fewer concepts, and clearer control flow over abstraction, extensibility, or pattern use.
- Distinctive: line 14
Keep the change within the requested boundary.
- Distinctive: line 17
Do not combine refactoring with dependency upgrades, formatting sweeps, security programs, performance rewrites, or unrelated cleanup.
- Distinctive: line 18
Do not change valid behavior, add arbitrary limits, or harden against theoretical threats under the label of refactoring.
- Distinctive: line 24
Read the implementation, callers, tests, and repository conventions.
- Distinctive: line 28
Run the smallest relevant existing tests before editing.
- Distinctive: line 29
Add characterization tests only when changed behavior is otherwise unprotected or ambiguous.
- Distinctive: line 34
Prefer rename, inline, delete, simplify, or local extraction before new types or architecture.
- Distinctive: line 35
Use existing project primitives and dependencies.
- Distinctive: line 36
Run focused validation after each meaningful step.
- Distinctive: line 39
If the work requires several new production modules, a generalized framework, a lifecycle/ownership protocol, or subsystem redesign, stop …
- Distinctive: line 40
If two attempts fail or remain unverified, revert to the last known-good state and reassess the actual boundary instead of layering more …
- Distinctive: line 43
Run the appropriate broader validation.
- Distinctive: line 45
Update documentation only where the refactor changed an actual contract or operating procedure.
- Distinctive: line 53
Add resilience, retries, caching, feature flags, monitoring, rollout machinery, or migration compatibility without a current requirement.
- Distinctive: line 55
Add production hooks solely for tests.
- Distinctive: line 56
Commit, format the whole repository, update snapshots, or change generated files unless requested or required by repository policy.
“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.
Files
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
- 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.
- 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.
- 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.
- 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.
- 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.
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.

