Inferensys

Prompt

Pre-Merge Test Gap Summary Prompt

A practical prompt playbook for using the Pre-Merge Test Gap Summary Prompt in production CI/CD pipelines to generate structured, evidence-backed merge gate reports.
Developer doing prompt engineering on laptop, prompt variations visible on screen, casual coding session.
PROMPT PLAYBOOK

When to Use This Prompt

Understand the specific job this prompt performs, the required inputs, and the boundaries where it should not be applied.

This prompt is designed for a single, high-stakes job: producing a structured, evidence-backed go/no-go recommendation for a pre-merge gate in a CI/CD pipeline. It is not a general-purpose code reviewer or a conversational assistant. Its sole function is to synthesize multiple pre-existing quality signals—a code diff, test results, coverage data, and static analysis findings—into a human-readable report that a release manager or lead engineer can act on immediately. The ideal user is an engineering team that has already automated their test suite, coverage tooling, and static analysis, and now needs a consistent, auditable summary to prevent regressions from reaching the main branch.

The prompt assumes a specific input contract: you must provide structured data from your test runner, coverage tool, and static analyzer alongside the code diff. If any of these data sources are missing, incomplete, or untrusted, the output quality degrades sharply because the prompt cannot verify facts it does not receive. Do not use this prompt for real-time code completion, inline suggestions during development, or general code review without test context. It is also unsuitable when the underlying tools have not been run, as the prompt will hallucinate gaps rather than report them accurately. The prompt is a synthesis engine, not a replacement for your test infrastructure.

In production, this prompt should be wired into a merge gate that blocks pull requests when blocking gaps are detected. The output includes a blocking_gaps array where each entry must tie a specific unremediated risk to linked evidence from your tool outputs. If your workflow requires human approval for all merges regardless of the recommendation, use the advisory_gaps section to highlight items that need a reviewer's attention without blocking the pipeline. Before deploying, validate that every blocking gap in the output references a concrete file path, line range, or finding ID from your input data. A gap without evidence is a hallucination and must trigger a retry or human escalation.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Pre-Merge Test Gap Summary Prompt delivers reliable value and where it introduces unacceptable risk.

01

Good Fit: CI/CD Merge Gates with Structured Evidence

Use when: Your pipeline already produces diffs, coverage reports, and static analysis results. The prompt synthesizes these into a single go/no-go report with blocking gaps tied to specific unremediated risks. Guardrail: Feed the prompt structured inputs only; do not ask it to generate coverage data from raw code.

02

Bad Fit: Replacing Human Judgment for Critical Paths

Avoid when: The code change touches authentication, authorization, payment processing, or safety-critical systems where a missed gap could cause user harm or financial loss. Guardrail: Require human review for all blocking gaps in security-sensitive or revenue-critical code paths before merge proceeds.

03

Required Inputs: Diff, Coverage Data, and Static Analysis

What you need: A unified diff, a coverage report mapping lines to tests, and static analysis findings with rule IDs and severity. Without all three, the prompt cannot produce a reliable gap summary. Guardrail: Validate input completeness before invoking the prompt; return an error if any required input is missing or empty.

04

Operational Risk: Hallucinated Gaps from Noisy Inputs

What to watch: When coverage data is stale or static analysis produces high false-positive rates, the model may invent plausible-sounding gaps that do not exist in the code. Guardrail: Require that every blocking gap cites a specific diff hunk, a specific uncovered line range from the coverage report, and a specific static analysis rule before it can block merge.

05

Latency Risk: Large Diffs with Deep Dependency Graphs

What to watch: Monorepo PRs touching hundreds of files with complex dependency graphs can produce context windows too large for reliable synthesis, leading to truncated or inconsistent reports. Guardrail: Set a maximum diff size; for changes exceeding the limit, split the analysis by module or service boundary and aggregate results in application code, not the prompt.

06

Calibration Risk: Go/No-Go Threshold Drift

What to watch: Over time, the model may become more permissive or more conservative in its recommendations without any change to the prompt, causing either missed gaps or unnecessary merge blocks. Guardrail: Maintain a golden dataset of known-gap and known-clean diffs; run the prompt against it weekly and alert if go/no-go decisions change without a prompt update.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template with square-bracket placeholders for generating a pre-merge test gap summary report from CI/CD pipeline data.

