with one click
refactor
Analyze code for SOLID violations and suggest targeted improvements
Menu
Analyze code for SOLID violations and suggest targeted improvements
Audit Claude Code agents defined in .claude/agents/ for description specificity, model tier appropriateness, tools scoping, and system prompt quality. Detects dispatch ambiguity between agents, flags over-permissive tool grants, and checks for human-in-the-loop patterns that break programmatic orchestration. Use when onboarding to a project with existing agents, after adding new agents to a fleet, or when an orchestrator consistently selects the wrong agent.
Audit Claude Code hooks defined in settings.json files for validity, performance safety, and correctness. Resolves each command against the filesystem, checks exit-code strategy for blocking hooks, flags missing timeouts, and reviews interactive vs async patterns. Use when setting up hooks for the first time, debugging a hook that never fires or hangs the agent, or doing a periodic hooks hygiene pass.
Autonomous improvement loop: scan codebase metrics, scaffold experiment files, run agent-driven iterations until metric improves
Post-deploy monitoring: watch production after a deploy and alert on regressions
Restore context after /clear by summarizing recent work and project state
Launch and navigate the ccboard TUI/Web dashboard for Claude Code. Use when monitoring token usage, tracking costs, browsing sessions, or checking MCP server status across projects.
| name | refactor |
| description | Analyze code for SOLID violations and suggest targeted improvements |
| argument-hint | <file_or_module> [--pattern <name>] |
| effort | medium |
| when_to_use | Use when a module has SOLID violations, code smells, or duplication to address. |
| disable-model-invocation | true |
Analyze code for SOLID violations and suggest targeted improvements.
Identify refactoring opportunities based on:
Determine the refactoring scope from user input:
# Get file/directory stats
if [ -f "$TARGET" ]; then
wc -l "$TARGET"
echo "Single file analysis"
elif [ -d "$TARGET" ]; then
find "$TARGET" -type f \( -name "*.ts" -o -name "*.js" -o -name "*.py" \) | wc -l
echo "Directory analysis"
fi
Look for:
# Find large files
find . -name "*.{ts,js,py}" -exec wc -l {} + 2>/dev/null | sort -rn | head -10
# Functions with high line count (approximate)
grep -rn "function\|def \|fn " --include="*.{ts,js,py,rs}" . | head -20
Look for:
Look for:
Look for:
Look for:
new Service())# Duplication patterns
grep -rn --include="*.{ts,js,py}" . 2>/dev/null | \
awk -F: '{print $3}' | sort | uniq -c | sort -rn | head -10
# Long parameter lists (> 4 params)
grep -rn "function.*,.*,.*,.*," --include="*.{ts,js}" . 2>/dev/null | head -10
# Deep nesting (4+ levels)
grep -rn "^\s\{16,\}" --include="*.{ts,js,py}" . 2>/dev/null | head -10
For each issue found, assess:
Target: [file/directory] Lines Analyzed: [count]
| Principle | Status | Issues Found |
|---|---|---|
| Single Responsibility | 🟡 | 3 large classes |
| Open/Closed | 🟢 | OK |
| Liskov Substitution | 🟢 | OK |
| Interface Segregation | 🔴 | 2 fat interfaces |
| Dependency Inversion | 🟡 | 5 direct instantiations |
UserServiceViolation: Single Responsibility Current: 450 lines handling auth + profile + notifications Suggested:
UserService.ts (450 lines)
↓ Extract
AuthService.ts (~150 lines)
ProfileService.ts (~150 lines)
NotificationService.ts (~100 lines)
Risk: Medium (update imports) Tests Needed: Update dependency injection in tests
Location: src/handlers/payment.ts:45
Current:
switch (paymentType) {
case 'card': // 50 lines
case 'bank': // 50 lines
case 'crypto': // 50 lines
}
Suggested: Strategy pattern with PaymentProcessor interface
Risk: Low (isolated change)
| Smell | Location | Severity |
|---|---|---|
| Long Method | api.ts:calculateTotal (120 lines) | 🟠 High |
| Duplicate Code | utils/*.ts (3 similar blocks) | 🟡 Medium |
| Deep Nesting | parser.ts:parse (6 levels) | 🟡 Medium |
validateEmail() to shared utils (used in 4 places)processOrder()Before applying suggestions:
Analyze specific file:
/refactor src/services/user.ts
Analyze directory:
/refactor src/api/
Focus on specific principle:
/refactor --focus=srp src/services/
With complexity threshold:
/refactor --threshold=high
$ARGUMENTS