← Back to library

Ask an editor agent why production is slow but dev is fine

The Prairie Programmer (Trevor Arnold) had one page that dragged in production yet loaded quickly locally. Cursor's agent suggested likely causes and fixes: it read the NestJS data-access layer, worked out which queries ran and recommended database indexes. Load times improved sharply. Agent-written Python unit tests that month were less successful because of broken mocks.

  • OutcomeGet a ranked list of likely causes for a production-only slowdown, tied to your actual queries, and a fix you can test the same day.
  • SetupUnder an hour
  • LevelIntermediate
  • CreditThe Prairie Programmer
View original
Works with
Custom agent

Published Oct 23, 2026Updated Oct 23, 2026AI dry run on sample input: passed Oct 23, 2026Source verified Oct 23, 2026

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?

  1. Describe the symptom preciselySay which page, how slow, and that development data does not reproduce it.
  2. Ask for causes, not a patchRequest possible explanations and remedies ranked by likelihood.
  3. Let it read the data layerThe agent traced the ORM calls to work out which queries and filters hit the database.
  4. Apply the cheapest fix firstAdd the suggested indexes in a staging copy and measure the page again.
  5. 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.

Prompt0 variables
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?
Small development datasets often hide missing indexes that only matter at production volume.
Did the agent fix the tests in the end?
No. The author found the service mock's return value was wrong and corrected it manually.

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.

More in IT & Security

All 82 IT & Security playbooks →

Related playbooks

IT & SecurityWorkflow✓ AI dry run

Distill agent sessions into shared memory every night

Save each completed agent session to its own transcript file, have one analyzer agent per transcript verify, enrich and organize small linked memory files, run an organizer once to merge duplicates and keep an index current, then attach the store to the agent's next session with read access only and repeat the pass nightly on new sessions.

Credit: Anthropic

An afternoon+
IT & SecuritySkill✓ AI dry run

Make your coding agent write the behavior before the code

Add a short standing rule to your coding agent's project file so every user-facing change starts as plain-language scenarios, becomes a failing test and only then gets the smallest code change that makes it pass.

Credit: u/cannyshammy on r/ClaudeCode

Minutes
IT & SecurityWorkflow✓ AI dry run

Onboard a coding agent like a junior engineer

Get real work out of an autonomous coding agent on a mature codebase by teaching it your conventions, the way you would onboard a new hire.

Credit: Varun Jindal, Engineer @ Lumos / Andrew Wang, Engineer @ Lumos

An afternoon+