[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M73ERVGPXDZJDNSCS2KPFJ70":3,"skill-same:01M73ERVGPXDZJDNSCS2KPFJ70":67},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":45,"commitSha":46,"skillDirectory":47,"forksCount":48,"repositoryHtmlUrl":49,"repositoryHomepageUrl":6,"ownerHtmlUrl":50,"ownerBlogUrl":6,"ownerDescription":51,"updatedAt":52,"install":53,"resources":66},"01M73ERVGPXDZJDNSCS2KPFJ70","refactoring",null,"Improves code structure and design while preserving behavior using systematic refactoring techniques. Use when: cleaning up code, reducing duplication, improving maintainability, or paying down technical debt.","5throck\u002Fai-workspace-standards","5throck","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F10958964?v=4","01M73BFEH0V0VS483TW4JD49JW","01M73BFEJ5VQZJHJSFTVPAZGDM",25,"AGPL-3.0","https:\u002F\u002Fgithub.com\u002F5throck\u002Fai-workspace-standards\u002Fblob\u002Fmain\u002Ftemplates\u002Fco-game\u002Fskills\u002Frefactoring\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: refactoring\ndescription: >\n  Improves code structure and design while preserving behavior using systematic\n  refactoring techniques. Use when: cleaning up code, reducing duplication, improving\n  maintainability, or paying down technical debt.\nversion: 1.2.0\nscope: co-develop\nstatus: active\nowner: pm\nlast_reviewed: 2026-11-06\nprerequisites: none\nrelates_to:\n  - skill: code-review\n    type: composes_with\ngemini-parity: skip\nmetadata:\n  type: process\n  triggers:\n    - refactor\n    - clean up code\n    - improve code\n    - reduce duplication\n    - pay down tech debt\n    - code smell\n    - improve design\n---\n\n## Context\n\nThis skill provides systematic refactoring capabilities, transforming code into better designs while ensuring behavior remains unchanged. It emphasizes safety, test coverage, and incremental improvements.\n\n## When to Use\n\n**Code Cleanup**:\n- Trigger: \"Refactor this code\" or \"Clean up implementation\"\n- Use Case: Improving code structure and organization\n\n**Debt Reduction**:\n- Trigger: \"Pay down technical debt\" or \"Improve code quality\"\n- Use Case: Addressing accumulated shortcuts and quick fixes\n\n**Design Improvement**:\n- Trigger: \"Improve code design\" or \"Apply design pattern\"\n- Use Case: Evolving code toward better architecture\n\n**Maintainability**:\n- Trigger: \"Make code more maintainable\" or \"Reduce complexity\"\n- Use Case: Ensuring code remains easy to understand and modify\n\n---\n\n## Execution Steps\n\n## Step 1: Refactoring Preparation\n\n**Purpose**: Ensure safe refactoring environment.\n\n**Preparation Checklist**:\n1. **Test Coverage**:\n   - [ ] Tests exist for code being refactored\n   - [ ] Tests cover main functionality\n   - [ ] Tests are currently passing\n   - [ ] Tests can be run quickly\n\n2. **Baseline Understanding**:\n   - [ ] Code purpose and behavior understood\n   - [ ] Current design issues identified\n   - [ ] Refactoring goals defined\n   - [ ] Success criteria established\n\n3. **Safety Measures**:\n   - [ ] Version control committed\n   - [ ] Branch created for refactoring\n   - [ ] Rollback plan considered\n   - [ ] Tests run before starting\n\n**Refactoring Goals**:\n- Remove duplication\n- Improve names and clarity\n- Simplify complex logic\n- Apply design patterns\n- Reduce coupling\n- Increase cohesion\n\n---\n\n## Step 2: Identify Code Smells\n\n**Purpose**: Find specific refactoring opportunities.\n\n**Common Code Smells**:\n1. **Duplication**:\n   - Duplicated code blocks\n   - Similar logic in multiple places\n   - Copy-pasted implementations\n\n2. **Long Methods**:\n   - Functions doing too many things\n   - Methods that are hard to understand\n   - Complex nested logic\n\n3. **Large Classes**:\n   - Classes with too many responsibilities\n   - God objects doing everything\n   - Classes with many dependencies\n\n4. **Poor Names**:\n   - Unclear variable\u002Ffunction names\n   - Abbreviations that aren't obvious\n   - Misleading names\n\n5. **Complex Conditionals**:\n   - Deep nesting\n   - Complex boolean expressions\n   - Multiple guard clauses\n\n**Detection Techniques**:\n- Code review with checklist\n- Static analysis tools (linters, SonarQube)\n- Cyclomatic complexity analysis\n- Duplicate code detection\n\n**Prioritization**:\n- High impact, low risk first\n- Areas with good test coverage\n- Frequently modified code\n- High technical debt areas\n\n---\n\n## Step 3: Apply Refactorings Systematically\n\n**Purpose**: Transform code using proven techniques.\n\n**Refactoring Process**:\n1. **Select Small Refactoring**:\n   - Choose one specific improvement\n   - Ensure test coverage exists\n   - Keep change size manageable\n\n2. **Apply Refactoring**:\n   - Follow refactoring pattern precisely\n   - Make mechanical transformations\n   - Don't change behavior\n\n3. **Run Tests**:\n   - All tests must pass\n   - Behavior unchanged\n   - No new test failures\n\n4. **Commit Incremental Change**:\n   - Small, atomic commits\n   - Clear commit messages\n   - Easy to revert if needed\n\n**Common Refactoring Patterns**:\n\n**Extract Method**:\n```python\n# Before\ndef process_order(order):\n    # validate\n    if not order.customer_id:\n        raise ValueError(\"No customer\")\n    if not order.items:\n        raise ValueError(\"No items\")\n    # calculate\n    total = sum(item.price for item in order.items)\n    tax = total * 0.1\n    final = total + tax\n    # save\n    order.total = final\n    order.save()\n\n# After\ndef process_order(order):\n    validate_order(order)\n    final = calculate_order_total(order)\n    save_order(order, final)\n\ndef validate_order(order):\n    if not order.customer_id:\n        raise ValueError(\"No customer\")\n    if not order.items:\n        raise ValueError(\"No items\")\n\ndef calculate_order_total(order):\n    total = sum(item.price for item in order.items)\n    tax = total * 0.1\n    return total + tax\n\ndef save_order(order, total):\n    order.total = total\n    order.save()\n```\n\n**Rename Variable\u002FMethod**:\n```python\n# Before\ndef d(x, y):\n    return x * y * 24\n\n# After\ndef calculate_daily_hours(hours_per_day, days_worked):\n    return hours_per_day * days_worked * 24\n```\n\n**Replace Magic Numbers**:\n```python\n# Before\nif score > 75:\n    grade = \"A\"\n\n# After\nEXCELLENCE_THRESHOLD = 75\nif score > EXCELLENCE_THRESHOLD:\n    grade = \"A\"\n```\n\n**Decompose Conditional**:\n```python\n# Before\ndef calculate_shipping(order):\n    if order.customer.is_premium and order.total > 100 and order.has_free_shipping:\n        return 0\n    elif order.customer.is_premium and order.total > 50:\n        return 5\n    else:\n        return 10\n\n# After\ndef calculate_shipping(order):\n    if qualifies_for_free_shipping(order):\n        return 0\n    if qualifies_for_reduced_shipping(order):\n        return 5\n    return 10\n\ndef qualifies_for_free_shipping(order):\n    return (order.customer.is_premium and \n            order.total > 100 and \n            order.has_free_shipping)\n\ndef qualifies_for_reduced_shipping(order):\n    return order.customer.is_premium and order.total > 50\n```\n\n---\n\n## Step 4: Maintain Test Safety Net\n\n**Purpose**: Ensure refactoring doesn't break behavior.\n\n**Test Strategy**:\n1. **Before Refactoring**:\n   - Run full test suite\n   - Document test results\n   - Ensure baseline success\n\n2. **During Refactoring**:\n   - Run tests after each change\n   - Fix any test failures immediately\n   - Don't proceed with failing tests\n\n3. **After Refactoring**:\n   - Run full test suite\n   - Verify behavior unchanged\n   - Check for unintended side effects\n\n**Regression Prevention**:\n- Keep test coverage high\n- Tests should verify behavior, not implementation\n- Add tests for edge cases discovered\n- Use characterizations tests for legacy code\n\n**Test Safety Indicators**:\n✅ **Safe to refactor**:\n- Comprehensive test coverage\n- Tests verify behavior\n- Tests are fast and reliable\n- Tests document expected behavior\n\n❌ **Risky to refactor**:\n- Low or no test coverage\n- Tests test implementation details\n- Tests are slow or flaky\n- Behavior not clearly specified\n\n---\n\n## Step 5: Incremental Improvement\n\n**Purpose**: Make steady progress without big risks.\n\n**Incremental Approach**:\n1. **Small Steps**:\n   - One refactoring at a time\n   - Commit after each successful change\n   - Run tests frequently\n   - Stop if tests fail\n\n2. **Build Confidence**:\n   - Start with low-risk areas\n   - Practice common refactorings\n   - Learn patterns and techniques\n   - Gradually tackle complex areas\n\n3. **Track Progress**:\n   - Document improvements made\n   - Measure code quality metrics\n   - Track technical debt reduction\n   - Celebrate small wins\n\n**Incremental Refactoring Cycle**:\n```\nIdentify Issue → Plan Refactoring → Apply Change → Run Tests → Commit → Repeat\n```\n\n**Batching Refactorings**:\n- Group related small refactorings\n- Make single logical commit\n- Keep batch size manageable\n- Ensure all tests pass\n\n---\n\n## Step 6: Validate Improvements\n\n**Purpose**: Confirm refactoring achieved goals.\n\n**Validation Checklist**:\n1. **Behavior Preservation**:\n   - [ ] All tests pass\n   - [ ] Functionality unchanged\n   - [ ] No regressions introduced\n   - [ ] Edge cases handled\n\n2. **Code Quality**:\n   - [ ] Code is clearer and more readable\n   - [ ] Duplication reduced\n   - [ ] Complexity decreased\n   - [ ] Names improved\n\n3. **Maintainability**:\n   - [ ] Easier to understand\n   - [ ] Easier to modify\n   - [ ] Better organized\n   - [ ] Better documented\n\n4. **Performance**:\n   - [ ] Performance not degraded\n   - [ ] No unnecessary complexity added\n   - [ ] Algorithms appropriate\n   - [ ] Resource usage reasonable\n\n**Quality Metrics**:\n- Cyclomatic complexity reduced\n- Code duplication decreased\n- Test coverage maintained or improved\n- Lines of code potentially reduced (though not a goal)\n\n---\n\n## Output Format\n\n**For Code Cleanup**:\n- Cleaner, more organized code\n- Removed duplication\n- Improved naming and clarity\n- Maintained behavior\n\n**For Debt Reduction**:\n- Addressed technical debt\n- Improved code structure\n- Better design patterns applied\n- Increased maintainability\n\n**For Design Improvement**:\n- Applied appropriate design patterns\n- Better separation of concerns\n- Reduced coupling\n- Increased cohesion\n\n---\n\n## Best Practices\n\n**Refactoring Discipline**:\n✅ **Do**:\n- Have test coverage before refactoring\n- Make small, incremental changes\n- Run tests frequently\n- Commit often with clear messages\n- Stop if tests fail\n- Focus on one improvement at a time\n\n❌ **Don't**:\n- Refactor without tests\n- Make large, sweeping changes\n- Skip running tests to \"save time\"\n- Mix refactoring with feature changes\n- Proceed with failing tests\n- Try to \"fix everything at once\"\n\n**Safety First**:\n✅ **Do**:\n- Create branch for refactoring\n- Run tests before starting\n- Keep commits atomic\n- Document refactoring rationale\n- Have rollback plan ready\n- Refactor in small steps\n\n❌ **Don't**:\n- Refactor on main branch\n- Start without baseline tests\n- Make large, risky commits\n- Refactor without understanding\n- Proceed without safety net\n- Rush refactoring process\n\n---\n\n## Common Mistakes to Avoid\n\n**Refactoring Anti-Patterns**:\n1. **Refactoring Without Tests**: Making changes without safety net\n2. **Big Bang Refactoring**: Trying to fix everything at once\n3. **Mixed Changes**: Combining refactoring with feature work\n4. **Premature Optimization**: Optimizing before measuring\n5. **Over-Engineering**: Adding complexity for hypothetical future needs\n\n**Process Anti-Patterns**:\n1. **Ignoring Failing Tests**: Continuing despite test failures\n2. **Skipping Validation**: Not confirming behavior preserved\n3. **No Clear Goal**: Refactoring without specific improvement target\n4. **Analysis Paralysis**: Spending too much time planning\n5. **Refactoring Procrastination**: Putting off necessary improvements\n\n---\n\n## Spoke Derivation Note\n\nThis file is the hub-doctrine canonical for the co-develop generic dev spine\n(spec 2026-11-01-hub-consolidation-design, Phase 1 batch D). Co-develop\npipelines run it as written. A spoke variant derives from this doctrine by\nsubstituting the bindings below — the derivation never edits the\nsingle-valued frontmatter doctrine: `scope: co-develop` stays as written\nhere, and the spoke label lives in this note only.\n\nNo {{PROJECT_*}} placeholder is needed in this skill: its per-spoke deltas\nare frontmatter labels, not body prose, so they are documented as bindings\nrather than parameterized. This canonical also cleans the stray `\", ` EOF\nartifact inherited from the pre-consolidation copies (all four measured\nL2\u002FL3 copies carried it).\n\n| Spoke | Derivation binding |\n|---|---|\n| co-game | Ships byte-identical to co-develop, including `scope: co-develop` (merge ruling 2026-11-06, DEC-20261106-03: diverged same-version copies are merged, not split by version bump); no per-spoke scope rendering. |\n| co-learning | Not adopted — absent from Projects\u002Fco-learning and its template. The fleet skill-graph projection carries only a dangling reference node for it (content_hash null); it is not an installed consumer. |\n| co-abap | Not adopted — co-abap carries no refactoring capability; its `abap-dev` skill is a domain-specific asset outside this generic spine. |\n\n---\n\n## Related Skills\n\n- **test-driven-development**: For building test safety net\n- **code-review**: For identifying refactoring opportunities\n- **design-patterns**: For applying specific design patterns\n- **performance-optimization**: For targeted performance improvements\n\n---\n\n## Refactoring Tools\n\n**Automated Refactoring**:\n- IDE refactoring tools (VS Code, IntelliJ, PyCharm)\n- Safe refactoring features\n- Automated rename, extract method, etc.\n- Cross-language support\n\n**Code Analysis Tools**:\n- **SonarQube**: Code quality and technical debt analysis\n- **CodeClimate**: Automated code review\n- **Linters**: Style and bug detection (ESLint, Pylint)\n- **Complexity Analyzers**: Cyclomatic complexity tools\n\n**Duplicate Code Detection**:\n- **CPD** (Copy-Paste Detector)\n- **JDeodorant**: Eclipse duplicate detection\n- **SonarQube**: Duplicate code analysis\n\n---\n\n## Refactoring Patterns Reference\n\n**Organizing Data**:\n- Self-Encapsulate Field\n- Replace Data Value with Object\n- Replace Type Code with Class\n- Replace Array with Object\n\n**Simplifying Conditional Expressions**:\n- Decompose Conditional\n- Consolidate Conditional Expression\n- Replace Conditional with Polymorphism\n- Introduce Guard Clause\n\n**Simplifying Method Calls**:\n- Rename Method\n- Add Parameter\n- Remove Parameter\n- Separate Query from Modifier\n\n**Dealing with Generalization**:\n- Pull Up Method\n- Push Down Method\n- Extract Class\n- Inline Class\n\n---\n\n## When NOT to Refactor\n\n**Avoid Refactoring When**:\n- Code is about to be replaced\n- Time pressure is extreme (document for later)\n- No tests available and can't add them\n- Code is poorly understood and risky to change\n- Business value is low (cost-benefit analysis)\n\n**Alternatives**:\n- Rewrite from scratch (for very bad code)\n- Document technical debt for future\n- Add tests first, then refactor\n- Stabilize before improving\n- Focus on new features instead\n","## Context\n\nThis skill provides systematic refactoring capabilities, transforming code into better designs while ensuring behavior remains unchanged. It emphasizes safety, test coverage, and incremental improvements.\n\n## When to Use\n\n**Code Cleanup**:\n- Trigger: \"Refactor this code\" or \"Clean up implementation\"\n- Use Case: Improving code structure and organization\n\n**Debt Reduction**:\n- Trigger: \"Pay down technical debt\" or \"Improve code quality\"\n- Use Case: Addressing accumulated shortcuts and quick fixes\n\n**Design Improvement**:\n- Trigger: \"Improve code design\" or \"Apply design pattern\"\n- Use Case: Evolving code toward better architecture\n\n**Maintainability**:\n- Trigger: \"Make code more maintainable\" or \"Reduce complexity\"\n- Use Case: Ensuring code remains easy to understand and modify\n\n---\n\n## Execution Steps\n\n## Step 1: Refactoring Preparation\n\n**Purpose**: Ensure safe refactoring environment.\n\n**Preparation Checklist**:\n1. **Test Coverage**:\n   - [ ] Tests exist for code being refactored\n   - [ ] Tests cover main functionality\n   - [ ] Tests are currently passing\n   - [ ] Tests can be run quickly\n\n2. **Baseline Understanding**:\n   - [ ] Code purpose and behavior understood\n   - [ ] Current design issues identified\n   - [ ] Refactoring goals defined\n   - [ ] Success criteria established\n\n3. **Safety Measures**:\n   - [ ] Version control committed\n   - [ ] Branch created for refactoring\n   - [ ] Rollback plan considered\n   - [ ] Tests run before starting\n\n**Refactoring Goals**:\n- Remove duplication\n- Improve names and clarity\n- Simplify complex logic\n- Apply design patterns\n- Reduce coupling\n- Increase cohesion\n\n---\n\n## Step 2: Identify Code Smells\n\n**Purpose**: Find specific refactoring opportunities.\n\n**Common Code Smells**:\n1. **Duplication**:\n   - Duplicated code blocks\n   - Similar logic in multiple places\n   - Copy-pasted implementations\n\n2. **Long Methods**:\n   - Functions doing too many things\n   - Methods that are hard to understand\n   - Complex nested logic\n\n3. **Large Classes**:\n   - Classes with too many responsibilities\n   - God objects doing everything\n   - Classes with many dependencies\n\n4. **Poor Names**:\n   - Unclear variable\u002Ffunction names\n   - Abbreviations that aren't obvious\n   - Misleading names\n\n5. **Complex Conditionals**:\n   - Deep nesting\n   - Complex boolean expressions\n   - Multiple guard clauses\n\n**Detection Techniques**:\n- Code review with checklist\n- Static analysis tools (linters, SonarQube)\n- Cyclomatic complexity analysis\n- Duplicate code detection\n\n**Prioritization**:\n- High impact, low risk first\n- Areas with good test coverage\n- Frequently modified code\n- High technical debt areas\n\n---\n\n## Step 3: Apply Refactorings Systematically\n\n**Purpose**: Transform code using proven techniques.\n\n**Refactoring Process**:\n1. **Select Small Refactoring**:\n   - Choose one specific improvement\n   - Ensure test coverage exists\n   - Keep change size manageable\n\n2. **Apply Refactoring**:\n   - Follow refactoring pattern precisely\n   - Make mechanical transformations\n   - Don't change behavior\n\n3. **Run Tests**:\n   - All tests must pass\n   - Behavior unchanged\n   - No new test failures\n\n4. **Commit Incremental Change**:\n   - Small, atomic commits\n   - Clear commit messages\n   - Easy to revert if needed\n\n**Common Refactoring Patterns**:\n\n**Extract Method**:\n```python\n# Before\ndef process_order(order):\n    # validate\n    if not order.customer_id:\n        raise ValueError(\"No customer\")\n    if not order.items:\n        raise ValueError(\"No items\")\n    # calculate\n    total = sum(item.price for item in order.items)\n    tax = total * 0.1\n    final = total + tax\n    # save\n    order.total = final\n    order.save()\n\n# After\ndef process_order(order):\n    validate_order(order)\n    final = calculate_order_total(order)\n    save_order(order, final)\n\ndef validate_order(order):\n    if not order.customer_id:\n        raise ValueError(\"No customer\")\n    if not order.items:\n        raise ValueError(\"No items\")\n\ndef calculate_order_total(order):\n    total = sum(item.price for item in order.items)\n    tax = total * 0.1\n    return total + tax\n\ndef save_order(order, total):\n    order.total = total\n    order.save()\n```\n\n**Rename Variable\u002FMethod**:\n```python\n# Before\ndef d(x, y):\n    return x * y * 24\n\n# After\ndef calculate_daily_hours(hours_per_day, days_worked):\n    return hours_per_day * days_worked * 24\n```\n\n**Replace Magic Numbers**:\n```python\n# Before\nif score > 75:\n    grade = \"A\"\n\n# After\nEXCELLENCE_THRESHOLD = 75\nif score > EXCELLENCE_THRESHOLD:\n    grade = \"A\"\n```\n\n**Decompose Conditional**:\n```python\n# Before\ndef calculate_shipping(order):\n    if order.customer.is_premium and order.total > 100 and order.has_free_shipping:\n        return 0\n    elif order.customer.is_premium and order.total > 50:\n        return 5\n    else:\n        return 10\n\n# After\ndef calculate_shipping(order):\n    if qualifies_for_free_shipping(order):\n        return 0\n    if qualifies_for_reduced_shipping(order):\n        return 5\n    return 10\n\ndef qualifies_for_free_shipping(order):\n    return (order.customer.is_premium and \n            order.total > 100 and \n            order.has_free_shipping)\n\ndef qualifies_for_reduced_shipping(order):\n    return order.customer.is_premium and order.total > 50\n```\n\n---\n\n## Step 4: Maintain Test Safety Net\n\n**Purpose**: Ensure refactoring doesn't break behavior.\n\n**Test Strategy**:\n1. **Before Refactoring**:\n   - Run full test suite\n   - Document test results\n   - Ensure baseline success\n\n2. **During Refactoring**:\n   - Run tests after each change\n   - Fix any test failures immediately\n   - Don't proceed with failing tests\n\n3. **After Refactoring**:\n   - Run full test suite\n   - Verify behavior unchanged\n   - Check for unintended side effects\n\n**Regression Prevention**:\n- Keep test coverage high\n- Tests should verify behavior, not implementation\n- Add tests for edge cases discovered\n- Use characterizations tests for legacy code\n\n**Test Safety Indicators**:\n✅ **Safe to refactor**:\n- Comprehensive test coverage\n- Tests verify behavior\n- Tests are fast and reliable\n- Tests document expected behavior\n\n❌ **Risky to refactor**:\n- Low or no test coverage\n- Tests test implementation details\n- Tests are slow or flaky\n- Behavior not clearly specified\n\n---\n\n## Step 5: Incremental Improvement\n\n**Purpose**: Make steady progress without big risks.\n\n**Incremental Approach**:\n1. **Small Steps**:\n   - One refactoring at a time\n   - Commit after each successful change\n   - Run tests frequently\n   - Stop if tests fail\n\n2. **Build Confidence**:\n   - Start with low-risk areas\n   - Practice common refactorings\n   - Learn patterns and techniques\n   - Gradually tackle complex areas\n\n3. **Track Progress**:\n   - Document improvements made\n   - Measure code quality metrics\n   - Track technical debt reduction\n   - Celebrate small wins\n\n**Incremental Refactoring Cycle**:\n```\nIdentify Issue → Plan Refactoring → Apply Change → Run Tests → Commit → Repeat\n```\n\n**Batching Refactorings**:\n- Group related small refactorings\n- Make single logical commit\n- Keep batch size manageable\n- Ensure all tests pass\n\n---\n\n## Step 6: Validate Improvements\n\n**Purpose**: Confirm refactoring achieved goals.\n\n**Validation Checklist**:\n1. **Behavior Preservation**:\n   - [ ] All tests pass\n   - [ ] Functionality unchanged\n   - [ ] No regressions introduced\n   - [ ] Edge cases handled\n\n2. **Code Quality**:\n   - [ ] Code is clearer and more readable\n   - [ ] Duplication reduced\n   - [ ] Complexity decreased\n   - [ ] Names improved\n\n3. **Maintainability**:\n   - [ ] Easier to understand\n   - [ ] Easier to modify\n   - [ ] Better organized\n   - [ ] Better documented\n\n4. **Performance**:\n   - [ ] Performance not degraded\n   - [ ] No unnecessary complexity added\n   - [ ] Algorithms appropriate\n   - [ ] Resource usage reasonable\n\n**Quality Metrics**:\n- Cyclomatic complexity reduced\n- Code duplication decreased\n- Test coverage maintained or improved\n- Lines of code potentially reduced (though not a goal)\n\n---\n\n## Output Format\n\n**For Code Cleanup**:\n- Cleaner, more organized code\n- Removed duplication\n- Improved naming and clarity\n- Maintained behavior\n\n**For Debt Reduction**:\n- Addressed technical debt\n- Improved code structure\n- Better design patterns applied\n- Increased maintainability\n\n**For Design Improvement**:\n- Applied appropriate design patterns\n- Better separation of concerns\n- Reduced coupling\n- Increased cohesion\n\n---\n\n## Best Practices\n\n**Refactoring Discipline**:\n✅ **Do**:\n- Have test coverage before refactoring\n- Make small, incremental changes\n- Run tests frequently\n- Commit often with clear messages\n- Stop if tests fail\n- Focus on one improvement at a time\n\n❌ **Don't**:\n- Refactor without tests\n- Make large, sweeping changes\n- Skip running tests to \"save time\"\n- Mix refactoring with feature changes\n- Proceed with failing tests\n- Try to \"fix everything at once\"\n\n**Safety First**:\n✅ **Do**:\n- Create branch for refactoring\n- Run tests before starting\n- Keep commits atomic\n- Document refactoring rationale\n- Have rollback plan ready\n- Refactor in small steps\n\n❌ **Don't**:\n- Refactor on main branch\n- Start without baseline tests\n- Make large, risky commits\n- Refactor without understanding\n- Proceed without safety net\n- Rush refactoring process\n\n---\n\n## Common Mistakes to Avoid\n\n**Refactoring Anti-Patterns**:\n1. **Refactoring Without Tests**: Making changes without safety net\n2. **Big Bang Refactoring**: Trying to fix everything at once\n3. **Mixed Changes**: Combining refactoring with feature work\n4. **Premature Optimization**: Optimizing before measuring\n5. **Over-Engineering**: Adding complexity for hypothetical future needs\n\n**Process Anti-Patterns**:\n1. **Ignoring Failing Tests**: Continuing despite test failures\n2. **Skipping Validation**: Not confirming behavior preserved\n3. **No Clear Goal**: Refactoring without specific improvement target\n4. **Analysis Paralysis**: Spending too much time planning\n5. **Refactoring Procrastination**: Putting off necessary improvements\n\n---\n\n## Spoke Derivation Note\n\nThis file is the hub-doctrine canonical for the co-develop generic dev spine\n(spec 2026-11-01-hub-consolidation-design, Phase 1 batch D). Co-develop\npipelines run it as written. A spoke variant derives from this doctrine by\nsubstituting the bindings below — the derivation never edits the\nsingle-valued frontmatter doctrine: `scope: co-develop` stays as written\nhere, and the spoke label lives in this note only.\n\nNo {{PROJECT_*}} placeholder is needed in this skill: its per-spoke deltas\nare frontmatter labels, not body prose, so they are documented as bindings\nrather than parameterized. This canonical also cleans the stray `\", ` EOF\nartifact inherited from the pre-consolidation copies (all four measured\nL2\u002FL3 copies carried it).\n\n| Spoke | Derivation binding |\n|---|---|\n| co-game | Ships byte-identical to co-develop, including `scope: co-develop` (merge ruling 2026-11-06, DEC-20261106-03: diverged same-version copies are merged, not split by version bump); no per-spoke scope rendering. |\n| co-learning | Not adopted — absent from Projects\u002Fco-learning and its template. The fleet skill-graph projection carries only a dangling reference node for it (content_hash null); it is not an installed consumer. |\n| co-abap | Not adopted — co-abap carries no refactoring capability; its `abap-dev` skill is a domain-specific asset outside this generic spine. |\n\n---\n\n## Related Skills\n\n- **test-driven-development**: For building test safety net\n- **code-review**: For identifying refactoring opportunities\n- **design-patterns**: For applying specific design patterns\n- **performance-optimization**: For targeted performance improvements\n\n---\n\n## Refactoring Tools\n\n**Automated Refactoring**:\n- IDE refactoring tools (VS Code, IntelliJ, PyCharm)\n- Safe refactoring features\n- Automated rename, extract method, etc.\n- Cross-language support\n\n**Code Analysis Tools**:\n- **SonarQube**: Code quality and technical debt analysis\n- **CodeClimate**: Automated code review\n- **Linters**: Style and bug detection (ESLint, Pylint)\n- **Complexity Analyzers**: Cyclomatic complexity tools\n\n**Duplicate Code Detection**:\n- **CPD** (Copy-Paste Detector)\n- **JDeodorant**: Eclipse duplicate detection\n- **SonarQube**: Duplicate code analysis\n\n---\n\n## Refactoring Patterns Reference\n\n**Organizing Data**:\n- Self-Encapsulate Field\n- Replace Data Value with Object\n- Replace Type Code with Class\n- Replace Array with Object\n\n**Simplifying Conditional Expressions**:\n- Decompose Conditional\n- Consolidate Conditional Expression\n- Replace Conditional with Polymorphism\n- Introduce Guard Clause\n\n**Simplifying Method Calls**:\n- Rename Method\n- Add Parameter\n- Remove Parameter\n- Separate Query from Modifier\n\n**Dealing with Generalization**:\n- Pull Up Method\n- Push Down Method\n- Extract Class\n- Inline Class\n\n---\n\n## When NOT to Refactor\n\n**Avoid Refactoring When**:\n- Code is about to be replaced\n- Time pressure is extreme (document for later)\n- No tests available and can't add them\n- Code is poorly understood and risky to change\n- Business value is low (cost-benefit analysis)\n\n**Alternatives**:\n- Rewrite from scratch (for very bad code)\n- Document technical debt for future\n- Add tests first, then refactor\n- Stabilize before improving\n- Focus on new features instead\n",{"name":5,"owner":23,"scope":24,"status":25,"version":26,"metadata":27,"relates_to":37,"description":41,"gemini-parity":42,"last_reviewed":43,"prerequisites":44},"pm","co-develop","active","1.2.0",{"type":28,"triggers":29},"process",[30,31,32,33,34,35,36],"refactor","clean up code","improve code","reduce duplication","pay down tech debt","code smell","improve design",[38],{"type":39,"skill":40},"composes_with","code-review","Improves code structure and design while preserving behavior using systematic refactoring techniques. Use when: cleaning up code, reducing duplication, improving maintainability, or paying down technical debt.\n","skip",1793923200000,"none","main","1162ccc568cf90c01b3886d6143cbfd851a37883","templates\u002Fco-game\u002Fskills\u002Frefactoring",9,"https:\u002F\u002Fgithub.com\u002F5throck\u002Fai-workspace-standards","https:\u002F\u002Fgithub.com\u002F5throck","Experienced in digital transformation, enterprise IT, startup acceleration, and business strategy. Focused on building practical systems that connect technolo","2026-11-14 21:22:34",{"source":8,"skillName":5,"commands":54,"prompt":64,"zipAvailable":65},[55,58,61],{"tool":56,"command":57},"npx","npx skills add 5throck\u002Fai-workspace-standards --skill refactoring",{"tool":59,"command":60},"bunx","bunx skills add 5throck\u002Fai-workspace-standards --skill refactoring",{"tool":62,"command":63},"pnpm","pnpm dlx skills add 5throck\u002Fai-workspace-standards --skill refactoring","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002F5throck\u002Fai-workspace-standards\u002Fblob\u002Fmain\u002Ftemplates\u002Fco-game\u002Fskills\u002Frefactoring\u002FSKILL.md",true,[],[68,76,81,86,91,96],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":75},"01M7BBJDYHJMGTJYSC37JVWY8S","i18n-layout","Text layout and encoding guidance: character encoding (UTF-8, legacy Korean code pages, BOM hazards), line endings, RTL\u002Fbidi handling, and script-specific font selection (Hangul focus). Use when: encoding is corrupted or mojibake appears, an RTL locale must render correctly, fonts must be chosen for a script, or CRLF\u002FBOM issues surface.","https:\u002F\u002Fgithub.com\u002F5throck\u002Fai-workspace-standards\u002Fblob\u002Fmain\u002Ftemplates\u002Fco-work\u002Fskills\u002Fi18n-layout\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":77,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":75},"01M7BBJ9XHAAS1AVGKZZ841VBZ","https:\u002F\u002Fgithub.com\u002F5throck\u002Fai-workspace-standards\u002Fblob\u002Fmain\u002Ftemplates\u002Fco-work\u002F.hermes\u002Fskills\u002Fi18n-layout\u002FSKILL.md",[],[],{"skillNo":82,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":75},"01M7BBJ5C3X8TKFKG5R9P9P49W","https:\u002F\u002Fgithub.com\u002F5throck\u002Fai-workspace-standards\u002Fblob\u002Fmain\u002Ftemplates\u002Fco-work\u002F.gemini\u002Fskills\u002Fi18n-layout\u002FSKILL.md",[],[],{"skillNo":87,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":75},"01M7BBJ1B52X0QMJ2QVBMPJB37","https:\u002F\u002Fgithub.com\u002F5throck\u002Fai-workspace-standards\u002Fblob\u002Fmain\u002Ftemplates\u002Fco-work\u002F.codex\u002Fskills\u002Fi18n-layout\u002FSKILL.md",[],[],{"skillNo":92,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":75},"01M7BBHX91BW2Q2R276MRX5AW3","https:\u002F\u002Fgithub.com\u002F5throck\u002Fai-workspace-standards\u002Fblob\u002Fmain\u002Ftemplates\u002Fco-work\u002F.claude\u002Fskills\u002Fi18n-layout\u002FSKILL.md",[],[],{"skillNo":97,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":75},"01M7BBHQWGXPSFRWN1PRC2NMMV","https:\u002F\u002Fgithub.com\u002F5throck\u002Fai-workspace-standards\u002Fblob\u002Fmain\u002Ftemplates\u002Fco-work\u002F.agents\u002Fskills\u002Fi18n-layout\u002FSKILL.md",[],[]]