This section provides the core prompt template for the Pre-Merge Test Gap Summary. It is designed to be pasted directly into your CI/CD pipeline configuration or LLM API call. The prompt instructs the model to synthesize multiple data sources—diff analysis, existing test results, coverage data, and static analysis findings—into a single structured report with a clear go/no-go recommendation. Every finding must be traceable to specific evidence, and blocking gaps must be tied to unremediated risks.

text
You are a senior QA automation architect reviewing a pull request before merge. Your task is to produce a Pre-Merge Test Gap Summary report.

## INPUT DATA

### Code Diff
[DIFF]

### Existing Test Results
[TEST_RESULTS]

### Code Coverage Report
[COVERAGE_REPORT]

### Static Analysis Findings
[STATIC_ANALYSIS_FINDINGS]

### Change Context
- Repository: [REPOSITORY_NAME]
- Source Branch: [SOURCE_BRANCH]
- Target Branch: [TARGET_BRANCH]
- Changed Files: [CHANGED_FILES_LIST]
- Risk Level Threshold for Blocking: [RISK_LEVEL_THRESHOLD]

## OUTPUT SCHEMA

Return a JSON object with the following structure:

{
  "merge_recommendation": "GO" | "NO_GO" | "CAUTION",
  "summary": "Brief narrative summary of test coverage status",
  "blocking_gaps": [
    {
      "gap_id": "string",
      "severity": "BLOCKING",
      "file_path": "string",
      "line_range": "start-end",
      "description": "What is untested and why it matters",
      "unremediated_risk": "Specific failure scenario that could reach production",
      "recommended_test_type": "unit | integration | e2e | contract | security | performance",
      "suggested_test_case": "Concrete test description with inputs and expected outcomes",
      "evidence_links": ["reference to diff hunk, coverage gap, or static analysis rule"]
    }
  ],
  "advisory_gaps": [
    {
      "gap_id": "string",
      "severity": "ADVISORY",
      "file_path": "string",
      "line_range": "start-end",
      "description": "What could benefit from additional testing",
      "risk_if_untested": "Potential but non-critical impact",
      "recommended_test_type": "unit | integration | e2e | contract | security | performance",
      "suggested_test_case": "Concrete test description",
      "evidence_links": ["references"]
    }
  ],
  "existing_coverage_notes": [
    {
      "gap_id": "string",
      "finding": "Description of a change that is adequately covered",
      "covering_tests": ["test names or file paths"],
      "confidence": "HIGH | MEDIUM | LOW"
    }
  ],
  "static_analysis_correlations": [
    {
      "static_finding_id": "string",
      "test_gap_relevance": "How this static finding relates to missing tests",
      "combined_risk": "Elevated risk when both conditions exist"
    }
  ]
}

## CONSTRAINTS

1. Every blocking gap MUST reference a specific diff hunk, uncovered code path, or static analysis rule. Do not flag generic concerns.
2. Blocking gaps MUST describe a concrete, unremediated risk that could cause a production failure.
3. Advisory gaps are for improvements, not critical risks. Do not inflate advisory gaps to blocking.
4. If a changed code path is covered by existing tests, list it in existing_coverage_notes with the test names.
5. Correlate static analysis findings with test gaps where the combination elevates risk beyond either alone.
6. Recommend NO_GO if any blocking gap exists. Recommend CAUTION if advisory gaps accumulate significant risk. Recommend GO only if all critical paths are tested.
7. Do not fabricate test results or coverage data. Work only from the provided inputs.
8. If inputs are insufficient to assess a gap, note the confidence as LOW and explain what data is missing.

## EXAMPLES

[FEW_SHOT_EXAMPLES]

## RISK LEVEL

[RISK_LEVEL]

To adapt this template, replace each square-bracket placeholder with structured data from your toolchain. The [DIFF] should contain the unified diff of the pull request. [TEST_RESULTS] should include pass/fail status and test names from your CI run. [COVERAGE_REPORT] should provide line-level or branch-level coverage data. [STATIC_ANALYSIS_FINDINGS] should include rule IDs, file locations, and descriptions. The [FEW_SHOT_EXAMPLES] placeholder is critical for calibration—provide 2-3 examples of correctly classified blocking vs. advisory gaps from your team's historical reviews. The [RISK_LEVEL] placeholder should contain your organization's risk tolerance policy, such as 'Blocking gaps require immediate test addition before merge; advisory gaps may be addressed in the next sprint.' Always validate the model's output against the schema before surfacing it in your merge gate. If the output contains blocking gaps without specific evidence links, reject the response and retry with stricter instructions.

IMPLEMENTATION TABLE

