[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7BKWQBD1ECQN841XZXJB0JH":3,"skill-same:01M7BKWQBD1ECQN841XZXJB0JH":71},{"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":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":6,"ownerDescription":31,"updatedAt":32,"install":33,"resources":46},"01M7BKWQBD1ECQN841XZXJB0JH","code-refactor",null,"Systematic code refactoring based on Martin Fowler's methodology. Use when users ask to refactor code, improve code structure, reduce technical debt, clean up legacy code, eliminate code smells, or improve code maintainability. This skill guides through a phased approach with research, planning, and safe incremental implementation.","YYC-Cube\u002FYYC3-Knowledge-Base","YYC-Cube","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F235006543?v=4","01M79J2PH4SWD2X0825X6PN748","yyc3","01M79J2PHVK3F6ZBYT8K2SCZCW",1,"MIT","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-AI-应用工具\u002FYYC3-AI-应用工具-claude-howto\u002F03-skills\u002Frefactor\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: code-refactor\ndescription: Systematic code refactoring based on Martin Fowler's methodology. Use when users ask to refactor code, improve code structure, reduce technical debt, clean up legacy code, eliminate code smells, or improve code maintainability. This skill guides through a phased approach with research, planning, and safe incremental implementation.\n---\n\n# Code Refactoring Skill\n\nA systematic approach to refactoring code based on Martin Fowler's *Refactoring: Improving the Design of Existing Code* (2nd Edition). This skill emphasizes safe, incremental changes backed by tests.\n\n> \"Refactoring is the process of changing a software system in such a way that it does not alter the external behavior of the code yet improves its internal structure.\" — Martin Fowler\n\n## Core Principles\n\n1. **Behavior Preservation**: External behavior must remain unchanged\n2. **Small Steps**: Make tiny, testable changes\n3. **Test-Driven**: Tests are the safety net\n4. **Continuous**: Refactoring is ongoing, not a one-time event\n5. **Collaborative**: User approval required at each phase\n\n## Workflow Overview\n\n```\nPhase 1: Research & Analysis\n    ↓\nPhase 2: Test Coverage Assessment\n    ↓\nPhase 3: Code Smell Identification\n    ↓\nPhase 4: Refactoring Plan Creation\n    ↓\nPhase 5: Incremental Implementation\n    ↓\nPhase 6: Review & Iteration\n```\n\n---\n\n## Phase 1: Research & Analysis\n\n### Objectives\n- Understand the codebase structure and purpose\n- Identify the scope of refactoring\n- Gather context about business requirements\n\n### Questions to Ask User\nBefore starting, clarify:\n\n1. **Scope**: Which files\u002Fmodules\u002Ffunctions need refactoring?\n2. **Goals**: What problems are you trying to solve? (readability, performance, maintainability)\n3. **Constraints**: Are there any areas that should NOT be changed?\n4. **Timeline pressure**: Is this blocking other work?\n5. **Test status**: Do tests exist? Are they passing?\n\n### Actions\n- [ ] Read and understand the target code\n- [ ] Identify dependencies and integrations\n- [ ] Document current architecture\n- [ ] Note any existing technical debt markers (TODOs, FIXMEs)\n\n### Output\nPresent findings to user:\n- Code structure summary\n- Identified problem areas\n- Initial recommendations\n- **Request approval to proceed**\n\n---\n\n## Phase 2: Test Coverage Assessment\n\n### Why Tests Matter\n> \"Refactoring without tests is like driving without a seatbelt.\" — Martin Fowler\n\nTests are the **key enabler** of safe refactoring. Without them, you risk introducing bugs.\n\n### Assessment Steps\n\n1. **Check for existing tests**\n   ```bash\n   # Look for test files\n   find . -name \"*test*\" -o -name \"*spec*\" | head -20\n   ```\n\n2. **Run existing tests**\n   ```bash\n   # JavaScript\u002FTypeScript\n   npm test\n\n   # Python\n   pytest -v\n\n   # Java\n   mvn test\n   ```\n\n3. **Check coverage (if available)**\n   ```bash\n   # JavaScript\n   npm run test:coverage\n\n   # Python\n   pytest --cov=.\n   ```\n\n### Decision Point: Ask User\n\n**If tests exist and pass:**\n- Proceed to Phase 3\n\n**If tests are missing or incomplete:**\nPresent options:\n1. Write tests first (recommended)\n2. Add tests incrementally during refactoring\n3. Proceed without tests (risky - requires user acknowledgment)\n\n**If tests are failing:**\n- STOP. Fix failing tests before refactoring\n- Ask user: Should we fix tests first?\n\n### Test Writing Guidelines (if needed)\n\nFor each function being refactored, ensure tests cover:\n- Happy path (normal operation)\n- Edge cases (empty inputs, null, boundaries)\n- Error scenarios (invalid inputs, exceptions)\n\nUse the \"red-green-refactor\" cycle:\n1. Write failing test (red)\n2. Make it pass (green)\n3. Refactor\n\n---\n\n## Phase 3: Code Smell Identification\n\n### What Are Code Smells?\nSymptoms of deeper problems in code. They're not bugs, but indicators that the code could be improved.\n\n### Common Code Smells to Check\n\nSee [references\u002Fcode-smells.md](references\u002Fcode-smells.md) for the complete catalog.\n\n#### Quick Reference\n\n| Smell | Signs | Impact |\n|-------|-------|--------|\n| **Long Method** | Methods > 30-50 lines | Hard to understand, test, maintain |\n| **Duplicated Code** | Same logic in multiple places | Bug fixes needed in multiple places |\n| **Large Class** | Class with too many responsibilities | Violates Single Responsibility |\n| **Feature Envy** | Method uses another class's data more | Poor encapsulation |\n| **Primitive Obsession** | Overuse of primitives instead of objects | Missing domain concepts |\n| **Long Parameter List** | Methods with 4+ parameters | Hard to call correctly |\n| **Data Clumps** | Same data items appearing together | Missing abstraction |\n| **Switch Statements** | Complex switch\u002Fif-else chains | Hard to extend |\n| **Speculative Generality** | Code \"just in case\" | Unnecessary complexity |\n| **Dead Code** | Unused code | Confusion, maintenance burden |\n\n### Analysis Steps\n\n1. **Automated Analysis** (if scripts available)\n   ```bash\n   python scripts\u002Fdetect-smells.py \u003Cfile>\n   ```\n\n2. **Manual Review**\n   - Walk through code systematically\n   - Note each smell with location and severity\n   - Categorize by impact (Critical\u002FHigh\u002FMedium\u002FLow)\n\n3. **Prioritization**\n   Focus on smells that:\n   - Block current development\n   - Cause bugs or confusion\n   - Affect most-changed code paths\n\n### Output: Smell Report\n\nPresent to user:\n- List of identified smells with locations\n- Severity assessment for each\n- Recommended priority order\n- **Request approval on priorities**\n\n---\n\n## Phase 4: Refactoring Plan Creation\n\n### Selecting Refactorings\n\nFor each smell, select an appropriate refactoring from the catalog.\n\nSee [references\u002Frefactoring-catalog.md](references\u002Frefactoring-catalog.md) for the complete list.\n\n#### Smell-to-Refactoring Mapping\n\n| Code Smell | Recommended Refactoring(s) |\n|------------|---------------------------|\n| Long Method | Extract Method, Replace Temp with Query |\n| Duplicated Code | Extract Method, Pull Up Method, Form Template Method |\n| Large Class | Extract Class, Extract Subclass |\n| Feature Envy | Move Method, Move Field |\n| Primitive Obsession | Replace Primitive with Object, Replace Type Code with Class |\n| Long Parameter List | Introduce Parameter Object, Preserve Whole Object |\n| Data Clumps | Extract Class, Introduce Parameter Object |\n| Switch Statements | Replace Conditional with Polymorphism |\n| Speculative Generality | Collapse Hierarchy, Inline Class, Remove Dead Code |\n| Dead Code | Remove Dead Code |\n\n### Plan Structure\n\nUse the template at [templates\u002Frefactoring-plan.md](templates\u002Frefactoring-plan.md).\n\nFor each refactoring:\n1. **Target**: What code will change\n2. **Smell**: What problem it addresses\n3. **Refactoring**: Which technique to apply\n4. **Steps**: Detailed micro-steps\n5. **Risks**: What could go wrong\n6. **Rollback**: How to undo if needed\n\n### Phased Approach\n\n**CRITICAL**: Introduce refactoring gradually in phases.\n\n**Phase A: Quick Wins** (Low risk, high value)\n- Rename variables for clarity\n- Extract obvious duplicate code\n- Remove dead code\n\n**Phase B: Structural Improvements** (Medium risk)\n- Extract methods from long functions\n- Introduce parameter objects\n- Move methods to appropriate classes\n\n**Phase C: Architectural Changes** (Higher risk)\n- Replace conditionals with polymorphism\n- Extract classes\n- Introduce design patterns\n\n### Decision Point: Present Plan to User\n\nBefore implementation:\n- Show complete refactoring plan\n- Explain each phase and its risks\n- Get explicit approval for each phase\n- **Ask**: \"Should I proceed with Phase A?\"\n\n---\n\n## Phase 5: Incremental Implementation\n\n### The Golden Rule\n> \"Change → Test → Green? → Commit → Next step\"\n\n### Implementation Rhythm\n\nFor each refactoring step:\n\n1. **Pre-check**\n   - Tests are passing (green)\n   - Code compiles\n\n2. **Make ONE small change**\n   - Follow the mechanics from the catalog\n   - Keep changes minimal\n\n3. **Verify**\n   - Run tests immediately\n   - Check for compilation errors\n\n4. **If tests pass (green)**\n   - Commit with descriptive message\n   - Move to next step\n\n5. **If tests fail (red)**\n   - STOP immediately\n   - Undo the change\n   - Analyze what went wrong\n   - Ask user if unclear\n\n### Commit Strategy\n\nEach commit should be:\n- **Atomic**: One logical change\n- **Reversible**: Easy to revert\n- **Descriptive**: Clear commit message\n\nExample commit messages:\n```\nrefactor: Extract calculateTotal() from processOrder()\nrefactor: Rename 'x' to 'customerCount' for clarity\nrefactor: Remove unused validateOldFormat() method\n```\n\n### Progress Reporting\n\nAfter each sub-phase, report to user:\n- Changes made\n- Tests still passing?\n- Any issues encountered\n- **Ask**: \"Continue with next batch?\"\n\n---\n\n## Phase 6: Review & Iteration\n\n### Post-Refactoring Checklist\n\n- [ ] All tests passing\n- [ ] No new warnings\u002Ferrors\n- [ ] Code compiles successfully\n- [ ] Behavior unchanged (manual verification)\n- [ ] Documentation updated if needed\n- [ ] Commit history is clean\n\n### Metrics Comparison\n\nRun complexity analysis before and after:\n```bash\npython scripts\u002Fanalyze-complexity.py \u003Cfile>\n```\n\nPresent improvements:\n- Lines of code change\n- Cyclomatic complexity change\n- Maintainability index change\n\n### User Review\n\nPresent final results:\n- Summary of all changes\n- Before\u002Fafter code comparison\n- Metrics improvements\n- Remaining technical debt\n- **Ask**: \"Are you satisfied with these changes?\"\n\n### Next Steps\n\nDiscuss with user:\n- Additional smells to address?\n- Schedule follow-up refactoring?\n- Apply similar changes elsewhere?\n\n---\n\n## Important Guidelines\n\n### When to STOP and Ask\n\nAlways pause and consult user when:\n- Unsure about business logic\n- Change might affect external APIs\n- Test coverage is inadequate\n- Significant architectural decision needed\n- Risk level increases\n- You encounter unexpected complexity\n\n### Safety Rules\n\n1. **Never refactor without tests** (unless user explicitly acknowledges risk)\n2. **Never make big changes** - break into tiny steps\n3. **Never skip the test run** after each change\n4. **Never continue if tests fail** - fix or rollback first\n5. **Never assume** - when in doubt, ask\n\n### What NOT to Do\n\n- Don't combine refactoring with feature additions\n- Don't refactor during production emergencies\n- Don't refactor code you don't understand\n- Don't over-engineer - keep it simple\n- Don't refactor everything at once\n\n---\n\n## Quick Start Example\n\n### Scenario: Long Method with Duplication\n\n**Before:**\n```javascript\nfunction processOrder(order) {\n  \u002F\u002F 150 lines of code with:\n  \u002F\u002F - Duplicated validation logic\n  \u002F\u002F - Inline calculations\n  \u002F\u002F - Mixed responsibilities\n}\n```\n\n**Refactoring Steps:**\n\n1. **Ensure tests exist** for processOrder()\n2. **Extract** validation into validateOrder()\n3. **Test** - should pass\n4. **Extract** calculation into calculateOrderTotal()\n5. **Test** - should pass\n6. **Extract** notification into notifyCustomer()\n7. **Test** - should pass\n8. **Review** - processOrder() now orchestrates 3 clear functions\n\n**After:**\n```javascript\nfunction processOrder(order) {\n  validateOrder(order);\n  const total = calculateOrderTotal(order);\n  notifyCustomer(order, total);\n  return { order, total };\n}\n```\n\n---\n\n## References\n\n- [Code Smells Catalog](references\u002Fcode-smells.md) - Complete list of code smells\n- [Refactoring Catalog](references\u002Frefactoring-catalog.md) - Refactoring techniques\n- [Refactoring Plan Template](templates\u002Frefactoring-plan.md) - Planning template\n\n## Scripts\n\n- `scripts\u002Fanalyze-complexity.py` - Analyze code complexity metrics\n- `scripts\u002Fdetect-smells.py` - Automated smell detection\n\n## Version History\n\n- v1.0.0 (2025-01-15): Initial release with Fowler methodology, phased approach, user consultation points\n","# Code Refactoring Skill\n\nA systematic approach to refactoring code based on Martin Fowler's *Refactoring: Improving the Design of Existing Code* (2nd Edition). This skill emphasizes safe, incremental changes backed by tests.\n\n> \"Refactoring is the process of changing a software system in such a way that it does not alter the external behavior of the code yet improves its internal structure.\" — Martin Fowler\n\n## Core Principles\n\n1. **Behavior Preservation**: External behavior must remain unchanged\n2. **Small Steps**: Make tiny, testable changes\n3. **Test-Driven**: Tests are the safety net\n4. **Continuous**: Refactoring is ongoing, not a one-time event\n5. **Collaborative**: User approval required at each phase\n\n## Workflow Overview\n\n```\nPhase 1: Research & Analysis\n    ↓\nPhase 2: Test Coverage Assessment\n    ↓\nPhase 3: Code Smell Identification\n    ↓\nPhase 4: Refactoring Plan Creation\n    ↓\nPhase 5: Incremental Implementation\n    ↓\nPhase 6: Review & Iteration\n```\n\n---\n\n## Phase 1: Research & Analysis\n\n### Objectives\n- Understand the codebase structure and purpose\n- Identify the scope of refactoring\n- Gather context about business requirements\n\n### Questions to Ask User\nBefore starting, clarify:\n\n1. **Scope**: Which files\u002Fmodules\u002Ffunctions need refactoring?\n2. **Goals**: What problems are you trying to solve? (readability, performance, maintainability)\n3. **Constraints**: Are there any areas that should NOT be changed?\n4. **Timeline pressure**: Is this blocking other work?\n5. **Test status**: Do tests exist? Are they passing?\n\n### Actions\n- [ ] Read and understand the target code\n- [ ] Identify dependencies and integrations\n- [ ] Document current architecture\n- [ ] Note any existing technical debt markers (TODOs, FIXMEs)\n\n### Output\nPresent findings to user:\n- Code structure summary\n- Identified problem areas\n- Initial recommendations\n- **Request approval to proceed**\n\n---\n\n## Phase 2: Test Coverage Assessment\n\n### Why Tests Matter\n> \"Refactoring without tests is like driving without a seatbelt.\" — Martin Fowler\n\nTests are the **key enabler** of safe refactoring. Without them, you risk introducing bugs.\n\n### Assessment Steps\n\n1. **Check for existing tests**\n   ```bash\n   # Look for test files\n   find . -name \"*test*\" -o -name \"*spec*\" | head -20\n   ```\n\n2. **Run existing tests**\n   ```bash\n   # JavaScript\u002FTypeScript\n   npm test\n\n   # Python\n   pytest -v\n\n   # Java\n   mvn test\n   ```\n\n3. **Check coverage (if available)**\n   ```bash\n   # JavaScript\n   npm run test:coverage\n\n   # Python\n   pytest --cov=.\n   ```\n\n### Decision Point: Ask User\n\n**If tests exist and pass:**\n- Proceed to Phase 3\n\n**If tests are missing or incomplete:**\nPresent options:\n1. Write tests first (recommended)\n2. Add tests incrementally during refactoring\n3. Proceed without tests (risky - requires user acknowledgment)\n\n**If tests are failing:**\n- STOP. Fix failing tests before refactoring\n- Ask user: Should we fix tests first?\n\n### Test Writing Guidelines (if needed)\n\nFor each function being refactored, ensure tests cover:\n- Happy path (normal operation)\n- Edge cases (empty inputs, null, boundaries)\n- Error scenarios (invalid inputs, exceptions)\n\nUse the \"red-green-refactor\" cycle:\n1. Write failing test (red)\n2. Make it pass (green)\n3. Refactor\n\n---\n\n## Phase 3: Code Smell Identification\n\n### What Are Code Smells?\nSymptoms of deeper problems in code. They're not bugs, but indicators that the code could be improved.\n\n### Common Code Smells to Check\n\nSee [references\u002Fcode-smells.md](references\u002Fcode-smells.md) for the complete catalog.\n\n#### Quick Reference\n\n| Smell | Signs | Impact |\n|-------|-------|--------|\n| **Long Method** | Methods > 30-50 lines | Hard to understand, test, maintain |\n| **Duplicated Code** | Same logic in multiple places | Bug fixes needed in multiple places |\n| **Large Class** | Class with too many responsibilities | Violates Single Responsibility |\n| **Feature Envy** | Method uses another class's data more | Poor encapsulation |\n| **Primitive Obsession** | Overuse of primitives instead of objects | Missing domain concepts |\n| **Long Parameter List** | Methods with 4+ parameters | Hard to call correctly |\n| **Data Clumps** | Same data items appearing together | Missing abstraction |\n| **Switch Statements** | Complex switch\u002Fif-else chains | Hard to extend |\n| **Speculative Generality** | Code \"just in case\" | Unnecessary complexity |\n| **Dead Code** | Unused code | Confusion, maintenance burden |\n\n### Analysis Steps\n\n1. **Automated Analysis** (if scripts available)\n   ```bash\n   python scripts\u002Fdetect-smells.py \u003Cfile>\n   ```\n\n2. **Manual Review**\n   - Walk through code systematically\n   - Note each smell with location and severity\n   - Categorize by impact (Critical\u002FHigh\u002FMedium\u002FLow)\n\n3. **Prioritization**\n   Focus on smells that:\n   - Block current development\n   - Cause bugs or confusion\n   - Affect most-changed code paths\n\n### Output: Smell Report\n\nPresent to user:\n- List of identified smells with locations\n- Severity assessment for each\n- Recommended priority order\n- **Request approval on priorities**\n\n---\n\n## Phase 4: Refactoring Plan Creation\n\n### Selecting Refactorings\n\nFor each smell, select an appropriate refactoring from the catalog.\n\nSee [references\u002Frefactoring-catalog.md](references\u002Frefactoring-catalog.md) for the complete list.\n\n#### Smell-to-Refactoring Mapping\n\n| Code Smell | Recommended Refactoring(s) |\n|------------|---------------------------|\n| Long Method | Extract Method, Replace Temp with Query |\n| Duplicated Code | Extract Method, Pull Up Method, Form Template Method |\n| Large Class | Extract Class, Extract Subclass |\n| Feature Envy | Move Method, Move Field |\n| Primitive Obsession | Replace Primitive with Object, Replace Type Code with Class |\n| Long Parameter List | Introduce Parameter Object, Preserve Whole Object |\n| Data Clumps | Extract Class, Introduce Parameter Object |\n| Switch Statements | Replace Conditional with Polymorphism |\n| Speculative Generality | Collapse Hierarchy, Inline Class, Remove Dead Code |\n| Dead Code | Remove Dead Code |\n\n### Plan Structure\n\nUse the template at [templates\u002Frefactoring-plan.md](templates\u002Frefactoring-plan.md).\n\nFor each refactoring:\n1. **Target**: What code will change\n2. **Smell**: What problem it addresses\n3. **Refactoring**: Which technique to apply\n4. **Steps**: Detailed micro-steps\n5. **Risks**: What could go wrong\n6. **Rollback**: How to undo if needed\n\n### Phased Approach\n\n**CRITICAL**: Introduce refactoring gradually in phases.\n\n**Phase A: Quick Wins** (Low risk, high value)\n- Rename variables for clarity\n- Extract obvious duplicate code\n- Remove dead code\n\n**Phase B: Structural Improvements** (Medium risk)\n- Extract methods from long functions\n- Introduce parameter objects\n- Move methods to appropriate classes\n\n**Phase C: Architectural Changes** (Higher risk)\n- Replace conditionals with polymorphism\n- Extract classes\n- Introduce design patterns\n\n### Decision Point: Present Plan to User\n\nBefore implementation:\n- Show complete refactoring plan\n- Explain each phase and its risks\n- Get explicit approval for each phase\n- **Ask**: \"Should I proceed with Phase A?\"\n\n---\n\n## Phase 5: Incremental Implementation\n\n### The Golden Rule\n> \"Change → Test → Green? → Commit → Next step\"\n\n### Implementation Rhythm\n\nFor each refactoring step:\n\n1. **Pre-check**\n   - Tests are passing (green)\n   - Code compiles\n\n2. **Make ONE small change**\n   - Follow the mechanics from the catalog\n   - Keep changes minimal\n\n3. **Verify**\n   - Run tests immediately\n   - Check for compilation errors\n\n4. **If tests pass (green)**\n   - Commit with descriptive message\n   - Move to next step\n\n5. **If tests fail (red)**\n   - STOP immediately\n   - Undo the change\n   - Analyze what went wrong\n   - Ask user if unclear\n\n### Commit Strategy\n\nEach commit should be:\n- **Atomic**: One logical change\n- **Reversible**: Easy to revert\n- **Descriptive**: Clear commit message\n\nExample commit messages:\n```\nrefactor: Extract calculateTotal() from processOrder()\nrefactor: Rename 'x' to 'customerCount' for clarity\nrefactor: Remove unused validateOldFormat() method\n```\n\n### Progress Reporting\n\nAfter each sub-phase, report to user:\n- Changes made\n- Tests still passing?\n- Any issues encountered\n- **Ask**: \"Continue with next batch?\"\n\n---\n\n## Phase 6: Review & Iteration\n\n### Post-Refactoring Checklist\n\n- [ ] All tests passing\n- [ ] No new warnings\u002Ferrors\n- [ ] Code compiles successfully\n- [ ] Behavior unchanged (manual verification)\n- [ ] Documentation updated if needed\n- [ ] Commit history is clean\n\n### Metrics Comparison\n\nRun complexity analysis before and after:\n```bash\npython scripts\u002Fanalyze-complexity.py \u003Cfile>\n```\n\nPresent improvements:\n- Lines of code change\n- Cyclomatic complexity change\n- Maintainability index change\n\n### User Review\n\nPresent final results:\n- Summary of all changes\n- Before\u002Fafter code comparison\n- Metrics improvements\n- Remaining technical debt\n- **Ask**: \"Are you satisfied with these changes?\"\n\n### Next Steps\n\nDiscuss with user:\n- Additional smells to address?\n- Schedule follow-up refactoring?\n- Apply similar changes elsewhere?\n\n---\n\n## Important Guidelines\n\n### When to STOP and Ask\n\nAlways pause and consult user when:\n- Unsure about business logic\n- Change might affect external APIs\n- Test coverage is inadequate\n- Significant architectural decision needed\n- Risk level increases\n- You encounter unexpected complexity\n\n### Safety Rules\n\n1. **Never refactor without tests** (unless user explicitly acknowledges risk)\n2. **Never make big changes** - break into tiny steps\n3. **Never skip the test run** after each change\n4. **Never continue if tests fail** - fix or rollback first\n5. **Never assume** - when in doubt, ask\n\n### What NOT to Do\n\n- Don't combine refactoring with feature additions\n- Don't refactor during production emergencies\n- Don't refactor code you don't understand\n- Don't over-engineer - keep it simple\n- Don't refactor everything at once\n\n---\n\n## Quick Start Example\n\n### Scenario: Long Method with Duplication\n\n**Before:**\n```javascript\nfunction processOrder(order) {\n  \u002F\u002F 150 lines of code with:\n  \u002F\u002F - Duplicated validation logic\n  \u002F\u002F - Inline calculations\n  \u002F\u002F - Mixed responsibilities\n}\n```\n\n**Refactoring Steps:**\n\n1. **Ensure tests exist** for processOrder()\n2. **Extract** validation into validateOrder()\n3. **Test** - should pass\n4. **Extract** calculation into calculateOrderTotal()\n5. **Test** - should pass\n6. **Extract** notification into notifyCustomer()\n7. **Test** - should pass\n8. **Review** - processOrder() now orchestrates 3 clear functions\n\n**After:**\n```javascript\nfunction processOrder(order) {\n  validateOrder(order);\n  const total = calculateOrderTotal(order);\n  notifyCustomer(order, total);\n  return { order, total };\n}\n```\n\n---\n\n## References\n\n- [Code Smells Catalog](references\u002Fcode-smells.md) - Complete list of code smells\n- [Refactoring Catalog](references\u002Frefactoring-catalog.md) - Refactoring techniques\n- [Refactoring Plan Template](templates\u002Frefactoring-plan.md) - Planning template\n\n## Scripts\n\n- `scripts\u002Fanalyze-complexity.py` - Analyze code complexity metrics\n- `scripts\u002Fdetect-smells.py` - Automated smell detection\n\n## Version History\n\n- v1.0.0 (2025-01-15): Initial release with Fowler methodology, phased approach, user consultation points\n",{"name":5,"description":7},"main","87afe6ce96220accf50a345dea46784c8c9f210e","YYC3-AI-应用工具\u002FYYC3-AI-应用工具-claude-howto\u002F03-skills\u002Frefactor",0,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base","https:\u002F\u002Fkb.yyc3.top\u002F","https:\u002F\u002Fgithub.com\u002FYYC-Cube","万象归元于云枢 | 深栈智启新纪元","2026-11-10 10:37:32",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill code-refactor",{"tool":39,"command":40},"bunx","bunx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill code-refactor",{"tool":42,"command":43},"pnpm","pnpm dlx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill code-refactor","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-AI-应用工具\u002FYYC3-AI-应用工具-claude-howto\u002F03-skills\u002Frefactor\u002FSKILL.md",true,[47,53,57,63,67],{"path":48,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":51,"sourceHtmlUrl":52},"references\u002Fcode-smells.md","REFERENCE","参考文档",13598,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-AI-应用工具\u002FYYC3-AI-应用工具-claude-howto\u002F03-skills\u002Frefactor\u002Freferences\u002Fcode-smells.md",{"path":54,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":55,"sourceHtmlUrl":56},"references\u002Frefactoring-catalog.md",24063,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-AI-应用工具\u002FYYC3-AI-应用工具-claude-howto\u002F03-skills\u002Frefactor\u002Freferences\u002Frefactoring-catalog.md",{"path":58,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":61,"sourceHtmlUrl":62},"scripts\u002Fanalyze-complexity.py","SCRIPT","脚本",20183,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-AI-应用工具\u002FYYC3-AI-应用工具-claude-howto\u002F03-skills\u002Frefactor\u002Fscripts\u002Fanalyze-complexity.py",{"path":64,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":65,"sourceHtmlUrl":66},"scripts\u002Fdetect-smells.py",28738,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-AI-应用工具\u002FYYC3-AI-应用工具-claude-howto\u002F03-skills\u002Frefactor\u002Fscripts\u002Fdetect-smells.py",{"path":68,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":69,"sourceHtmlUrl":70},"templates\u002Frefactoring-plan.md",6388,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-AI-应用工具\u002FYYC3-AI-应用工具-claude-howto\u002F03-skills\u002Frefactor\u002Ftemplates\u002Frefactoring-plan.md",[72,79,86,93,100,107],{"skillNo":73,"name":74,"nameZh":6,"description":75,"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":19},"01M7CTDWHERCXPQCP0K03A86AS","vercel-sandbox","Run agent-browser + Chrome inside Vercel Sandbox microVMs for browser automation from any Vercel-deployed app. Use when the user needs browser automation in a Vercel app (Next.js, SvelteKit, Nuxt, Remix, Astro, etc.), wants to run headless Chrome without binary size limits, needs persistent browser sessions across commands, or wants ephemeral isolated browser environments. Triggers include \"Vercel Sandbox browser\", \"microVM Chrome\", \"agent-browser in sandbox\", \"browser automation on Vercel\", or any task requiring Chrome in a Vercel Sandbox.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fvercel-sandbox\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":19},"01M7CTD8D2BNJY54S65M47HEJA","slack","Interact with Slack workspaces using browser automation. Use when the user needs to check unread channels, navigate Slack, send messages, extract data, find information, search conversations, or automate any Slack task. Triggers include \"check my Slack\", \"what channels have unreads\", \"send a message to\", \"search Slack for\", \"extract from Slack\", \"find who said\", or any task requiring programmatic Slack interaction.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fslack\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":19},"01M7CTCSSB8ZP3Q58C3YZDZK1W","electron","Automate Electron desktop apps (VS Code, Slack, Discord, Figma, Notion, Spotify, etc.) using agent-browser via Chrome DevTools Protocol. Use when the user needs to interact with an Electron app, automate a desktop app, connect to a running app, control a native app, or test an Electron application. Triggers include \"automate Slack app\", \"control VS Code\", \"interact with Discord app\", \"test this Electron app\", \"connect to desktop app\", or any task requiring automation of a native Electron application.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Felectron\u002FSKILL.md",[],[],{"skillNo":94,"name":95,"nameZh":6,"description":96,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":19},"01M7CTCBJY76688V4DCZGWFHGQ","dogfood","Systematically explore and test a web application to find bugs, UX issues, and other problems. Use when asked to \"dogfood\", \"QA\", \"exploratory test\", \"find issues\", \"bug hunt\", \"test this app\u002Fsite\u002Fplatform\", or review the quality of a web application. Produces a structured report with full reproduction evidence -- step-by-step screenshots, repro videos, and detailed repro steps for every issue -- so findings can be handed directly to the responsible teams.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fdogfood\u002FSKILL.md",[],[],{"skillNo":101,"name":102,"nameZh":6,"description":103,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":104,"categories":105,"keywords":106,"publishedAt":19},"01M7CTC4H0FFGVEAQR9PA4GA1A","agent-browser","Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to \"open a website\", \"fill out a form\", \"click a button\", \"take a screenshot\", \"scrape data from a page\", \"test this web app\", \"login to a site\", \"automate browser actions\", or any task requiring programmatic web interaction.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fagent-browser\u002FSKILL.md",[],[],{"skillNo":108,"name":109,"nameZh":6,"description":110,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":111,"categories":112,"keywords":113,"publishedAt":19},"01M7CTBKVFYBG78FDSABSDJTTQ","shadcn","Manages shadcn components and projects — adding, searching, fixing, debugging, styling, and composing UI, including chat interfaces. Provides project context, component docs, and usage examples. Applies when working with shadcn\u002Fui, component registries, presets, --preset codes, or any project with a components.json file. Also triggers for \"shadcn init\", \"create an app with --preset\", \"switch to --preset\", and for building a design system or applying a DESIGN.md or brand spec to shadcn\u002Fui.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-UI-界面组件\u002FYYC3-UI-界面组件-ui\u002Fskills\u002Fshadcn\u002FSKILL.md",[],[]]