2025-06-24 21:24:14 +02:00
|
|
|
|
# /improve - Enhance code quality, performance and architecture
|
|
|
|
|
|
|
|
|
|
|
|
## Legend
|
|
|
|
|
|
| Symbol | Meaning | | Abbrev | Meaning |
|
|
|
|
|
|
|--------|---------|---|--------|---------|
|
|
|
|
|
|
| → | leads to | | cfg | configuration |
|
|
|
|
|
|
| & | and/with | | impl | implementation |
|
|
|
|
|
|
| w/ | with | | perf | performance |
|
|
|
|
|
|
| @ | at/located | | ops | operations |
|
|
|
|
|
|
| > | greater than | | val | validation |
|
|
|
|
|
|
| ∀ | for all/every | | req | requirements |
|
|
|
|
|
|
| ∃ | exists/there is | | deps | dependencies |
|
|
|
|
|
|
| ∴ | therefore | | env | environment |
|
|
|
|
|
|
| ∵ | because | | db | database |
|
|
|
|
|
|
| ≡ | equivalent | | api | interface |
|
|
|
|
|
|
| ≈ | approximately | | docs | documentation |
|
|
|
|
|
|
| 📁 | directory/path | | std | standard |
|
|
|
|
|
|
| 🔢 | number/count | | def | default |
|
|
|
|
|
|
| 📝 | text/string | | ctx | context |
|
|
|
|
|
|
| ⚙ | setting/config | | err | error |
|
|
|
|
|
|
| 🎛 | control/flags | | exec | execution |
|
|
|
|
|
|
| 🔧 | configuration | | qual | quality |
|
|
|
|
|
|
| 📋 | group/category | | rec | recovery |
|
|
|
|
|
|
| 🚨 | critical/urgent | | sev | severity |
|
|
|
|
|
|
| ⚠ | warning/caution | | resp | response |
|
|
|
|
|
|
| 🔄 | retry/recovery | | esc | escalation |
|
|
|
|
|
|
| ✅ | success/fixed | | tok | token |
|
|
|
|
|
|
| ❌ | failure/error | | opt | optimization |
|
|
|
|
|
|
| ℹ | information | | UX | user experience |
|
|
|
|
|
|
| ⚡ | fast/quick | | UI | user interface |
|
|
|
|
|
|
| 🐌 | slow/delayed | | C | critical |
|
|
|
|
|
|
| ✨ | complete/done | | H | high |
|
|
|
|
|
|
| 📖 | read operation | | M | medium |
|
|
|
|
|
|
| ✏ | edit operation | | L | low |
|
|
|
|
|
|
| 🗑 | delete operation | | |
|
|
|
|
|
|
|
|
|
|
|
|
## Purpose
|
|
|
|
|
|
Enhance code quality, performance, and architecture for systems specified in $ARGUMENTS using systematic improvement methodologies.
|
|
|
|
|
|
|
|
|
|
|
|
## Syntax
|
|
|
|
|
|
`/improve [flags] [target]`
|
|
|
|
|
|
|
|
|
|
|
|
## Universal Flags
|
|
|
|
|
|
--plan: "Show execution plan before running"
|
|
|
|
|
|
--uc: "UltraCompressed mode (~70% token reduction)"
|
|
|
|
|
|
--ultracompressed: "Alias for --uc"
|
|
|
|
|
|
--think: "Multi-file analysis w/ context (4K tokens)"
|
|
|
|
|
|
--think-hard: "Deep architectural analysis (10K tokens)"
|
|
|
|
|
|
--ultrathink: "Critical system redesign (32K tokens)"
|
|
|
|
|
|
--c7: "Enable Context7→library documentation lookup"
|
|
|
|
|
|
--seq: "Enable Sequential→complex analysis & thinking"
|
|
|
|
|
|
--magic: "Enable Magic→UI component generation"
|
|
|
|
|
|
--pup: "Enable Puppeteer→browser automation & testing"
|
|
|
|
|
|
--all-mcp: "Enable all MCP servers"
|
|
|
|
|
|
--no-mcp: "Disable all MCP servers (native tools only)"
|
|
|
|
|
|
--no-c7: "Disable Context7 specifically"
|
|
|
|
|
|
--no-seq: "Disable Sequential thinking specifically"
|
|
|
|
|
|
--no-magic: "Disable Magic UI builder specifically"
|
|
|
|
|
|
--no-pup: "Disable Puppeteer specifically"
|
|
|
|
|
|
|
|
|
|
|
|
## Command-Specific Flags
|
|
|
|
|
|
|
|
|
|
|
|
**Improvement Focus:**
|
|
|
|
|
|
- `--quality`: Code structure, maintainability, and clean code principles
|
|
|
|
|
|
- `--performance`: System performance, bottlenecks, and optimization
|
|
|
|
|
|
- `--security`: Security improvements and vulnerability fixes
|
|
|
|
|
|
- `--architecture`: System design and architectural improvements
|
|
|
|
|
|
- `--ux`: User experience and interface improvements
|
|
|
|
|
|
|
|
|
|
|
|
**Quality Enhancements:**
|
|
|
|
|
|
- `--solid`: Apply SOLID principles systematically
|
|
|
|
|
|
- `--refactor`: Clean code refactoring with modern patterns
|
|
|
|
|
|
- `--metrics`: Generate comprehensive quality metrics
|
|
|
|
|
|
- `--coverage`: Improve test coverage and quality
|
|
|
|
|
|
|
|
|
|
|
|
**Performance Optimization:**
|
|
|
|
|
|
- `--profile`: Performance profiling and bottleneck analysis
|
|
|
|
|
|
- `--cache`: Implement caching strategies
|
|
|
|
|
|
- `--async`: Optimize for asynchronous operations
|
|
|
|
|
|
- `--database`: Database query and schema optimization
|
|
|
|
|
|
|
|
|
|
|
|
**Execution Modes:**
|
|
|
|
|
|
- `--iterate`: Iterative improvement until threshold reached
|
|
|
|
|
|
- `--threshold [percent]`: Set target improvement percentage (default 85%)
|
|
|
|
|
|
- `--watch`: Continuous improvement monitoring
|
|
|
|
|
|
- `--interactive`: Guided improvement with user choices
|
|
|
|
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
- `/improve --quality --solid --metrics` → Code quality with SOLID principles
|
|
|
|
|
|
- `/improve --performance --profile --cache` → Performance optimization with caching
|
|
|
|
|
|
- `/improve --iterate --threshold 90 --interactive` → Iterative improvement to 90%
|
|
|
|
|
|
- `/improve --security --architecture --seq` → Security and architecture analysis
|
|
|
|
|
|
- `/improve --ux --performance --watch` → UX and performance with monitoring
|
2025-06-22 14:02:49 +02:00
|
|
|
|
|
|
|
|
|
|
## Code Quality Mode (--quality)
|
|
|
|
|
|
|
2025-06-24 21:24:14 +02:00
|
|
|
|
**SOLID Principles Application:**
|
|
|
|
|
|
- **Single Responsibility**: One class, one clear purpose
|
|
|
|
|
|
- **Open/Closed**: Extensible without modification
|
2025-06-22 14:02:49 +02:00
|
|
|
|
- **Liskov Substitution**: Subtypes must be substitutable
|
|
|
|
|
|
- **Interface Segregation**: Specific over general interfaces
|
2025-06-24 21:24:14 +02:00
|
|
|
|
- **Dependency Inversion**: Depend on abstractions, not concretions
|
2025-06-22 14:02:49 +02:00
|
|
|
|
|
2025-06-24 21:24:14 +02:00
|
|
|
|
**Refactoring Techniques:**
|
|
|
|
|
|
- Extract methods and classes for complex logic
|
2025-06-22 14:02:49 +02:00
|
|
|
|
- Inline unnecessary abstractions
|
2025-06-24 21:24:14 +02:00
|
|
|
|
- Rename variables and functions for clarity
|
2025-06-22 14:02:49 +02:00
|
|
|
|
- Move code to appropriate modules
|
|
|
|
|
|
- Remove duplication (DRY principle)
|
|
|
|
|
|
- Simplify conditionals and loops
|
|
|
|
|
|
- Reduce coupling, increase cohesion
|
|
|
|
|
|
|
2025-06-24 21:24:14 +02:00
|
|
|
|
**Quality Metrics Tracking:**
|
2025-06-22 14:02:49 +02:00
|
|
|
|
- Cyclomatic complexity (target < 5)
|
2025-06-24 21:24:14 +02:00
|
|
|
|
- Method/function length (target < 20 lines)
|
|
|
|
|
|
- Class cohesion and coupling metrics
|
2025-06-22 14:02:49 +02:00
|
|
|
|
- Code duplication percentage
|
|
|
|
|
|
- Test coverage (target > 80%)
|
|
|
|
|
|
- Documentation completeness
|
2025-06-24 21:24:14 +02:00
|
|
|
|
- Technical debt assessment
|
2025-06-22 14:02:49 +02:00
|
|
|
|
|
2025-06-24 21:24:14 +02:00
|
|
|
|
**Clean Code Principles:**
|
2025-06-22 14:02:49 +02:00
|
|
|
|
- Meaningful, self-documenting names
|
2025-06-24 21:24:14 +02:00
|
|
|
|
- Functions that do one thing well
|
|
|
|
|
|
- Consistent coding style and formatting
|
|
|
|
|
|
- Proper error handling and logging
|
|
|
|
|
|
- Elimination of magic numbers and strings
|
|
|
|
|
|
- Comments that explain why, not what
|
2025-06-22 14:02:49 +02:00
|
|
|
|
|
|
|
|
|
|
## Performance Mode (--performance)
|
|
|
|
|
|
|
2025-06-24 21:24:14 +02:00
|
|
|
|
**Code Optimization:**
|
2025-06-22 14:02:49 +02:00
|
|
|
|
- Algorithm complexity reduction (O(n²) → O(n log n))
|
2025-06-24 21:24:14 +02:00
|
|
|
|
- Efficient data structures selection
|
2025-06-22 14:02:49 +02:00
|
|
|
|
- Caching frequently accessed data
|
2025-06-24 21:24:14 +02:00
|
|
|
|
- Lazy loading and pagination strategies
|
|
|
|
|
|
- Asynchronous and parallel processing
|
2025-06-22 14:02:49 +02:00
|
|
|
|
- Memory usage optimization
|
|
|
|
|
|
|
2025-06-24 21:24:14 +02:00
|
|
|
|
**Database Optimization:**
|
|
|
|
|
|
- Query optimization and proper indexing
|
2025-06-22 14:02:49 +02:00
|
|
|
|
- N+1 query elimination
|
2025-06-24 21:24:14 +02:00
|
|
|
|
- Connection pooling implementation
|
|
|
|
|
|
- Batch operations for bulk updates
|
|
|
|
|
|
- Strategic denormalization
|
2025-06-22 14:02:49 +02:00
|
|
|
|
- Query result caching
|
|
|
|
|
|
|
2025-06-24 21:24:14 +02:00
|
|
|
|
**Frontend Optimization:**
|
|
|
|
|
|
- Bundle size reduction and tree shaking
|
2025-06-22 14:02:49 +02:00
|
|
|
|
- Code splitting and lazy loading
|
|
|
|
|
|
- Image and asset optimization
|
|
|
|
|
|
- Render performance improvements
|
2025-06-24 21:24:14 +02:00
|
|
|
|
- Service worker caching strategies
|
|
|
|
|
|
- React/Vue re-render optimization
|
2025-06-22 14:02:49 +02:00
|
|
|
|
|
2025-06-24 21:24:14 +02:00
|
|
|
|
**System Optimization:**
|
2025-06-22 14:02:49 +02:00
|
|
|
|
- Load balancing strategies
|
2025-06-24 21:24:14 +02:00
|
|
|
|
- CDN implementation and optimization
|
2025-06-22 14:02:49 +02:00
|
|
|
|
- Compression (gzip/brotli)
|
2025-06-24 21:24:14 +02:00
|
|
|
|
- HTTP/2 and proper caching headers
|
|
|
|
|
|
- Resource pooling and connection management
|
|
|
|
|
|
- Microservice communication optimization
|
2025-06-22 14:02:49 +02:00
|
|
|
|
|
|
|
|
|
|
## Iterative Mode (--iterate)
|
|
|
|
|
|
|
2025-06-24 21:24:14 +02:00
|
|
|
|
**Improvement Process:**
|
|
|
|
|
|
|
|
|
|
|
|
**1. Baseline Measurement:**
|
|
|
|
|
|
- Current performance metrics
|
|
|
|
|
|
- Code quality scores
|
|
|
|
|
|
- Test coverage percentage
|
|
|
|
|
|
- User experience metrics
|
|
|
|
|
|
- System reliability indicators
|
|
|
|
|
|
|
|
|
|
|
|
**2. Targeted Improvements:**
|
|
|
|
|
|
- Identify highest impact areas (80/20 rule)
|
|
|
|
|
|
- Prioritize improvements by ROI
|
|
|
|
|
|
- Make incremental, measurable changes
|
|
|
|
|
|
- Maintain working state throughout
|
|
|
|
|
|
|
|
|
|
|
|
**3. Progress Tracking:**
|
|
|
|
|
|
- Measure improvement after each iteration
|
|
|
|
|
|
- Document changes and their impact
|
|
|
|
|
|
- Calculate return on investment
|
|
|
|
|
|
- Adjust strategy based on results
|
|
|
|
|
|
|
|
|
|
|
|
**4. Completion Criteria:**
|
|
|
|
|
|
- Target threshold achievement
|
|
|
|
|
|
- Diminishing returns detection
|
|
|
|
|
|
- Time or budget constraints
|
|
|
|
|
|
- "Good enough" quality level
|
|
|
|
|
|
|
|
|
|
|
|
**Focus Areas by Type:**
|
|
|
|
|
|
- **Quality**: Complexity reduction, duplication removal, coverage increase
|
|
|
|
|
|
- **Performance**: Response time, throughput, resource utilization
|
|
|
|
|
|
- **User Experience**: Load time, responsiveness, error reduction
|
|
|
|
|
|
- **Maintainability**: Documentation, test quality, code structure
|
|
|
|
|
|
|
|
|
|
|
|
## Architecture Improvements (--architecture)
|
|
|
|
|
|
|
|
|
|
|
|
**Design Patterns:**
|
|
|
|
|
|
- Apply appropriate design patterns
|
|
|
|
|
|
- Implement dependency injection
|
|
|
|
|
|
- Use domain-driven design principles
|
|
|
|
|
|
- Implement proper separation of concerns
|
|
|
|
|
|
|
|
|
|
|
|
**System Architecture:**
|
|
|
|
|
|
- Microservices decomposition
|
|
|
|
|
|
- Event-driven architecture
|
|
|
|
|
|
- CQRS implementation where appropriate
|
|
|
|
|
|
- API design and optimization
|
|
|
|
|
|
|
|
|
|
|
|
**Scalability Enhancements:**
|
|
|
|
|
|
- Horizontal scaling strategies
|
|
|
|
|
|
- Database sharding and replication
|
|
|
|
|
|
- Caching layer implementation
|
|
|
|
|
|
- Load balancing optimization
|
|
|
|
|
|
|
|
|
|
|
|
## Deliverables
|
|
|
|
|
|
- **Improvement Reports**: Detailed analysis of changes and their impact
|
|
|
|
|
|
- **Quality Metrics**: Before/after comparison of quality indicators
|
|
|
|
|
|
- **Performance Benchmarks**: Speed and efficiency improvements
|
|
|
|
|
|
- **Refactored Code**: Clean, optimized, and maintainable codebase
|
|
|
|
|
|
- **Documentation**: Updated docs reflecting improvements
|
|
|
|
|
|
|
|
|
|
|
|
## Output Locations
|
|
|
|
|
|
- **Reports**: `.claudedocs/metrics/improvement-{type}-{timestamp}.md`
|
|
|
|
|
|
- **Benchmarks**: `.claudedocs/metrics/performance-{timestamp}.json`
|
|
|
|
|
|
- **Quality Metrics**: `.claudedocs/metrics/quality-{timestamp}.md`
|
|
|
|
|
|
|
|
|
|
|
|
## Research Requirements
|
|
|
|
|
|
External_Library_Research:
|
|
|
|
|
|
- Identify library/framework mentioned
|
|
|
|
|
|
- Context7 lookup for official documentation
|
|
|
|
|
|
- Verify API patterns and examples
|
|
|
|
|
|
- Check version compatibility
|
|
|
|
|
|
- Document findings in implementation
|
|
|
|
|
|
Pattern_Research:
|
|
|
|
|
|
- Search existing codebase for similar patterns
|
|
|
|
|
|
- Magic component search if UI-related
|
|
|
|
|
|
- WebSearch for official documentation
|
|
|
|
|
|
- Validate approach with Sequential thinking
|
|
|
|
|
|
- Document pattern choice rationale
|
|
|
|
|
|
API_Integration_Research:
|
|
|
|
|
|
- Official documentation lookup
|
|
|
|
|
|
- Authentication requirements
|
|
|
|
|
|
- Rate limiting and error handling
|
|
|
|
|
|
- SDK availability and examples
|
|
|
|
|
|
- Integration testing approach
|
|
|
|
|
|
|
|
|
|
|
|
## Report Notifications
|
|
|
|
|
|
📄 Analysis report saved to: {path}
|
|
|
|
|
|
📊 Metrics updated: {path}
|
|
|
|
|
|
📋 Summary saved to: {path}
|
|
|
|
|
|
💾 Checkpoint created: {path}
|
|
|
|
|
|
📚 Documentation created: {path}
|
|
|
|
|
|
📁 Created directory: {path}
|
|
|
|
|
|
✅ {operation} completed successfully
|
|
|
|
|
|
❌ {operation} failed: {reason}
|
|
|
|
|
|
⚠ {operation} completed w/ warnings
|
2025-06-22 14:02:49 +02:00
|
|
|
|
|
|
|
|
|
|
## Best Practices
|
|
|
|
|
|
|
2025-06-24 21:24:14 +02:00
|
|
|
|
**Improvement Methodology:**
|
|
|
|
|
|
1. **Measure Before Changing**: Establish baseline metrics
|
|
|
|
|
|
2. **Focus on Bottlenecks**: Address highest impact issues first
|
|
|
|
|
|
3. **Incremental Changes**: Make one improvement at a time
|
|
|
|
|
|
4. **Verify Improvements**: Validate changes with metrics
|
|
|
|
|
|
5. **Document Changes**: Record what was changed and why
|
|
|
|
|
|
6. **Consider Trade-offs**: Balance competing concerns
|
|
|
|
|
|
|
|
|
|
|
|
**Common Pitfalls to Avoid:**
|
|
|
|
|
|
- Premature optimization without profiling
|
|
|
|
|
|
- Over-engineering simple solutions
|
|
|
|
|
|
- Breaking changes without proper testing
|
|
|
|
|
|
- Ignoring existing test suite
|
|
|
|
|
|
- Gold-plating beyond requirements
|
|
|
|
|
|
|
|
|
|
|
|
**Balance Considerations:**
|
|
|
|
|
|
- Performance vs code readability
|
2025-06-22 14:02:49 +02:00
|
|
|
|
- Flexibility vs simplicity
|
|
|
|
|
|
- Speed vs correctness
|
2025-06-24 21:24:14 +02:00
|
|
|
|
- Present needs vs future scalability
|
|
|
|
|
|
|
|
|
|
|
|
## Common Improvement Scenarios
|
|
|
|
|
|
|
|
|
|
|
|
### Code Quality Issues
|
|
|
|
|
|
```bash
|
|
|
|
|
|
/improve --quality --solid --metrics --dry-run
|
|
|
|
|
|
# → Identifies SOLID principle violations
|
|
|
|
|
|
# → Suggests refactoring for better modularity
|
|
|
|
|
|
# → Measures complexity metrics before/after changes
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### Performance Bottlenecks
|
|
|
|
|
|
```bash
|
|
|
|
|
|
/improve --performance --iterate --threshold 90%
|
|
|
|
|
|
# → Profiles CPU and memory usage patterns
|
|
|
|
|
|
# → Implements algorithmic optimizations
|
|
|
|
|
|
# → Continues until 90% performance threshold met
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### Technical Debt Reduction
|
|
|
|
|
|
```bash
|
|
|
|
|
|
/improve --quality --iterate --technical-debt
|
|
|
|
|
|
# → Identifies code duplication and anti-patterns
|
|
|
|
|
|
# → Suggests consolidation opportunities
|
|
|
|
|
|
# → Implements incremental refactoring strategy
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### Error Handling Enhancement
|
|
|
|
|
|
```bash
|
|
|
|
|
|
/improve --resilience --error-handling --comprehensive
|
|
|
|
|
|
# → Reviews exception handling patterns
|
|
|
|
|
|
# → Implements proper logging and monitoring
|
|
|
|
|
|
# → Adds circuit breakers and retry mechanisms
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## Troubleshooting
|
|
|
|
|
|
- **Complex Codebases**: Use `--iterate --interactive` for guided improvements
|
|
|
|
|
|
- **Performance Issues**: Combine `--performance --profile --seq` for deep analysis
|
|
|
|
|
|
- **Quality Problems**: Apply `--quality --solid --metrics` for comprehensive fixes
|
|
|
|
|
|
- **Architecture Concerns**: Use `--architecture --think-hard` for system-wide improvements
|
|
|
|
|
|
|
|
|
|
|
|
## Success Messages
|
|
|
|
|
|
✅ {operation} completed successfully
|
|
|
|
|
|
📝 Created: {file_path}
|
|
|
|
|
|
✏ Updated: {file_path}
|
|
|
|
|
|
✨ Task completed: {task_title}
|