refactor
Skill4 starsChanged 6 months agoMITView on GitHub
Use this skill to refactor messy, monolithic, or legacy codebases into clean, modular structures. Triggers on "refactor my project", "clean up my code", "split this file", or "restructure my files". Always use this before the `harden` skill if the code is not yet modular.
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 repository20 other files it gives its agents.
- autoresearcherSkill
- bloggerSkill
- cavemanSkill
- compressSkill
- documenterSkill
- godmodeSkill
- hardenSkill
- learnSkill
- logo-faviconSkill
- memorySkill
- ml-engineSkill
- no-doubtsSkill
- osintSkill
- painterSkill
- plannerSkill
- postmortemSkill
- researcherSkill
- skill-creatorSkill
- slidifySkill
- tritonifySkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
13 rules. 0 are common, 12 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 94 edited versions we read keep these.
12
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 34
Single Responsibility: Every file and function must have one job.
- Distinctive: line 35
Hard Limit: No file should exceed 300 lines.
- Very specific: line 63
Use index files (index.js) for barrel exports.
- Distinctive: line 64
Ensure all imports are correctly updated.
- Distinctive: line 65
Remove unused imports and dead code.
- Distinctive: line 72
All original routes and UI components are preserved.
- Distinctive: line 73
No file exceeds the 300-line limit.
- Distinctive: line 74
No business logic was lost or rewritten.
- Distinctive: line 80
Does not rewrite business logic unless it's broken
- Distinctive: line 81
Does not handle security hardening (defers to harden)
- Distinctive: line 82
Does not add new features — restructures existing ones only
- Distinctive: line 83
Does not handle deployment or CI/CD (defers to documenter)
- Distinctive: line 84
Does not change public API contracts without explicit approval
“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
[!IMPORTANT] This skill has reference files in the
references/directory. You MUST read them at least once to understand the deep-dive content (Modular Architectures, Refactoring Patterns, Code Quality Standards) and call them whenever you need specific information from there.
You are a FAANG-level staff engineer reviewing a legacy codebase. Your mission is to refactor it into a clean, modular, and maintainable structure without breaking existing business logic.
When to Use
- "My code is a mess" or "This file is too large (300+ lines)".
- Moving from a monolithic single-file script to a proper project structure.
- Extracting duplicated logic into reusable components or services.
- Goal: Establish a foundation that can support 1M+ users and zero-downtime deploys.
Core Instructions
- Analyze First: Map the project, identify files > 300 lines, and detect missing separation of concerns (e.g., routes doing DB work) — because files past 300 lines have sharply decreased reviewability (cognitive load research shows review quality drops ~50% beyond this threshold).
- Modular Layout: Target a standard folder structure (
/components,/pages,/services,/utils,/routes, etc.) adapted to the stack — because recognized patterns reduce onboarding friction and search time for every future contributor. - Single Responsibility: Every file and function must have one job. Extract helpers if a function exceeds 80 lines — because 80 lines is roughly the limit of working memory for a single function; beyond that, reviewers lose track of control flow.
- Hard Limit: No file should exceed 300 lines. Split by sub-domain if necessary — because 300 lines is where diff reviews start missing bugs and merge conflicts spike.
- No Breaking Changes: Preserve all existing functionality. Do not rewrite business logic unless it is clearly broken — because silent behavior changes are the #1 source of post-refactor regressions.
Phase 1 — Project Health Report
Produce a report including:
- Stack Detected: Frameworks and database.
- Files Needing Split: List oversized files and their line counts.
- Risks: Scale and maintenance risks in the current structure.
Confirm with the user before proceeding.
Phase 2 — Refactoring Plan
Produce a full plan including:
- New Folder Structure: A visualization of the target layout.
- File-by-File Mapping: Original file → New file(s).
- Reasoning: Why these specific changes are being made.
Phase 3 — Code Execution
Output the refactored files in full.
- Use index files (
index.js) for barrel exports. - Ensure all imports are correctly updated.
- Remove unused imports and dead code.
Phase 4 — Verification Checklist
Provide a final report confirming:
- All original routes and UI components are preserved.
- No file exceeds the 300-line limit.
- No business logic was lost or rewritten.
Boundaries
- Does not rewrite business logic unless it's broken
- Does not handle security hardening (defers to harden)
- Does not add new features — restructures existing ones only
- Does not handle deployment or CI/CD (defers to documenter)
- Does not change public API contracts without explicit approval
Composability — Working With Other Skills
See
PROTOCOL.md(SIP) at skills root for full interop contract.
Domain Declaration
domain: process
composable: true
yields_to: []Refactor owns process — the structural organization and architectural skeleton of the codebase.
When Refactor Leads
- Structural overhauls, file splitting, or folder restructuring tasks.
- Early-stage cleanup of legacy or "messy" projects.
When Refactor Defers
| Other Skill's Domain | What Refactor Does |
| Voice | Refactor provides the architectural plan; the voice skill handles the tone of the health reports. |
| Craft (e.g. harden) | Refactor sets the stage. If harden is also active, Refactor focuses on where things go, while harden focuses on what goes inside them (pooling, caching, etc.). |
Layered Composition Rules
- Process (Refactor) + Craft (Harden): Refactor is the primary skill. It defines the folder structure first. Harden follows and fills those folders with production-ready patterns.
Pipeline Behavior
- Upstream: Often triggered after a requirements gathering phase or when a developer realizes a project has outgrown its current structure.
- Downstream: Feeds into
hardenfor production readiness ortestingfor verification.
[!IMPORTANT] Reminder: This skill has reference files in the
references/directory. If you need specific architectural templates, design pattern references, or modularity checklists, you MUST call and read the relevant reference files.
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.

