/godmode:performance-tuningfrom GodMode
Guides performance tuning with a measurement-first protocol: set a target, baseline, profile, change one thing, re-measure. Use when something is slow, memory-hungry, or a performance budget is breached.
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.
None: SKILL.md is the whole skill.
Intuition about where time goes is wrong more often than it is right. You measure the problem, profile to find where the time or memory actually goes, change one thing, and measure again with the same method. No measurement, no optimisation: every change is justified by a number before and proven by a number after.
NO OPTIMISATION WITHOUT A MEASUREMENT PROVING THE PROBLEM
No exceptions. No workarounds. No shortcuts.
Required:
Skip:
godmode:fault-diagnosis or godmode:test-first.digraph perf {
rankdir=TB;
target [label="1. Target\n(number + percentile)", shape=box];
baseline [label="2. Baseline\n(repeatable measurement)", shape=box];
met [label="Target met?", shape=diamond];
profile [label="3. Profile\n(where does it go?)", shape=box];
hypo [label="4. One hypothesis", shape=box];
change [label="5. Change one thing", shape=box];
remeasure [label="6. Re-measure\n(same method)", shape=box];
better [label="Significant\nimprovement?", shape=diamond];
revert [label="Revert", shape=box];
done [label="7. Record + guard", shape=box];
target -> baseline -> met;
met -> done [label="yes"];
met -> profile [label="no"];
profile -> hypo -> change -> remeasure -> better;
better -> met [label="yes, keep"];
better -> revert [label="no"];
revert -> hypo;
}
Set the target. A number, a percentile and a context: "p95 under 300 ms for GET /orders at 50 requests per second", "LCP 2.5 s or less at the 75th percentile on mobile", "bundle under 200 KB gzipped". Without a target there is no end condition; ask the user for one or propose one.
Take a baseline that you can repeat. Same input data, same environment (production-like, not a debug build), warm-up runs discarded, several runs, and the spread reported, not one number. Save the exact command and its output. Tools are in the table below.
Profile before you guess. Use a profiler, query plan, trace or bundle analyser to find where the time, memory or bytes go. The evidence is a profile artefact (flame graph, EXPLAIN ANALYZE output, trace) that names the hot spot. Usual suspects, in rough order: database queries (N+1, missing index, full scans), network round trips made in sequence, serialisation of oversized payloads, algorithmic complexity, synchronous I/O, and memory churn.
State one hypothesis that links the hot spot to a change: "The order list makes one query per item (N+1); a single joined query should cut p95 from 920 ms to under 300 ms."
Change one thing. One change per measurement, behind passing tests, so the effect is attributable. Keep the change on its own commit.
Re-measure with the identical method and compare against the baseline, including the spread. If the improvement is within the noise or misses the expectation, revert it, even if it "should" help. If it helps, go back to step 2 with the new baseline until the target is met.
Record and guard. Write the before and after numbers, the method and the commit in the PR description. Add a guard so the regression cannot return silently: a benchmark in CI, a budget check (godmode:quality-gates), or a test that asserts the query count.
| What | Measure | Profile |
|---|---|---|
| A command or script end to end | hyperfine --warmup 3 'cmd' (compare two: hyperfine 'old' 'new') | the language profiler below |
| Python | pytest-benchmark, timeit | py-spy record -o profile.svg -- python app.py, py-spy top --pid <pid> |
| Node.js | hyperfine, a benchmark library | node --cpu-prof app.js (CPU), node --heap-prof app.js (memory); open the files in browser DevTools |
| Go | go test -bench . -benchmem | go test -bench . -cpuprofile cpu.out, then go tool pprof cpu.out |
| Rust | a benchmark harness such as Criterion | perf or a flame-graph tool on Linux |
| PostgreSQL query | EXPLAIN (ANALYZE, BUFFERS) <query> | the same plan: look for sequential scans, row-estimate errors, loops |
| HTTP service under load | a load generator at a fixed request rate, reporting percentiles | APM traces or the language profiler on the server |
| Web page | lighthouse <url> (lab), field data from real users for Core Web Vitals | browser DevTools Performance panel |
| Bundle size | the bundler's analyser or a size-limit check | the same analyser, per module |
EXPLAIN ANALYZE executes the statement. For INSERT, UPDATE or DELETE, run it inside a transaction and roll back.
A budget turns "fast enough" into a check. Set budgets where the user feels the result, and enforce them in CI.
| Kind | Example budget | Source of the number |
|---|---|---|
| Largest Contentful Paint | 2.5 s or less | Core Web Vitals "good", 75th percentile of page loads, mobile and desktop separately |
| Interaction to Next Paint | 200 ms or less | Core Web Vitals "good", 75th percentile |
| Cumulative Layout Shift | 0.1 or less | Core Web Vitals "good", 75th percentile |
| API latency | p95 and p99 per endpoint at expected load | the product's requirement or service-level objective |
| Query time | per query on production-sized data | the endpoint budget minus everything else |
| Bundle or binary size | per entry point, gzipped | what the target devices and networks tolerate |
| Memory | peak resident memory per process | the container or device limit with headroom |
Report percentiles, not averages: an average hides the slow requests users complain about.
| Anti-pattern | Why it fails | Instead |
|---|---|---|
| Caching first | Adds staleness, invalidation bugs and memory; hides the slow code | Fix the slow query or call; cache only with a measured need and an invalidation plan |
| Index everything | Indexes slow writes and use storage | Add the index the query plan asks for, and confirm with a new plan |
| Async or parallel everything | No gain for CPU-bound work, harder debugging, new races | Use concurrency for independent I/O that the profile shows waiting |
| Micro-optimising a loop the profiler did not flag | Saves nanoseconds, costs clarity | Only touch code on the hot path |
| Several changes at once | You cannot tell which helped, or which hurt | One change per measurement |
| Benchmarking a debug build or tiny data | Numbers do not transfer to production | Production-like build, data volume and hardware |
| One run, no spread | Noise looks like improvement | Several runs with warm-up; compare spreads |
| Rewriting in a faster language | Months of risk for a hot spot that is usually one query | Profile; fix the hot spot first |
| Rationalisation | Truth |
|---|---|
| "I know where the bottleneck is." | Profilers exist because that belief is wrong so often. Show the profile. |
| "This will be slow at scale." | Then measure at that scale with a load test. Until then it is a guess. |
| "Caching will make everything faster." | Caching makes cache hits faster and everything else more complicated. Measure what is slow first. |
| "Best practice says to add an index here." | Best practice does not know your queries. The query plan does. |
| "While I'm in here, I'll tune this too." | Unmeasured, unplanned changes are noise in the next measurement. One change at a time. |
| "It feels faster." | Feelings are not a measurement. Run the same benchmark. |
| "The improvement is small but it can't hurt." | Every change costs clarity and review time. Changes within the noise are reverted. |
Never:
Always:
godmode:fault-diagnosis: when slowness is really a bug (a hang, a leak, a retry storm), diagnose it there.godmode:system-design: when the profile points at architecture (data model, service boundaries, hosting), the decision moves there.godmode:quality-gates: budgets and benchmarks become CI gates.godmode:test-first: tests pin behaviour before the optimisation changes code.godmode:grounding: profiler flags and framework performance features are checked against current documentation.godmode:completion-gate: the before and after numbers are the evidence that the work is done.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
33 skills in this plugin
/agent-briefingUse when writing a prompt for a subagent or teammate, deciding how much context another agent needs, writing or reading a handoff report between agents, or sending a message to another agent mid-task./codebase-conventionsUse when about to add or change code in an existing codebase: a new file, module, route, component, service, test, migration, error path or dependency, especially in a project the agent did not write or has not yet surveyed in this session./code-reviewUse when a task, feature or bug fix is implemented and before it is committed, merged or handed back to the user, and when the user asks for a review of a change, a branch or a pull request./completion-gateUse when about to say that work is done, fixed, passing, working, deployed or ready, before committing, opening or merging a pull request, closing a task, moving to the next task, or reporting a subagent's result as finished./cross-model-reviewUse when a reviewed change is about to land on a shared branch, be released or be deployed, and when the user asks for a second opinion on a change from a different model or a different AI vendor./delegated-executionUse when a written implementation plan is ready to execute in the current session and its tasks are mostly independent, so each one can go to a fresh implementer subagent with its own review.npx claudepluginhub noobygains/godmode --plugin godmodeOther plugins' skills for the same job