Skip to content
agentscamp

Perf Commands

A curated collection of 4 perf commands for building with AI coding agents.

Command

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.

/add-caching<function or endpoint to cache>
Command

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.

/find-n-plus-one<path or area to scan (optional)>
Command

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.

/profile-postgres-queries<database/connection details, a slow endpoint, or a description of the workload>
Command

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.

/set-perf-budget<the LLM endpoint/feature to budget, plus any target numbers (e.g. 'chat API, p95 < 2s, < $0.02/req')>