refactor
Skill2 starsChanged 14 days agoMITView on GitHub
- Rule of Three: Third instance triggers extraction. Exception: security and validation logic warrants unification at 2+. - Adding features: Restructure to accommodate the change first. - Fixing bugs: Clarify structure to expose the error. - Code review: Improve unfamiliar code incrementally. - Smells detected: See violation catalog in references/refactoring-guide.md. - Execute disciplined, semantics-preserving transformations to remove DRY, SOLID, and Structure violations, improving maintainability without altering observable behavior. Determine scope by the first available source: Abort if no scope exists.
196 other projects use a version of this.
Adopted by
Most recently taken up by
- Doist/todoist-aitheir own version, first seen Nov 9, 2026
- Doist/todoist-clitheir own version, first seen Nov 8, 2026
- rvdbreemen/OTGW-firmwaretheir own version, first seen Nov 8, 2026
- paulocsb/worldcup-fifa-pooltheir own version, first seen Nov 8, 2026
- DnsQueen/orcinus-skillstheir own version, first seen Nov 8, 2026
- taixuann/development-spacetheir own version, first seen Nov 8, 2026
Used with
Projects with it also use ascii-diagram, debug-fix and 10 more.
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.
SethGammonSkillascii-diagram
Generate perfectly aligned ASCII diagrams — architecture, flow, sequence, box-and-arrow. Uses a programmatic character-grid approach so alignment is guaranteed by math, not token prediction. Includes post-render verification.
Also in 4 projects that use this
zebbernSkilldebug-fix
Find and fix a bug or issue — from any source (GitHub issue, error message, user report, or observed behavior)
Also in 4 projects that use this
parcadeiSkillagent-context-isolation
Agent Context Isolation
Also in 3 projects that use this
parcadeiSkillagentica-infrastructure
Reference guide for Agentica multi-agent infrastructure APIs
Also in 3 projects that use this
- +8 more from parcadei
Other versions196 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 196
- github/awesome-copilot★ 41ksame name
- unkeyed/unkey★ 5.5ksame name
- parcadei/Continuous-Claude★ 3.9ksame name
- parcadei/Continuous-Claude-v2★ 3.9ksame name
- parcadei/Continuous-Claude-v3★ 3.9ksame name
- adobe/S3Mock★ 1.2ksame name
- SethGammon/Citadel★ 927same name
- poshan0126/dotclaude★ 871same name
- JordanCoin/codemap★ 710same name
- membrane/api-gateway★ 658same name
186 more not listed
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 repository21 other files it gives its agents.
- auto-commitSkill
- cleanSkill
- code-reviewSkill
- coverageSkill
- documentSkill
- purifySkill
- puritySkill
- spae-buildSkill
- spae-checkSkill
- spae-fixSkill
- spae-inspectSkill
- spae-orchestrateSkill
- spae-planSkill
- spae-prepareSkill
- spae-spawnSkill
- spae-specSkill
- spae-verifySkill
- structureSkill
- testSkill
- tipSkill
- troubleshootSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
15 rules. 0 are common, 8 are distinctive, and 7 are very specific to this project.
0
Common
Most of the 169 edited versions we read keep these.
8
Distinctive
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 63
Read relevant production code, adjacent tests, and test commands.
- Very specific: line 74
When detected smells carry high regression risk resisting safe atomic extraction under existing tests: record in Findings, omit edits, and …
- Very specific: line 94
Run the full suite after each ACT step.
- Distinctive: line 116
Two Hats: Never add features or new tests while refactoring.
- Very specific: line 125
No Confirmation Halts: Never halt to request user scope confirmation or interactive direction.
- Distinctive: line 131
Inherit Baseline: Treat the test suite as-found at refactor start as the authoritative baseline, regardless of prior tooling in the same …
- Distinctive: line 148
No hacks, workarounds, or shortcuts.
- Very specific: line 150
Never edit build or tool configuration files.
- Very specific: line 153
Never suppress or disable compiler or linter diagnostics.
- Very specific: line 155
Never weaken type contracts to silence errors.
- Distinctive: line 160
Every detection line names code examined or why none applies—restating the section never counts.
- Distinctive: line 166
No dangling references or unintended interface breaks.
- Very specific: line 169
No self-introduced cleanup violation remains per references/cleanup-guide.md.
- Distinctive: line 177
Keep prose terse while ensuring clarity.
- Distinctive: line 179
Use lists and sub-lists for long sentences and dense paragraphs.
“Common” is measured: kept by at least 6 in 10 of the 169 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 agent
When to use
- Rule of Three: Third instance triggers extraction. Exception: security and validation logic warrants unification at 2+.
- Adding features: Restructure to accommodate the change first.
- Fixing bugs: Clarify structure to expose the error.
- Code review: Improve unfamiliar code incrementally.
- Smells detected: See violation catalog in
references/refactoring-guide.md.
Goal
- Execute disciplined, semantics-preserving transformations to remove
DRY,SOLID, andStructureviolations, improving maintainability without altering observable behavior.
Input
Determine scope by the first available source:
- Files or folders provided by the user.
- Current changes in the repository.
Abort if no scope exists.
Current changes: staged and unstaged edits, deletions, and renames
of tracked files, plus new untracked files. Requires a versioned
project. Abort with a clear message if none detected.
Testing
See references/testing-guide.md for test structure, isolation,
mocking, assertion, and performance standards.
Shell commands
See references/shell-command-guide.md for command safety, timeouts,
redirects, and non-interactive environment directives.
Cleanup
See references/cleanup-guide.md for the self-introduced-artifact
checklist and diff-only audit scope.
Workflow
- GATE—Precondition guard. Halt immediately on failure.
- Abort if no scope exists.
- Read
references/testing-guide.md. - Read
references/shell-command-guide.md. - Read
references/cleanup-guide.md. - Read relevant production code, adjacent tests, and test commands.
- Confirm automated test suite passes before touching code.
- Detect
antipatternsusing theDRY,SRP,OCP,LSP,ISP,DIP, andStructuresections of the violation catalog inreferences/refactoring-guide.md, plus long methods andprimitiveobsession. - Record one detection line for each section and one for those remaining smells: code examined (or why none applies) and violations found.
- Short-circuit: once every line exists, halt and emit
Result: No Changesif none found a violation. - When detected smells carry high regression risk resisting safe
atomic extraction under existing tests: record in
Findings, omit edits, and emitResult: No Changes.
- ORIENT—Name the smallest production area worth refactoring and
what won't change. Capture pre-task baseline snapshot per
references/cleanup-guide.md. - PLAN—Declare the minimal change and rationale.
- Target one cohesive responsibility boundary (for example, extracting a dedicated collaborator, domain service, or validation module) rather than whole-class overhauls or disconnected micro-edits.
- Declare the ordered sequence of transformations needed to decouple that responsibility.
- Analyze package, module, or class boundaries for cyclic imports and unresolved downstream consumers.
- Select the fix from the playbook; resolve compound violations using
the triage rules in
references/refactoring-guide.md.
- ACT—Apply one transformation at a time. Execute only what PLAN declared.
- VERIFY—Loop over every criterion declared in PLAN:
- Run the full suite after each
ACTstep. - Audit task edits against the pre-task baseline using the
Self-cleanup checklist in
references/cleanup-guide.md; remove every self-introduced artifact before proceeding. - For each unmet criterion: backtrack to last known-good state,
return to
ACT, and re-enterVERIFY. - Exit only when all criteria pass.
- Halt only for out-of-scope blockers (failing baseline tests, compilation errors, or missing runtime environments); never treat complex codebase smells as blockers.
- Run the full suite after each
- REPORT—Emit the result following the result directives and using the result template.
Directives
- Cohesive Scope: Scope each invocation to one distinct responsibility boundary; batch related transformations internally under sequential test verification rather than micro-slicing single methods.
- Detection lines: Surface them as one
Actionsline (for example,detection: 8/8 lines; 1 found); keep per-section detail out of the result. - Two Hats: Never add features or new tests while refactoring. Extracting internal functions, modules, or cohesive units under existing test suites satisfies Two Hats without requiring new test files.
- Violations: Detect and fix using the violation catalog and fix
playbook in
references/refactoring-guide.md.
Constraints
- No Confirmation Halts: Never halt to request user scope
confirmation or interactive direction; execute the smallest safe
transformation within detected scope or emit
Result: No Changes. - Zero Behavioral Change: External function and observable behavior must remain identical.
- Defer if Broken: Stabilize failing code before refactoring.
- Inherit Baseline: Treat the test suite as-found at refactor start as the authoritative baseline, regardless of prior tooling in the same session.
- Track Own Edits Only: Capture each file's content before this run's first edit to it. Revert means rewriting captured content back, or deleting files this run created—never a git-level reset, stash, checkout, or restore, which erases uncommitted work from earlier phases in the same tree.
- Never Leave It Broken: End every refactor with the suite green again or the offending edits reverted, regardless of why VERIFY halts.
- Self-Inflicted Failures Stay In-Scope: A failure this pass's own
edits cause never qualifies as an out-of-scope blocker; loop
VERIFY's backtrack step instead of halting. - Bug Found Mid-Refactor: A pre-existing bug the refactor exposes counts as out-of-scope. Revert the edits that surfaced it, then report the bug as a separate finding. Never fix it in the same pass (Two Hats).
- No hacks, workarounds, or shortcuts.
- Forbid laziness; fix issues properly, correctly, and idiomatically.
- Never edit build or tool configuration files; for example,
tsconfig.json,.eslintrc.*,webpack.config.*,vite.config.*,jest.config.*,Makefile,pyproject.toml,Cargo.toml. - Never suppress or disable compiler or linter diagnostics; for example,
@ts-ignore,eslint-disable,@SuppressWarnings,# type: ignore. - Never weaken type contracts to silence errors; for example,
as any,!non-null assertions, or broadening union types.
Verification
- Every detection line names code examined or why none applies—restating the section never counts.
- Full test suite passes 100% with no new failures or errors.
- Code compiles without warnings or missing dependencies.
- Complexity metrics (class size, method length, parameter count) show measurable reduction.
- No dangling references or unintended interface breaks.
- Re-run smell detection against the violation catalog to confirm no new violations introduced.
- No self-introduced cleanup violation remains per
references/cleanup-guide.md. Result: Failedonly follows a working tree the agent restores to the pre-refactor baseline; never a suite left red.
Result directives
- Minimum words. Maximum signal.
- Keep prose terse while ensuring clarity.
- Optimize prose for agent, token, and context efficiency.
- Use lists and sub-lists for long sentences and dense paragraphs.
- Emit the result template as live markdown—never in a code fence.
- Output nothing outside the template.
Result template
<!-- prettier-ignore-start -->### Execution Summary
- **Actions**:
- [Terse list of actions taken]
- **Files**:
- [Terse list of affected files]
- **Findings**:
- [Terse list of notable findings]
- **Summary**:
- [Terse list of summary of changes]
> **Refactor Status** • `[scope]`
> **Result**: [Complete | No Changes | Failed]
> **Impact**: [Terse impact statement]<!-- prettier-ignore-end -->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.

