refactor
Skill0 starsChanged 3 months agoMITView on GitHub
Universal refactoring engine: systematically evaluate, modernize, and refactor user interfaces, application code, software architecture, runtime performance, database schemas, and multi-page consistency — routed through seven execution modes. Use when asked to refactor UI components or layouts, clean up code smells and reduce cyclomatic complexity, decouple architectural modules and boundaries, optimize runtime performance and bundle sizes, refactor database schemas with zero downtime, sweep consistency across an entire app, or run a pre-release polish pass. Not for novel feature creation from scratch (new-project/webdev) or full security vulnerability exploitation (muse-security).
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 9 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 repository47 other files it gives its agents.
- AGENTS.mdAGENTS.md
- llms.txtllms.txt
- accountsSkill
- analyticsSkill
- automationSkill
- brandSkill
- client-commsSkill
- contentSkill
- crmSkill
- databaseSkill
- designSkill
- devopsSkill
- growthSkill
- gtmSkill
- incident-responseSkill
- mobileSkill
- opsSkill
- paidadsSkill
- qa-launchSkill
- researchSkill
- retainSkill
- sales-enablementSkill
- seoSkill
- smmSkill
- telegramSkill
- webdevSkill
- context-anchorSkill
- coupling-routerSkill
- evidence-ledgerSkill
- relaySkill
- secretarySkill
- gitSkill
- new-projectSkill
- updateagentsSkill
- updatedocsSkill
- animateSkill
- designscopeSkill
- auditSkill
- code-reviewSkill
- dead-letterSkill
- gauntlet-loopSkill
- humanizeSkill
- muse-securitySkill
- puaSkill
- clean-system-cacheSkill
- coachSkill
- periodic-retreatSkill
The file
We split this skill into the rules it gives an agent
7 rules. 0 are common, 4 are distinctive, and 3 are very specific to this project.
0
Common
Most of the 94 edited versions we read keep these.
4
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 42
Every invocation resolves to exactly one mode.
- Very specific: line 54
Only the resolved mode's reference is loaded — the rest stay on disk, saving tokens on every run.
- Very specific: line 72
When executing the ui or sweep mode, adhere strictly to the 10 atomic heuristics:
- Very specific: line 104
Ensure existing tests pass (bun test).
- Distinctive: line 108
Never combine refactoring with behavioral feature additions.
- Distinctive: line 124
Pixel drift in tokens mode: When centralizing design tokens, pixel values must remain visually identical.
- Distinctive: line 130
Run before reporting completion:
“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
🪄 refactor — Universal Refactoring Engine
One unified department for systematic software refactoring across all layers of the stack. Transforms legacy, messy, or inconsistent code and interfaces into clean, maintainable, and high-performance production assets without altering external behavior.
Modes — quick commands
Every invocation resolves to exactly one mode. Match the request, then load only the matched reference:
| Mode | Trigger phrases | Behavior | Reference |
| ui | "refactor this UI", "make this look professional", "improve design", "fix contrast", "refactoring-ui", "ui polish" | Visual and interface refactoring: 10 Refactoring UI atomic heuristics, spacing ladders, modern container queries, typography hierarchy, and WCAG 2.2 contrast parity | references/ui.md |
| code | "refactor this function", "clean up this code", "reduce complexity", "make this DRY", "extract method" | Code-level refactoring: cyclomatic complexity reduction, SOLID principles, eliminating dead code, function extraction, and TypeScript strict typing | references/code.md |
| architecture | "refactor codebase structure", "decouple modules", "clean architecture", "break circular dependency", "modularize" | Structural refactoring: modular boundaries, separating business logic from UI/framework, domain-driven organization, and dependency inversion | references/architecture.md |
| perf | "optimize performance", "refactor for speed", "reduce bundle size", "fix memory leak", "perf refactor" | Runtime & build refactoring: algorithmic efficiency ($O(n^2) \rightarrow O(n)$), tree-shaking, component memoization, dynamic imports, and Core Web Vitals optimization | references/perf.md |
| database | "refactor schema", "zero-downtime migration", "normalize tables", "fix N+1 queries", "db refactor" | Data layer refactoring: non-breaking column migrations, query optimization, indexing strategy, and ORM query batching | references/database.md |
| sweep | "sweep consistency", "unify all pages", "standardize components across app", "design consistency" | Multi-page consistency refactoring (strictly on-demand, never runs automatically): sweeping duplicate components into single sources of truth, aligning button styles, cards, and patterns across the app | references/sweep.md |
| polish | "final polish before release", "clean up deprecated code", "pre-merge polish", "ship readiness" | Pre-launch refactoring pass: dead-letter triage, deprecated API cleanup, lint/formatting sweep, and edge-case hardening | references/polish.md |
Only the resolved mode's reference is loaded — the rest stay on disk, saving tokens on every run. Note: sweep mode carries codebase-wide blast radius and is strictly on-demand; automated agents must never run it automatically without explicit user direction.
When to Use
- Refactoring a UI component, screen, or dashboard using the 10 atomic Refactoring UI heuristics.
- Simplifying complex functions, reducing cyclomatic complexity, or cleaning up messy procedural code.
- Decoupling monolithic modules, breaking circular dependencies, or enforcing clean architecture boundaries.
- Diagnosing and refactoring performance bottlenecks, memory leaks, and oversized bundles.
- Migrating database tables or columns with zero production downtime using the expand/contract pattern.
- Sweeping duplicate UI components or hardcoded tokens across an entire multi-page application.
- Conducting a final pre-merge or pre-launch technical polish pass.
Quick Reference & Atomic UI Heuristics
When executing the ui or sweep mode, adhere strictly to the 10 atomic heuristics:
| # | Heuristic Domain | Core Problem Solved | Primary Technique |
| 01 | Visual Hierarchy | Everything competing for attention | Primary focal point + aggressive de-emphasis of secondary elements |
| 02 | Typography Scale | Inconsistent, uncalibrated font sizes | Modular type scale (12, 14, 16, 20, 24, 32, 48px) with optical weights |
| 03 | Color Palette | Saturated, garish, or arbitrary colors | 9-step neutrals + primary brand hue + functional status semantics |
| 04 | Spacing Grid | Arbitrary margins and cramped layouts | Strict 4px/8px ramp; generous whitespace before adding borders |
| 05 | Button Hierarchy | Competing CTAs of equal visual weight | Solid primary, neutral secondary, ghost/link tertiary |
| 06 | Visual Clutter | Border soup, redundant divider lines | Surface contrast, directional spacing, removing self-evident labels |
| 07 | Empty States | Blank screens that confuse users | Action-oriented guidance, illustrative placeholder, instant CTA |
| 08 | Shadows & Depth | Flat cards, muddy drop-shadows | Layered diffuse shadows; shadows = depth, borders = structure |
| 09 | Color Contrast | Low-contrast text failing accessibility | WCAG 2.2 AA ($\ge 4.5:1$ text, $\ge 3:1$ UI/large) |
| 10 | Grouping & Proximity | Related items drifting apart | Inter-group gap $\ge 2\times$ intra-group; space before surfaces before lines |
| 11 | Anti-Slop 5-State Gate | Happy-path only components break in prod | Explicit Empty, Loading, Error, Success, and Overflow states |
Automated Tooling
Ships zero-dependency Bun scripts under scripts/:
- Anti-Pattern Scanner:
bun refactor/scripts/audit-ui.ts <file_or_dir> - WCAG Contrast Checker:
bun refactor/scripts/check-contrast.ts <file_or_dir>
Procedure
- Intake & Scope:
- Identify the exact layer requiring refactoring (UI, code, architecture, performance, database, or cross-page sweep).
- Resolve to exactly one execution mode.
- Safety Baseline:
- Ensure existing tests pass (
bun test). Never refactor on broken tests. - For database refactoring, confirm a staging replica and rollback path exist.
- Ensure existing tests pass (
- Execute Atomic Transformations:
- Make small, incremental changes. Rerun tests after each atomic step.
- Never combine refactoring with behavioral feature additions.
- Verification:
- For
ui: check 5-state gate and runcheck-contrast.ts. - For
code: check complexity reduction and clean linting (bun run lint). - For
architecture: verify dependency acyclicity. - For
perf: confirm benchmark delta. - For
database: verify zero locks held >100ms. - For
sweep&polish: verify zero regressions and type-check passing.
- For
Pitfalls
- Refactoring without tests: Blindly refactoring complex logic without automated regression tests causes subtle bugs. Write a characterization test first if tests are missing.
- Scope creep: Adding "just one quick feature" while refactoring breaks the refactoring discipline.
- Over-abstraction: Introducing 5 layers of design patterns for a simple 20-line utility function. Keep it lean and pragmatic.
- Pixel drift in tokens mode: When centralizing design tokens, pixel values must remain visually identical.
Verification
Run before reporting completion:
- Target files verified and exist.
- No secrets in output artifacts.
- WCAG 2.2 AA contrast verified for any color or typography change.
bun testpasses with zero behavioral regressions.bun run lintandbun run type-checkpass cleanly.- Release verdict emitted (
SHIP READYorBLOCK).
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.

