Audit Git Diffs for Race Conditions and Shared Mutable State
Reviews code diffs for silent concurrency bugs, mapping concurrent execution timelines and providing exact thread-safe mitigation fixes.
Agent prompt for ChatGPT and Claude
You get: Summary, findings Table and hardened Code Snippets
Prompt
mkdir -p .agents/skills/audit-git-diffs-for-race-conditions-and-shared-mutable-state && curl -sL "https://prompts-gpt.com/prompts/audit-git-diffs-for-race-conditions-and-shared-mutable-state/raw" -o .agents/skills/audit-git-diffs-for-race-conditions-and-shared-mutable-state/SKILL.mdAct as a principal systems engineer specialized in concurrency and multithreaded debugging. Your task is to audit the git diff I will paste below to detect silent race conditions, unsafe shared state, non-atomic read-modify-writes, and deadlocks.
Rules:
1. Focus strictly on lines introduced or modified in the diff, plus immediate surrounding context.
2. Ignore general style or cosmetic issues; highlight only hazards where timing, reordering, or concurrent execution can corrupt data or panic.
3. For every discovered issue, trace a concrete execution timeline with at least two threads or concurrent tasks.
4. Provide the exact thread-safe patch using language-standard primitives (such as mutexes, atomic types, or immutable structures).
Output format:
- Summary: A 2-sentence overview of overall concurrency safety in this diff.
- Findings Table: A Markdown table with four columns: Location (file and line), Shared State / Hazard, Concurrent Timeline (Thread A vs Thread B sequence), and Recommended Mitigation.
- Hardened Code Snippets: For each finding, display the exact corrected code block.
- Assumptions and Blind Spots: Note what runtime model, runtime scheduler settings, or external database guarantees this analysis assumes.
Paste your git diff below this prompt to begin.Example output
Tips and common edits
Why this works
- Forces a step-by-step concurrent execution timeline, preventing vague warnings about thread safety.
- Restricts review strictly to shared mutable state, eliminating off-topic style suggestions.
- Demands a four-column structured comparison linking exact file locations to thread-safe remediations.
Paste your git diff or pull request patch directly under the prompt in GitHub Copilot Chat, ChatGPT, or Claude to uncover subtle multithreading flaws.
Common edits
- Specify your target concurrency runtime, such as Tokio in Rust, asyncio in Python, or virtual threads in Java.
- Add a constraint requiring distributed lock patterns (like Redis Redlock) instead of in-memory primitives.
Reuse it: Use in a workflowAdapt in the builder
Prompt details
- By
- Prompts-GPT editors
- Published
More like this
Audit a TypeScript API Route for Race Conditions, Auth, and N+1 Bugs
Get a severity-ranked security and performance audit of your TypeScript API route with exact line numbers, concrete exploit or failure scenarios, and minimal targeted fix diffs.
Audit PR Git Diffs for Scope Creep and Churn
Reviews git diff statistics and patch files to immediately flag out-of-scope edits, accidental whitespace formatting churn, and unrequested dependency updates.
Review AI Pull Requests for Phantom Imports and Bloat
Audits pull request diffs generated by coding agents to flag fake dependencies, single-call wrappers, and premature abstractions.
Verify the Coding Agent's 'Done' Claim Against the Diff and Test Output
Checks each claim in a coding agent's final summary against the actual diff and test runs, marks it verified, unverified or contradicted with evidence, and lists unmentioned changes, skipped tests and stubs.
Conventional Commit and PR Description from a Diff and Ticket
Produces a Conventional Commits message and a reviewer-ready PR description covering what changed, why, how to test it, and the risks, based on your diff and ticket.
Audit a Pull Request Diff for Breaking API Changes
Separates wire-breaking schema, status code, and migration changes from safe additions, returning a consumer impact table and deprecation plan.
- Audit Cursor Rules Files for Conflicts and Context Bloat
- Audit AI Code Diffs for Performance Regressions
- Create a Deterministic Code Review System Prompt for Cursor
- Security Review of a Code Snippet: Ranked Findings With Exploit Path and Fix
- Pull Request Review with Merge Recommendation
- Pre-PR Self-Review and Pull Request Description from a Git Diff