[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6CBACDT4CBD6TG13NFFASPB":3,"skill-same:01M6CBACDT4CBD6TG13NFFASPB":66},{"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":26,"linkOnly":27,"markdownContent":28,"markdownBody":29,"frontMatter":30,"refName":34,"commitSha":35,"skillDirectory":36,"forksCount":37,"repositoryHtmlUrl":38,"repositoryHomepageUrl":39,"ownerHtmlUrl":40,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":41,"install":42,"resources":55},"01M6CBACDT4CBD6TG13NFFASPB","refactoring",null,"Systematic refactoring plan creation — detect code smells, phase improvements safely, and deliver a step-by-step rollout with success criteria. Language- and framework-agnostic.","shahboura\u002Fagents-opencode","shahboura","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F210767?v=4","01M6C6WKTBT0NH92BEPQRHQSYM","Shehab El Hadidy","01M6C6WKYXG8AE68MCGBNE5ZFR",2,"MIT","https:\u002F\u002Fgithub.com\u002Fshahboura\u002Fagents-opencode\u002Fblob\u002Fmain\u002F.opencode\u002Fskills\u002Frefactoring\u002FSKILL.md",[],[5,19,20,21,22,23,24,25],"development","code","framework","plan","plan creation","rollout","opencode","2026-11-10 10:12:30",false,"---\nname: refactoring\ndescription: >-\n  Systematic refactoring plan creation — detect code smells, phase improvements\n  safely, and deliver a step-by-step rollout with success criteria. Language-\n  and framework-agnostic.\nlicense: MIT\ncompatibility: opencode\nmetadata:\n  author: shahboura\n  version: \"1.0.0\"\n  audience: developers\n  workflow: development\n---\n\n# Refactoring — structured improvement without behavior change\n\n## What I do\n\n- **Decide what should not exist first:** apply the deletion test and YAGNI before\n  proposing any extraction\n- Detect code smells from the twelve-smell baseline in `references\u002Fcode-smells.md`\n- Produce a phased refactoring plan that preserves existing behavior\n- Define risk mitigations and measurable success criteria\n\n## When to use me\n\nActivate this skill when:\n\n- Code shows duplication, high complexity, or poor separation of concerns\n- A module or class has grown too large to maintain safely\n- You need a safe, test-first improvement roadmap before touching production code\n- Any request containing \"refactor\", \"clean up\", \"reduce complexity\",\n  \"restructure\", \"break apart\", or \"eliminate duplication\"\n\n## Key Rules\n\n### Refactoring Principles (always apply, in this order)\n\n1. **Delete first (YAGNI)** — the safest refactor is removing code nobody needs. Dead\n   code, unused flags, single-use indirection: delete before you extract, rename, or\n   abstract. Extraction adds lines; deletion cannot regress behavior nobody uses.\n2. **Apply the deletion test** — delete the module and see where the complexity lands.\n   If it concentrates in the callers, the module earns its keep. If it vanishes, the\n   module was a pass-through — leave it deleted. Run this test before defending any\n   seam, wrapper, or layer.\n3. **Speculative generality gets deleted or inlined** — an abstraction with one caller\n   and no scheduled second caller is a guess. Inline it until a real need exists.\n4. **One adapter is a hypothetical seam; two adapters make it real** — do not add an\n   interface, port, or factory until a second implementation is on the roadmap. A seam\n   with one implementation is a wrapper with extra files.\n5. **Preserve Behavior** — functionality stays the same; refactoring is not rewriting\n6. **Small Steps** — make tiny, verifiable changes so every commit is safe to revert\n7. **Test First** — ensure tests exist before refactoring; add missing coverage first\n8. **Commit Often** — each small change is its own checkpoint\n9. **Review Code** — get feedback early and often\n\nDeletion first does not weaken rule 5: removing unused code changes behavior for nobody.\nIf a piece of code has a live caller, it is not a deletion candidate — refactor it instead.\n\n### Code Smell Detection\n\nBefore building the plan, scan the target area. The baseline catalogue of twelve\nFowler smells — what each one is, its signal, and how to fix it — lives in\n`references\u002Fcode-smells.md`. Read the entries matching what you find; do not carry the\nwhole list into the plan.\n\n### Five-Phase Refactoring Plan\n\n#### Phase 1 — Preparation (Safety First)\n\n**Goal:** Build a safety net so changes can be verified.\n\n- Add unit tests for every function\u002Fmethod in the target area\n- Add integration tests for features that cross module boundaries\n- Achieve ≥80% code coverage on the target area before touching production code\n- Run the full suite and confirm all tests pass\n\n#### Phase 2 — Extract & Simplify\n\n**Goal:** Delete what has no caller, then break down what remains into\nsingle-responsibility pieces.\n\n- Delete first: dead code, unused exports, unreferenced flags and config, and any\n  abstraction with a single implementation and no second one scheduled. Apply the\n  deletion test before keeping a module.\n- Extract helper functions: pull validation, calculation, persistence, and\n  notification out of monolithic functions\n- Eliminate duplication: identify repeated patterns across files, extract to a\n  shared utility, update all call sites, and add dedicated tests\n- Verify: run the full test suite after each extraction\n\n#### Phase 3 — Improve Architecture\n\n**Goal:** Better separation of concerns and testability.\n\n- Introduce a service layer only when a second consumer or a test seam already\n  exists (Controllers → Services → Repositories \u002F Functions → Services → Data)\n- Replace large switch\u002Fif-else chains on type codes with the Strategy pattern\n  (interface + concrete implementations + lookup map)\n- Move business logic close to the data it operates on (resolve feature envy)\n- Verify: all existing tests still pass; add tests for new layers\n\n#### Phase 4 — Performance Optimization\n\n**Goal:** Improve performance without changing behavior.\n\n- Identify N+1 query problems and add eager loading or batched fetches\n- Add missing database indexes on join columns and common filter predicates\n- Benchmark before and after each change; do not \"optimize\" without data\n- Verify: behavior unchanged, performance metrics improved\n\n#### Phase 5 — Final Cleanup\n\n**Goal:** Polish and document.\n\n- Rename ambiguous variables to domain-language names; remove abbreviations\n- Add API documentation (JSDoc, XML doc comments, or equivalent)\n- Update architecture documentation and record design decisions\n- Verify: all tests pass, documentation is current\n\n### Common Refactoring Patterns\n\n| Pattern | When to apply |\n|---|---|\n| **Extract Method** | A function does too many things or exceeds ~30 lines |\n| **Extract Class** | A class has mixed concerns or too many public methods |\n| **Rename** | Names are ambiguous, abbreviated, or misaligned with domain language |\n| **Introduce Parameter Object** | Groups of related parameters appear in multiple signatures |\n| **Replace Conditional with Polymorphism** | Switch\u002Fif-else chains on type codes drive behavior selection |\n| **Simplify Conditional** | Nested if-else or complex boolean expressions reduce readability |\n\n### Risk Assessment Format\n\n| Risk | Impact | Mitigation |\n|------|--------|------------|\n| Breaking changes | High | Comprehensive test suite first |\n| Performance regression | Medium | Benchmark before\u002Fafter each phase |\n| Merge conflicts | Low | Frequent rebasing, small PRs |\n| Scope creep | Medium | Stick to phases; defer feature changes |\n\n### Success Criteria\n\nAfter refactoring:\n\n- [ ] All tests pass (100%)\n- [ ] Code coverage ≥80%\n- [ ] Cyclomatic complexity \u003C10 per function\n- [ ] No unremediated code duplication\n- [ ] Performance improved or maintained (measured)\n- [ ] Documentation updated\n- [ ] No behavior change — the suite passed before and after\n\n## Validation Commands\n\n```bash\n# Manual verification checklist — no automated validation\n# [ ] Deletion was considered first: the deletion test was applied and YAGNI reviewed\n# [ ] Remaining refactoring principles (behavior, small steps, tests) are observed\n# [ ] Code smells are named from references\u002Fcode-smells.md, with severity and fix\n# [ ] Each phase has concrete, verifiable tasks (not \"improve code\")\n# [ ] Risks and mitigations are listed\n# [ ] Success criteria are measurable (not \"code is better\")\n# [ ] The plan preserves existing behavior — no feature changes included\n```\n","# Refactoring — structured improvement without behavior change\n\n## What I do\n\n- **Decide what should not exist first:** apply the deletion test and YAGNI before\n  proposing any extraction\n- Detect code smells from the twelve-smell baseline in `references\u002Fcode-smells.md`\n- Produce a phased refactoring plan that preserves existing behavior\n- Define risk mitigations and measurable success criteria\n\n## When to use me\n\nActivate this skill when:\n\n- Code shows duplication, high complexity, or poor separation of concerns\n- A module or class has grown too large to maintain safely\n- You need a safe, test-first improvement roadmap before touching production code\n- Any request containing \"refactor\", \"clean up\", \"reduce complexity\",\n  \"restructure\", \"break apart\", or \"eliminate duplication\"\n\n## Key Rules\n\n### Refactoring Principles (always apply, in this order)\n\n1. **Delete first (YAGNI)** — the safest refactor is removing code nobody needs. Dead\n   code, unused flags, single-use indirection: delete before you extract, rename, or\n   abstract. Extraction adds lines; deletion cannot regress behavior nobody uses.\n2. **Apply the deletion test** — delete the module and see where the complexity lands.\n   If it concentrates in the callers, the module earns its keep. If it vanishes, the\n   module was a pass-through — leave it deleted. Run this test before defending any\n   seam, wrapper, or layer.\n3. **Speculative generality gets deleted or inlined** — an abstraction with one caller\n   and no scheduled second caller is a guess. Inline it until a real need exists.\n4. **One adapter is a hypothetical seam; two adapters make it real** — do not add an\n   interface, port, or factory until a second implementation is on the roadmap. A seam\n   with one implementation is a wrapper with extra files.\n5. **Preserve Behavior** — functionality stays the same; refactoring is not rewriting\n6. **Small Steps** — make tiny, verifiable changes so every commit is safe to revert\n7. **Test First** — ensure tests exist before refactoring; add missing coverage first\n8. **Commit Often** — each small change is its own checkpoint\n9. **Review Code** — get feedback early and often\n\nDeletion first does not weaken rule 5: removing unused code changes behavior for nobody.\nIf a piece of code has a live caller, it is not a deletion candidate — refactor it instead.\n\n### Code Smell Detection\n\nBefore building the plan, scan the target area. The baseline catalogue of twelve\nFowler smells — what each one is, its signal, and how to fix it — lives in\n`references\u002Fcode-smells.md`. Read the entries matching what you find; do not carry the\nwhole list into the plan.\n\n### Five-Phase Refactoring Plan\n\n#### Phase 1 — Preparation (Safety First)\n\n**Goal:** Build a safety net so changes can be verified.\n\n- Add unit tests for every function\u002Fmethod in the target area\n- Add integration tests for features that cross module boundaries\n- Achieve ≥80% code coverage on the target area before touching production code\n- Run the full suite and confirm all tests pass\n\n#### Phase 2 — Extract & Simplify\n\n**Goal:** Delete what has no caller, then break down what remains into\nsingle-responsibility pieces.\n\n- Delete first: dead code, unused exports, unreferenced flags and config, and any\n  abstraction with a single implementation and no second one scheduled. Apply the\n  deletion test before keeping a module.\n- Extract helper functions: pull validation, calculation, persistence, and\n  notification out of monolithic functions\n- Eliminate duplication: identify repeated patterns across files, extract to a\n  shared utility, update all call sites, and add dedicated tests\n- Verify: run the full test suite after each extraction\n\n#### Phase 3 — Improve Architecture\n\n**Goal:** Better separation of concerns and testability.\n\n- Introduce a service layer only when a second consumer or a test seam already\n  exists (Controllers → Services → Repositories \u002F Functions → Services → Data)\n- Replace large switch\u002Fif-else chains on type codes with the Strategy pattern\n  (interface + concrete implementations + lookup map)\n- Move business logic close to the data it operates on (resolve feature envy)\n- Verify: all existing tests still pass; add tests for new layers\n\n#### Phase 4 — Performance Optimization\n\n**Goal:** Improve performance without changing behavior.\n\n- Identify N+1 query problems and add eager loading or batched fetches\n- Add missing database indexes on join columns and common filter predicates\n- Benchmark before and after each change; do not \"optimize\" without data\n- Verify: behavior unchanged, performance metrics improved\n\n#### Phase 5 — Final Cleanup\n\n**Goal:** Polish and document.\n\n- Rename ambiguous variables to domain-language names; remove abbreviations\n- Add API documentation (JSDoc, XML doc comments, or equivalent)\n- Update architecture documentation and record design decisions\n- Verify: all tests pass, documentation is current\n\n### Common Refactoring Patterns\n\n| Pattern | When to apply |\n|---|---|\n| **Extract Method** | A function does too many things or exceeds ~30 lines |\n| **Extract Class** | A class has mixed concerns or too many public methods |\n| **Rename** | Names are ambiguous, abbreviated, or misaligned with domain language |\n| **Introduce Parameter Object** | Groups of related parameters appear in multiple signatures |\n| **Replace Conditional with Polymorphism** | Switch\u002Fif-else chains on type codes drive behavior selection |\n| **Simplify Conditional** | Nested if-else or complex boolean expressions reduce readability |\n\n### Risk Assessment Format\n\n| Risk | Impact | Mitigation |\n|------|--------|------------|\n| Breaking changes | High | Comprehensive test suite first |\n| Performance regression | Medium | Benchmark before\u002Fafter each phase |\n| Merge conflicts | Low | Frequent rebasing, small PRs |\n| Scope creep | Medium | Stick to phases; defer feature changes |\n\n### Success Criteria\n\nAfter refactoring:\n\n- [ ] All tests pass (100%)\n- [ ] Code coverage ≥80%\n- [ ] Cyclomatic complexity \u003C10 per function\n- [ ] No unremediated code duplication\n- [ ] Performance improved or maintained (measured)\n- [ ] Documentation updated\n- [ ] No behavior change — the suite passed before and after\n\n## Validation Commands\n\n```bash\n# Manual verification checklist — no automated validation\n# [ ] Deletion was considered first: the deletion test was applied and YAGNI reviewed\n# [ ] Remaining refactoring principles (behavior, small steps, tests) are observed\n# [ ] Code smells are named from references\u002Fcode-smells.md, with severity and fix\n# [ ] Each phase has concrete, verifiable tasks (not \"improve code\")\n# [ ] Risks and mitigations are listed\n# [ ] Success criteria are measurable (not \"code is better\")\n# [ ] The plan preserves existing behavior — no feature changes included\n```\n",{"name":5,"license":15,"metadata":31,"description":7,"compatibility":25},{"author":9,"version":32,"audience":33,"workflow":19},"1.0.0","developers","main","9b951b5b2e5d07d427baff330db5deb2a8c67511",".opencode\u002Fskills\u002Frefactoring",0,"https:\u002F\u002Fgithub.com\u002Fshahboura\u002Fagents-opencode","https:\u002F\u002Fagnts.elkodr.com\u002F","https:\u002F\u002Fgithub.com\u002Fshahboura","2026-11-05 13:30:42",{"source":8,"skillName":5,"commands":43,"prompt":53,"zipAvailable":54},[44,47,50],{"tool":45,"command":46},"npx","npx skills add shahboura\u002Fagents-opencode --skill refactoring",{"tool":48,"command":49},"bunx","bunx skills add shahboura\u002Fagents-opencode --skill refactoring",{"tool":51,"command":52},"pnpm","pnpm dlx skills add shahboura\u002Fagents-opencode --skill refactoring","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fshahboura\u002Fagents-opencode\u002Fblob\u002Fmain\u002F.opencode\u002Fskills\u002Frefactoring\u002FSKILL.md",true,[56,62],{"path":57,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":60,"sourceHtmlUrl":61},"agents\u002Fopenai.yaml","REFERENCE","参考文档",268,"https:\u002F\u002Fgithub.com\u002Fwelflau\u002Fai-dev-system\u002Fblob\u002Fmain\u002Fbackend\u002Fconfig_packs\u002Fweb-dev\u002Fshared\u002Fskills\u002Fnextjs-turbopack\u002Fagents\u002Fopenai.yaml",{"path":63,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":64,"sourceHtmlUrl":65},"references\u002Fcode-smells.md",5316,"https:\u002F\u002Fgithub.com\u002Fshahboura\u002Fagents-opencode\u002Fblob\u002Fmain\u002F.opencode\u002Fskills\u002Frefactoring\u002Freferences\u002Fcode-smells.md",[67,73,82,87,92,97],{"skillNo":68,"name":69,"nameZh":6,"description":6,"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":26},"01M6CBBX1C6NV7VY8XK21DV5FW","python","https:\u002F\u002Fgithub.com\u002Fshahboura\u002Fagents-opencode\u002Fblob\u002Fmain\u002Fscripts\u002Ffixtures\u002Fvalidate-agents\u002Fvalid\u002F.opencode\u002Fskills\u002Fpython\u002FSKILL.md",[],[69],{"skillNo":74,"name":75,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":26},"01M6CBBVB7W6ABJH8XP3Z8PPMK","docs-validation","https:\u002F\u002Fgithub.com\u002Fshahboura\u002Fagents-opencode\u002Fblob\u002Fmain\u002Fscripts\u002Ffixtures\u002Fvalidate-agents\u002Fvalid\u002F.opencode\u002Fskills\u002Fdocs-validation\u002FSKILL.md",[],[79,80,81],"docs","validation","docs validation",{"skillNo":83,"name":69,"nameZh":6,"description":6,"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":26},"01M6CBBT2WC781609MH5RN7KM7","https:\u002F\u002Fgithub.com\u002Fshahboura\u002Fagents-opencode\u002Fblob\u002Fmain\u002Fscripts\u002Ffixtures\u002Fvalidate-agents\u002Funknown-skill\u002F.opencode\u002Fskills\u002Fpython\u002FSKILL.md",[],[69],{"skillNo":88,"name":75,"nameZh":6,"description":6,"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":91,"publishedAt":26},"01M6CBBRNY6TDRZ5627GC8436D","https:\u002F\u002Fgithub.com\u002Fshahboura\u002Fagents-opencode\u002Fblob\u002Fmain\u002Fscripts\u002Ffixtures\u002Fvalidate-agents\u002Funknown-skill\u002F.opencode\u002Fskills\u002Fdocs-validation\u002FSKILL.md",[],[79,80,81],{"skillNo":93,"name":69,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":26},"01M6CBBQDS170GBYA1CVW3DC5D","https:\u002F\u002Fgithub.com\u002Fshahboura\u002Fagents-opencode\u002Fblob\u002Fmain\u002Fscripts\u002Ffixtures\u002Fvalidate-agents\u002Finline-skill\u002F.opencode\u002Fskills\u002Fpython\u002FSKILL.md",[],[69],{"skillNo":98,"name":75,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":26},"01M6CBBP222WAW802YHY37F48A","https:\u002F\u002Fgithub.com\u002Fshahboura\u002Fagents-opencode\u002Fblob\u002Fmain\u002Fscripts\u002Ffixtures\u002Fvalidate-agents\u002Finline-skill\u002F.opencode\u002Fskills\u002Fdocs-validation\u002FSKILL.md",[],[79,80,81]]