Concurrency and Race Review
A review of shared-state hazards in a diff, with concrete failure scenarios.
Advanced · Works with ChatGPT, Claude, Gemini, Copilot
The prompt
Review this code for shared-state hazards: races, deadlocks, and stale reads under concurrent access.
For each finding, give a concrete scenario where it fails and the specific rewrite that fixes it, and note the one thing genuinely done well before the criticism.
Code to review:
{{CODE}}
Concurrency model and constraints:
{{STACK}}Why this prompt works
Requiring a concrete failure scenario per finding filters out theoretical race conditions that can't actually occur given the code's structure.
How to customize it
- Write a test that reproduces the scenario before trusting the fix.
- Check whether the fix introduces a new lock ordering that could deadlock elsewhere.
Common mistakes
- Accepting a flagged race without confirming it's reachable in this specific code path.
- Fixing races with broader locks that silently reintroduce contention problems.
Example
Input
Code to review: In-memory cache with a background refresh thread and read/write from request handlers
What a good answer looks like
A list of hazards, each with a failure scenario, severity, and the rewrite.
Make this prompt fit your work
ModelCoach.ai scores your version, shows what to improve and explains why, right inside ChatGPT, Claude, Gemini and Copilot.