Code review
AuraScore 81/100

Concurrency and Thread Safety Code Review Framework

Systematically evaluate asynchronous logic and shared-state synchronization in critical backend services.

Use this template when auditing complex concurrent code, multithreaded jobs, or async pipelines for race conditions and deadlocks. It helps engineers establish a structured checklist to identify resource contention and ensure thread safety.

Template

Role: Principal Distributed Systems Engineer specializing in multi-threaded runtime optimization.

Context

  • Target service: {{target_service}}
  • Language runtime: {{language_runtime}}
  • Target throughput: {{throughput_target}}
  • Pull request diff: {{code_diff}}
  • Observed contention issues: {{known_bottlenecks}}

Task

Construct a comprehensive concurrency code review framework that evaluates the provided code diff for race conditions, memory visibility gaps, and thread contention, generating an actionable evaluation matrix with remediations to meet throughput goals.

Method

  1. Map all mutable shared state across the lifecycle of {{target_service}} within the provided diff.
  2. Trace synchronization primitives and lock lifecycles against runtime behaviors in {{language_runtime}}.
  3. Analyze potential deadlock scenarios, including inverted locking orders and unreleased lock guards in error paths.
  4. Evaluate non-blocking primitives, atomic references, and volatile markers for correct memory barrier enforcement.
  5. Assess thread pool sizing, task rejection policies, and queue saturation under {{throughput_target}} load.
  6. Investigate the impact on {{known_bottlenecks}} to ensure the change does not degrade latency profiles.
  7. Formulate specific code-level refactoring patterns to eliminate discovered race conditions.

Constraints

  • MUST evaluate specific synchronization patterns native to {{language_runtime}}.
  • MUST NOT recommend unbounded queue allocations or global blocking locks without justification.
  • Every identified concurrency issue must be paired with a code remediation sample.
  • Focus strictly on concurrency, thread management, and shared state integrity.

Output format

  • Executive Concurrency Summary (2-3 paragraphs)
  • Synchronization Risk Matrix (Markdown table with columns: Code Location, Concurrency Threat, Severity, Recommended Fix)
  • Remediation Code Blueprints (diff snippets with before/after blocks)
  • Concurrency Verification Checklist (5-7 item validation checklist for local load testing)

Self-review

  • Confirm all shared mutable state identified in {{code_diff}} has been cataloged.
  • Verify that each recommended synchronization primitive aligns with {{language_runtime}} idioms.
  • Check that the output directly addresses {{known_bottlenecks}} and throughput viability.
AuraScore breakdown
81/100Provisional
Instruction clarity15/15 · Strong

Explicit role, a named task, and discrete steps the model can follow.

Context architecture12/12 · Strong

Background, inputs and variables the model needs before it starts.

Constraint engineering10/12 · Adequate

Hard boundaries — what the model must and must not do.

Output specification6/14 · Thin

A named, field-level shape for the response.

Reasoning structure10/10 · Strong

Ordered work items that force analysis before an answer.

Model compatibility10/10 · Strong

Length and structure that travel across frontier models.

Token efficiency7/10 · Adequate

Signal density — instruction weight without padding.

Reusability7/7 · Strong

Documented variables so the scaffold adapts to new inputs.

Robustness3/5 · Adequate

Quality bar, assumptions and behaviour when inputs are thin.

Observed performance1/5 · Thin

How much real usage the template has behind it.

developers
developers-code-review
software-engineering-debugging
concurrency
code-review
distributed-systems