Reduce token usage by selecting a planning strategy, loading Serena memories, enforcing symbol-first exploration, and reporting savings. Use when starting a non-trivial task, asking to reduce token costs, requesting efficient execution, or wanting optimized Claude Code workflows.
Activates all Claude Code optimization strategies for the given task. Routes to the correct planning strategy, enforces symbol-first exploration, loads Serena memories, and reports token savings.
Use this as the default way to start any non-trivial work session.
/optimize [task description]
/optimize [action]
/optimize "Add email verification to the auth system"
/optimize "Fix the N+1 query in OrdersController#index"
/optimize status
/optimize report
When you run /optimize "your task", Claude will:
Triggers: Bug fixes, single-file tweaks, small config changes
Process:
Token savings: 60-70% vs full spec workflow
Triggers: New features, moderate refactoring, API endpoint additions
Process:
Token savings: 40-50% vs full spec workflow
Triggers: New modules, architectural changes, cross-cutting concerns
Process:
requirements.mddesign.mdtasks.mdToken savings: High upfront cost, maximum long-term clarity
status — Show current optimization configurationReports what's active:
/optimize status
report — Token usage summary for the sessionProduces a session summary:
/optimize report
Output format:
## Optimization Report
Strategy used: Intent-Planning
Tokens used: ~18K
Estimated baseline: ~85K
Savings: 79%
Cache hit rate: 84%
Optimizations applied:
- Symbol-first exploration: 65% savings on file reads
- Memory system: 60% savings on context loading
- Adaptive planning: 45% savings vs full spec
- Prompt caching: 90% savings on re-reads
- Model selection: Haiku used for 3/7 subtasks
metrics — Show all token optimization targetsDisplays the savings targets from ~/.claude/settings/token-optimization.json.
/optimize metrics
This skill automatically loads:
Serena memories (if Serena MCP available):
architecture.mdcodebase-conventions.mdmodule-structure.md (if working on a module)testing-strategy.md (if tests involved)Constitution (if .claude/settings/constitution.json exists) — checks task against architectural rules before starting
Existing specs — searches .claude/specs/ for similar past work to reuse patterns
| Task type | Model | Reason |
|---|---|---|
| Requirements, task lists | Haiku | Template-driven, fast |
| Implementation, design | Sonnet | Balanced cost/quality |
| Security, architecture, judge | Opus | Critical decisions only |
Target distribution: 40% Haiku / 55% Sonnet / 5% Opus
The following rules are mandatory when /optimize is active:
Never read a full file before using symbolic discovery:
✅ mcp__serena__find_symbol("ClassName") → read only needed methods
❌ Read("app/models/user.rb") → reads entire file
Always load Serena memories before exploring code:
✅ mcp__serena__list_memories() → load relevant ones → start work
❌ Start reading files immediately
System prompts, tool definitions, and memories are cached automatically. First load costs full tokens; subsequent reads cost 10%.
Use the cheapest model that can do the job. Don't use Sonnet for template-driven tasks. Never use Opus unless it's a critical architectural/security decision.
Run existing tests, a regression grep, or manual validation before reporting a task as done. If a verification step was skipped, say so plainly rather than implying success. Aligns with ~/.claude/CLAUDE.md §Faithful Reporting.
/optimize "Fix the duplicate email validation in UserService"
What happens:
find_symbol("UserService/validate_email")/optimize "Add Stripe webhook handling for subscription events"
What happens:
/optimize "Build a multi-tenant billing system with per-seat pricing"
What happens:
Optimization still works at 40-50% savings without Serena. Memory-first and symbol-first strategies fall back to Read + Grep.
Run /optimize status — check if:
/context load first)Override explicitly:
/optimize --strategy unified "your task"
/optimize --strategy planning "your task"
/context — Memory management/cache-inspector — Cache performance monitoring/init-project — Initialize optimization for a new project