When should you use it?
- A page is slow only on production data
- You suspect queries but cannot see which
- The codebase is open in an agent-capable editor
Not for: Outages needing immediate rollback; Databases you cannot change indexes on without review
What do you need, and what do you get?
You need
- The repository
- Symptoms and timings from production
- Read access to schema definitions
You get
- A list of probable causes with reasoning
- Index and query recommendations
- Before-and-after timings
How does it work, step by step?
- Describe the symptom preciselySay which page, how slow, and that development data does not reproduce it.
- Ask for causes, not a patchRequest possible explanations and remedies ranked by likelihood.
- Let it read the data layerThe agent traced the ORM calls to work out which queries and filters hit the database.
- Apply the cheapest fix firstAdd the suggested indexes in a staging copy and measure the page again.
- Be wary of test generationWhen the author tried agent-written unit tests, faulty mock setup kept them failing until he debugged by hand.
The prompt
Our own prompt, inspired by The Prairie Programmer and written to work in Custom agent. Values in lime are placeholders.
Production page [route] takes [N] seconds to load; on dev it is instant. Read the controllers, services and ORM calls behind it. List the likely causes in order of probability, show the exact queries you think are slow, and suggest the cheapest fix for each, such as an index. Write any schema change as a migration. Do not apply anything to production.
Inspired by The Prairie Programmer: December 2025 Lessons. The prompt above is written by playbooks.bot in our own words; nothing from the original is quoted.
What can go wrong?
- New indexes slow writes and take time to build on large tables; schedule them.
- Repeatedly prompting an agent to fix failing mocks did not work for the author; step through the code yourself.
Our take
Trevor Arnold's plain note from day-to-day work is useful precisely because the results split. Diagnosis excelled when the agent could read both the code and the database access pattern; generating tests stalled because mocks need an exact picture of behavior the agent did not have. Always ask for an explain plan before and after adding an index so the improvement is measured rather than felt. Keep index changes in a migration file reviewed like any other schema change, and watch write amplification on hot tables. Describe the symptom precisely, including that local is fine, so the agent does not chase unrelated code. Prefer the cheapest fix first: an index beats a rewrite. Be wary of letting agents invent test doubles; write those yourself or point it at existing fixtures. Re-check the slow page under realistic load after deploy, not only on your laptop. Document which queries were touched so the next on-call shift is not surprised.
Where the time goes back: Turning a vague slowdown into a short list of query-level suspects saves hours of profiling guesswork.
FAQ
Why did dev not show the problem?
Did the agent fix the tests in the end?
Source and credit
Inspired by The Prairie Programmer. We describe the idea in our own words, link to the original, and wrote the prompt ourselves; nothing is quoted.
- Inspired by
- December 2025 Lessons
- Creator
- The Prairie Programmer
- Published on
- trevorarnold.substack.com (Substack)
- Original date
- Jan 5, 2026
- License
- Not openly licensed (the poster keeps all rights), so we quote nothing and link to the original
- Originally for
- Custom agent
- AI dry run
- Oct 23, 2026: passed. Dry-run tested by our AI test agent on sample input. PASS: Gates held on desk check; no live sends or purchases.
AI dry run on sample data; not run with live connected accounts. The playbooks.bot test agent filled the prompt with synthetic inputs, produced the output and checked it against the page's stated outputs and guardrails. - Verified
- Oct 23, 2026: source link resolves to the original, the credited creator published it, our excerpt or prompt matches it, and the license allows our use.
Are you the creator? Claim or correct this page.