refactor
Skill1 starsChanged 18 days 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 twenty 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).
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 160 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 55
Only the resolved mode's reference is loaded — the rest stay on disk, saving tokens on every run.
- Very specific: line 91
When executing the ui or sweep mode, adhere strictly to the 10 atomic heuristics:
- Very specific: line 123
Ensure existing tests pass (bun test).
- Distinctive: line 127
Never combine refactoring with behavioral feature additions.
- Distinctive: line 143
Pixel drift in tokens mode: When centralizing design tokens, pixel values must remain visually identical.
- Distinctive: line 149
Run before reporting completion:
“Common” is measured: kept by at least 6 in 10 of the 160 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
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 |
audit | "pre-refactor audit", "audit codebase health", "refactor scope audit" | Measured pain, test-covered seams, blast radius, surgical-diff and rollback discipline — before code moves. | references/audit.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.
Support references (load on topic)
Loadable by topic; also routable as /refactor-<file> commands (not separate routed modes):
- 06-visual-clutter.md
- 11-five-state-anti-slop.md
- 08-shadows-elevation.md
- 03-color-palette.md
- 04-spacing-layout.md
- 05-button-hierarchy.md
- modern-techniques.md
- 02-typography-scale.md
- 09-contrast-accessibility.md
- 07-empty-states.md
- 01-visual-hierarchy.md
- 10-grouping-alignment.md
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).
Other versions187 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 187
- 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★ 707same name
- membrane/api-gateway★ 656same name
177 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.
Used alongsideProjects with it also use debug-fix, ascii-diagram 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.
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
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
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
In this repository49 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- 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
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.

