Works for one user, falls apart at a hundred

A practical fix and a copyable AI coding prompt. Replace bracketed placeholders with your project details.

1. Check the problem

AI-generated code assumes a single-user demo: caches that never invalidate, sockets that never resync. It passes your manual test and breaks under real traffic. Name the shared state, add a load test (k6, Locust, Playwright), and wire up error tracking.

2. Use the prompt

This works for one user but I'm worried about concurrency. Walk the code for shared or global state, caches, and any resource two users could touch at once. List the race conditions and stale-state risks, explain what breaks under load, and propose a fix for each. Then write a load test that reproduces the worst one.

3. Verify the fix

Review the proposed diff, run the relevant checks and exercise the original failing flow before merging.

Continue in the related workflow chapter or read the longer explanation.