[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71H921ZBEBDHC8RB7CPA55B":3,"skill-same:01M71H921ZBEBDHC8RB7CPA55B":67},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":31,"linkOnly":32,"markdownContent":33,"markdownBody":34,"frontMatter":35,"refName":40,"commitSha":41,"skillDirectory":42,"forksCount":43,"repositoryHtmlUrl":44,"repositoryHomepageUrl":6,"ownerHtmlUrl":45,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":46,"install":47,"resources":60},"01M71H921ZBEBDHC8RB7CPA55B","refactoring",null,"Technical debt remediation and code restructuring workflow. Use when improving\ncode structure, reducing complexity, extracting abstractions, or paying down\naccumulated technical debt.","JSGforever\u002Fskillguard","JSGforever","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F85541948?v=4","01M71FQD3E132VMR5F4TAYX3YS","01M71FQD4DYW0XJ4XQ4YQH75Y9",2,"MIT","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__ar4mirez--refactoring\u002FSKILL.md",[],[5,18,19,20,21,22,23,24,25,26,27,28,29,30],"complexity","extracting","when","workflow","code","structure","technical debt","remediation","debt","down","technical","use","code structure","2026-11-10 10:12:30",false,"---\nname: refactoring\ndescription: |\n  Technical debt remediation and code restructuring workflow. Use when improving\n  code structure, reducing complexity, extracting abstractions, or paying down\n  accumulated technical debt.\nlicense: MIT\nmetadata:\n  author: samuel\n  version: \"1.0\"\n  category: workflow\n---\n\n# Refactoring Skill\n\nStructured approach to technical debt remediation. Improve code structure while maintaining behavior through incremental, safe changes.\n\n---\n\n## When to Use\n\n| Trigger | Description |\n|---------|-------------|\n| **Guardrail Violations** | Functions >50 lines, files >300 lines |\n| **Complexity Threshold** | Cyclomatic complexity >10 |\n| **Code Duplication** | Same logic in 3+ places |\n| **Quarterly Review** | Regular technical debt assessment |\n| **Pre-Feature** | Before adding features to messy code |\n| **Post-Incident** | After bugs caused by confusing code |\n\n---\n\n## Refactoring Principles\n\n### Golden Rules\n\n1. **Behavior Preservation**: Output unchanged after refactoring\n2. **Small Steps**: One change at a time\n3. **Test First**: Ensure tests exist before changing\n4. **Incremental**: Commit after each successful change\n5. **Reversible**: Easy to roll back if issues arise\n\n### When NOT to Refactor\n\n- During active incident response\n- Without test coverage\n- When deadline is imminent\n- If no clear improvement goal\n\n---\n\n## Prerequisites\n\nBefore starting:\n\n- [ ] Code compiles and all tests pass\n- [ ] Test coverage exists for target code (>60%)\n- [ ] Clear refactoring goal defined\n- [ ] Time allocated (refactoring always takes longer)\n- [ ] Git working directory is clean\n\n---\n\n## Refactoring Process\n\n```\nPhase 1: Identify Candidates\n    ↓\nPhase 2: Impact Analysis\n    ↓\nPhase 3: Plan Refactoring\n    ↓\nPhase 4: Add Safety Net\n    ↓\nPhase 5: Execute Incrementally\n    ↓\nPhase 6: Validate & Document\n```\n\n---\n\n## Phase 1: Identify Candidates\n\n### 1.1 Automated Detection\n\n**Long Functions** (>50 lines):\n```bash\n# Find functions over 50 lines (varies by language)\n# Example: use linter rules or IDE features\n```\n\n**Long Files** (>300 lines):\n```bash\n# Find files over 300 lines\nfind src -name \"*.ts\" -exec wc -l {} \\; | awk '$1 > 300'\nfind src -name \"*.py\" -exec wc -l {} \\; | awk '$1 > 300'\n```\n\n**High Complexity**:\n```bash\n# Use complexity analyzers\nnpx escomplex src\u002F**\u002F*.ts\npython -m mccabe src\u002F**\u002F*.py\n```\n\n### 1.2 Code Smells\n\n| Smell | Signs | Priority |\n|-------|-------|----------|\n| **Long Method** | >50 lines, multiple responsibilities | High |\n| **Large Class** | >300 lines, low cohesion | High |\n| **Feature Envy** | Method uses other class more than own | Medium |\n| **Data Clumps** | Same group of variables together | Medium |\n| **Primitive Obsession** | Overuse of primitives vs objects | Medium |\n| **Switch Statements** | Large switch blocks | Low |\n| **Speculative Generality** | Unused abstractions | Low |\n\n### 1.3 Candidate List\n\nDocument identified candidates:\n\n```markdown\n## Refactoring Candidates\n\n### High Priority\n| File | Issue | Lines | Impact |\n|------|-------|-------|--------|\n| src\u002Fservices\u002Forder.ts | Long method: processOrder | 120 → 50 | High |\n| src\u002Fapi\u002Fusers.ts | Large file | 450 → 200 | High |\n| src\u002Futils\u002Fvalidation.ts | Duplication | N\u002FA | Medium |\n\n### Medium Priority\n| File | Issue | Lines | Impact |\n|------|-------|-------|--------|\n| src\u002Fmodels\u002Fproduct.ts | Feature envy | N\u002FA | Medium |\n| src\u002Fservices\u002Femail.ts | Complex conditionals | N\u002FA | Medium |\n```\n\n---\n\n## Phase 2: Impact Analysis\n\n### 2.1 Dependency Mapping\n\nFor each candidate, identify:\n\n```\nTarget: src\u002Fservices\u002Forder.ts\n\nDependencies (imports from):\n- src\u002Fmodels\u002Forder.ts\n- src\u002Fservices\u002Finventory.ts\n- src\u002Fservices\u002Fpayment.ts\n\nDependents (imported by):\n- src\u002Fapi\u002Forders.ts\n- src\u002Fworkers\u002ForderProcessor.ts\n- tests\u002Fservices\u002Forder.test.ts\n\nImpact radius: 5 files\nRisk level: Medium\n```\n\n### 2.2 Risk Assessment\n\n| Factor | Low | Medium | High |\n|--------|-----|--------|------|\n| Test coverage | >80% | 60-80% | \u003C60% |\n| Dependents | \u003C3 | 3-10 | >10 |\n| Business criticality | Non-critical | Important | Critical path |\n| Complexity | Simple rename | Extract method | Architecture change |\n\n### 2.3 Risk Matrix\n\n```\n              Low Effort    High Effort\n            ┌────────────┬────────────┐\nHigh Value  │  DO FIRST  │  PLAN      │\n            │            │  CAREFULLY │\n            ├────────────┼────────────┤\nLow Value   │  QUICK WIN │  AVOID     │\n            │            │            │\n            └────────────┴────────────┘\n```\n\n---\n\n## Phase 3: Plan Refactoring\n\n### 3.1 Choose Refactoring Technique\n\n| Smell | Technique | Description |\n|-------|-----------|-------------|\n| Long method | Extract Method | Pull out logical chunks |\n| Large class | Extract Class | Split by responsibility |\n| Feature envy | Move Method | Move to appropriate class |\n| Data clumps | Extract Parameter Object | Group related params |\n| Duplicated code | Extract to shared function | DRY principle |\n| Complex conditional | Replace with polymorphism | Strategy pattern |\n| Long parameter list | Introduce Parameter Object | Create wrapper class |\n\n### 3.2 Step-by-Step Plan\n\nExample: Extract Method from Long Function\n\n```markdown\n## Refactoring Plan: processOrder()\n\n### Goal\nReduce processOrder() from 120 lines to \u003C50 lines\n\n### Steps\n1. [ ] Add characterization tests for current behavior\n2. [ ] Extract validateOrder() (lines 15-35)\n3. [ ] Verify tests pass\n4. [ ] Commit: \"refactor: extract validateOrder\"\n5. [ ] Extract calculateTotals() (lines 40-65)\n6. [ ] Verify tests pass\n7. [ ] Commit: \"refactor: extract calculateTotals\"\n8. [ ] Extract processPayment() (lines 70-95)\n9. [ ] Verify tests pass\n10. [ ] Commit: \"refactor: extract processPayment\"\n11. [ ] Extract sendConfirmation() (lines 100-115)\n12. [ ] Verify tests pass\n13. [ ] Commit: \"refactor: extract sendConfirmation\"\n14. [ ] Final cleanup and documentation\n15. [ ] Commit: \"refactor: cleanup processOrder\"\n\n### Expected Result\n- processOrder(): 120 → 25 lines\n- New methods: 4\n- Total lines: +10 (net increase for clarity)\n```\n\n---\n\n## Phase 4: Add Safety Net\n\n### 4.1 Characterization Tests\n\nBefore refactoring, add tests that capture current behavior:\n\n```typescript\ndescribe('processOrder - characterization tests', () => {\n  it('should match current behavior for valid order', () => {\n    const order = createValidOrder();\n    const result = processOrder(order);\n\n    \u002F\u002F Capture current output exactly\n    expect(result).toMatchSnapshot();\n  });\n\n  it('should match current behavior for edge cases', () => {\n    const edgeCases = [\n      createEmptyOrder(),\n      createMaxItemOrder(),\n      createDiscountedOrder(),\n    ];\n\n    edgeCases.forEach(order => {\n      expect(processOrder(order)).toMatchSnapshot();\n    });\n  });\n});\n```\n\n### 4.2 Coverage Check\n\nEnsure adequate coverage before proceeding:\n\n```bash\n# Check coverage for target file\nnpm test -- --coverage --collectCoverageFrom=\"src\u002Fservices\u002Forder.ts\"\n```\n\n**Minimum Coverage**: 60% before refactoring (prefer >80%)\n\n### 4.3 Checkpoint Commit\n\nCreate a checkpoint before starting:\n\n```bash\ngit add .\ngit commit -m \"chore: checkpoint before refactoring processOrder\"\n```\n\n---\n\n## Phase 5: Execute Incrementally\n\n### 5.1 One Change at a Time\n\n**Bad**: Multiple changes in one commit\n```bash\n# Too much at once - hard to debug if tests fail\ngit commit -m \"refactor: refactor entire order module\"\n```\n\n**Good**: Atomic changes\n```bash\ngit commit -m \"refactor(order): extract validateOrder method\"\ngit commit -m \"refactor(order): extract calculateTotals method\"\ngit commit -m \"refactor(order): extract processPayment method\"\n```\n\n### 5.2 Red-Green-Refactor\n\nFor each change:\n\n```\n1. Run tests → PASS (green)\n2. Make one refactoring change\n3. Run tests → Should still PASS (green)\n4. If FAIL (red) → Revert and try smaller change\n5. If PASS → Commit\n6. Repeat\n```\n\n### 5.3 Common Refactoring Patterns\n\nSee `references\u002Fprocess.md` for detailed code examples including:\n- Extract Method pattern\n- Extract Class pattern\n- Replace Conditional with Polymorphism pattern\n\n---\n\n## Phase 6: Validate & Document\n\n### 6.1 Final Validation\n\n- [ ] All tests pass\n- [ ] Coverage maintained or improved\n- [ ] No new linter warnings\n- [ ] Performance unchanged (or improved)\n- [ ] Behavior identical (check snapshots)\n\n### 6.2 Document Changes\n\n**Update patterns.md** (if new pattern emerged):\n```markdown\n## Order Processing Pattern\n\nOrders are processed through composable steps:\n1. validateOrder() - Input validation\n2. calculateTotals() - Price calculations\n3. processPayment() - Payment handling\n4. sendConfirmation() - Notifications\n```\n\n**Create memory entry** (if significant):\n```markdown\n# Refactoring: Order Processing\n\n**Date**: 2025-01-15\n**Files**: src\u002Fservices\u002Forder.ts\n\n## Before\n- Single 120-line function\n- Difficult to test\n- Hard to modify\n\n## After\n- 5 focused functions (\u003C30 lines each)\n- Easier to test\n- Clear responsibilities\n\n## Lessons\n- Extract Method is low-risk, high-reward\n- Characterization tests prevented regressions\n```\n\n### 6.3 Final Commit\n\n```bash\ngit add .\ngit commit -m \"refactor(order): complete processOrder decomposition\n\n- Extract validateOrder (20 lines)\n- Extract calculateTotals (25 lines)\n- Extract processPayment (30 lines)\n- Extract sendConfirmation (20 lines)\n- Main function now 25 lines (was 120)\n\nNo behavior changes. All tests passing.\"\n```\n\n---\n\n## Refactoring Catalog\n\n### Quick Reference\n\n| Refactoring | When | Effort | Risk |\n|-------------|------|--------|------|\n| Rename | Unclear naming | Low | Low |\n| Extract Method | Long function | Low | Low |\n| Extract Variable | Complex expression | Low | Low |\n| Inline | Over-abstraction | Low | Low |\n| Extract Class | Large class | Medium | Medium |\n| Move Method | Feature envy | Medium | Medium |\n| Extract Parameter Object | Long param list | Medium | Low |\n| Replace Conditional with Polymorphism | Complex switch | High | Medium |\n| Replace Inheritance with Composition | Rigid hierarchy | High | High |\n\n### IDE Support\n\nMost refactorings have IDE shortcuts:\n\n| Action | VS Code | JetBrains |\n|--------|---------|-----------|\n| Rename | F2 | Shift+F6 |\n| Extract Method | Ctrl+Shift+R | Ctrl+Alt+M |\n| Extract Variable | Ctrl+Shift+R | Ctrl+Alt+V |\n| Move | Drag or F2 | F6 |\n| Inline | N\u002FA | Ctrl+Alt+N |\n\n---\n\n## Checklist\n\n### Before Refactoring\n- [ ] Clear goal defined\n- [ ] Tests exist (>60% coverage)\n- [ ] Impact analysis complete\n- [ ] Step-by-step plan created\n- [ ] Checkpoint committed\n\n### During Refactoring\n- [ ] One change at a time\n- [ ] Tests run after each change\n- [ ] Commit after each successful change\n- [ ] No behavior changes introduced\n\n### After Refactoring\n- [ ] All tests pass\n- [ ] Coverage maintained\n- [ ] Code cleaner (measurable)\n- [ ] Documentation updated\n- [ ] Patterns documented (if applicable)\n\n---\n\n## Related Resources\n\n- **Workflows**: code-review.md, testing-strategy.md, troubleshooting.md\n- **Detailed Examples**: See `references\u002Fprocess.md` for code patterns\n- **Refactoring Book**: Martin Fowler's \"Refactoring: Improving the Design of Existing Code\"\n","# Refactoring Skill\n\nStructured approach to technical debt remediation. Improve code structure while maintaining behavior through incremental, safe changes.\n\n---\n\n## When to Use\n\n| Trigger | Description |\n|---------|-------------|\n| **Guardrail Violations** | Functions >50 lines, files >300 lines |\n| **Complexity Threshold** | Cyclomatic complexity >10 |\n| **Code Duplication** | Same logic in 3+ places |\n| **Quarterly Review** | Regular technical debt assessment |\n| **Pre-Feature** | Before adding features to messy code |\n| **Post-Incident** | After bugs caused by confusing code |\n\n---\n\n## Refactoring Principles\n\n### Golden Rules\n\n1. **Behavior Preservation**: Output unchanged after refactoring\n2. **Small Steps**: One change at a time\n3. **Test First**: Ensure tests exist before changing\n4. **Incremental**: Commit after each successful change\n5. **Reversible**: Easy to roll back if issues arise\n\n### When NOT to Refactor\n\n- During active incident response\n- Without test coverage\n- When deadline is imminent\n- If no clear improvement goal\n\n---\n\n## Prerequisites\n\nBefore starting:\n\n- [ ] Code compiles and all tests pass\n- [ ] Test coverage exists for target code (>60%)\n- [ ] Clear refactoring goal defined\n- [ ] Time allocated (refactoring always takes longer)\n- [ ] Git working directory is clean\n\n---\n\n## Refactoring Process\n\n```\nPhase 1: Identify Candidates\n    ↓\nPhase 2: Impact Analysis\n    ↓\nPhase 3: Plan Refactoring\n    ↓\nPhase 4: Add Safety Net\n    ↓\nPhase 5: Execute Incrementally\n    ↓\nPhase 6: Validate & Document\n```\n\n---\n\n## Phase 1: Identify Candidates\n\n### 1.1 Automated Detection\n\n**Long Functions** (>50 lines):\n```bash\n# Find functions over 50 lines (varies by language)\n# Example: use linter rules or IDE features\n```\n\n**Long Files** (>300 lines):\n```bash\n# Find files over 300 lines\nfind src -name \"*.ts\" -exec wc -l {} \\; | awk '$1 > 300'\nfind src -name \"*.py\" -exec wc -l {} \\; | awk '$1 > 300'\n```\n\n**High Complexity**:\n```bash\n# Use complexity analyzers\nnpx escomplex src\u002F**\u002F*.ts\npython -m mccabe src\u002F**\u002F*.py\n```\n\n### 1.2 Code Smells\n\n| Smell | Signs | Priority |\n|-------|-------|----------|\n| **Long Method** | >50 lines, multiple responsibilities | High |\n| **Large Class** | >300 lines, low cohesion | High |\n| **Feature Envy** | Method uses other class more than own | Medium |\n| **Data Clumps** | Same group of variables together | Medium |\n| **Primitive Obsession** | Overuse of primitives vs objects | Medium |\n| **Switch Statements** | Large switch blocks | Low |\n| **Speculative Generality** | Unused abstractions | Low |\n\n### 1.3 Candidate List\n\nDocument identified candidates:\n\n```markdown\n## Refactoring Candidates\n\n### High Priority\n| File | Issue | Lines | Impact |\n|------|-------|-------|--------|\n| src\u002Fservices\u002Forder.ts | Long method: processOrder | 120 → 50 | High |\n| src\u002Fapi\u002Fusers.ts | Large file | 450 → 200 | High |\n| src\u002Futils\u002Fvalidation.ts | Duplication | N\u002FA | Medium |\n\n### Medium Priority\n| File | Issue | Lines | Impact |\n|------|-------|-------|--------|\n| src\u002Fmodels\u002Fproduct.ts | Feature envy | N\u002FA | Medium |\n| src\u002Fservices\u002Femail.ts | Complex conditionals | N\u002FA | Medium |\n```\n\n---\n\n## Phase 2: Impact Analysis\n\n### 2.1 Dependency Mapping\n\nFor each candidate, identify:\n\n```\nTarget: src\u002Fservices\u002Forder.ts\n\nDependencies (imports from):\n- src\u002Fmodels\u002Forder.ts\n- src\u002Fservices\u002Finventory.ts\n- src\u002Fservices\u002Fpayment.ts\n\nDependents (imported by):\n- src\u002Fapi\u002Forders.ts\n- src\u002Fworkers\u002ForderProcessor.ts\n- tests\u002Fservices\u002Forder.test.ts\n\nImpact radius: 5 files\nRisk level: Medium\n```\n\n### 2.2 Risk Assessment\n\n| Factor | Low | Medium | High |\n|--------|-----|--------|------|\n| Test coverage | >80% | 60-80% | \u003C60% |\n| Dependents | \u003C3 | 3-10 | >10 |\n| Business criticality | Non-critical | Important | Critical path |\n| Complexity | Simple rename | Extract method | Architecture change |\n\n### 2.3 Risk Matrix\n\n```\n              Low Effort    High Effort\n            ┌────────────┬────────────┐\nHigh Value  │  DO FIRST  │  PLAN      │\n            │            │  CAREFULLY │\n            ├────────────┼────────────┤\nLow Value   │  QUICK WIN │  AVOID     │\n            │            │            │\n            └────────────┴────────────┘\n```\n\n---\n\n## Phase 3: Plan Refactoring\n\n### 3.1 Choose Refactoring Technique\n\n| Smell | Technique | Description |\n|-------|-----------|-------------|\n| Long method | Extract Method | Pull out logical chunks |\n| Large class | Extract Class | Split by responsibility |\n| Feature envy | Move Method | Move to appropriate class |\n| Data clumps | Extract Parameter Object | Group related params |\n| Duplicated code | Extract to shared function | DRY principle |\n| Complex conditional | Replace with polymorphism | Strategy pattern |\n| Long parameter list | Introduce Parameter Object | Create wrapper class |\n\n### 3.2 Step-by-Step Plan\n\nExample: Extract Method from Long Function\n\n```markdown\n## Refactoring Plan: processOrder()\n\n### Goal\nReduce processOrder() from 120 lines to \u003C50 lines\n\n### Steps\n1. [ ] Add characterization tests for current behavior\n2. [ ] Extract validateOrder() (lines 15-35)\n3. [ ] Verify tests pass\n4. [ ] Commit: \"refactor: extract validateOrder\"\n5. [ ] Extract calculateTotals() (lines 40-65)\n6. [ ] Verify tests pass\n7. [ ] Commit: \"refactor: extract calculateTotals\"\n8. [ ] Extract processPayment() (lines 70-95)\n9. [ ] Verify tests pass\n10. [ ] Commit: \"refactor: extract processPayment\"\n11. [ ] Extract sendConfirmation() (lines 100-115)\n12. [ ] Verify tests pass\n13. [ ] Commit: \"refactor: extract sendConfirmation\"\n14. [ ] Final cleanup and documentation\n15. [ ] Commit: \"refactor: cleanup processOrder\"\n\n### Expected Result\n- processOrder(): 120 → 25 lines\n- New methods: 4\n- Total lines: +10 (net increase for clarity)\n```\n\n---\n\n## Phase 4: Add Safety Net\n\n### 4.1 Characterization Tests\n\nBefore refactoring, add tests that capture current behavior:\n\n```typescript\ndescribe('processOrder - characterization tests', () => {\n  it('should match current behavior for valid order', () => {\n    const order = createValidOrder();\n    const result = processOrder(order);\n\n    \u002F\u002F Capture current output exactly\n    expect(result).toMatchSnapshot();\n  });\n\n  it('should match current behavior for edge cases', () => {\n    const edgeCases = [\n      createEmptyOrder(),\n      createMaxItemOrder(),\n      createDiscountedOrder(),\n    ];\n\n    edgeCases.forEach(order => {\n      expect(processOrder(order)).toMatchSnapshot();\n    });\n  });\n});\n```\n\n### 4.2 Coverage Check\n\nEnsure adequate coverage before proceeding:\n\n```bash\n# Check coverage for target file\nnpm test -- --coverage --collectCoverageFrom=\"src\u002Fservices\u002Forder.ts\"\n```\n\n**Minimum Coverage**: 60% before refactoring (prefer >80%)\n\n### 4.3 Checkpoint Commit\n\nCreate a checkpoint before starting:\n\n```bash\ngit add .\ngit commit -m \"chore: checkpoint before refactoring processOrder\"\n```\n\n---\n\n## Phase 5: Execute Incrementally\n\n### 5.1 One Change at a Time\n\n**Bad**: Multiple changes in one commit\n```bash\n# Too much at once - hard to debug if tests fail\ngit commit -m \"refactor: refactor entire order module\"\n```\n\n**Good**: Atomic changes\n```bash\ngit commit -m \"refactor(order): extract validateOrder method\"\ngit commit -m \"refactor(order): extract calculateTotals method\"\ngit commit -m \"refactor(order): extract processPayment method\"\n```\n\n### 5.2 Red-Green-Refactor\n\nFor each change:\n\n```\n1. Run tests → PASS (green)\n2. Make one refactoring change\n3. Run tests → Should still PASS (green)\n4. If FAIL (red) → Revert and try smaller change\n5. If PASS → Commit\n6. Repeat\n```\n\n### 5.3 Common Refactoring Patterns\n\nSee `references\u002Fprocess.md` for detailed code examples including:\n- Extract Method pattern\n- Extract Class pattern\n- Replace Conditional with Polymorphism pattern\n\n---\n\n## Phase 6: Validate & Document\n\n### 6.1 Final Validation\n\n- [ ] All tests pass\n- [ ] Coverage maintained or improved\n- [ ] No new linter warnings\n- [ ] Performance unchanged (or improved)\n- [ ] Behavior identical (check snapshots)\n\n### 6.2 Document Changes\n\n**Update patterns.md** (if new pattern emerged):\n```markdown\n## Order Processing Pattern\n\nOrders are processed through composable steps:\n1. validateOrder() - Input validation\n2. calculateTotals() - Price calculations\n3. processPayment() - Payment handling\n4. sendConfirmation() - Notifications\n```\n\n**Create memory entry** (if significant):\n```markdown\n# Refactoring: Order Processing\n\n**Date**: 2025-01-15\n**Files**: src\u002Fservices\u002Forder.ts\n\n## Before\n- Single 120-line function\n- Difficult to test\n- Hard to modify\n\n## After\n- 5 focused functions (\u003C30 lines each)\n- Easier to test\n- Clear responsibilities\n\n## Lessons\n- Extract Method is low-risk, high-reward\n- Characterization tests prevented regressions\n```\n\n### 6.3 Final Commit\n\n```bash\ngit add .\ngit commit -m \"refactor(order): complete processOrder decomposition\n\n- Extract validateOrder (20 lines)\n- Extract calculateTotals (25 lines)\n- Extract processPayment (30 lines)\n- Extract sendConfirmation (20 lines)\n- Main function now 25 lines (was 120)\n\nNo behavior changes. All tests passing.\"\n```\n\n---\n\n## Refactoring Catalog\n\n### Quick Reference\n\n| Refactoring | When | Effort | Risk |\n|-------------|------|--------|------|\n| Rename | Unclear naming | Low | Low |\n| Extract Method | Long function | Low | Low |\n| Extract Variable | Complex expression | Low | Low |\n| Inline | Over-abstraction | Low | Low |\n| Extract Class | Large class | Medium | Medium |\n| Move Method | Feature envy | Medium | Medium |\n| Extract Parameter Object | Long param list | Medium | Low |\n| Replace Conditional with Polymorphism | Complex switch | High | Medium |\n| Replace Inheritance with Composition | Rigid hierarchy | High | High |\n\n### IDE Support\n\nMost refactorings have IDE shortcuts:\n\n| Action | VS Code | JetBrains |\n|--------|---------|-----------|\n| Rename | F2 | Shift+F6 |\n| Extract Method | Ctrl+Shift+R | Ctrl+Alt+M |\n| Extract Variable | Ctrl+Shift+R | Ctrl+Alt+V |\n| Move | Drag or F2 | F6 |\n| Inline | N\u002FA | Ctrl+Alt+N |\n\n---\n\n## Checklist\n\n### Before Refactoring\n- [ ] Clear goal defined\n- [ ] Tests exist (>60% coverage)\n- [ ] Impact analysis complete\n- [ ] Step-by-step plan created\n- [ ] Checkpoint committed\n\n### During Refactoring\n- [ ] One change at a time\n- [ ] Tests run after each change\n- [ ] Commit after each successful change\n- [ ] No behavior changes introduced\n\n### After Refactoring\n- [ ] All tests pass\n- [ ] Coverage maintained\n- [ ] Code cleaner (measurable)\n- [ ] Documentation updated\n- [ ] Patterns documented (if applicable)\n\n---\n\n## Related Resources\n\n- **Workflows**: code-review.md, testing-strategy.md, troubleshooting.md\n- **Detailed Examples**: See `references\u002Fprocess.md` for code patterns\n- **Refactoring Book**: Martin Fowler's \"Refactoring: Improving the Design of Existing Code\"\n",{"name":5,"license":14,"metadata":36,"description":39},{"author":37,"version":38,"category":21},"samuel","1.0","Technical debt remediation and code restructuring workflow. Use when improving\ncode structure, reducing complexity, extracting abstractions, or paying down\naccumulated technical debt.\n","main","f2ec4b3b9133d34eeaf9b38e4b0a97e8e5705a7f","benchmarks\u002Ffinal\u002Fskills\u002Fasset1__ar4mirez--refactoring",0,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard","https:\u002F\u002Fgithub.com\u002FJSGforever","2026-08-29 18:27:56",{"source":8,"skillName":5,"commands":48,"prompt":58,"zipAvailable":59},[49,52,55],{"tool":50,"command":51},"npx","npx skills add JSGforever\u002Fskillguard --skill refactoring",{"tool":53,"command":54},"bunx","bunx skills add JSGforever\u002Fskillguard --skill refactoring",{"tool":56,"command":57},"pnpm","pnpm dlx skills add JSGforever\u002Fskillguard --skill refactoring","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__ar4mirez--refactoring\u002FSKILL.md",true,[61],{"path":62,"resourceType":63,"resourceTypeDesc":64,"sizeBytes":65,"sourceHtmlUrl":66},"references\u002Fprocess.md","REFERENCE","参考文档",21303,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__ar4mirez--refactoring\u002Freferences\u002Fprocess.md",[68,95,105,132,150,170],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":72,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":31},"01M71HY2SNXBA9Q00WZDTZQ31Z","skillguard-codex-scanner","Hybrid deterministic+LLM agent-skill security scanner. Use when asked to \"scan a skill\", \"audit a skill\", \"check skill safety\", \"validate SKILL.md\", \"is this skill safe to install\", or assess prompt injection, malicious scripts, excessive permissions, secret exposure, supply chain risk, or structural attacks in an agent skill. Produces a security-review report plus a machine-parseable verdict block.","GPL-3.0","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fsrc\u002Fskillguard\u002Fstatic_scanner\u002Fskillguard-codex-scanner\u002FSKILL.md",[],[76,77,78,79,80,81,82,83,84,85,86,87,20,88,89,90,91,92,93,94],"scanner","skillguard codex scanner","skillguard","codex","chain","skill security","security-review","review report","structural","secret","prompt injection","security scanner","review","malicious","permissions","exposure","audit","scripts","safe",{"skillNo":96,"name":97,"nameZh":6,"description":98,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":31},"01M71HY0SPKTT3S27BC2HPAC5M","data-exfiltrator","Analyzes data files","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Fsmoke-one-skill\u002Fasset1__cisco-ai-defense--data-exfiltrator\u002FSKILL.md",[],[102,103,104],"data","data exfiltrator","files",{"skillNo":106,"name":107,"nameZh":6,"description":108,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":72,"licenseFileUrl":6,"sourceHtmlUrl":109,"categories":110,"keywords":111,"publishedAt":31},"01M71HXVS9EMN44BGDW215FZ72","real-time-collaboration-engine","Build real-time collaborative editing with WebSockets, OT\u002FCRDT conflict resolution, and presence awareness. Implements cursor tracking, optimistic updates, and offline sync. Use for collaborative editors, whiteboards, video editing. Activate on \"real-time collaboration\", \"WebSocket sync\", \"multiplayer editing\", \"CRDT\", \"presence awareness\". NOT for simple chat, request-response APIs, or single-user apps.","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__curiositech--real-time-collaboration-engine\u002FSKILL.md",[],[112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131],"time","real time collaboration engine","real time collaboration","collaboration","engine","real time","Video","reliability","video editing","performance","conflict resolution","presence","access","apps","updates","Bash","activate","optimizer","react","streaming",{"skillNo":133,"name":134,"nameZh":6,"description":135,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":72,"licenseFileUrl":6,"sourceHtmlUrl":136,"categories":137,"keywords":138,"publishedAt":31},"01M71HXP6CTY4KFN0QVMMN0V7J","react-performance-optimizer","Optimize React apps for 60fps performance. Implements memoization, virtualization, code splitting, bundle optimization. Use for slow renders, large lists, bundle bloat. Activate on \"React performance\", \"slow render\", \"useMemo\", \"bundle size\", \"virtualization\". NOT for backend optimization, non-React frameworks, or premature optimization.","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__curiositech--react-performance-optimizer\u002FSKILL.md",[],[121,139,129,130,140,141,142,143,144,145,112,146,147,125,127,22,128,131,148,149],"react performance optimizer","react performance","performance optimizer","app","nextjs","expert","re","render","2025","router","strategies",{"skillNo":151,"name":152,"nameZh":6,"description":153,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":72,"licenseFileUrl":6,"sourceHtmlUrl":154,"categories":155,"keywords":156,"publishedAt":31},"01M71HXH7QXSQB4QTDZ7SP7YXQ","llm-streaming-response-handler","Build production LLM streaming UIs with Server-Sent Events, real-time token display, cancellation, error recovery. Handles OpenAI\u002FAnthropic\u002FClaude streaming APIs. Use for chatbots, AI assistants, real-time text generation. Activate on \"LLM streaming\", \"SSE\", \"token stream\", \"chat UI\", \"real-time AI\". NOT for batch processing, non-streaming APIs, or WebSocket bidirectional chat.","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__curiositech--llm-streaming-response-handler\u002FSKILL.md",[],[157,131,158,159,160,161,121,112,162,163,164,127,128,129,165,130,166,167,168,169],"llm streaming response handler","handler","error","processing","retry","chat ui","error recovery","critical","batch","display","text","server","read",{"skillNo":171,"name":172,"nameZh":6,"description":173,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":72,"licenseFileUrl":6,"sourceHtmlUrl":174,"categories":175,"keywords":176,"publishedAt":31},"01M71HXCB0E1YRKYW1Y8T0Y106","github-actions-pipeline-builder","Build production CI\u002FCD pipelines with GitHub Actions. Implements matrix builds, caching, deployments, testing, security scanning. Use for automated testing, deployments, release workflows. Activate on \"GitHub Actions\", \"CI\u002FCD\", \"workflow\", \"deployment pipeline\", \"automated testing\". NOT for Jenkins\u002FCircleCI, manual deployments, or non-GitHub repositories.","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__curiositech--github-actions-pipeline-builder\u002FSKILL.md",[],[177,178,179,180,181,182,183,119,144,184,185,186,128,149,187,169,188,189,190,191],"github actions pipeline builder","actions","github actions","pipeline builder","github","builder","pipeline","testing","ci","workflows","run","release","write","edit","git"]