[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6JP11F3K1HD6MBNS302BXF3":3,"skill-same:01M6JP11F3K1HD6MBNS302BXF3":74},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":38,"linkOnly":39,"markdownContent":40,"markdownBody":41,"frontMatter":42,"refName":43,"commitSha":44,"skillDirectory":45,"forksCount":14,"repositoryHtmlUrl":46,"repositoryHomepageUrl":6,"ownerHtmlUrl":47,"ownerBlogUrl":6,"ownerDescription":48,"updatedAt":49,"install":50,"resources":63},"01M6JP11F3K1HD6MBNS302BXF3","refactoring",null,"Systematic code improvement via design principles, smell detection, and safe transformation patterns. Triggers: refactor this, clean this up, simplify this code, reduce complexity, extract this, this code is messy, tech debt, improve this code, code smell, rename, extract function, dead code.","SWEStash\u002Fswe-workflow-skills","SWEStash","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F272895713?v=4","01M6JNRQ84JN5WFK9S1V5H4G46","SWE Stash","01M6JNRQCM45X8WPNHY30TSAB0",1,"MIT","https:\u002F\u002Fgithub.com\u002FSWEStash\u002Fswe-workflow-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fbackend\u002Fskills\u002Frefactoring\u002FSKILL.md",[],[5,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],"design principles","improvement","reduce","tech","systematic","triggers","transformation","rename","patterns","clean","design","complexity","up","dead code","improve","simplify","refactor","code","safe","2026-11-10 10:12:30",false,"---\nname: refactoring\ndescription: \"Systematic code improvement via design principles, smell detection, and safe transformation patterns. Triggers: refactor this, clean this up, simplify this code, reduce complexity, extract this, this code is messy, tech debt, improve this code, code smell, rename, extract function, dead code.\"\n---\n\n# Refactoring\n\nGuide safe, incremental code improvements that preserve behavior while enhancing design. Refactoring is disciplined — every change is small, tested, and reversible.\n\n## Core Rule\n\n**Never change behavior and structure in the same step.** Either you're adding a feature (behavior change) or you're refactoring (structure change). Mixing them creates bugs that are hard to trace.\n\n## Workflow\n\n### Step 1: Ensure Test Coverage\n\nBefore refactoring anything, verify that tests exist for the behavior you're about to restructure. If tests are missing:\n\n1. Write characterization tests that document current behavior (even if the behavior has quirks)\n2. Run them and confirm they pass\n3. Only then begin refactoring\n\nIf the user resists writing tests first, explain: refactoring without tests is not refactoring, it's rewriting with hope.\n\n### Step 2: Identify Smells\n\nRead the code and identify code smells. Prioritize by impact — don't try to fix everything at once. The most common smells, roughly ordered by severity:\n\n1. **Long function** (>30 lines) → Extract method\n2. **Duplicated logic** → Extract and share\n3. **Deep nesting** (>3 levels) → Early returns, extract method\n4. **Long parameter list** (>4 params) → Introduce parameter object\n5. **Feature envy** → Move method to the class it uses most\n6. **Primitive obsession** → Introduce domain types\n7. **Shotgun surgery** → Consolidate related logic\n8. **Divergent change** → Split class by responsibility\n\nSee [references\u002Ftransformations.md](references\u002Ftransformations.md) for the complete catalog of safe transformations.\n\n### Step 3: Plan the Sequence\n\nOrder refactoring steps so that each step:\n- Is small enough to verify easily\n- Keeps all tests green\n- Makes the next step easier\n\nA good sequence often looks like:\n1. Rename for clarity (cheapest, highest readability impact)\n2. Extract helpers to reduce function length\n3. Consolidate duplicates using the extracted helpers\n4. Move methods to better homes\n5. Simplify interfaces\n\n### Step 4: Execute — One Step at a Time\n\nFor each transformation:\n\n1. **Explain** what you're about to do and why\n2. **Apply** the single transformation\n3. **Run tests** and confirm green\n4. **Show the diff** to the user\n\nIf tests break, undo immediately. A failing test after refactoring means the transformation changed behavior — that's a bug, not a test to fix.\n\n### Step 5: Review the Result\n\nAfter completing the planned sequence:\n\n- Compare before\u002Fafter: Is the intent clearer? Is the code simpler?\n- Run the full test suite\n- Check that no public API changed (unless that was the goal)\n- Look for any new smells introduced by the refactoring\n\n## Principles Applied\n\n- **DRY**: Eliminate duplication discovered during refactoring\n- **KISS**: Every transformation should make the code simpler, not more abstract\n- **SRP**: Each extracted function\u002Fclass should have one reason to change\n- **YAGNI**: Don't introduce abstractions for hypothetical future needs during refactoring\n- **Functional Independence**: Refactoring should reduce coupling, not increase it\n- **Boy Scout Rule**: Leave the code cleaner than you found it — every refactoring session should improve the surrounding code slightly, not just the target. Small cleanups (renaming, removing dead code) near the area you're working in compound over time.\n- **Kent Beck's 4 Rules of Simple Design**: After refactoring, the code should: (1) keep all tests green, (2) reveal intention clearly, (3) contain no duplication, (4) use the fewest classes and methods needed. Apply these as a checklist during Step 5 review.\n\n## Cross-Skill References\n\n- `technical-debt-review` — use to identify which areas are worth refactoring at a strategic level before starting\n- `dependency-impact-analysis` — use before refactoring a shared component or public interface to understand blast radius\n- `code-slop-cleanup` — most slop cleanup *is* a micro-refactor: use that skill for the pre-PR diff-scoped pass (removal-only, judged against file conventions); use this one when the cleanup turns structural (extract, move, re-abstract). They chain naturally: strip slop first, then refactor what remains\n","# Refactoring\n\nGuide safe, incremental code improvements that preserve behavior while enhancing design. Refactoring is disciplined — every change is small, tested, and reversible.\n\n## Core Rule\n\n**Never change behavior and structure in the same step.** Either you're adding a feature (behavior change) or you're refactoring (structure change). Mixing them creates bugs that are hard to trace.\n\n## Workflow\n\n### Step 1: Ensure Test Coverage\n\nBefore refactoring anything, verify that tests exist for the behavior you're about to restructure. If tests are missing:\n\n1. Write characterization tests that document current behavior (even if the behavior has quirks)\n2. Run them and confirm they pass\n3. Only then begin refactoring\n\nIf the user resists writing tests first, explain: refactoring without tests is not refactoring, it's rewriting with hope.\n\n### Step 2: Identify Smells\n\nRead the code and identify code smells. Prioritize by impact — don't try to fix everything at once. The most common smells, roughly ordered by severity:\n\n1. **Long function** (>30 lines) → Extract method\n2. **Duplicated logic** → Extract and share\n3. **Deep nesting** (>3 levels) → Early returns, extract method\n4. **Long parameter list** (>4 params) → Introduce parameter object\n5. **Feature envy** → Move method to the class it uses most\n6. **Primitive obsession** → Introduce domain types\n7. **Shotgun surgery** → Consolidate related logic\n8. **Divergent change** → Split class by responsibility\n\nSee [references\u002Ftransformations.md](references\u002Ftransformations.md) for the complete catalog of safe transformations.\n\n### Step 3: Plan the Sequence\n\nOrder refactoring steps so that each step:\n- Is small enough to verify easily\n- Keeps all tests green\n- Makes the next step easier\n\nA good sequence often looks like:\n1. Rename for clarity (cheapest, highest readability impact)\n2. Extract helpers to reduce function length\n3. Consolidate duplicates using the extracted helpers\n4. Move methods to better homes\n5. Simplify interfaces\n\n### Step 4: Execute — One Step at a Time\n\nFor each transformation:\n\n1. **Explain** what you're about to do and why\n2. **Apply** the single transformation\n3. **Run tests** and confirm green\n4. **Show the diff** to the user\n\nIf tests break, undo immediately. A failing test after refactoring means the transformation changed behavior — that's a bug, not a test to fix.\n\n### Step 5: Review the Result\n\nAfter completing the planned sequence:\n\n- Compare before\u002Fafter: Is the intent clearer? Is the code simpler?\n- Run the full test suite\n- Check that no public API changed (unless that was the goal)\n- Look for any new smells introduced by the refactoring\n\n## Principles Applied\n\n- **DRY**: Eliminate duplication discovered during refactoring\n- **KISS**: Every transformation should make the code simpler, not more abstract\n- **SRP**: Each extracted function\u002Fclass should have one reason to change\n- **YAGNI**: Don't introduce abstractions for hypothetical future needs during refactoring\n- **Functional Independence**: Refactoring should reduce coupling, not increase it\n- **Boy Scout Rule**: Leave the code cleaner than you found it — every refactoring session should improve the surrounding code slightly, not just the target. Small cleanups (renaming, removing dead code) near the area you're working in compound over time.\n- **Kent Beck's 4 Rules of Simple Design**: After refactoring, the code should: (1) keep all tests green, (2) reveal intention clearly, (3) contain no duplication, (4) use the fewest classes and methods needed. Apply these as a checklist during Step 5 review.\n\n## Cross-Skill References\n\n- `technical-debt-review` — use to identify which areas are worth refactoring at a strategic level before starting\n- `dependency-impact-analysis` — use before refactoring a shared component or public interface to understand blast radius\n- `code-slop-cleanup` — most slop cleanup *is* a micro-refactor: use that skill for the pre-PR diff-scoped pass (removal-only, judged against file conventions); use this one when the cleanup turns structural (extract, move, re-abstract). They chain naturally: strip slop first, then refactor what remains\n",{"name":5,"description":7},"main","800dc9ad0ca2914d6ad15b8c5159d9b57bb104c2","plugins\u002Fbackend\u002Fskills\u002Frefactoring","https:\u002F\u002Fgithub.com\u002FSWEStash\u002Fswe-workflow-skills","https:\u002F\u002Fgithub.com\u002FSWEStash","A stash of things we felt like building","2026-11-12 00:14:33",{"source":8,"skillName":5,"commands":51,"prompt":61,"zipAvailable":62},[52,55,58],{"tool":53,"command":54},"npx","npx skills add SWEStash\u002Fswe-workflow-skills --skill refactoring",{"tool":56,"command":57},"bunx","bunx skills add SWEStash\u002Fswe-workflow-skills --skill refactoring",{"tool":59,"command":60},"pnpm","pnpm dlx skills add SWEStash\u002Fswe-workflow-skills --skill refactoring","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FSWEStash\u002Fswe-workflow-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fbackend\u002Fskills\u002Frefactoring\u002FSKILL.md",true,[64,70],{"path":65,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":68,"sourceHtmlUrl":69},"evals\u002Fevals.json","REFERENCE","参考文档",3752,"https:\u002F\u002Fgithub.com\u002FSWEStash\u002Fswe-workflow-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fbackend\u002Fskills\u002Frefactoring\u002Fevals\u002Fevals.json",{"path":71,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":72,"sourceHtmlUrl":73},"references\u002Ftransformations.md",7155,"https:\u002F\u002Fgithub.com\u002FSWEStash\u002Fswe-workflow-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fbackend\u002Fskills\u002Frefactoring\u002Freferences\u002Ftransformations.md",[75,101,127,150,174,199],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":38},"01M6JQFADV3T1MS9V1BNZS1232","writing-skills","Use when authoring, editing, or reviewing a skill in this library — a new SKILL.md, one that under-triggers, or hardening an existing one. Covers description and listing-budget rules, frontmatter, progressive disclosure, the 3-eval rule, and pressure-testing against rationalizations.","https:\u002F\u002Fgithub.com\u002FSWEStash\u002Fswe-workflow-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwriting-skills\u002FSKILL.md",[],[82,83,84,85,86,87,88,89,90,91,92,93,24,94,95,96,97,98,99,100],"writing","writing skills","testing","eval","write","edit","Budget","authoring","new skill","library","frontmatter","editing","use","Existing","Rules","write a skill","when","listing","progressive disclosure",{"skillNo":102,"name":103,"nameZh":6,"description":104,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":105,"categories":106,"keywords":107,"publishedAt":38},"01M6JQF5DGMXPMQQVZBP8DH9SY","working-agreement","Define and validate how a multi-session project is run — where plans, status and decisions live, session routines, new work, milestone close. README\u002FCONTRIBUTING → project-documentation.","https:\u002F\u002Fgithub.com\u002FSWEStash\u002Fswe-workflow-skills\u002Fblob\u002Fmain\u002Fskills\u002Fworking-agreement\u002FSKILL.md",[],[108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,24,126],"working agreement","project","definition of done","done","milestone","documentation","work","progress","how","contributing","close","run","sync","status","live","do","README","session","routines",{"skillNo":128,"name":129,"nameZh":6,"description":130,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":131,"categories":132,"keywords":133,"publishedAt":38},"01M6JQF0SMRHN82RBSWMABC4J0","verification-before-completion","Evidence gate before any claim that work is done, fixed, passing, or deployed. Route here when a message declares the work finished or asks to commit, push, merge, ship, or close it out, including a brief sign-off, and before git-workflow or release-management act on it. Writing the commit message or PR text itself → git-workflow.","https:\u002F\u002Fgithub.com\u002FSWEStash\u002Fswe-workflow-skills\u002Fblob\u002Fmain\u002Fskills\u002Fverification-before-completion\u002FSKILL.md",[],[134,135,136,137,138,139,82,140,111,141,142,143,114,144,118,145,146,147,148,149],"verification","verification before completion","brief","ready","fix","claim","workflow","commit","text","route","message","merge","release","git","act","ship",{"skillNo":151,"name":152,"nameZh":6,"description":153,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":154,"categories":155,"keywords":156,"publishedAt":38},"01M6JQEVGE9NJZ11DV60AE6VWC","ui-ux-design","Design user experiences from an engineer's perspective — user flows, wireframes, interaction patterns, responsive strategy, navigation, loading\u002Ferror\u002Fempty states. Triggers: design the UI, user flow, wireframe, how should this screen look, loading state, error state, empty state, responsive design, navigation, page layout, form design, mockup.","https:\u002F\u002Fgithub.com\u002FSWEStash\u002Fswe-workflow-skills\u002Fblob\u002Fmain\u002Fskills\u002Fui-ux-design\u002FSKILL.md",[],[29,157,158,159,160,161,162,163,164,165,166,167,116,168,169,27,170,171,172,173],"ux","ui","ui ux design","error","states","loading","flows","engineer","interaction","layout","responsive design","screen","flow","mockup","responsive","form","page",{"skillNo":175,"name":176,"nameZh":6,"description":177,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":178,"categories":179,"keywords":180,"publishedAt":38},"01M6JQEN4HVFTZWQYWGTDS76K9","threat-modeling","Design-time security analysis of a system or feature before it's built — trust boundaries, attack surface, STRIDE per element, abuse cases, prioritized mitigations that become security requirements. Triggers: threat model, STRIDE, trust boundary, attack surface, what could go wrong security-wise, security design review, abuse case, secure this design, security requirements. Reviewing EXISTING code\u002Fconfig for vulnerabilities → security-audit; use this skill while the design is still on the whiteboard.","https:\u002F\u002Fgithub.com\u002FSWEStash\u002Fswe-workflow-skills\u002Fblob\u002Fmain\u002Fskills\u002Fthreat-modeling\u002FSKILL.md",[],[181,182,183,184,185,186,29,187,188,189,36,190,191,192,193,194,195,196,197,198],"modeling","threat modeling","threat","model","time","element","whiteboard","security analysis","analysis","review","threat model","audit","security-audit","secure","config","go","security","trust",{"skillNo":200,"name":201,"nameZh":6,"description":202,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":203,"categories":204,"keywords":205,"publishedAt":38},"01M6JQEFT7VT3FQM16170EG9FW","test-suite-design","Design comprehensive test suites for existing code — strategy across unit\u002Fintegration\u002Fe2e, fixtures, factories, helpers. Triggers: add tests, write tests for, increase coverage, test this module, testing strategy, test plan, what tests do I need, test infrastructure, test helpers, this has no tests. Not for TDD — use tdd-workflow.","https:\u002F\u002Fgithub.com\u002FSWEStash\u002Fswe-workflow-skills\u002Fblob\u002Fmain\u002Fskills\u002Ftest-suite-design\u002FSKILL.md",[],[29,206,207,208,209,210,84,211,212,140,36,213,214,86,215,216,123,217,218,24],"test suite","test","test suite design","coverage","unit","write tests","testing strategy","across","plan","add","infrastructure","test plan","for"]