Inferensys

Prompt

Concurrency Code Review Checklist Prompt

A practical prompt playbook for using Concurrency Code Review Checklist Prompt in production AI workflows.
Operations team reviewing AI workflow automation on laptop, workflow builder visible, casual office setup.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the specific job-to-be-done, the ideal user, and the boundaries for the Concurrency Code Review Checklist Prompt.

Engineering teams standardizing concurrency review practices need a systematic, repeatable checklist that adapts to the specific code change, language, and concurrency primitives involved. This prompt generates a context-specific review checklist with pass/fail criteria, replacing ad-hoc reviewer memory with a structured artifact that can be tracked, audited, and improved over time. The ideal user is a senior engineer or tech lead conducting a pre-merge review for a pull request that touches shared state, locks, channels, async operations, or transaction boundaries.

Use this prompt when your team reviews PRs that modify synchronization logic, introduce new concurrent data structures, or alter goroutine/thread lifecycles. The prompt requires the actual code diff, the target language, and a list of concurrency primitives in play as inputs. It is designed to be wired into a CI/CD pipeline or a code review tool where it can produce a markdown checklist artifact that reviewers work through item by item, checking off each pass/fail criterion before approving the change.

Do not use this prompt as a substitute for runtime race detectors, stress tests, or formal verification tools. The checklist is a review aid, not a correctness proof. It cannot guarantee the absence of race conditions, and it should never be the sole gate for safety-critical or financial transaction code paths. For high-risk changes, always pair the generated checklist with automated race detection under load and a human approval step that verifies each checklist item against the actual code behavior.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Concurrency Code Review Checklist Prompt works well and where it introduces risk. Use these cards to decide if this prompt fits your review pipeline before integrating it.

01

Good Fit: Standardized Review Workflows

Use when: engineering teams want a consistent, repeatable concurrency review process for every PR. The prompt excels at generating structured checklists with pass/fail criteria mapped to specific concurrency primitives. Guardrail: always pair the generated checklist with a human reviewer who can override or supplement checklist items based on domain knowledge the prompt cannot access.

02

Bad Fit: Novel Synchronization Primitives

Avoid when: the code change introduces a custom lock-free data structure, a new synchronization algorithm, or an unusual memory ordering pattern not covered by standard library primitives. The prompt relies on known patterns and may miss correctness violations in novel concurrent designs. Guardrail: escalate novel synchronization code to a senior systems engineer for formal review and consider using a dedicated lock-free correctness review prompt instead.

03

Required Inputs

What you must provide: the code diff or code snippet under review, the programming language and concurrency primitives used (e.g., mutexes, channels, async/await), and the type of change (new feature, bug fix, refactor). Without these, the checklist will be generic and miss context-specific risks. Guardrail: include a concurrency context block in your PR template that authors fill out before the prompt runs.

04

Operational Risk: Checklist Fatigue

Risk: if every PR generates a long checklist, reviewers may start skimming or ignoring items, defeating the purpose. This is especially dangerous for low-risk changes where the signal-to-noise ratio drops. Guardrail: implement a severity filter that only surfaces checklist items rated medium or higher risk, and allow reviewers to dismiss low-risk items with a single click while logging the dismissal for audit.

05

Operational Risk: Language-Specific Blind Spots

Risk: the prompt may generate checklist items that are syntactically valid but semantically wrong for the specific language runtime or framework. For example, Go channel checklist items applied to Rust async channels without adaptation. Guardrail: always include the exact language version, runtime, and framework in the prompt context, and maintain language-specific checklist templates that have been validated by language experts on your team.

06

Boundary: When to Use a Different Prompt

Risk: this prompt generates a review checklist but does not perform the review itself. Teams sometimes confuse checklist generation with automated concurrency bug detection. Guardrail: use this prompt for process standardization and reviewer guidance. For automated detection of specific concurrency bugs, use a dedicated detection prompt (e.g., deadlock potential analysis, race condition detection) and feed its output into the checklist as evidence.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable, context-aware prompt template for generating a structured concurrency review checklist from a code change.

