refactor
Skill1 starsChanged 4 months 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.
111 other projects use a version of this.
Adopted by
Most recently taken up by
- AllThingsSmitty/proven-skillstheir own version, first seen Oct 6, 2026
- GUOJIE-HONG/skillstheir own version, first seen Oct 5, 2026
- morodomi/dev-crewtheir own version, first seen Oct 5, 2026
- gilsmt/skillstheir own version, first seen Oct 4, 2026
- Integralist/agent-skillstheir own version, first seen Oct 4, 2026
- AlvaroVFon/skillstheir own version, first seen Oct 3, 2026
Used with
Projects with it also use modern-go, to-design 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.
jidechaoSkillmodern-go
Modernize Go code by applying version-appropriate idioms and APIs (gofix-style transformations). Scans go.mod for the Go version, then transforms Go source files to use modern patterns—from Go 1.0 through 1.26+. Use when the user says "现代化","现代Go语言", "地道的", "idiomatic", "modernize", "modern-go", "update Go code", "gofix", or wants to upgrade Go idioms.
Also in 3 projects that use this
jidechaoSkillto-design
Generate a design document (design proposal) from a PRD, in the style of Go's official design proposals — Abstract / Background / Design / Rationale / Compatibility / Implementation, heavy on the 'why' and tradeoffs. Triggers on: to-design, prd-to-design, prd转设计文档, 生成设计文档, 写设计文档, design doc, design proposal, 设计提案, 技术设计文档.
Also in 3 projects that use this
chidekinaSkilltest-gen
Generate test cases from type constraints and specs. Creates boundary tests, edge cases, and fixtures automatically. Pact-lang inspired. Triggers on: generate tests, test from spec, create fixtures, boundary tests.
Also in 5 projects that use this
pvnarpSkillincident
Guides incident response and post-mortem analysis. Covers triage, mitigation, root cause analysis, and prevention. Use when responding to active incidents, writing post-mortems, or improving incident processes.
Also in 6 projects that use this
platformplatformSkilldb-query
Query the local Postgres database of the active Aspire worktree via psql.
Also in 3 projects that use this
JetBrainsSkillfix-bug
End-to-end bug fix workflow for the Exposed project. Accepts a GitHub issue (#NUMBER), YouTrack issue (EXPOSED-NUMBER), or YouTrack URL (https://youtrack.jetbrains.com/issue/EXPOSED-NUMBER). Fetches the issue, creates a failing reproducer test, commits on a new branch, implements the fix, validates, and opens a PR. Use this skill whenever the user wants to fix a bug from an issue tracker, mentions a EXPOSED issue number, or references a GitHub issue to fix.
Also in 6 projects that use this
- +2 more from jidechao
Other versions111 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 111
- github/awesome-copilot★ 40ksame name
- parcadei/Continuous-Claude-v3★ 3.9ksame name
- codeaholicguy/ai-devkit★ 1.6ksame name
- SethGammon/Citadel★ 922same name
- solatis/claude-config★ 909same name
- boshu2/agentops★ 447same name
- nwiizo/tfmcp★ 373same name
- smallnest/goal-workflow★ 287same name
- oasm-platform/open-asm★ 204same name
- sd0xdev/sd0x-harness★ 191same name
101 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 repository19 other files it gives its agents.
- auto-commitSkill
- cleanSkill
- code-reviewSkill
- coverageSkill
- documentSkill
- purifySkill
- spae-buildSkill
- spae-checkSkill
- spae-fixSkill
- spae-inspectSkill
- spae-orchestrateSkill
- spae-planSkill
- spae-prepareSkill
- spae-spawnSkill
- spae-specSkill
- spae-verifySkill
- testSkill
- tipSkill
- troubleshootSkill
The file
We split this skill into the rules it gives an agent
12 rules. 0 are common, 7 are distinctive, and 5 are very specific to this project.
0
Common
Most of the 94 edited versions we read keep these.
7
Distinctive
This author's own choices. Worth a look.
5
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 80
Run the full suite after each ACT step.
- Distinctive: line 93
Two Hats: Never add features or new tests while refactoring.
- Distinctive: line 102
Inherit Baseline: Treat the test suite as-found at refactor start as the authoritative baseline, regardless of prior tooling in the same …
- Distinctive: line 119
No hacks, workarounds, or shortcuts.
- Very specific: line 121
Never edit build or tool configuration files.
- Very specific: line 124
Never suppress or disable compiler or linter diagnostics.
- Very specific: line 126
Never weaken type contracts to silence errors.
- Distinctive: line 135
No dangling references or unintended interface breaks.
- Very specific: line 138
No self-introduced cleanup violation remains per references/cleanup-guide.md.
- Distinctive: line 146
Keep prose terse while ensuring clarity.
- Distinctive: line 148
Use lists and sub-lists over paragraphs and long sentences.
“Common” is measured: kept by at least 6 in 10 of the 94 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 the violation catalog inreferences/refactoring-guide.md. - Short-circuit: halt and emit
Result: No Changesif none detected: duplicated logic, long methods, large classes,primitiveobsession,SOLIDviolations.
- ORIENT—Name the smallest production area worth refactoring and what won't change.
- PLAN—Declare the minimal change and rationale.
- 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 the task's own
git diff/git statusagainst the Self-cleanup checklist inreferences/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.
- Run the full suite after each
- REPORT—Emit the result following the result directives and using the result template.
Directives
- Two Hats: Never add features or new tests while refactoring.
- Violations: Detect and fix using the violation catalog and fix
playbook in
references/refactoring-guide.md.
Constraints
- 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
- 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 over paragraphs and long sentences.
- 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.