Prompt Variables

Each placeholder must be replaced with structured data from your CI/CD toolchain. Variables are designed to be assembled programmatically before the prompt is sent. Validate types, non-null constraints, and size limits before assembly.

PlaceholderPurposeExampleValidation Notes

[DIFF]

Unified diff of the code changes under review, including file paths and line ranges.

diff --git a/src/auth/login.ts b/src/auth/login.ts @@ -12,7 +12,15 @@ ...

Must be non-empty string. Validate diff format (unified or git). Reject if only whitespace changes. Max 50KB to stay within context window.

[COVERAGE_REPORT]

Structured coverage data for the files touched by the diff, including line and branch coverage percentages.

{"files": [{"path": "src/auth/login.ts", "lineCoverage": 0.72, "branchCoverage": 0.45, "uncoveredLines": [18,19,20,21,22]}]}

Must be valid JSON. Each file entry requires path, lineCoverage, and uncoveredLines array. Null allowed if coverage tool unavailable; prompt must handle missing coverage gracefully.

[TEST_RESULTS]

Latest test suite execution results, including passed, failed, skipped, and flaky test counts with failure messages.

{"summary": {"passed": 142, "failed": 3, "skipped": 0, "flaky": 2}, "failures": [{"test": "testLoginExpiredToken", "message": "Expected 401, got 500"}]}

Must be valid JSON. Failed test messages required for gap correlation. Null allowed if no test run exists; prompt must note absence of test signal.

[STATIC_ANALYSIS_FINDINGS]

Deduplicated static analysis findings for the changed files, including rule ID, severity, file, line, and message.

[{"rule": "S3776", "severity": "critical", "file": "src/auth/login.ts", "line": 18, "message": "Cognitive complexity is 17, maximum allowed is 15"}]

Must be valid JSON array. Each finding requires file, line, severity, and message fields. Empty array allowed. Validate severity values against allowed enum: critical, high, medium, low, info.

[CHANGE_METADATA]

Context about the change: branch name, author, commit count, files changed, lines added/removed, and linked issue or ticket references.

{"branch": "feat/oauth-refresh", "author": "jane-dev", "commits": 4, "filesChanged": 7, "linesAdded": 142, "linesRemoved": 38, "ticketRefs": ["AUTH-421"]}

Must be valid JSON. ticketRefs array can be empty. Validate that filesChanged matches the count of unique files in [DIFF]. Author field required for audit trail.

[RISK_THRESHOLDS]

Organization-specific thresholds that define blocking vs advisory gap severity, coverage minimums, and risk score cutoffs.

{"minLineCoverage": 0.80, "minBranchCoverage": 0.70, "blockingSeverities": ["critical", "high"], "maxRiskScore": 7}

Must be valid JSON. All numeric thresholds required. blockingSeverities must be a subset of allowed severity enum. Prompt must treat gaps exceeding these thresholds as blocking.

[OUTPUT_SCHEMA]

Expected JSON schema for the test gap summary output, defining the structure of blocking gaps, advisory gaps, and the go/no-go recommendation.

{"type": "object", "properties": {"blockingGaps": {"type": "array"}, "advisoryGaps": {"type": "array"}, "recommendation": {"type": "string", "enum": ["go", "no-go"]}}}

Must be valid JSON Schema. recommendation enum must include go and no-go. Prompt must be constrained to output only this schema. Validate output against this schema post-generation.

[EVIDENCE_LINKS]

Base URLs or identifiers for linking gaps back to CI artifacts, coverage reports, and static analysis dashboards.

Must be valid JSON. All URL fields optional; null allowed for any field. If provided, URLs must be valid and resolvable within the CI environment. Prompt must embed these as evidence links in gap entries.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Pre-Merge Test Gap Summary Prompt into a CI/CD pipeline or automated merge gate system.

The Pre-Merge Test Gap Summary Prompt is designed to operate as a merge gate decision point within a CI/CD pipeline, not as an ad-hoc developer tool. It consumes structured inputs from upstream pipeline stages—diff analysis, test run results, coverage reports, and static analysis findings—and produces a structured go/no-go recommendation. The harness must treat this prompt as a deterministic evaluation step: given the same inputs, the output structure and blocking gap criteria should be consistent enough to automate merge decisions for low-risk changes while escalating ambiguous or high-risk cases for human review.

