<< All versions
Skill v1.0.0
currentLLM-judged scan90/100omar-obando/qwen-orchestrator/refactoring
──Details
PublishedOctober 24, 2026 at 07:51 AM
Content Hashsha256:182ce75ec994b336...
Git SHA53355824c98e
──Files
Files (1 file, 3.7 KB)
SKILL.md3.7 KBactive
SKILL.md · 153 lines · 3.7 KB
version: "1.0.0" name: refactoring description: > Code refactoring skill focused on safe, incremental transformations that preserve behavior. Covers extract method, rename, introduce parameter, replace conditional with polymorphism, and other Fowler refactoring patterns. license: MIT
Refactoring Skill — Safe Code Transformations
This skill provides systematic refactoring guidance ensuring behavior preservation.
Core Principle
Refactoring changes the STRUCTURE without changing the BEHAVIOR.If behavior needs to change, that's a feature — do it separately.
Refactoring Catalog
Extract Method
typescript
// BEFOREfunction printOwing(invoice) {// Print bannerconsole.log('*******************');console.log('*** Customer Owes ***');console.log('*******************');// Calculate outstandinglet outstanding = 0;for (const o of invoice.orders) {outstanding += o.amount;}// Print detailsconsole.log(`name: ${invoice.customer}`);console.log(`amount: ${outstanding}`);}// AFTERfunction printOwing(invoice: Invoice): void {printBanner();const outstanding = calculateOutstanding(invoice.orders);printDetails(invoice.customer, outstanding);}
Replace Conditional with Polymorphism
typescript
// BEFOREfunction getDiscount(customerType: string): number {if (customerType === 'premium') return 0.2;if (customerType === 'gold') return 0.15;if (customerType === 'silver') return 0.1;return 0;}// AFTERabstract class Customer {abstract getDiscount(): number;}class PremiumCustomer extends Customer {getDiscount(): number {return 0.2;}}class GoldCustomer extends Customer {getDiscount(): number {return 0.15;}}
Introduce Parameter Object
typescript
// BEFOREfunction createReport(title: string,startDate: Date,endDate: Date,format: string,includeCharts: boolean,groupBy: string) { ... }// AFTERinterface ReportOptions {title: string;dateRange: { start: Date; end: Date };format: 'pdf' | 'html' | 'csv';includeCharts: boolean;groupBy: 'day' | 'week' | 'month';}function createReport(options: ReportOptions) { ... }
Safe Refactoring Protocol
- GREEN: Ensure all tests pass before starting
- SMALL: Make one refactoring at a time
- TEST: Run tests after EACH refactoring step
- COMMIT: Commit after each successful refactoring
- REVIEW: Code review the refactoring separately
Refactoring Checklist
Before refactoring:
- [ ] All existing tests pass
- [ ] Test coverage is adequate for the code being refactored
- [ ] No feature work mixed in
- [ ] Rollback plan exists (git commit before starting)
During refactoring:
- [ ] One transformation at a time
- [ ] Tests run after each step
- [ ] No behavior changes
- [ ] No dead code left behind
After refactoring:
- [ ] All tests still pass
- [ ] No new lint warnings
- [ ] Code is cleaner than before
- [ ] No functionality lost
Forbidden Actions
- NEVER mix refactoring with feature changes
- NEVER refactor without passing tests first
- NEVER skip running tests between steps
- NEVER leave dead code after refactoring
- NEVER change behavior during refactoring
When NOT to Use
Do NOT use this skill when:
- Writing new application logic (use domain-driven skill)
- Designing database schemas (use database-design skill)
- Writing API endpoint implementations (use api-design skill)
- Reviewing code for security issues (use code-review skill)
- Performing security audits (use security-auditor skill)
- Writing SQL queries (use sql-best-practices skill)
- Designing multi-page website layouts (use design-system skill)
- Reviewing git workflows (use git-workflow skill)