Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio
AI

The AI Prompt That Spots a Race Condition in a Review Diff

- 25.11.26 - ErcanOPAK

🤖 The AI Prompt That Spots a Race Condition in a Review Diff

Reviewing a pull request for a subtle race condition is hard because the two interleavings that cause the bug rarely sit next to each other in the diff — one thread’s read might be several files away from the write that invalidates it. Pasting the diff into a tightly scoped prompt gets a model to specifically hunt for shared-mutable-state patterns that a human reviewer, skimming for logic correctness, tends to skip past entirely.

🔎 The Problem

You are reviewing this diff for concurrency bugs only - ignore style, naming,
and any logic issue that isn't concurrency-related.

For every piece of shared mutable state touched in this diff (fields, static
members, caches, connection pools), check:
1. Is it read and written from more than one thread/task without a lock,
   an atomic operation, or an immutable snapshot?
2. Could two callers interleave in a way that corrupts state or causes a
   stale read (check-then-act patterns especially)?
3. Does a new async method introduce a yield point in the middle of a
   sequence that assumed it would run atomically?

List each finding as: file, line range, the specific interleaving that breaks
it, and the smallest fix. If you find nothing, say so explicitly rather than
commenting on unrelated code.

<diff>
PASTE DIFF HERE
</diff>

✅ Why This Works

  • Scoping the model to “concurrency bugs only” stops a real finding from drowning in a dozen unrelated style nitpicks, which is the usual reason a race condition gets missed in a normal review pass.
  • Asking for the specific interleaving, not just “this might not be thread-safe,” forces an answer concrete enough that you can actually verify it against the code in under a minute.
  • Requiring an explicit “found nothing” response instead of generic praise keeps a clean diff from getting a false positive just because the model wants to say something.

🚨 Why This Is Dangerous

  • Treat every flagged interleaving as a hypothesis to verify against the actual call sites, not a confirmed bug — a model that’s never seen your deployment topology can misjudge whether two code paths can genuinely run concurrently at all.

The bug that only shows up once in ten thousand requests is rarely found by running the code — it’s found by someone, or something, asking the right question about who else might be touching that variable.

— AI Power User

Related posts:

AI Prompt: Generate Cold Emails That Convert

AI Prompt: Generate Cold Emails That Convert

The AI Prompt That Names Your Variables Better Than You Do

The AI Prompt That Names Your Variables Better Than You Do

AI Prompt: Learn Any Programming Concept with Analogies and Examples

AI Prompt: Learn Any Programming Concept with Analogies and Examples

Views: 9
Found this useful? Share it
XLinkedInWhatsApp

Post navigation

SQL Server: Fix a Partition Switch Failing on a Mismatched Index
CSS: Fix a Nested :is() Selector Losing Specificity Weight

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Most Read

  1. 01How to make theater mode the default for Youtube 1,079 views
  2. 02How to add default value for Entity Framework migrations for DateTime and Bool 997 views
  3. 03Get the User Name and Domain Name from an Email Address in SQL 996 views
  4. 04Get the First and Last Word from a String or Sentence in SQL 873 views
  5. 05How to select distinct rows in a datatable in C# 868 views
  6. 06How to enable, disable and check if Service Broker is enabled on a database in SQL Server 671 views
  7. 07Add Constraint to SQL Table to ensure email contains @ 631 views
  8. 08Average of all values in a column that are not zero in SQL 584 views
  9. 09How to use Map Mode for Vertical Scroll Mode in Visual Studio 562 views
Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
Back to top
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com