name: optimize description: API cost & performance scanner — identify expensive operations and optimization opportunities argument-hint: Optional focus area (e.g., "ai", "caching", "queries", "latency")
/optimize — API Cost & Performance Scanner
You are scanning this project's API and infrastructure for cost and performance optimization opportunities.
Ethos
!sh .aif/partials/ethos-include.sh 2>/dev/null || sh ~/.claude/skills/partials/ethos-include.sh
Context
- Architecture: !
cat .aif/context/architecture.md 2>/dev/null || echo "No architecture context found" - Project overview: !
cat .aif/context/project-overview.md 2>/dev/null || echo "No project overview found"
Input
Focus: $ARGUMENTS
Prerequisites
Before proceeding, verify that .aif/context/architecture.md and .aif/context/project-overview.md exist. If any of these files are missing, stop and tell the user: "The .aif/ structure hasn't been initialized. Run /init first to set up the project context."
Instructions
Step 1: Determine Focus
- If given a focus area, prioritize that dimension
- If no argument, scan all dimensions
- Read
.aif/context/architecture.mdfor current caching and optimization patterns
Step 2: Launch Scanner Agents
Launch 3 formal scanner agents in parallel using the Agent tool. Each agent is defined in ~/.claude/agents/ with its full scanning checklist and model selection (sonnet for deep analysis).
- api-cost-scanner agent — provide the focus scope and architecture.md for caching context
- db-perf-scanner agent — provide the focus scope
- latency-scanner agent — provide the focus scope
Each agent returns structured findings with estimated impact, effort, and risk.
Step 3: Build Optimization Report
Cost Summary
| Service | Est. Monthly Usage | Est. Monthly Cost | Top Optimization | |---------|-------------------|-------------------|------------------| | Claude Sonnet | X calls | $X | ... | | Claude Haiku | X calls | $X | ... | | Gemini Flash | X calls | $X | ... | | SerpAPI | X calls | $X | ... | | Firestore | X reads/writes | $X | ... | | GCS | X operations | $X | ... |
Performance Hotspots
Rank endpoints by estimated latency, highlighting:
- Sequential operations that could be parallel
- Missing caches
- N+1 query patterns
- Unnecessary data fetching
Optimization Opportunities
For each opportunity:
- What: Description of the optimization
- Impact: Cost savings or latency reduction estimate
- Effort: Small / Medium / Large
- Risk: Low / Medium / High (chance of breaking something)
Step 4: Prioritized Recommendations
- Rank optimizations by impact/effort ratio
- Group into quick wins (small effort, high impact) and strategic improvements
- Suggest which items warrant a full AIF requirement (candidates for
/spec)
Expert Next.js App Router
Developpement
Un skill qui transforme Claude en expert Next.js App Router.
Générateur de README
Developpement
Crée des README.md professionnels et complets pour vos projets.
Rédacteur de Documentation API
Developpement
Génère de la documentation API complète au format OpenAPI/Swagger.