Perf Commands
Explore 4 curated perf commands for building with AI coding agents — what each one does, when to use it, and how to add it to your workflow.
Four slash commands for performance work that starts with measurement. /find-n-plus-one scans code, read-only, for N+1 query patterns such as loops that query once per row, and reports each one with its location and the eager-load, batch or set-based fix. /profile-postgres-queries ranks a Postgres workload's queries by total time with pg_stat_statements, runs EXPLAIN on the worst offenders and recommends the fix with the most leverage.
The other two change code. /add-caching adds a cache to one expensive function or endpoint after confirming it is safe to cache, with a designed key, TTL, invalidation and stampede handling. /set-perf-budget sets p95 and p99 latency and cost-per-request ceilings for an LLM feature, measures them against real traffic and adds a check that fails when the budget is breached. Find the slow path first, fix it, then budget it so it stays fixed.
4 commands
Add Caching
Add a caching layer to one expensive function or endpoint correctly — confirm it's cacheable, design the cache key/TTL/layer/invalidation, handle stampedes, wrap the call in one place, and report the design.
Find N+1 Queries
Scan code read-only for N+1 query patterns — loops that query per iteration and handlers that fan out per-row — and report each with a location, why it is N+1, and the concrete eager-load/batch/set-based fix.
Profile Postgres Queries
Profile a Postgres workload to find the queries actually costing you — rank by total time with pg_stat_statements, EXPLAIN the worst offenders, and recommend the highest-leverage fix.
Set Perf Budget
Define and enforce a cost and latency budget for an LLM feature or endpoint — set p95/p99 latency and cost-per-request ceilings, instrument to measure them against real traffic, and wire a check that fails when the budget is breached.