refactoring-advisor
Provides refactoring recommendations and step-by-step improvement plans. Use when planning refactoring, improving code structure, or reducing technical debt.
What this skill does
# Refactoring Advisor
## Quick Start
Plan refactoring based on identified issues:
1. Identify the problem (code smell, complexity)
2. Select appropriate refactoring pattern
3. Create step-by-step plan
4. Ensure tests exist
5. Refactor incrementally
## Instructions
### Step 1: Assess Current State
Analyze the code:
- What is the problem? (long method, god class, etc.)
- What is the impact? (maintainability, testability)
- What is the risk? (how much code depends on it)
### Step 2: Select Refactoring Strategy
| Problem | Strategy | Risk |
|---------|----------|------|
| Long Method | Extract Method | Low |
| God Class | Extract Class | Medium |
| Duplicated Code | Extract Method | Low |
| Switch Statement | Replace with Polymorphism | High |
| Long Parameter List | Introduce Parameter Object | Medium |
### Step 3: Create Refactoring Plan
**Template:**
```markdown
## Refactoring: [Name]
**Problem:** [Description]
**Goal:** [Desired outcome]
**Risk Level:** [Low/Medium/High]
### Prerequisites
- [ ] Tests exist and pass
- [ ] Code is committed
- [ ] Dependencies identified
### Steps
1. [First small change]
2. [Run tests]
3. [Next small change]
4. [Run tests]
...
### Validation
- [ ] All tests pass
- [ ] No functionality changed
- [ ] Code is cleaner
```
### Step 4: Execute Incrementally
**Golden Rule:** Make the change easy, then make the easy change
1. Make one small change
2. Run tests
3. Commit
4. Repeat
## Refactoring Examples
### Extract Method
**Before:**
```javascript
function printOwing(invoice) {
let outstanding = 0;
console.log("***********************");
console.log("**** Customer Owes ****");
console.log("***********************");
for (const o of invoice.orders) {
outstanding += o.amount;
}
console.log(`name: ${invoice.customer}`);
console.log(`amount: ${outstanding}`);
}
```
**Plan:**
1. Extract banner printing
2. Run tests
3. Extract outstanding calculation
4. Run tests
5. Extract details printing
6. Run tests
**After:**
```javascript
function printOwing(invoice) {
printBanner();
const outstanding = calculateOutstanding(invoice);
printDetails(invoice, outstanding);
}
function printBanner() {
console.log("***********************");
console.log("**** Customer Owes ****");
console.log("***********************");
}
function calculateOutstanding(invoice) {
return invoice.orders.reduce((sum, o) => sum + o.amount, 0);
}
function printDetails(invoice, outstanding) {
console.log(`name: ${invoice.customer}`);
console.log(`amount: ${outstanding}`);
}
```
### Extract Class
**Before:**
```javascript
class Person {
name;
officeAreaCode;
officeNumber;
getTelephoneNumber() {
return `(${this.officeAreaCode}) ${this.officeNumber}`;
}
}
```
**Plan:**
1. Create TelephoneNumber class
2. Move areaCode field
3. Run tests
4. Move number field
5. Run tests
6. Move getTelephoneNumber method
7. Run tests
8. Update Person to use TelephoneNumber
9. Run tests
**After:**
```javascript
class TelephoneNumber {
areaCode;
number;
toString() {
return `(${this.areaCode}) ${this.number}`;
}
}
class Person {
name;
telephoneNumber;
getTelephoneNumber() {
return this.telephoneNumber.toString();
}
}
```
## Safety Checklist
Before refactoring:
- [ ] Tests exist and pass
- [ ] Code is in version control
- [ ] You understand what the code does
- [ ] You have time to complete the refactoring
During refactoring:
- [ ] Make small changes
- [ ] Run tests after each change
- [ ] Commit working states
- [ ] Don't add features while refactoring
After refactoring:
- [ ] All tests pass
- [ ] Code review completed
- [ ] Documentation updated
- [ ] No functionality changed
Related in Code Review
gstack
IncludedFast headless browser for QA testing and site dogfooding. Navigate pages, interact with elements, verify state, diff before/after, take annotated screenshots, test responsive layouts, forms, uploads, dialogs, and capture bug evidence. Use when asked to open or test a site, verify a deployment, dogfood a user flow, or file a bug with screenshots. (gstack)
startup-due-diligence
IncludedLegal due diligence review for seed-stage and Series A startups (US, Delaware C-Corp focus). Supports both investor and founder perspectives. Capabilities include: (1) Interactive document review and issue spotting; (2) Document request list generation; (3) Cap table and SAFE/convertible note analysis; (4) Red flag identification with severity ratings; (5) Diligence report generation. TRIGGERS: due diligence, DD, startup investment, cap table review, Series A, seed round, investor diligence, legal review startup, SAFE analysis, convertible note, 409A, founder vesting.
interview-master
IncludedThis skill should be used when the user asks to "generate interview questions", "prepare for interview", "optimize resume", "conduct mock interview", "analyze git commits for resume", "generate resume from code", "review my resume", or mentions interview preparation, career assistance, or extracting project experience from git history. Provides comprehensive interview and career development guidance for both job seekers and interviewers.
fix-issue
IncludedFixes GitHub issues using parallel analysis agents for root cause investigation, code exploration, and regression detection. Reads issue context from gh CLI, searches codebase and memory for related patterns, generates a fix with tests, and links the resolution back to the issue via PR. Includes prevention analysis to avoid recurrence. Use when debugging errors, resolving regressions, fixing bugs, or triaging issues.
sf-apex
IncludedGenerates and reviews Salesforce Apex code with 150-point scoring. TRIGGER when: user writes, reviews, or fixes Apex classes, triggers, test classes, batch/queueable/schedulable jobs, or touches .cls/.trigger files. DO NOT TRIGGER when: LWC JavaScript (use sf-lwc), Flow XML (use sf-flow), SOQL-only queries (use sf-soql), or non-Salesforce code.
swift-development
IncludedComprehensive Swift development for building, testing, and deploying iOS/macOS applications. Use when Claude needs to: (1) Build Swift packages or Xcode projects from command line, (2) Run tests with XCTest or Swift Testing framework, (3) Manage iOS simulators with simctl, (4) Handle code signing, provisioning profiles, and app distribution, (5) Format or lint Swift code with SwiftFormat/SwiftLint, (6) Work with Swift Package Manager (SPM), (7) Implement Swift 6 concurrency patterns (async/await, actors, Sendable), (8) Create SwiftUI views with MVVM architecture, (9) Set up Core Data or SwiftData persistence, or any other Swift/iOS/macOS development tasks.