[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6JQBTPP545S6RH0MFZQG5R8":3,"skill-same:01M6JQBTPP545S6RH0MFZQG5R8":84},{"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":28,"publishedAt":48,"linkOnly":49,"markdownContent":50,"markdownBody":51,"frontMatter":52,"refName":53,"commitSha":54,"skillDirectory":55,"forksCount":14,"repositoryHtmlUrl":56,"repositoryHomepageUrl":6,"ownerHtmlUrl":57,"ownerBlogUrl":6,"ownerDescription":58,"updatedAt":59,"install":60,"resources":73},"01M6JQBTPP545S6RH0MFZQG5R8","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\u002Fskills\u002Frefactoring\u002FSKILL.md",[18,23],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":26,"taxonomyTypeDesc":27},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[5,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47],"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","skills\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":61,"prompt":71,"zipAvailable":72},[62,65,68],{"tool":63,"command":64},"npx","npx skills add SWEStash\u002Fswe-workflow-skills --skill refactoring",{"tool":66,"command":67},"bunx","bunx skills add SWEStash\u002Fswe-workflow-skills --skill refactoring",{"tool":69,"command":70},"pnpm","pnpm dlx skills add SWEStash\u002Fswe-workflow-skills --skill refactoring","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FSWEStash\u002Fswe-workflow-skills\u002Fblob\u002Fmain\u002Fskills\u002Frefactoring\u002FSKILL.md",true,[74,80],{"path":75,"resourceType":76,"resourceTypeDesc":77,"sizeBytes":78,"sourceHtmlUrl":79},"evals\u002Fevals.json","REFERENCE","参考文档",3752,"https:\u002F\u002Fgithub.com\u002FSWEStash\u002Fswe-workflow-skills\u002Fblob\u002Fmain\u002Fskills\u002Frefactoring\u002Fevals\u002Fevals.json",{"path":81,"resourceType":76,"resourceTypeDesc":77,"sizeBytes":82,"sourceHtmlUrl":83},"references\u002Ftransformations.md",7155,"https:\u002F\u002Fgithub.com\u002FSWEStash\u002Fswe-workflow-skills\u002Fblob\u002Fmain\u002Fskills\u002Frefactoring\u002Freferences\u002Ftransformations.md",[85,124,151,175,206,233],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":104,"publishedAt":48},"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",[91,94,97,98,101],{"categoryNo":92,"categoryName":93,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量",{"categoryNo":95,"categoryName":96,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":99,"categoryName":100,"taxonomyType":26,"taxonomyTypeDesc":27},"01JBSEEDCAT000000000000036","内容创作者",{"categoryNo":102,"categoryName":103,"taxonomyType":26,"taxonomyTypeDesc":27},"01JBSEEDCAT000000000000040","财务",[105,106,107,108,109,110,111,112,113,114,115,116,34,117,118,119,120,121,122,123],"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":125,"name":126,"nameZh":6,"description":127,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":128,"categories":129,"keywords":131,"publishedAt":48},"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",[130],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},[132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,34,150],"working agreement","project","definition of done","done","milestone","documentation","work","progress","how","contributing","close","run","sync","status","live","do","README","session","routines",{"skillNo":152,"name":153,"nameZh":6,"description":154,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":155,"categories":156,"keywords":158,"publishedAt":48},"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",[157],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},[159,160,161,162,163,164,105,165,135,166,167,168,138,169,142,170,171,172,173,174],"verification","verification before completion","brief","ready","fix","claim","workflow","commit","text","route","message","merge","release","git","act","ship",{"skillNo":176,"name":177,"nameZh":6,"description":178,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":179,"categories":180,"keywords":188,"publishedAt":48},"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",[181,184,185],{"categoryNo":182,"categoryName":183,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000015","视觉设计",{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":186,"categoryName":187,"taxonomyType":26,"taxonomyTypeDesc":27},"01JBSEEDCAT000000000000032","设计师",[39,189,190,191,192,193,194,195,196,197,198,199,140,200,201,37,202,203,204,205],"ux","ui","ui ux design","error","states","loading","flows","engineer","interaction","layout","responsive design","screen","flow","mockup","responsive","form","page",{"skillNo":207,"name":208,"nameZh":6,"description":209,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":210,"categories":211,"keywords":214,"publishedAt":48},"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",[212,213],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":24,"categoryName":25,"taxonomyType":26,"taxonomyTypeDesc":27},[215,216,217,218,219,220,39,221,222,223,46,224,225,226,227,228,229,230,231,232],"modeling","threat modeling","threat","model","time","element","whiteboard","security analysis","analysis","review","threat model","audit","security-audit","secure","config","go","security","trust",{"skillNo":234,"name":235,"nameZh":6,"description":236,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":237,"categories":238,"keywords":244,"publishedAt":48},"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",[239,240,241,242,243],{"categoryNo":92,"categoryName":93,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":182,"categoryName":183,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":24,"categoryName":25,"taxonomyType":26,"taxonomyTypeDesc":27},{"categoryNo":186,"categoryName":187,"taxonomyType":26,"taxonomyTypeDesc":27},[39,245,246,247,248,249,107,250,251,165,46,252,253,109,254,255,147,256,257,34],"test suite","test","test suite design","coverage","unit","write tests","testing strategy","across","plan","add","infrastructure","test plan","for"]