mirror of
https://github.com/SuperClaude-Org/SuperClaude_Framework.git
synced 2025-12-29 16:16:08 +00:00
Major optimization: 35% token reduction through template system & file consolidation
- Consolidated 7 redundant YAML files into 3 comprehensive files: * error-recovery + error-recovery-enhanced → error-handling.yml * performance-monitoring + performance-tracker → performance.yml * task-management + todo-task-integration + auto-task-trigger → task-system.yml - Created 3 new shared resource files: * severity-levels.yml (universal classification system) * execution-lifecycle.yml (common execution hooks) * constants.yml (paths, symbols, standards) - Migrated all 18 commands to use expanded template system - Updated cross-references throughout command system - Achieved 6,440 token savings (35.5% reduction) while maintaining full functionality 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
317
.claude/commands/shared/performance.yml
Normal file
317
.claude/commands/shared/performance.yml
Normal file
@@ -0,0 +1,317 @@
|
||||
# Performance Monitoring & Optimization System
|
||||
|
||||
## Legend
|
||||
| Symbol | Meaning | | Abbrev | Meaning |
|
||||
|--------|---------|---|--------|---------|
|
||||
| ⚡ | fast/optimized | | perf | performance |
|
||||
| 📊 | metrics/data | | exec | execution |
|
||||
| ⏱ | timing/duration | | tok | token |
|
||||
| 🔄 | continuous | | opt | optimization |
|
||||
|
||||
## Performance Metrics
|
||||
|
||||
```yaml
|
||||
Command_Performance:
|
||||
Timing_Metrics:
|
||||
Start_Time: "Record command initiation timestamp"
|
||||
End_Time: "Record command completion timestamp"
|
||||
Duration: "end_time - start_time"
|
||||
Phases: "Breakdown by major operations (analysis, execution, reporting)"
|
||||
|
||||
Token_Metrics:
|
||||
Input_Tokens: "Tokens in user command + context"
|
||||
Output_Tokens: "Tokens in response + tool calls"
|
||||
MCP_Tokens: "Tokens consumed by MCP servers"
|
||||
Efficiency_Ratio: "output_value / total_tokens"
|
||||
Context_Size: "Total context size throughout operation"
|
||||
|
||||
Operation_Metrics:
|
||||
Tools_Used: "List of tools called (Read, Edit, Bash, etc)"
|
||||
Files_Accessed: "Number of files read/written/analyzed"
|
||||
MCP_Calls: "Which MCP servers used + frequency"
|
||||
Error_Count: "Number of errors encountered"
|
||||
Retry_Count: "Number of retry attempts needed"
|
||||
|
||||
Success_Metrics:
|
||||
Completion_Status: "success|partial|failure"
|
||||
User_Satisfaction: "Interruptions, corrections, positive signals"
|
||||
Quality_Score: "Estimated output quality (1-10)"
|
||||
Objectives_Met: "Did operation achieve stated goals?"
|
||||
|
||||
Op_Duration_Tracking:
|
||||
Average_vs_Current: "Compare current execution to historical average"
|
||||
Trend_Analysis: "Track performance changes over time"
|
||||
Baseline_Comparison: "Measure against established benchmarks"
|
||||
|
||||
Token_Consumption_Analysis:
|
||||
Usage_per_Operation: "Token consumption by command type"
|
||||
Baseline_Comparison: "Compare to expected token usage"
|
||||
Efficiency_Ratios: "Value delivered per token consumed"
|
||||
Optimization_Opportunities: "Areas for token reduction"
|
||||
|
||||
Success_Rate_Monitoring:
|
||||
Command_Completion_Rate: "Percentage of successful completions"
|
||||
Error_Frequency: "Types and frequency of errors"
|
||||
Retry_Patterns: "When and why retries are needed"
|
||||
User_Intervention_Rate: "How often users need to correct/guide"
|
||||
```
|
||||
|
||||
## Performance Baselines & Thresholds
|
||||
|
||||
```yaml
|
||||
Command_Benchmarks:
|
||||
Simple_Commands:
|
||||
read_file: "<2s, <200 tokens"
|
||||
edit_file: "<3s, <300 tokens"
|
||||
analyze_single_file: "<5s, <500 tokens"
|
||||
git_status: "<3s, <100 tokens"
|
||||
|
||||
Medium_Commands:
|
||||
build_component: "<30s, <2000 tokens"
|
||||
test_execution: "<45s, <1500 tokens"
|
||||
security_scan: "<60s, <3000 tokens"
|
||||
analyze_multiple_files: "<45s, <2500 tokens"
|
||||
|
||||
Complex_Commands:
|
||||
full_codebase_analysis: "<120s, <5000 tokens"
|
||||
architecture_design: "<180s, <8000 tokens"
|
||||
comprehensive_security_audit: "<300s, <10000 tokens"
|
||||
|
||||
MCP_Server_Performance:
|
||||
Context7: "<5s response, 100-2000 tokens typical"
|
||||
Sequential: "<30s analysis, 500-10000 tokens typical"
|
||||
Magic: "<10s generation, 500-2000 tokens typical"
|
||||
Puppeteer: "<15s operation, minimal tokens"
|
||||
|
||||
Performance_Thresholds:
|
||||
Time_Limits:
|
||||
Yellow_Warning: ">30s operations → Consider alternatives"
|
||||
Red_Alert: ">60s → Force timeout, explain delay, offer cancellation"
|
||||
Critical: ">120s → Immediate intervention required"
|
||||
|
||||
Token_Limits:
|
||||
Moderate_Usage: ">2K tokens single op → Simplify approach"
|
||||
High_Usage: ">5K session → Suggest /compact mode"
|
||||
Critical_Usage: ">10K → Force optimization"
|
||||
|
||||
Error_Patterns:
|
||||
Concern_Level: "3+ retries same operation → Switch strategy"
|
||||
Critical_Level: "Repeated failures → Escalate to manual approach"
|
||||
System_Issue: "5+ consecutive failures → System health check"
|
||||
```
|
||||
|
||||
## Adaptive Optimization Strategies
|
||||
|
||||
```yaml
|
||||
Real_Time_Performance_Optimization:
|
||||
Slow_Operations_Response:
|
||||
Detection: "Operations exceeding 30s threshold"
|
||||
Immediate_Actions:
|
||||
- Switch to faster tools (rg vs grep, parallel processing)
|
||||
- Reduce operation scope (specific files vs full scan)
|
||||
- Enable parallel processing where possible
|
||||
- Break large operations into smaller chunks
|
||||
|
||||
High_Token_Usage_Response:
|
||||
Detection: ">70% context or >5K tokens in single operation"
|
||||
Immediate_Actions:
|
||||
- Auto-suggest UltraCompressed mode (--uc)
|
||||
- Cache repeated content and use references
|
||||
- Summarize large outputs instead of full details
|
||||
- Use shared templates instead of duplicating content
|
||||
|
||||
Error_Pattern_Response:
|
||||
Repeated_Failures:
|
||||
Detection: "3+ failures of same operation type"
|
||||
Actions:
|
||||
- Switch to alternative tool/approach
|
||||
- Adjust strategy based on error type
|
||||
- Request user guidance for complex issues
|
||||
- Document known issue for future prevention
|
||||
|
||||
Workflow_Acceleration:
|
||||
Pattern_Recognition:
|
||||
Successful_Sequences: "Learn from effective command chains"
|
||||
Efficient_Combinations: "Track optimal persona + command + flag combinations"
|
||||
User_Preferences: "Adapt to user's working style over time"
|
||||
|
||||
Predictive_Optimization:
|
||||
Context_Preloading: "Anticipate likely-needed resources"
|
||||
Smart_Caching: "Store and reuse expensive analysis results"
|
||||
Skip_Redundant: "Avoid re-analysis of unchanged files"
|
||||
Progressive_Refinement: "Start broad, narrow focus as needed"
|
||||
|
||||
When_Slow_Strategies:
|
||||
File_Operations: "Use faster tools (rg vs grep, fd vs find)"
|
||||
Large_Codebases: "Focus on specific areas, progressive analysis"
|
||||
Complex_Analysis: "Break into phases, provide interim results"
|
||||
Network_Operations: "Parallel requests, intelligent caching"
|
||||
|
||||
When_High_Token_Usage:
|
||||
Verbose_Output: "Switch to concise/compressed mode automatically"
|
||||
Repeated_Content: "Use cross-references instead of duplication"
|
||||
Large_Responses: "Summarize key points, provide detailed links"
|
||||
Context_Management: "Smart context trimming, keep only essential"
|
||||
|
||||
When_Errors_Occur:
|
||||
Tool_Failures: "Try alternative tools/approaches immediately"
|
||||
Permission_Issues: "Provide specific fix guidance"
|
||||
Missing_Dependencies: "Guide installation with exact commands"
|
||||
Configuration_Problems: "Auto-detect and suggest corrections"
|
||||
```
|
||||
|
||||
## Monitoring Implementation
|
||||
|
||||
```yaml
|
||||
Data_Collection:
|
||||
Lightweight_Tracking:
|
||||
Performance_Impact: "<1% overhead on operations"
|
||||
Background_Collection: "No user interruption during monitoring"
|
||||
Privacy_Preserving: "Local storage only, no external transmission"
|
||||
User_Configurable: "Can be disabled via settings"
|
||||
|
||||
Storage_Format:
|
||||
Location: ".claudedocs/metrics/performance-YYYY-MM-DD.jsonl"
|
||||
Format: "JSON Lines (one record per command execution)"
|
||||
Retention_Policy: "30 days rolling storage, monthly aggregation"
|
||||
Size_Management: "10MB max per day, auto-rotation"
|
||||
|
||||
Data_Structure:
|
||||
timestamp: "ISO 8601 format"
|
||||
command: "Full command with flags"
|
||||
persona: "Active persona (if any)"
|
||||
duration_ms: "Execution time in milliseconds"
|
||||
tokens_input: "Input token count"
|
||||
tokens_output: "Output token count"
|
||||
tools_used: "Array of tool names"
|
||||
mcp_servers: "Array of MCP servers used"
|
||||
success: "Boolean completion status"
|
||||
error_count: "Number of errors encountered"
|
||||
user_corrections: "Number of user interruptions/corrections"
|
||||
optimization_applied: "Any auto-optimizations used"
|
||||
```
|
||||
|
||||
## Performance Reporting
|
||||
|
||||
```yaml
|
||||
Real_Time_Feedback:
|
||||
Transparency_Messages:
|
||||
- "Operation taking longer than expected, switching to faster method"
|
||||
- "Optimizing approach to reduce token usage"
|
||||
- "Primary method failed, trying backup approach"
|
||||
- "Completed efficiently using optimized strategy"
|
||||
|
||||
Progress_Updates:
|
||||
- Show percentage completion for long operations
|
||||
- Indicate optimization strategies being applied
|
||||
- Provide ETAs for remaining work
|
||||
- Alert when alternative approaches are being tried
|
||||
|
||||
Automated_Reports:
|
||||
Daily_Summary:
|
||||
Location: ".claudedocs/metrics/daily-summary-YYYY-MM-DD.md"
|
||||
Content:
|
||||
- Command execution statistics
|
||||
- Token efficiency metrics
|
||||
- Error frequency analysis
|
||||
- Optimization wins and opportunities
|
||||
- Performance trend indicators
|
||||
|
||||
Weekly_Trends:
|
||||
Location: ".claudedocs/metrics/weekly-trends-YYYY-WW.md"
|
||||
Content:
|
||||
- Performance trend analysis over 7 days
|
||||
- Usage pattern identification
|
||||
- Efficiency improvements over time
|
||||
- Bottleneck identification and resolution
|
||||
- User workflow optimization suggestions
|
||||
|
||||
Monthly_Insights:
|
||||
Location: ".claudedocs/metrics/monthly-insights-YYYY-MM.md"
|
||||
Content:
|
||||
- Long-term performance trends
|
||||
- System optimization recommendations
|
||||
- User productivity analysis
|
||||
- Technology stack efficiency assessment
|
||||
|
||||
Performance_Insights:
|
||||
Bottleneck_Identification: "Which operations consume most resources"
|
||||
Efficiency_Trends: "Performance improvement over time"
|
||||
User_Patterns: "Most effective workflows and flag combinations"
|
||||
Optimization_Recommendations: "Specific suggestions for improvement"
|
||||
Success_Factor_Analysis: "What leads to successful outcomes"
|
||||
```
|
||||
|
||||
## Integration Points
|
||||
|
||||
```yaml
|
||||
Command_Wrapper_Integration:
|
||||
Pre_Execution:
|
||||
- Record start timestamp and context state
|
||||
- Capture input context size and complexity
|
||||
- Note active persona, flags, and user preferences
|
||||
- Check for known performance issues with operation
|
||||
|
||||
During_Execution:
|
||||
- Track tool usage and performance
|
||||
- Monitor MCP server response times
|
||||
- Count errors, retries, and optimization attempts
|
||||
- Provide real-time feedback on long operations
|
||||
|
||||
Post_Execution:
|
||||
- Record completion time and final status
|
||||
- Calculate total token consumption
|
||||
- Assess success metrics and quality
|
||||
- Store performance record for future analysis
|
||||
- Generate optimization recommendations
|
||||
|
||||
Auto_Optimization_Features:
|
||||
Context_Size_Management:
|
||||
- Auto-suggest /compact when context >70%
|
||||
- Enable --uc mode for responses >2K tokens
|
||||
- Cache expensive analysis results
|
||||
- Trim redundant context intelligently
|
||||
|
||||
Tool_Selection_Optimization:
|
||||
- Prefer faster tools for routine operations
|
||||
- Use parallel execution when safe and beneficial
|
||||
- Skip redundant file reads and analyses
|
||||
- Choose optimal MCP server for each task
|
||||
|
||||
User_Experience_Enhancement:
|
||||
- Proactive performance feedback during operations
|
||||
- Intelligent optimization suggestions
|
||||
- Alternative approach recommendations
|
||||
- Learning from user preferences and corrections
|
||||
```
|
||||
|
||||
## Configuration & Customization
|
||||
|
||||
```yaml
|
||||
Performance_Settings:
|
||||
Monitoring_Level:
|
||||
minimal: "Basic timing and success tracking"
|
||||
standard: "Full performance monitoring (default)"
|
||||
detailed: "Comprehensive analysis with detailed breakdowns"
|
||||
disabled: "No performance tracking"
|
||||
|
||||
Optimization_Aggressiveness:
|
||||
conservative: "Optimize only when significant benefit"
|
||||
balanced: "Reasonable optimization vs consistency trade-offs"
|
||||
aggressive: "Maximum optimization, accept some workflow changes"
|
||||
|
||||
Alert_Preferences:
|
||||
real_time: "Show optimization messages during operations"
|
||||
summary: "Daily/weekly performance summaries only"
|
||||
critical_only: "Alert only on significant issues"
|
||||
silent: "No performance notifications"
|
||||
|
||||
Auto_Optimization_Controls:
|
||||
Enable_Auto_UC: "Automatically enable UltraCompressed mode"
|
||||
Enable_Tool_Switching: "Allow automatic tool substitution"
|
||||
Enable_Scope_Reduction: "Automatically reduce operation scope when slow"
|
||||
Enable_Parallel_Processing: "Use parallel execution when beneficial"
|
||||
```
|
||||
|
||||
---
|
||||
*Performance System v1.0 - Comprehensive monitoring, analysis, and optimization for SuperClaude*
|
||||
Reference in New Issue
Block a user