Pipeline integration requires a pre-processing stage that assembles the [DIFF_ANALYSIS], [TEST_RESULTS], [COVERAGE_DATA], and [STATIC_ANALYSIS_FINDINGS] into the prompt's input slots. Each input must include file paths, line ranges, and severity or coverage percentages to enable traceable gap identification. The harness should validate the output schema before acting on the recommendation: check that blocking_gaps is a list, each gap has a risk_description and evidence_links array, and every blocking gap references a specific unremediated risk. If the output fails schema validation, retry once with the same inputs and a stricter [OUTPUT_SCHEMA] constraint. After two failures, fail the pipeline open with a human review flag—never silently pass a merge gate on malformed output. For model choice, use a model with strong structured output adherence (GPT-4o, Claude 3.5 Sonnet, or equivalent) and set temperature=0 to minimize variance in gap classification.

Logging and audit are critical because this prompt influences merge decisions. Log the full prompt input, raw model output, parsed recommendation, and any schema validation errors to an immutable audit store. Include the pipeline run ID, commit SHA, and timestamp. For human review escalation, configure the harness to route any merge request where recommendation is BLOCKED or REVIEW_REQUIRED to a review queue with the full gap summary attached. Do not use this prompt as the sole gate for security-sensitive or infrastructure changes—always require a human co-signer for changes touching authentication, authorization, data migrations, or infrastructure-as-code. The harness should also track false positive/negative rates over time by comparing blocking gap decisions against post-merge incidents, feeding that data back into prompt calibration and risk threshold tuning.

IMPLEMENTATION TABLE

Expected Output Contract

Every field the Pre-Merge Test Gap Summary Prompt must return, with the type, required status, and the validation rule to apply before the output can be used in a merge gate decision.

Field or ElementType or FormatRequiredValidation Rule

merge_decision

enum: GO | NO_GO | NEEDS_REVIEW

Must be one of the three allowed values. If any blocking_gap has status=OPEN, decision must not be GO.

blocking_gaps

array of objects

Array must be present even if empty. Each object must contain gap_id, file_path, risk_description, and status fields.

blocking_gaps[].gap_id

string, format: BG-XXX

Must match pattern ^BG-\d{3}$. Must be unique within the blocking_gaps array.

blocking_gaps[].status

enum: OPEN | RESOLVED | ACCEPTED_RISK

If status is RESOLVED or ACCEPTED_RISK, the evidence_link field must be non-null and contain a valid URL or commit hash.

advisory_gaps

array of objects

Array must be present even if empty. No gap in this array may have the same gap_id as any gap in blocking_gaps.

evidence_summary

object

Must contain diff_files_count, tests_run, tests_failed, and coverage_delta_pct fields. coverage_delta_pct must be a number between -100.0 and 100.0.

static_analysis_findings

array of objects

If present, each object must include rule_id, severity, and file_path. severity must be one of: CRITICAL, HIGH, MEDIUM, LOW, INFO.

recommendation

string

Must be a non-empty string between 50 and 500 characters. Must reference at least one specific blocking gap or confirm that no blocking gaps exist.

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when generating pre-merge test gap summaries and how to guard against it.

01

Hallucinated Coverage Gaps

What to watch: The model invents test gaps for code paths that are actually covered, or fabricates file paths and line numbers that don't exist in the diff. This erodes trust and creates busywork for developers chasing phantom gaps. Guardrail: Require every flagged gap to cite a specific diff hunk and existing test file. Add a validator that cross-references reported file paths against the actual diff and test suite before the report is surfaced.

02

Go/No-Go Decision Without Evidence Links

What to watch: The summary produces a blocking recommendation but fails to tie it to specific, unremediated risks. This forces release managers to either blindly trust the model or manually re-verify every finding, defeating the purpose of automation. Guardrail: Enforce a structured output schema where every blocking gap must include a risk_id, a diff_hunk_ref, and an evidence_summary field. Reject reports that contain blocking gaps with null or empty evidence fields.

03

Stale Coverage Data Poisoning

What to watch: The prompt ingests a coverage report that was generated against a different commit than the diff under review, causing false positives (new code flagged as uncovered because the report is old) or false negatives (gaps hidden because the report predates the change). Guardrail: Require the coverage report to include a commit SHA. Add a pre-processing check that compares the coverage commit SHA to the diff base commit and rejects mismatches with a clear error before the prompt runs.

04

Static Analysis Noise Overwhelming Signal

