[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7DBKXP6J5VX1PV7TJ77CPCS":3,"skill-same:01M7DBKXP6J5VX1PV7TJ77CPCS":44},{"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":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":29,"install":30,"resources":43},"01M7DBKXP6J5VX1PV7TJ77CPCS","refactor",null,"Safe, behaviour-preserving refactoring of a module or codebase in small test-gated steps. Use when the user says \"refactor\", \"clean up\", \"tidy\", \"simplify\", \"extract\", \"this is a mess\", or asks to improve code structure without changing what it does.","placek\u002Fskills","placek","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F161099?v=4","01M7DBK104XJBJAZV9R389VS3W","Paweł Placzyński","01M7DBK10PZZDANKK8646CE0Q6",0,"MIT","https:\u002F\u002Fgithub.com\u002Fplacek\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Frefactor\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: refactor\ndescription: Safe, behaviour-preserving refactoring of a module or codebase in small test-gated steps. Use when the user says \"refactor\", \"clean up\", \"tidy\", \"simplify\", \"extract\", \"this is a mess\", or asks to improve code structure without changing what it does.\n---\n\n# Refactor\n\nImprove the structure of existing code without changing what it does. A refactoring is a sequence of small, named, behaviour-preserving steps, each proven by the tests before the next begins. This is the *change the shape* discipline; adding behaviour is `tdd`, and judging a finished diff is `code-review`.\n\n## The contract\n\n1. **Behaviour is preserved.** Outputs, side effects, errors, and public contracts stay identical. If a step would change any of them, it is a feature or a bug fix, not a refactoring: stop and ask.\n2. **One operation per step.** Each step is a single named technique (\"Extract Function\", \"Rename\", \"Move Method\") that can be reviewed in a minute and reverted on its own.\n3. **Tests gate every step.** Green before, green after. Red means revert the step and take a smaller one; never fix forward.\n4. **No hat-switching.** Do not fix bugs, add features, or \"while I'm here\" anything. Note them for a follow-up.\n\nRead `CONTEXT.md` (if it exists) so new names use the project's vocabulary, and respect ADRs in the area. Load the `codebase-design` skill (`skill_view`) when the question is where a seam belongs or how deep a module should be; use its terms (module, interface, depth, seam, adapter).\n\n## Process\n\n### 1. Baseline\n\n- Read every file you intend to change. Read, don't skim.\n- Find the test command (project config, README, CI). Run it. **The suite must be green before any edit.** If it is red, stop and report; don't refactor on a red baseline.\n- If the target has no tests, say so. Either write **characterization tests** first (they assert what the code does *now*, right or wrong, at the public interface) or get the user's explicit acknowledgement that verification is manual. Never proceed silently.\n- Commit or stash unrelated changes so `git status` is clean. Every green step will be a commit.\n\n### 2. Diagnose\n\nIf the user named a specific operation (\"extract this\", \"rename X\"), skip to step 3.\n\nOtherwise walk the code against the **smell baseline** in the `code-review` skill (load it with `skill_view`; the list is in its \"Identify the standards sources\" section). Rank what you find:\n\n- **Blocker**: prevents understanding or safe change (a 200-line function, a god class)\n- **Major**: real duplication, coupling, or complexity\n- **Minor**: naming, small structure\n\nPresent the ranked list, each item with the smell, the location, and the technique you'd apply. Wait for the user to pick.\n\n### 3. Plan\n\nBreak the agreed work into atomic steps, blockers first. Each step must leave the code compiling and the tests runnable. State the plan before touching anything:\n\n```\n1. Extract calculateDiscount() from processOrder()\n2. Extract applyTaxes() from processOrder()\n3. Rename processOrder() -> placeOrder() (12 call sites)\n```\n\nFlag any step that crosses a **red line** and get explicit confirmation before including it:\n\n- a public or exported signature, name, or module path\n- a serialised shape: JSON keys, DB schema, wire format, file format, env var names\n- concurrency: lock order, async boundaries, where side effects sit relative to awaits\n- the error contract: what is thrown or returned, and when\n- a symbol whose callers you haven't fully mapped (grep first; dynamic calls and external packages won't show up)\n\n### 4. Execute, one step at a time\n\nFor each step:\n\n1. State the operation: \"Extract Function: lines 67-89 of `processOrder` into `calculateDiscount`\".\n2. Apply exactly that change.\n3. Run the fast static check first if the project has one (typecheck, linter, compile), then the tests. Show the command and the result.\n4. **Green**: commit with the technique as the message (`refactor: extract calculateDiscount`). Move to the next step.\n5. **Red**: revert the step (`git checkout -- .` or undo the edit). Say which test failed and why. Split the step smaller or reconsider it. Do not proceed until the tree is green.\n\nRe-read a file before editing it if you haven't looked at it in a while; in long sessions the code may have moved under you.\n\n### 5. Verify and wrap up\n\n- Run the **full** test suite once more at the end, plus the typecheck\u002Flint, even if every step was green (steps may have used a subset).\n- Tests should pass **without having been modified**. If you had to change a test to get green, you changed behaviour: call it out.\n- Summarise: each operation applied, files touched, what got shorter or simpler. Then list what you deliberately did *not* touch (remaining smells, bugs noticed, follow-on ideas) so the user can open tickets for them.\n\n## Technique cheatsheet\n\n| Smell | Technique |\n|---|---|\n| Long function | Extract Function; Replace Temp with Query; Decompose Conditional |\n| Duplicated code | Extract Function \u002F Class; Pull Up Method |\n| Large class, divergent change | Extract Class along the axes of change |\n| Long parameter list, data clumps | Introduce Parameter Object; Preserve Whole Object |\n| Primitive obsession | Replace Primitive with Object; Replace Type Code with Class |\n| Repeated switch on type | Replace Conditional with Polymorphism, or one shared map |\n| Nested conditionals | Replace Nested Conditional with Guard Clauses |\n| Magic numbers \u002F strings | Replace Magic Literal with Constant |\n| Feature envy, message chains | Move Function; Hide Delegate |\n| Middle man, lazy class | Inline Function \u002F Class; Remove Middle Man |\n| Speculative generality, dead code | Delete it; Collapse Hierarchy; Remove Parameter |\n| Refused bequest | Replace Subclass with Delegate |\n\nFull catalogue: [refactoring.com\u002Fcatalog](https:\u002F\u002Frefactoring.com\u002Fcatalog\u002F).\n\n## When not to refactor\n\n- Code that works and nobody needs to change: no benefit, only risk.\n- Code about to be deleted or rewritten.\n- No tests and no way to add them, and the user won't accept manual verification.\n- A deadline the user cares about more than this cleanup: note the debt and stop.\n\n## Credits\n\nDistilled from Martin Fowler's *Refactoring* via three MIT-licensed skills: the process and red lines from [MuhiminOsim\u002Fcode-refactoring-skill](https:\u002F\u002Fgithub.com\u002FMuhiminOsim\u002Fcode-refactoring-skill), the smell\u002Ftechnique tables from [Tyler-R-Kendrick\u002Fagent-skills](https:\u002F\u002Fgithub.com\u002FTyler-R-Kendrick\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fdev\u002Fcraftsmanship\u002Frefactoring\u002FSKILL.md), and the rules and checklist from [github\u002Fawesome-copilot](https:\u002F\u002Fgithub.com\u002Fgithub\u002Fawesome-copilot\u002Fblob\u002Fmain\u002Fskills\u002Frefactor\u002FSKILL.md).\n","# Refactor\n\nImprove the structure of existing code without changing what it does. A refactoring is a sequence of small, named, behaviour-preserving steps, each proven by the tests before the next begins. This is the *change the shape* discipline; adding behaviour is `tdd`, and judging a finished diff is `code-review`.\n\n## The contract\n\n1. **Behaviour is preserved.** Outputs, side effects, errors, and public contracts stay identical. If a step would change any of them, it is a feature or a bug fix, not a refactoring: stop and ask.\n2. **One operation per step.** Each step is a single named technique (\"Extract Function\", \"Rename\", \"Move Method\") that can be reviewed in a minute and reverted on its own.\n3. **Tests gate every step.** Green before, green after. Red means revert the step and take a smaller one; never fix forward.\n4. **No hat-switching.** Do not fix bugs, add features, or \"while I'm here\" anything. Note them for a follow-up.\n\nRead `CONTEXT.md` (if it exists) so new names use the project's vocabulary, and respect ADRs in the area. Load the `codebase-design` skill (`skill_view`) when the question is where a seam belongs or how deep a module should be; use its terms (module, interface, depth, seam, adapter).\n\n## Process\n\n### 1. Baseline\n\n- Read every file you intend to change. Read, don't skim.\n- Find the test command (project config, README, CI). Run it. **The suite must be green before any edit.** If it is red, stop and report; don't refactor on a red baseline.\n- If the target has no tests, say so. Either write **characterization tests** first (they assert what the code does *now*, right or wrong, at the public interface) or get the user's explicit acknowledgement that verification is manual. Never proceed silently.\n- Commit or stash unrelated changes so `git status` is clean. Every green step will be a commit.\n\n### 2. Diagnose\n\nIf the user named a specific operation (\"extract this\", \"rename X\"), skip to step 3.\n\nOtherwise walk the code against the **smell baseline** in the `code-review` skill (load it with `skill_view`; the list is in its \"Identify the standards sources\" section). Rank what you find:\n\n- **Blocker**: prevents understanding or safe change (a 200-line function, a god class)\n- **Major**: real duplication, coupling, or complexity\n- **Minor**: naming, small structure\n\nPresent the ranked list, each item with the smell, the location, and the technique you'd apply. Wait for the user to pick.\n\n### 3. Plan\n\nBreak the agreed work into atomic steps, blockers first. Each step must leave the code compiling and the tests runnable. State the plan before touching anything:\n\n```\n1. Extract calculateDiscount() from processOrder()\n2. Extract applyTaxes() from processOrder()\n3. Rename processOrder() -> placeOrder() (12 call sites)\n```\n\nFlag any step that crosses a **red line** and get explicit confirmation before including it:\n\n- a public or exported signature, name, or module path\n- a serialised shape: JSON keys, DB schema, wire format, file format, env var names\n- concurrency: lock order, async boundaries, where side effects sit relative to awaits\n- the error contract: what is thrown or returned, and when\n- a symbol whose callers you haven't fully mapped (grep first; dynamic calls and external packages won't show up)\n\n### 4. Execute, one step at a time\n\nFor each step:\n\n1. State the operation: \"Extract Function: lines 67-89 of `processOrder` into `calculateDiscount`\".\n2. Apply exactly that change.\n3. Run the fast static check first if the project has one (typecheck, linter, compile), then the tests. Show the command and the result.\n4. **Green**: commit with the technique as the message (`refactor: extract calculateDiscount`). Move to the next step.\n5. **Red**: revert the step (`git checkout -- .` or undo the edit). Say which test failed and why. Split the step smaller or reconsider it. Do not proceed until the tree is green.\n\nRe-read a file before editing it if you haven't looked at it in a while; in long sessions the code may have moved under you.\n\n### 5. Verify and wrap up\n\n- Run the **full** test suite once more at the end, plus the typecheck\u002Flint, even if every step was green (steps may have used a subset).\n- Tests should pass **without having been modified**. If you had to change a test to get green, you changed behaviour: call it out.\n- Summarise: each operation applied, files touched, what got shorter or simpler. Then list what you deliberately did *not* touch (remaining smells, bugs noticed, follow-on ideas) so the user can open tickets for them.\n\n## Technique cheatsheet\n\n| Smell | Technique |\n|---|---|\n| Long function | Extract Function; Replace Temp with Query; Decompose Conditional |\n| Duplicated code | Extract Function \u002F Class; Pull Up Method |\n| Large class, divergent change | Extract Class along the axes of change |\n| Long parameter list, data clumps | Introduce Parameter Object; Preserve Whole Object |\n| Primitive obsession | Replace Primitive with Object; Replace Type Code with Class |\n| Repeated switch on type | Replace Conditional with Polymorphism, or one shared map |\n| Nested conditionals | Replace Nested Conditional with Guard Clauses |\n| Magic numbers \u002F strings | Replace Magic Literal with Constant |\n| Feature envy, message chains | Move Function; Hide Delegate |\n| Middle man, lazy class | Inline Function \u002F Class; Remove Middle Man |\n| Speculative generality, dead code | Delete it; Collapse Hierarchy; Remove Parameter |\n| Refused bequest | Replace Subclass with Delegate |\n\nFull catalogue: [refactoring.com\u002Fcatalog](https:\u002F\u002Frefactoring.com\u002Fcatalog\u002F).\n\n## When not to refactor\n\n- Code that works and nobody needs to change: no benefit, only risk.\n- Code about to be deleted or rewritten.\n- No tests and no way to add them, and the user won't accept manual verification.\n- A deadline the user cares about more than this cleanup: note the debt and stop.\n\n## Credits\n\nDistilled from Martin Fowler's *Refactoring* via three MIT-licensed skills: the process and red lines from [MuhiminOsim\u002Fcode-refactoring-skill](https:\u002F\u002Fgithub.com\u002FMuhiminOsim\u002Fcode-refactoring-skill), the smell\u002Ftechnique tables from [Tyler-R-Kendrick\u002Fagent-skills](https:\u002F\u002Fgithub.com\u002FTyler-R-Kendrick\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fdev\u002Fcraftsmanship\u002Frefactoring\u002FSKILL.md), and the rules and checklist from [github\u002Fawesome-copilot](https:\u002F\u002Fgithub.com\u002Fgithub\u002Fawesome-copilot\u002Fblob\u002Fmain\u002Fskills\u002Frefactor\u002FSKILL.md).\n",{"name":5,"description":7},"main","e497f06e0ce7566ccddbbef069ee67c7030ddc92","skills\u002Frefactor","https:\u002F\u002Fgithub.com\u002Fplacek\u002Fskills","https:\u002F\u002Fgithub.com\u002Fplacek","2026-09-24 19:45:07",{"source":8,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add placek\u002Fskills --skill refactor",{"tool":36,"command":37},"bunx","bunx skills add placek\u002Fskills --skill refactor",{"tool":39,"command":40},"pnpm","pnpm dlx skills add placek\u002Fskills --skill refactor","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fplacek\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Frefactor\u002FSKILL.md",true,[],[45,52,59,66,73,80],{"skillNo":46,"name":47,"nameZh":6,"description":48,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":49,"categories":50,"keywords":51,"publishedAt":19},"01M7DBN24MTZG2RW2H4SHBKWJD","writing-for-agents","Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.","https:\u002F\u002Fgithub.com\u002Fplacek\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fwriting-for-agents\u002FSKILL.md",[],[],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":56,"categories":57,"keywords":58,"publishedAt":19},"01M7DBMZ5XCN7NFTPR7MHY7J99","wayfinder","Plan a huge chunk of work (more than one agent session can hold) as a shared map of decision tickets in `.todo\u002F`, and resolve them one at a time until the way to the destination is clear.","https:\u002F\u002Fgithub.com\u002Fplacek\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fwayfinder\u002FSKILL.md",[],[],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M7DBMXCFM1T8DJVBC33F9HBD","wait-what","Stop. That last message did not land: re-pitch it.","https:\u002F\u002Fgithub.com\u002Fplacek\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fwait-what\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M7DBMVEV44RQA6STN17T0XXM","verify","Evidence before claims. Use before saying anything is done, fixed, passing, or ready, and before committing, merging, or opening a PR.","https:\u002F\u002Fgithub.com\u002Fplacek\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fverify\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M7DBMS4XNZYTPSPW3RBM3H34","triage","Move issues in `.todo\u002F` through a state machine of triage roles, categorise, verify, grill if needed, and write agent-ready briefs.","https:\u002F\u002Fgithub.com\u002Fplacek\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Ftriage\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M7DBMNT02S0W0K3R4WKX53RA","to-tickets","Break a plan, spec, or the current conversation into a set of tracer-bullet tickets, each declaring its blocking edges, saved as one markdown file per ticket in `.todo\u002F`.","https:\u002F\u002Fgithub.com\u002Fplacek\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fto-tickets\u002FSKILL.md",[],[]]