This prompt is designed for platform and security engineering teams running differential static analysis (SAST) on pull requests. The core job-to-be-done is turning a raw delta of new, resolved, and changed findings between a feature branch and its base branch into a structured, actionable summary. The ideal user is a CI/CD pipeline maintainer or a developer who needs to understand, before merge, whether a PR introduces regressions, intentionally suppresses warnings, or shifts the risk profile of the codebase. The prompt assumes you already have a tool (such as Semgrep, CodeQL, or a custom diff scanner) that produces a machine-readable list of finding differences.
Prompt
Incremental Scan Diff Interpretation Prompt

When to Use This Prompt
Define the job, ideal user, required context, and constraints for interpreting incremental static analysis scan diffs in CI/CD pipelines.
Use this prompt when your differential scan output is too noisy for manual review, when you need a consistent format for downstream automation (like posting a comment on the PR or updating a security dashboard), or when you want to detect subtle changes such as a suppression comment being added without a corresponding fix. The prompt is not a replacement for the SAST tool itself; it does not run scans or decide if a finding is a true positive. It interprets the diff between two known scan result sets. Do not use this prompt for full-repository scans without a base comparison, for real-time intrusion detection, or for making autonomous merge-blocking decisions without human review of high-severity regressions.
The prompt requires structured input: a list of findings from the base branch and a list from the feature branch, each with at minimum a rule ID, file path, line number, and finding message. It produces a JSON summary categorizing each delta as new, resolved, or changed, with regression alerts for any resolved finding that reappears and suppression change detection for findings where the code or configuration was altered to silence the rule. Before deploying this prompt in a production pipeline, you must validate its output against known diffs, test edge cases like renamed files and moved code blocks, and implement a human-review gate for any finding classified as a suppression change or a high-severity regression. The next step after reading this section is to copy the prompt template, adapt the input schema to your SAST tool's output format, and wire it into your CI job with the validation harness described in the implementation section.
Use Case Fit
Where the Incremental Scan Diff Interpretation Prompt delivers value and where it creates risk. Use these cards to decide if this prompt fits your pipeline before wiring it into CI/CD.
Good Fit: PR-Based Differential Scanning
Use when: your CI/CD pipeline runs differential static analysis comparing a feature branch against a base branch and produces raw new/resolved/changed finding lists. Guardrail: ensure the prompt receives structured diff output, not raw full-repo scan results, to prevent context-window overload and hallucinated findings.
Bad Fit: Full-Repo Baseline Scans
Avoid when: you need to interpret an initial full-repository scan with no base comparison. The prompt expects a diff context and will fabricate false baseline comparisons or misattribute pre-existing findings as new. Guardrail: use a separate SAST triage prompt for initial baselines and only apply this prompt after the second scan.
Required Inputs: Structured Diff Data
What to watch: the prompt depends on structured input containing finding IDs, file paths, line numbers, rule IDs, severity, and status changes (new, resolved, changed, suppressed). Missing fields cause hallucinated details. Guardrail: validate input schema before prompt execution and abort with a clear error if required fields are absent.
Operational Risk: Suppression Change Blindness
What to watch: intentional suppression removals or modifications can be misclassified as regressions, causing unnecessary build failures. Guardrail: require the prompt to flag suppression changes separately and route them for human review rather than auto-blocking the pipeline.
Operational Risk: Cross-Scan Finding Identity Drift
What to watch: static analysis tools may assign different finding IDs to the same issue across scans, causing the prompt to misreport resolved-then-reintroduced patterns as new findings. Guardrail: implement finding fingerprinting by code location and rule ID before passing data to the prompt, and log identity mismatches for platform team review.
Operational Risk: Severity Inflation in Diffs
What to watch: a rule severity change in the tool configuration can cause the prompt to report mass severity shifts as finding changes, flooding the output with noise. Guardrail: detect configuration changes in the pipeline metadata and suppress severity-only change reporting when the underlying code is unchanged.
Copy-Ready Prompt Template
A reusable prompt template with square-bracket placeholders for interpreting incremental static analysis scan diffs in CI/CD pipelines.
This template is designed to be dropped into a CI/CD step that runs after a differential static analysis tool produces a raw diff between the current branch and the base branch. The prompt instructs the model to interpret new, resolved, and changed findings, detect regression risks, and flag suspicious suppression changes. The output is a structured summary that can be posted as a PR comment, logged for audit, or used to gate a merge decision.
textYou are a static analysis triage specialist reviewing an incremental scan diff from a CI/CD pipeline. Your task is to interpret the diff between the current branch scan results and the base branch scan results. You will receive a structured diff containing new findings, resolved findings, and changed findings. ## INPUT [DETAILED_DIFF] ## CONTEXT - Base branch: [BASE_BRANCH] - Current branch: [CURRENT_BRANCH] - Repository: [REPOSITORY_NAME] - Scan tool: [TOOL_NAME] - Scan ruleset version: [RULESET_VERSION] - Known suppression patterns: [SUPPRESSION_PATTERNS] - Critical paths or services: [CRITICAL_PATHS] ## OUTPUT_SCHEMA Return a JSON object with the following structure: { "summary": { "new_findings_count": <int>, "resolved_findings_count": <int>, "changed_findings_count": <int>, "net_change": <int>, "overall_risk_direction": "increased" | "decreased" | "unchanged" }, "new_findings": [ { "finding_id": "<string>", "rule_id": "<string>", "file": "<string>", "line": <int>, "severity": "<string>", "category": "<string>", "is_regression": <bool>, "regression_evidence": "<string or null>", "risk_assessment": "high" | "medium" | "low", "explanation": "<string>", "suggested_action": "block_merge" | "warn" | "note" } ], "resolved_findings": [ { "finding_id": "<string>", "rule_id": "<string>", "file": "<string>", "resolution_confidence": "confirmed_fix" | "likely_fix" | "uncertain", "suppression_change_detected": <bool>, "suppression_change_detail": "<string or null>", "note": "<string>" } ], "changed_findings": [ { "finding_id": "<string>", "rule_id": "<string>", "file": "<string>", "change_type": "severity_increased" | "severity_decreased" | "location_shifted" | "metadata_updated", "before": "<string>", "after": "<string>", "significance": "escalation" | "deescalation" | "neutral", "explanation": "<string>" } ], "regression_alerts": [ { "finding_id": "<string>", "alert_reason": "<string>", "previously_resolved_in": "<string or null>", "urgency": "immediate_review" | "review_before_merge" | "monitor" } ], "suppression_anomalies": [ { "finding_id": "<string>", "anomaly_type": "unexpected_suppression" | "suppression_removed" | "suppression_weakened", "detail": "<string>", "requires_approval": <bool> } ], "merge_recommendation": { "decision": "approve" | "block" | "conditional", "conditions": ["<string>"], "blocking_findings": ["<finding_id>"], "rationale": "<string>" } } ## CONSTRAINTS 1. A regression is a new finding that matches a previously resolved finding in the same file and rule, or a finding in code that was previously clean for that rule. 2. Flag any suppression change (addition, removal, or modification) as a suppression anomaly. Suppression changes in critical paths require explicit approval. 3. If a resolved finding shows evidence of suppression rather than a code fix, set resolution_confidence to "uncertain" and set suppression_change_detected to true. 4. For changed findings where severity increased, classify significance as "escalation" and explain why. 5. The merge_recommendation must be "block" if any new finding has suggested_action "block_merge" or if any regression_alert has urgency "immediate_review". 6. If the diff is empty or contains no findings, return a valid summary with zero counts and a merge_recommendation of "approve". 7. Do not invent findings. Only interpret what is present in [DETAILED_DIFF]. 8. If [DETAILED_DIFF] is malformed or unparseable, return {"error": "unparseable_diff", "detail": "<reason>"}. ## RISK_LEVEL [RISK_LEVEL] If RISK_LEVEL is "high", apply stricter criteria: treat all new medium-severity findings in critical paths as blocking, require explicit approval for all suppression changes, and flag any uncertain resolution as a regression alert.
Adapt this template by replacing the square-bracket placeholders with values from your CI/CD context. [DETAILED_DIFF] should contain the raw output from your differential scan tool, structured as a list of added, removed, and modified findings with their full metadata. [CRITICAL_PATHS] should list file patterns, directories, or services that trigger elevated scrutiny. [SUPPRESSION_PATTERNS] should include the syntax your team uses for inline suppressions (e.g., // nosemgrep: rule-id or # pylint: disable=rule) so the model can detect when suppressions are added or removed. [RISK_LEVEL] should be set to "high" for repositories handling sensitive data, authentication, or payment logic, and "standard" otherwise. The output schema is designed to be machine-readable for automated merge gating while remaining human-readable for PR reviewers.
Before deploying this prompt in a blocking CI step, run it against a golden dataset of known diffs with expected classifications. Validate that regression detection correctly identifies re-introduced findings, that suppression anomalies are caught, and that the merge recommendation aligns with your team's actual decisions. Start with a non-blocking advisory mode that posts the output as a PR comment, and only promote to a merge gate after at least two weeks of shadow evaluation with no false blocks or missed regressions.
Prompt Variables
Required inputs for the Incremental Scan Diff Interpretation Prompt. Each placeholder must be populated before the prompt is assembled and sent. Missing or malformed inputs are the most common cause of incorrect diff summaries.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[BASE_BRANCH_SCAN_RESULTS] | The full SAST scan output from the target base branch, used as the reference point for detecting new, resolved, or changed findings. | {"findings": [{"id": "F-101", "rule": "java/sql-injection", "file": "src/db/Query.java", "line": 42, "severity": "HIGH"}]} | Must be valid JSON. Schema must match [NEW_BRANCH_SCAN_RESULTS]. If empty, treat all findings as new. Validate against expected SAST tool output schema before use. |
[NEW_BRANCH_SCAN_RESULTS] | The full SAST scan output from the feature or PR branch, representing the current state to be compared against the base. | {"findings": [{"id": "F-201", "rule": "java/sql-injection", "file": "src/db/Query.java", "line": 45, "severity": "HIGH"}]} | Must be valid JSON. Schema must match [BASE_BRANCH_SCAN_RESULTS]. Reject if finding IDs collide with base branch IDs without explicit correlation logic. Validate field presence: id, rule, file, line, severity. |
[SUPPRESSION_RULES] | The current set of intentional suppressions, baseline acceptances, and false positive markers active for the repository. Used to detect suppression changes. | {"suppressed": [{"finding_id": "F-101", "reason": "False positive: sanitizer at line 44", "expires": "2025-06-01"}]} | Must be valid JSON. If empty or null, treat as no active suppressions. Validate that suppressed finding IDs exist in [BASE_BRANCH_SCAN_RESULTS] or [NEW_BRANCH_SCAN_RESULTS]. Flag orphaned suppressions. |
[DIFF_CONTEXT] | The unified diff or file change list for the PR, used to correlate finding location changes with actual code modifications. | diff --git a/src/db/Query.java b/src/db/Query.java @@ -40,6 +42,8 @@ ... | Plain text or null. If null, location-based correlation is disabled and the prompt relies solely on finding ID matching. Validate that file paths in diff match paths in scan results. Large diffs may need truncation with a note. |
[REPOSITORY_POLICIES] | Organizational policies governing severity thresholds, blocking rules, and required review gates for different finding types. | {"block_on_new": ["CRITICAL", "HIGH"], "require_review_for": ["MEDIUM"], "auto_suppress_below": "LOW"} | Must be valid JSON. If null, prompt defaults to reporting all findings without policy-based triage decisions. Validate severity values against known tool severity scales. Missing policy for a severity level should trigger a warning. |
[OUTPUT_SCHEMA] | The exact JSON schema the model must conform to in its response, defining the structure for new, resolved, changed, and suppression-delta sections. | {"type": "object", "properties": {"new_findings": {"type": "array"}, "resolved_findings": {"type": "array"}, "changed_findings": {"type": "array"}, "suppression_changes": {"type": "array"}, "regression_alerts": {"type": "array"}, "summary": {"type": "object"}}, "required": ["new_findings", "resolved_findings", "changed_findings", "suppression_changes", "regression_alerts", "summary"]} | Must be valid JSON Schema. Required fields must be present in output. Validate output against this schema post-generation. Schema mismatch is a retry condition. |
[CORRELATION_STRATEGY] | The method for matching findings between base and new scans: by finding ID, by file+line+rule fingerprint, or by semantic equivalence. | "fingerprint" | Must be one of: "id", "fingerprint", "semantic". If "fingerprint", validate that both scan results include fingerprint fields or that fingerprinting logic is applied pre-prompt. If "id", validate ID uniqueness across branches. Incorrect strategy leads to false new or false resolved findings. |
[REGRESSION_RULES] | Conditions that trigger a regression alert, such as a previously resolved finding reappearing or a severity upgrade on an existing finding. | {"reappearance": true, "severity_upgrade": true, "suppression_removal_without_fix": true} | Must be valid JSON. If null, no regression alerts are generated. Validate that regression conditions reference finding states that can be detected from the input data. Missing regression detection for severity upgrades is a common failure mode. |
Implementation Harness Notes
How to wire the Incremental Scan Diff Interpretation Prompt into a CI/CD pipeline or security workflow.
This prompt is designed to be called as a single step within a CI/CD pipeline job that runs after a differential static analysis scan completes. The harness must provide the prompt with three structured inputs: the base-branch scan results, the current-branch scan results, and a machine-readable diff of findings. The model's output is a structured JSON object containing new, resolved, and changed findings, regression alerts, and suppression change detection. Because this prompt influences whether code is blocked from merging, the harness must enforce strict output validation before any downstream action is taken.
Implement the harness as a pipeline step that first executes your SAST tool in differential mode (e.g., semgrep --baseline-commit HEAD~1 or codeql database diff-run). Capture both the raw tool output and a normalized JSON representation of findings. Construct the prompt input by serializing the base and current findings into the [BASE_SCAN] and [CURRENT_SCAN] placeholders, and compute a structural diff of the two finding sets for the [FINDING_DIFF] placeholder. After receiving the model response, validate it against a strict JSON schema that requires new_findings, resolved_findings, changed_findings, regression_alerts, and suppression_changes arrays. Each finding object must include finding_id, rule_id, file_path, line_number, and severity. Reject any response that fails schema validation and retry once with an error message injected into the prompt context. If the second attempt also fails, fail the pipeline step with a clear error log and the raw model output for debugging.
For high-risk repositories, add a human-review gate before the harness takes automated action. If the model flags any regression_alerts or detects suppression changes on findings previously marked as won't fix, route the output to a security review channel (e.g., a Slack notification or Jira ticket) rather than auto-blocking the merge. Log every invocation with the prompt version, model used, input finding counts, output summary statistics, and validation status. This audit trail is essential for tuning false-positive rates and defending pipeline decisions during compliance reviews. Avoid wiring this prompt directly to a merge-blocking webhook without first running it in warn-only mode for at least two sprint cycles to calibrate thresholds.
Expected Output Contract
Fields, format, and validation rules for the incremental scan diff interpretation output. Use this contract to validate the model response before it enters downstream CI/CD logic or human review queues.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
diff_summary.base_branch | string | Must match the [BASE_BRANCH] input exactly. Parse check: non-empty, no trailing whitespace. | |
diff_summary.target_branch | string | Must match the [TARGET_BRANCH] input exactly. Parse check: non-empty, no trailing whitespace. | |
diff_summary.total_new_findings | integer | Must equal the count of items in findings.new[]. Schema check: non-negative integer. | |
findings.new[].rule_id | string | Must match a rule ID present in [SCAN_OUTPUT_DIFF]. Parse check: non-empty, alphanumeric with hyphens or underscores. | |
findings.new[].severity | string | Must be one of [CRITICAL, HIGH, MEDIUM, LOW, INFO]. Enum check: case-sensitive match. | |
findings.resolved[].resolution_confidence | string | Must be one of [CONFIRMED, LIKELY, UNCERTAIN]. If UNCERTAIN, human review is required before closing. | |
regression_alerts[].original_finding_id | string | If present, must reference a finding ID from [RESOLVED_FINDINGS_HISTORY]. Null allowed when no prior resolution exists. | |
suppression_changes[].intent_assessment | string | Must be one of [INTENTIONAL, ACCIDENTAL, UNCLEAR]. UNCLEAR assessments require a human-review gate before merge. |
Common Failure Modes
Incremental scan diff interpretation fails in predictable ways. These are the most common failure modes and the guardrails that catch them before they reach a developer or a merge decision.
Baseline Drift Causes False New Findings
What to watch: When the base branch scan is stale or was run with different rules, the diff reports dozens of spurious 'new' findings that already existed. Guardrail: Pin the base scan commit SHA and rule version in the prompt context. Reject diffs where the base scan metadata does not match the current scan configuration.
Suppression Changes Misinterpreted as Resolutions
What to watch: A developer suppresses a finding in-code, and the model reports it as 'resolved' instead of 'intentionally suppressed,' hiding risk from auditors. Guardrail: Require the prompt to classify every removed finding as either 'fixed-by-code-change,' 'suppressed-inline,' or 'removed-by-rule-change.' Flag suppressions for separate human review.
File Renames Break Finding Identity
What to watch: When files are moved or renamed, the diff engine loses track of findings, reporting them as 'resolved' in the old path and 'new' in the new path. Guardrail: Include a pre-processing step that matches findings by fingerprint (rule ID + code snippet hash) across paths. Instruct the model to report these as 'moved' with both locations.
Merge Commits Inflate the Diff Scope
What to watch: A large merge commit pulls in hundreds of changes from the base branch, and the model attributes pre-existing findings from the merged code to the PR author. Guardrail: Constrain the diff analysis to changes introduced by the PR commits only. Explicitly instruct the model to ignore findings on lines that were not modified by the PR's own commits.
Severity Inflation on Regressions
What to watch: A low-severity finding that existed on the base branch is re-introduced in a new location, and the model escalates it to critical simply because it is 'new' in the diff. Guardrail: Include the original finding severity in the context. Instruct the model that a regression inherits the original severity unless the new code path meaningfully increases exploitability, and require explicit justification for any escalation.
Partial Fixes Reported as Complete Resolutions
What to watch: A developer fixes one instance of a pattern but leaves the same vulnerability class elsewhere in the file, and the model marks the finding as fully resolved. Guardrail: Instruct the model to verify that the entire finding location is gone, not just the specific line flagged. Add a post-processing check that re-scans the file for the same rule ID before accepting a 'resolved' status.
Evaluation Rubric
Criteria for evaluating the quality and safety of the Incremental Scan Diff Interpretation output before merging the result into a CI/CD pipeline or developer notification.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
New Finding Completeness | All new findings present in the [DIFF_INPUT] are listed in the output with file path, line, and rule ID. | A finding from the raw diff is missing from the structured output. | Parse output and raw diff. Assert set of (file, line, rule) in output equals set in diff. |
Resolved Finding Accuracy | Findings marked as resolved exist in the base scan but not in the head scan, and the resolution reason is plausible. | A finding is marked resolved but still appears in the head scan, or the reason is 'suppressed' but no suppression change is detected. | Cross-reference resolved list against head scan results. Flag mismatches. |
Regression Alert Correctness | A regression alert is raised for every finding where severity increased or a previously resolved finding reappeared. | A severity upgrade or reappearance is present in the diff but no regression alert is generated. | Inject a known regression into test diff. Assert alert is present with correct severity delta. |
Suppression Change Detection | Intentional suppression additions or removals are detected and reported with the affected rule and scope. | A suppression comment is added or removed in the diff but the output reports no suppression change. | Scan diff for suppression pattern changes. Assert output contains a matching suppression change record. |
False Positive Filtering | Findings previously marked as false positives in [SUPPRESSION_BASELINE] are excluded from the new findings list. | A known false positive from the baseline appears in the new findings output. | Provide a baseline with a known FP. Assert the FP does not appear in the output's new findings. |
Risk Ranking Order | Findings are ordered by a composite risk score where reachability and severity outweigh count. | A critical-severity, reachable finding is listed below a low-severity, unreachable informational finding. | Provide a diff with mixed severities. Assert the output list is sorted by risk score descending. |
Output Schema Validity | Output strictly conforms to the [OUTPUT_SCHEMA] with all required fields present and correctly typed. | Output is missing a required field like 'regression_alerts' or 'risk_score' is a string. | Validate output against the JSON Schema. Assert no validation errors. |
Uncertainty Flagging | Findings where the tool cannot confidently determine intent (e.g., ambiguous suppression) are flagged with 'confidence': 'low' and routed for human review. | An ambiguous suppression change is reported as a definitive intentional change with 'confidence': 'high'. | Provide a diff with an ambiguous comment. Assert the output has 'confidence': 'low' and 'review_required': true. |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Start with the base prompt and a single SAST tool (e.g., Semgrep or CodeQL). Use loose output validation—accept plain text or markdown summaries instead of strict JSON. Focus on getting the diff interpretation logic right before adding schema enforcement.
Simplify the [FINDING_SCHEMA] placeholder to a short field list: type, file, line, status, summary. Skip severity reclassification and suppression change detection in early iterations.
Watch for
- The model conflating pre-existing findings with new ones when the base-branch scan data is incomplete
- Overly verbose explanations that bury the regression alert signal
- Missing
resolvedvschangeddistinction when a finding shifts line numbers without changing the underlying issue

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us