The following prompt template is designed to be dropped into your code review pipeline. It instructs the model to act as a systems-level reviewer, analyzing a provided code diff against a set of concurrency primitives and generating a structured, actionable checklist. The template uses square-bracket placeholders that your application must populate before sending the request to the model. The most critical placeholders are [CODE_DIFF], which should contain the unified diff of the change, and [LANGUAGE], which tailors the analysis to language-specific memory models and concurrency constructs.

text
You are a senior systems engineer performing a concurrency-focused code review.
Your task is to analyze the provided code change and generate a structured review checklist.

## Input Context
- **Language:** [LANGUAGE]
- **Change Type:** [CHANGE_TYPE, e.g., bug_fix, new_feature, refactor]
- **Concurrency Primitives Used:** [PRIMITIVES_USED, e.g., mutex, channels, async/await, locks]
- **Risk Level of Change:** [RISK_LEVEL, e.g., low, medium, high, critical]

## Code Diff to Review
```[LANGUAGE]
[CODE_DIFF]

Instructions

  1. Identify every section of the diff that touches shared state, synchronization, I/O, or async boundaries.
  2. For each identified section, generate a checklist item.
  3. Each checklist item must include:
    • Category: [Data Race, Deadlock, Atomicity Violation, Thread Safety, Resource Leak, Correctness]
    • Location: File path and line range from the diff.
    • Check: A specific, pass/fail question the reviewer must answer.
    • Guidance: A brief explanation of what to look for to pass the check.
  4. Do not include items for code that is purely algorithmic with no concurrency implications.
  5. Group checklist items by category, ordered by risk severity.

Output Schema

Return a JSON object with the following structure: { "review_checklist": [ { "category": "string", "location": "string", "check": "string", "guidance": "string" } ], "risk_summary": "string" }

Constraints

  • Only report on code present in the diff. Do not hallucinate issues in unchanged files.
  • If no concurrency risks are found, return an empty checklist and a risk_summary stating that.
  • Use precise technical language appropriate for a [LANGUAGE] code review.

To adapt this template, your application should first run a static analysis or diff-parsing step to populate [PRIMITIVES_USED] and [CHANGE_TYPE]. This pre-processing prevents the model from guessing and grounds the review in concrete facts. The [RISK_LEVEL] can be set based on the component's criticality or a prior triage step. For high-risk or critical changes, the generated checklist should be treated as an advisory tool; a human reviewer must sign off on each item. Implement a post-processing validation step that parses the JSON output and verifies that every location field references a file path and line range that exists in the original [CODE_DIFF] to catch model hallucinations before they reach the reviewer.

IMPLEMENTATION TABLE

Prompt Variables

Required and optional inputs for the Concurrency Code Review Checklist Prompt. Validate these before calling the model to prevent checklist generation based on incomplete or ambiguous context.

PlaceholderPurposeExampleValidation Notes

[CODE_DIFF]

The code change to review for concurrency issues

diff --git a/pkg/worker/pool.go b/pkg/worker/pool.go ...

Required. Must be non-empty. Parse check: valid unified diff or raw code block. Reject if only a ticket ID or URL is provided without code.

[LANGUAGE]

Target programming language for concurrency primitive selection

Go

Required. Must match a supported language identifier. Validate against allowlist: Go, Java, Python, Rust, C++, C#, Kotlin, TypeScript, Scala. Reject unknown values.

[CHANGE_TYPE]

Category of code change to scope checklist relevance

goroutine lifecycle refactor

Required. Must be one of: new feature, bug fix, refactor, performance optimization, dependency update, configuration change. Free-text subcategory allowed after primary type.

[CONCURRENCY_PRIMITIVES]

Concurrency primitives used in the diff or surrounding codebase

goroutines, channels, sync.Mutex, context.Context

Optional but strongly recommended. Comma-separated list. If omitted, the model must infer from [CODE_DIFF], which increases checklist incompleteness risk. Validate against known primitives for [LANGUAGE].

[EXISTING_TESTS]

Relevant existing test code or test coverage summary for the changed paths

func TestWorkerPoolShutdown(t *testing.T) { ... }

Optional. Include if available to help the model assess test gaps. If null, the checklist should flag missing test coverage as a high-priority item.

[KNOWN_ISSUES]

Previously identified concurrency bugs or flaky test reports in the same area

JIRA-4521: deadlock on pool shutdown under load

Optional. Include bug IDs, stack traces, or symptom descriptions. If null, the model should note that no prior issues were provided and recommend checking incident history.

[REVIEW_DEPTH]

Desired thoroughness of the checklist

comprehensive

Optional. Defaults to standard. Must be one of: quick, standard, comprehensive. Controls checklist length and depth of interleaving analysis. Reject values outside enum.

[OUTPUT_FORMAT]

Desired structure for the generated checklist

markdown with pass/fail checkboxes

Optional. Defaults to markdown checklist. Must be one of: markdown, json, yaml. If json or yaml, the model must include a schema with item, severity, pass_fail, and finding_location fields.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the concurrency checklist prompt into a CI pipeline, code review tool, or manual review workflow with validation, retries, and human approval gates.

The Concurrency Code Review Checklist Prompt is designed to be integrated into a deterministic software delivery pipeline, not just used as an ad-hoc chat. The primary integration points are a CI/CD system (like GitHub Actions, GitLab CI, or Jenkins) triggered on pull request events, or a code review platform's automation API. The harness must extract the code diff, identify the primary language and changed concurrency primitives, and inject them into the prompt's [CODE_DIFF], [LANGUAGE], and [CONCURRENCY_PRIMITIVES] placeholders. Because concurrency bugs are high-severity and hard to reproduce, the output should be treated as a structured artifact that is attached to the PR as a review checklist, not as a passing or failing CI status on its own.

A robust implementation requires a multi-stage harness. First, a pre-processing stage parses the diff to extract only relevant files (e.g., excluding documentation or config changes) and uses a static analysis tool or simple regex to detect concurrency primitives like synchronized, Lock, go, async, or Mutex. This stage populates the [CONCURRENCY_PRIMITIVES] and [LANGUAGE] fields. Second, the LLM call stage sends the assembled prompt to a capable model (GPT-4o or Claude 3.5 Sonnet are recommended for their structured output reliability). The call must specify a strict JSON schema for the response, matching the checklist structure defined in the prompt's [OUTPUT_SCHEMA]. Third, a validation stage parses the JSON output and runs schema validation, checking that every checklist item has a non-empty id, category, criterion, and pass_fail_guidance. Any malformed response triggers a single retry with a repair prompt that includes the validation error. If the retry also fails, the harness logs the failure and posts a comment on the PR requesting a manual concurrency review, ensuring the pipeline never silently drops a critical safety check.

For high-risk codebases (financial systems, safety-critical services, or multi-threaded data pipelines), the harness should include a human approval gate. After the checklist is generated and validated, it is posted as a PR comment or review summary. The CI pipeline should block the merge until a designated reviewer with concurrency expertise checks a box or applies a label (e.g., concurrency-reviewed). This prevents the checklist from becoming a rubber-stamp artifact. Additionally, log every prompt invocation, including the diff hash, model response, validation status, and reviewer action, to an observability platform. This audit trail is essential for post-incident analysis if a concurrency bug slips through, allowing the team to trace whether the checklist was generated correctly, reviewed adequately, or ignored. Avoid using this prompt on every trivial commit; gate it on changes touching files with known concurrency patterns or directories flagged in a .concurrency-review.yml configuration file to manage cost and reviewer fatigue.

IMPLEMENTATION TABLE

Expected Output Contract

Defines the structure, types, and validation rules for the checklist generated by the Concurrency Code Review Checklist Prompt. Use this contract to parse the model's output, validate it before presenting to a reviewer, and detect malformed or incomplete responses.

Field or ElementType or FormatRequiredValidation Rule

checklist_title

String

Must be a non-empty string summarizing the review scope. Validate with length > 0 and length < 200 characters.

generated_at

ISO 8601 datetime string

Must parse as a valid ISO 8601 datetime. If the model fails to produce a valid timestamp, the application layer should inject the current time.

context_summary

String

Must be a non-empty string describing the code change, language, and concurrency primitives analyzed. Validate with length > 10 characters.

checklist_items

Array of objects

Must be a non-empty array. Validate that array length >= 1. If empty, retry the prompt or escalate for manual review.

checklist_items[].id

String (slug format)

Must match the pattern ^[a-z0-9]+(?:-[a-z0-9]+)*$. Validate with regex. Used as a stable key for tracking pass/fail results across runs.

checklist_items[].category

Enum string

Must be one of: 'synchronization', 'transaction', 'thread_safety', 'async_flow', 'resource_management', 'testing', or 'other'. Validate against the allowed enum set.

checklist_items[].description

String

Must be a non-empty string describing the specific check to perform. Validate with length > 20 characters to ensure actionable detail.

checklist_items[].pass_criteria

String

Must be a non-empty string defining what passing looks like. Validate with length > 10 characters. Should be phrased as an observable condition.

checklist_items[].severity

Enum string

Must be one of: 'critical', 'high', 'medium', or 'low'. Validate against the allowed enum set. Critical findings should block merge.

checklist_items[].code_locations

Array of strings or null

If present, each string must match a file path pattern like 'path/to/file.ext:line_number'. Validate with regex. Null is allowed when no specific location is identified.

PRACTICAL GUARDRAILS

Common Failure Modes

Concurrency review prompts fail in predictable ways. These are the most common failure modes when using a Concurrency Code Review Checklist Prompt, along with practical guardrails to prevent them.

01

Checklist Ignores Language-Specific Primitives

What to watch: The model generates a generic checklist that misses language-specific concurrency primitives (e.g., suggesting synchronized blocks for Go code or missing asyncio patterns for Python). The checklist becomes irrelevant to the actual codebase. Guardrail: Always include the target language and framework in the prompt input. Validate the first generated checklist against a known list of that language's concurrency primitives before adopting it.

02

False Positives on Safe Patterns

What to watch: The prompt flags safe concurrency patterns as risky because it lacks context about framework guarantees or established team patterns (e.g., flagging a thread-safe singleton as a race condition). This erodes reviewer trust and creates noise. Guardrail: Maintain a team-specific exclusion list of known-safe patterns. Run the prompt against a golden dataset of previously reviewed safe code and measure the false positive rate before deployment.

03

Missed Deadlocks from Distributed Locks

What to watch: The checklist focuses only on in-process locks (mutexes, semaphores) and misses deadlock risks from distributed locks, database row locks, or external resource contention. Guardrail: Explicitly include distributed resource types in the prompt input when the code change touches databases, message queues, or external APIs. Add checklist items for lock timeout and lease duration verification.

04

Checklist Too Generic for the Change Size

What to watch: A small, focused PR receives an exhaustive 50-item checklist covering every concurrency concern, overwhelming the reviewer. Conversely, a large refactor gets a superficial checklist that misses critical paths. Guardrail: Include the diff size and change type in the prompt input. Instruct the model to prioritize checklist items by relevance and limit output to the top-N items proportional to change complexity.

05

Pass/Fail Criteria Are Subjective

What to watch: Checklist items use vague pass/fail language like 'check for thread safety' without concrete verification steps. Reviewers interpret criteria differently, leading to inconsistent reviews. Guardrail: Require the prompt to output specific, verifiable conditions for each checklist item (e.g., 'Verify all accesses to [shared_field] occur within a lock block' rather than 'Check shared state access').

06

Checklist Misses Transaction Boundary Gaps

What to watch: The prompt generates a thread-safety checklist but misses database transaction boundary issues when the code change spans both application logic and data access layers. Guardrail: When the diff includes both concurrency primitives and database operations, explicitly request transaction boundary analysis in the prompt. Cross-reference checklist items with transaction isolation level requirements.

IMPLEMENTATION TABLE

Evaluation Rubric

Criteria for testing the quality of the generated concurrency review checklist before integrating it into a CI/CD pipeline or review workflow. Each criterion maps to a pass standard, a failure signal, and a concrete test method.

CriterionPass StandardFailure SignalTest Method

Language and Primitive Relevance

Checklist items reference concurrency primitives and patterns specific to [LANGUAGE] (e.g., asyncio for Python, goroutines for Go).

Checklist contains generic threading advice or primitives from a different language ecosystem.

Spot-check 3 random items against the [LANGUAGE] concurrency model documentation.

Change-Type Specificity

At least 80% of checklist items directly address the provided [CHANGE_TYPE] (e.g., lock ordering, shared state mutation).

Checklist is a generic concurrency 101 list with items irrelevant to the specific code change.

Classify each checklist item as 'relevant' or 'generic' to [CHANGE_TYPE]; calculate relevance ratio.

Actionable Pass/Fail Criteria

Every checklist item includes a concrete, verifiable condition (e.g., 'Lock A is always acquired before Lock B').

Items are vague questions like 'Is the code thread-safe?' or 'Check for race conditions.'

Parse each item for a boolean condition or a specific observable state; flag items without one.

Code Location Mapping

Each checklist item maps to a specific file path or code block from the [CODE_DIFF] when applicable.

Items lack any reference to the code under review, making them untethered from the actual change.

Extract file paths or line ranges from each item; verify they exist in the provided [CODE_DIFF].

Severity Classification

Each finding includes a severity level (e.g., Critical, High, Medium, Low) with a clear definition.

Severity is missing, inconsistent, or uses non-standard labels without a provided legend.

Validate that every item has a severity field from a predefined set and that the set is defined in the preamble.

False Positive Resistance

Checklist does not flag standard library patterns or well-known safe idioms as risks (e.g., a simple mutex lock/unlock).

Checklist flags a standard, correctly implemented sync.Mutex or ReentrantLock as a potential deadlock.

Run the prompt against a 'clean' diff with known safe concurrency patterns; verify zero Critical or High findings.

Output Schema Compliance

The generated checklist is valid JSON matching the [OUTPUT_SCHEMA] without extra or missing fields.

Output is malformed JSON, missing required fields like severity or location, or contains extra commentary.

Validate the raw output against the [OUTPUT_SCHEMA] using a JSON schema validator.

Fix Suggestion Quality

For items with a 'Fail' status, a concrete code patch or refactoring pattern is suggested in the [FIX_SUGGESTION] field.

Fix suggestions are generic ('add a lock') or missing for items marked as 'Fail'.

For all 'Fail' items, assert that the [FIX_SUGGESTION] field is non-null and contains a code block or a specific API reference.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with lighter validation. Remove the strict pass/fail schema requirement and let the model output a markdown checklist. Accept free-text findings without enforcing the [severity] and [location] format. Focus on getting useful concurrency signals fast.

Prompt modification

  • Replace [OUTPUT_SCHEMA] with: Output a markdown checklist with sections for each concurrency concern found.
  • Remove [CONSTRAINTS] around required fields.
  • Add: If unsure about a finding, flag it with LOW confidence and move on.

Watch for

  • Missing schema checks leading to inconsistent formatting across runs
  • Overly broad instructions producing generic advice instead of code-specific findings
  • No severity differentiation, making it hard to prioritize review effort
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.