What to watch: The prompt treats every linter warning or low-severity static analysis finding as a test gap, producing a bloated report where critical gaps are buried under hundreds of style or pedantic findings. Guardrail: Add a severity filter in the prompt instructions that requires findings to be ranked by actual risk (exploitability, crash potential, data loss). Instruct the model to collapse low-severity findings into a single advisory section and reserve the blocking section for high-confidence, high-impact gaps only.

05

Context Window Truncation on Large Diffs

What to watch: For large changesets, the combined diff, coverage report, and static analysis output exceed the model's context window. The model silently drops the tail of the input, missing entire files or test suites and producing an incomplete gap analysis with no warning. Guardrail: Implement a pre-flight token counter. If the combined input exceeds a safe threshold (e.g., 80% of the model's context limit), chunk the diff by module or file and run the prompt per-chunk, then merge results with a deduplication pass. Log a warning when chunking is triggered.

06

Over-Confident Risk Scoring Without Calibration

What to watch: The model assigns high risk scores to gaps based on superficial patterns (e.g., any auth-related code is high risk) without considering actual exploitability or deployment context. This leads to alert fatigue and ignored blocking recommendations. Guardrail: Include historical incident data or bug frequency per module as input context when available. Add a calibration note in the output requiring that risk scores be reviewed against the team's actual incident history. For production harnesses, track risk score accuracy against post-merge incidents over time and flag when calibration drifts.

IMPLEMENTATION TABLE

Evaluation Rubric

Run these checks against a golden dataset of known changesets with expected gap classifications. Each criterion validates a specific quality dimension of the pre-merge test gap summary output.

CriterionPass StandardFailure SignalTest Method

Blocking gap traceability

Every blocking gap includes a specific file path, line range, and risk rationale tied to an unremediated code change

Blocking gap listed without line reference or with generic rationale like 'needs tests'

Parse output for blocking gaps; assert each has non-null file_path, line_start, and risk_rationale fields that reference a diff hunk

Advisory gap relevance

All advisory gaps map to actual code changes with lower risk or existing partial coverage

Advisory gap references unchanged code or duplicates an existing test case

Cross-reference advisory gap locations against the input diff; assert each location appears in the changeset

Evidence link validity

Every gap includes at least one evidence link to a coverage report line, static analysis finding, or test result

Gap has null or broken evidence_links array; link points to unrelated artifact

Validate evidence_links is non-empty array; assert each URL or artifact ID resolves to a valid reference in the input context

Go/no-go recommendation consistency

Recommendation matches blocking gap count: 'no-go' when blocking gaps > 0, 'go' when blocking gaps = 0

Recommendation is 'go' but blocking gaps exist in output; recommendation is 'no-go' with zero blocking gaps

Extract recommendation field and blocking_gaps count; assert logical consistency between the two

False positive rate on known-safe changesets

Zero blocking gaps reported for changesets with full coverage and no static analysis warnings

Blocking gap flagged on fully-covered refactor or documentation-only change

Run prompt against golden dataset entries labeled 'safe'; assert blocking_gaps array is empty

False negative rate on known-gap changesets

At least one blocking gap reported for changesets with known untested critical paths

Zero blocking gaps returned for changeset where a new auth check or data mutation lacks coverage

Run prompt against golden dataset entries labeled 'gap'; assert blocking_gaps contains at least one entry matching the known gap location

Output schema compliance

Output matches the defined [OUTPUT_SCHEMA] exactly: all required fields present, correct types, no extra top-level keys

Missing required field; field has wrong type; extra unrecognized keys in top-level object

Validate output against JSON Schema; assert strict compliance with no additional properties allowed

Gap classification accuracy

Each gap is classified as 'blocking' or 'advisory' matching the golden dataset label for that code location

Gap classified as 'advisory' when golden label is 'blocking' for the same location, or vice versa

For each gap in output, look up expected classification in golden dataset by file_path and line_range; assert match rate >= 95%

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Add strict JSON schema validation in your harness. Wrap the prompt in a retry loop: if the output fails schema validation, feed the validation error back to the model with "Fix these schema violations and return valid JSON only." Add a [CONFIDENCE_THRESHOLD] parameter and instruct the model to mark any gap with confidence below threshold as advisory regardless of severity. Log every go/no-go recommendation with the full input context for audit.

Watch for

  • Silent format drift when the model changes JSON key names across runs
  • The model marking real blocking gaps as advisory to avoid false positives
  • Missing evidence_links fields when coverage data is sparse
  • Retry loops exceeding latency budgets; cap at 2 retries before escalating to human review
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.