/godmode:optimizefrom godmode
Runs an autonomous optimization loop that tests multiple changes in parallel, measures a numeric metric, and keeps only the best improvement. Useful for performance tuning or any measurable optimization task.
Ships in godmode. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
/godmode:optimize, "make faster", "improve", "optimize"Ask: Goal, Metric (cmd -> single number),
Direction (up/down), Scope (file globs).
# Run metric_cmd 3 times, take median
metric_cmd; metric_cmd; metric_cmd
IF variance >5%: 10 runs, trim outliers, median of 8. If metric variance > 5% across 3 runs: consider Docker isolation for deterministic measurement. Log variance alongside metric in results.tsv. Commit baseline as iteration 0.
METRIC: shell cmd -> single number (target)
GUARD: test_cmd && lint_cmd && build_cmd (must pass)
Change must BOTH improve metric AND pass guard.
Guard failure -> DISCARD (terminal, counts against
2-rework cap).
On start: check .godmode/session-state.json. If resuming (stop_reason is null), restore baseline/round/approach_history and skip to saved round.
After each iteration: atomically save state (round, baseline, current_best, last_kept_commit, consecutive_discards, approach_history, failure_classes) to .godmode/session-state.json.
On completion: set stop_reason in the state file.
Before IDEATE: read .godmode/lessons.md for optimization-specific insights.
After session: append lessons (e.g., "Metric X is I/O-bound, not CPU-bound" or "Table Y too small for index benefit").
WHILE current_round < max_rounds:
1. REVIEW: in-scope files + results.tsv + git log
Read last 10 rows of optimize-failures.tsv before proposing next change. Avoid repeating the most common failure class.
Profile first: identify hotspot before changing.
IF bounded AND remaining < 3: exploit only.
2. HYPOTHESIZE: 3 independent untested changes
(algorithmic > caching > structural)
IF >5 consecutive discards: STUCK RECOVERY
3. DISPATCH 3 AGENTS (parallel, worktrees)
Each: ONE change -> commit -> guard -> 3x verify
Timeout: 5 min per agent. Exceeded -> kill+discard.
4. PICK WINNER: largest improvement
improved + guard pass -> cherry-pick, update baseline
improved + guard fail -> rework (max 2), else discard
no improvement -> discard all
5. LOG to .godmode/optimize-results.tsv
6. STATUS every 5 rounds.
Last 3 keeps <1% -> radical -> compound -> STOP
STOP: target | max rounds | diminishing | guard broken
When stuck or when the search space is wide, test multiple approaches simultaneously:
Trigger: after 2 consecutive single-agent discards, switch to parallel mode. Return to single-agent mode after a successful parallel keep.
Log to results.tsv: round | agent_1_change | agent_1_delta | agent_2_change | agent_2_delta | agent_3_change | agent_3_delta | winner | status
IF >5 consecutive discards:
0. DIAGNOSE: Re-read ALL in-scope files (stale model)
On 3+ consecutive discards: PAUSE. Read the last 3 diffs and test outputs.
Write a 2-sentence diagnosis explaining the shared failure pattern.
Use the diagnosis to pick a fundamentally different approach.
Log the diagnosis to optimize-failures.tsv in the reason column.
1. Try OPPOSITE approach (informed by diagnosis)
2. If opposite fails -> radical rewrite (informed by diagnosis)
3. If radical fails -> accept defeat, log, stop
Discard if: +5 lines AND improvement < 0.5%
Discard if: complexity up AND improvement < 1%
Keep if: lines removed with equal/better metric
Tie-break: fewer lines wins
SKILL.md §14. Principles prelude, pre-commit audit (agents/optimizer.md step 10a), terse/stdio/tokens, DispatchContext validation, Progressive Disclosure routing, discard cost hierarchy all fire by default. Token logging to .godmode/token-log.tsv happens per round unless GODMODE_TOKENS=0.Append .godmode/optimize-results.tsv:
round agent change metric_before metric_after delta_pct status failure_class
On DISCARD: also append to .godmode/optimize-failures.tsv with failure_class and reason.
KEEP if: metric improved AND guard passed.
DISCARD if: metric worsened OR guard failed.
On discard: git reset --hard HEAD~1.
After DISCARD: read optimize-failures.tsv. Count by failure_class.
If >3 in same class: announce "Approach category exhausted: {class}. Switching strategy."
Before next IDEATE: skip any change similar to the top failure class.
Before KEEP: run metric_cmd 3x. If stdev > |improvement|: DISCARD as noise. "Would this optimization help if the specific bottleneck moved?" If NO → DISCARD.
STOP when FIRST of:
- target_reached: metric meets target
- budget_exhausted: max_rounds reached
- diminishing: 3 consecutive keeps each < 1%
- stuck: >5 consecutive discards after recovery
On failure: git reset --hard HEAD~1. Never pause.
| Failure | Action |
|---|---|
| Metric non-numeric | Pipe through tail -1 or awk |
| Noisy metric (>5%) | 10 runs, trim outliers, median 8 |
| All 3 agents regress | Stuck recovery, opposite approach |
| Agent timeout (>5m) | Kill worktree, discard, next round |
# Profile and benchmark
npm run build -- --profile
npx lighthouse http://localhost:3000 --output=json
pytest --benchmark-only
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
optimization, automation, performance-tuning, parallel-testing
Claude Code installs this plugin but refuses to load it
hooks/hooks.json: hooks.json declares PreToolUse/PermissionRequest at its top level, outside the "hooks" object — a PreToolUse/PermissionRequest hook that cannot be loaded may be what guards the permissions declared beside it, so nothing it sits in is applied until the entry is fixed or removed
hooks/hooks.json: hooks.json declares PreToolUse/PermissionRequest at its top level, outside the "hooks" object — a PreToolUse/PermissionRequest hook that cannot be loaded may be what guards the permissions declared beside it, so nothing it sits in is applied until the entry is fixed or removed
Checked against Claude Code 2.1.332. The listing below is what the repository ships; Claude Code doesn't load it as published.
135 skills in this plugin
/a11yAccessibility. WCAG 2.1 AA/AAA, a11y audit, color contrast, keyboard navigation, screen reader, Axe, Pa11y, Lighthouse./agentAI agent development. ReAct/plan-and-execute/multi-agent architectures, tool design, memory systems, guardrails, orchestration (LangChain, LlamaIndex, CrewAI, AutoGen)./analyticsProduct analytics implementation — event tracking, funnel analysis, A/B testing, Segment/Amplitude/Mixpanel/PostHog, privacy-compliant instrumentation./angularAngular architecture. NgRx, Signals, RxJS, standalone components, lazy loading, dependency injection, Jasmine, Jest.Other plugins' skills for the same job