refactoring-guide
Skill1 starsChanged 9 days agoMITView on GitHub
Plan and perform safe refactors that improve structure without changing behavior. Use whenever the user asks to clean up, simplify, restructure, de-duplicate, modernize, or 'make this more readable or maintainable' code, or complains that a function or class is too long or messy.
4 other projects use a version of this.
Adopted by
Most recently taken up by
- jaskirat1616/grok-skillstheir own version, first seen Nov 1, 2026
- JayRHa/agent-skillstheir own version, first seen Oct 15, 2026
- JayRHa/AgentSkillstheir own version, first seen Jun 9, 2026
- peopleforrester/claude-dotfilestheir own version, first seen Apr 5, 2026
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 4
- jaskirat1616/grok-skills★ 22same name
- JayRHa/agent-skills★ 12same name
- JayRHa/AgentSkills★ 12same name
- peopleforrester/claude-dotfiles★ 3same 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.
- adr-writerSkill
- api-design-reviewSkill
- changelog-generatorSkill
- chart-selectorSkill
- code-reviewSkill
- commit-and-pr-writerSkill
- csv-profilerSkill
- debugging-playbookSkill
- docker-best-practicesSkill
- email-drafterSkill
- executive-summarySkill
- incident-postmortemSkill
- meeting-actionsSkill
- okr-writerSkill
- plain-language-editorSkill
- prd-writerSkill
- pre-push-secret-scanSkill
- prompt-improverSkill
- readme-writerSkill
- resume-tailorSkill
- security-reviewSkill
- source-evaluatorSkill
- sql-optimizerSkill
- study-plan-builderSkill
- test-writerSkill
- my-skill-nameSkill
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 3 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
3
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 32
Do not rename, reformat, and restructure in one commit.
- Distinctive: line 34
Do not add abstractions for hypothetical futures.
- Distinctive: line 35
Keep the language idioms of the codebase.
“Common” is measured: kept by at least 6 in 10 of the 4 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
Refactoring Guide
Refactoring changes structure, not behavior. If behavior must change, separate that into its own step.
Before touching anything
- Confirm a safety net. Are there tests? If not, write characterization tests that pin current behavior first, or state the risk plainly.
- Name the smell and the goal. Examples: long function, deep nesting, duplicated logic, primitive obsession, god class, feature envy, boolean flag arguments, shotgun surgery.
- Choose the smallest step that helps.
Common moves
| Smell | Move |
| Long function | Extract function with a name that says what, not how |
| Deep nesting | Guard clauses / early return |
| Duplicated code | Extract and parameterize, only after seeing 3 real copies |
| Flag arguments | Split into two functions or use an enum/strategy |
| Magic numbers | Named constants |
| Large conditional on type | Polymorphism or lookup table |
| Data clumps | Introduce a small value object |
| Dead code | Delete it (version control remembers) |
Rules
- Make one refactor per step and keep each step independently reviewable.
- Do not rename, reformat, and restructure in one commit.
- Preserve public interfaces unless the user approves a breaking change.
- Do not add abstractions for hypothetical futures. Three similar lines beat a premature framework.
- Keep the language idioms of the codebase.
Output
Show the refactored code, then a short list of steps taken, what behavior is intentionally unchanged, and how to verify (tests to run, manual checks). Flag anything that looked like a latent bug instead of silently fixing it.
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.

