Smart Optimize Tool
Streamline your workflow with this comprehensive, performance, optimization, response. Includes structured workflows, validation checks, and reusable patterns for performance.
Smart Optimize Tool
Intelligently detect and apply performance optimizations across your entire application stack, from frontend rendering to backend queries to infrastructure configuration.
When to Use This Command
Run this command when...
- You want a holistic performance assessment that identifies optimizations across the full stack rather than a single layer
- Application performance has degraded and you need intelligent detection of the root causes across multiple systems
- You are preparing for a load test or launch and want proactive optimization of all critical paths
- Multiple small performance issues have accumulated and you need a systematic pass to address them all
- You want smart prioritization of which optimizations deliver the most impact for the least effort
Quick Start
# .claude/commands/smart-optimize-tool.md --- name: Smart Optimize Tool description: Full-stack performance detection and optimization command: true --- Optimize smartly: $ARGUMENTS 1. Scan the full application stack for performance issues 2. Rank findings by impact and implementation effort 3. Apply high-impact, low-effort optimizations first 4. Report results with before/after comparisons
# Invoke the command claude "/smart-optimize-tool the entire API layer" # Expected output # > Scanning API layer for performance issues... # > Found 9 optimization opportunities: # > [HIGH impact, LOW effort] Add database indexes for 3 slow queries # > [HIGH impact, MED effort] Implement response compression (gzip) # > [MED impact, LOW effort] Add connection pooling to DB client # > [MED impact, MED effort] Cache repeated authorization lookups # > [LOW impact, LOW effort] Remove 4 unused middleware from chain # > ... (4 more) # > Applying top 5 optimizations... # > Results: avg response time 380ms -> 120ms (68% improvement)
Core Concepts
| Concept | Description |
|---|---|
| Full-Stack Scanning | Analyzes frontend, backend, database, and infrastructure layers for issues |
| Impact-Effort Matrix | Ranks each optimization by expected performance gain versus implementation complexity |
| Smart Prioritization | Applies high-impact, low-effort fixes first to maximize return on optimization time |
| Incremental Measurement | Measures the effect of each optimization individually before applying the next |
| Stack-Aware Analysis | Understands how frontend, API, database, and caching layers interact and affect each other |
Smart Optimize Matrix
======================
LOW effort MED effort HIGH effort
+-------------+-------------+-------------+
HIGH | ** DO | * PLAN | CONSIDER |
impact | FIRST ** | NEXT | LATER |
+-------------+-------------+-------------+
MED | * DO | EVALUATE | SKIP |
impact | SECOND | | USUALLY |
+-------------+-------------+-------------+
LOW | QUICK | SKIP | SKIP |
impact | WINS | | |
+-------------+-------------+-------------+
Configuration
| Parameter | Description | Default | Example | Required |
|---|---|---|---|---|
$ARGUMENTS | Target scope for optimization | entire project | "API layer", "frontend bundle" | No |
max_optimizations | Maximum number of optimizations to apply | 5 | 10 | No |
min_impact | Minimum impact threshold to include | low | "medium", "high" | No |
max_effort | Maximum effort level to include | high | "low", "medium" | No |
apply_mode | Whether to apply changes or just report | apply | "report-only" | No |
Best Practices
-
Start with report-only mode -- Use
apply_mode: "report-only"on the first run to review all findings before any code changes are made. This lets you exclude optimizations that conflict with your design constraints. -
Optimize one layer at a time -- Scope to "database queries" or "frontend rendering" rather than the full stack when you want controlled, reviewable changes.
-
Measure baseline before starting -- Record current performance metrics (response times, bundle size, memory usage) so the before-after comparisons are accurate and meaningful.
-
Run tests between optimizations -- Apply one fix, verify tests pass, then move to the next. Batching optimizations makes it hard to identify which change introduced a regression.
-
Re-run after major changes -- Performance characteristics change as features are added. Schedule periodic smart optimization passes after significant codebase changes.
Common Issues
Conflicting optimizations: Two optimizations may interfere with each other, such as adding an index and changing a query to no longer use that column. The tool checks for conflicts but edge cases exist. Review applied changes holistically.
False positives in impact estimation: Static analysis may overestimate the impact of optimizations that affect rarely-executed code paths. Cross-reference findings with actual production metrics or access logs.
Optimization removed for readability reasons: Some technically valid optimizations (loop unrolling, inlining) reduce code readability. If preserve_readability is important to your team, set max_effort: "low" to stay conservative.
Reviews
No reviews yet. Be the first to review this template!
Similar Templates
Git Commit Message Generator
Generates well-structured conventional commit messages by analyzing staged changes. Follows Conventional Commits spec with scope detection.
React Component Scaffolder
Scaffolds a complete React component with TypeScript types, Tailwind styles, Storybook stories, and unit tests. Follows project conventions automatically.
CI/CD Pipeline Generator
Generates GitHub Actions workflows for CI/CD including linting, testing, building, and deploying. Detects project stack automatically.