This prompt is designed for API and library maintainers who need to automatically assess whether a pull request introduces breaking changes to public contracts, schemas, or documented behaviors. The core job-to-be-done is to transform a raw code diff into a structured risk assessment that flags backward-incompatible modifications—such as removed endpoints, changed field types, tightened validation, or altered default values—before they reach production. The ideal user is a platform engineer, tech lead, or CI/CD pipeline operator who owns API stability and needs consistent, evidence-backed analysis that integrates directly into code review tools or release gates.
Prompt
Breaking Change Detection Prompt

When to Use This Prompt
Define the job, reader, and constraints for the Breaking Change Detection Prompt.
Use this prompt when you have a concrete diff against a known public API surface and you need a machine-readable report that maps each finding to a specific line, severity level, and migration note. The prompt assumes you can provide the diff content, a description of the public contract (e.g., an OpenAPI spec, interface definitions, or documented endpoints), and any versioning policy constraints. It is not suitable for reviewing internal-only refactors with no public surface, for assessing performance regressions without API signature changes, or for security-focused vulnerability scanning—those require separate specialized prompts. The prompt also does not replace human judgment for critical path decisions; its output should be treated as a review aid that flags candidates for manual verification.
Before wiring this into an automated pipeline, you must establish a ground-truth dataset of known breaking and non-breaking changes to measure false positive and false negative rates. The evaluation criteria should include precision (are flagged changes truly breaking?), recall (did the prompt miss any known breaking changes from your changelog?), and severity classification accuracy. If your API follows semantic versioning, the prompt's output should align with your MAJOR/MINOR/PATCH bump rules. Start by running this prompt against historical PRs with documented breaking changes to calibrate expectations, and always route high-severity findings to a human reviewer before blocking a merge or deployment.
Use Case Fit
Where the Breaking Change Detection Prompt works, where it fails, and what you must provide to get a reliable risk assessment.
Good Fit: Public API Surface Changes
Use when: reviewing PRs that modify public method signatures, exported functions, API route handlers, or serialized data models. Why: the prompt excels at mapping syntactic changes to semantic contract violations.
Bad Fit: Internal Refactors
Avoid when: the diff only touches private methods, internal helper functions, or implementation details not exposed to consumers. Risk: the prompt will generate false positives by flagging any signature change as breaking, even when the public contract is unchanged.
Required Inputs
Must provide: the full diff, the public API specification or contract file (OpenAPI, protobuf, or interface definitions), and a list of deprecated endpoints. Without these: the model cannot distinguish intentional breaking changes from unintentional ones.
Operational Risk: False Positives
What to watch: the prompt may flag additive changes (new optional parameters, new response fields) as breaking. Guardrail: post-process the output through a contract validator that checks backward compatibility rules before surfacing findings to the author.
Operational Risk: Missed Semantic Breakage
What to watch: the prompt detects syntactic breaks (removed fields, changed types) but may miss semantic breaks (changed error codes, altered rate limits, modified retry behavior). Guardrail: pair with integration test diffs and behavioral change logs for full coverage.
Human Approval Boundary
What to watch: the prompt cannot decide whether a breaking change is acceptable for a given release. Guardrail: all detected breaking changes must route to a human reviewer who owns the versioning policy and can approve, reject, or schedule the change for the next major version.
Copy-Ready Prompt Template
The reusable prompt with square-bracket placeholders for detecting breaking changes in a PR diff.
The prompt below is designed to be copied directly into your application or evaluation harness. It accepts a code diff, an optional public API specification, and a set of constraints that define what constitutes a breaking change for your project. The placeholders let you inject project-specific definitions without rewriting the core logic. Use this template as the foundation for a CI/CD step that flags risky changes before they reach production.
textYou are an API compatibility reviewer. Your task is to analyze the provided code diff and identify any breaking changes to public APIs, schemas, or contracts. ## INPUT [DIFF] ## OPTIONAL CONTEXT Public API specification or contract document: [API_SPEC] ## DEFINITIONS A breaking change is any modification that would cause existing, correctly-functioning consumers to fail or behave incorrectly. Use the following project-specific definitions to guide your analysis: [BREAKING_CHANGE_DEFINITIONS] ## CONSTRAINTS - Only report changes that affect public, documented, or exported interfaces. - Ignore internal refactors, private method changes, and implementation details unless they alter public behavior. - If a change is additive (new optional field, new endpoint), classify it as NON_BREAKING. - If a change is subtractive or modifies existing behavior, classify it as BREAKING. - For each finding, cite the specific file and line range from the diff. - If no breaking changes are detected, explicitly state that. ## OUTPUT SCHEMA Return a JSON object with the following structure: { "summary": "A one-sentence summary of the overall risk level.", "risk_level": "HIGH" | "MEDIUM" | "LOW" | "NONE", "breaking_changes": [ { "severity": "CRITICAL" | "MAJOR" | "MINOR", "category": "SIGNATURE_CHANGE" | "BEHAVIOR_CHANGE" | "SCHEMA_CHANGE" | "REMOVAL" | "RENAMING" | "CONTRACT_VIOLATION", "location": "file:line_range", "description": "What changed and why it breaks consumers.", "migration_guidance": "What consumers must do to adapt, or 'N/A' if removal is intentional." } ], "non_breaking_changes": [ { "category": "ADDITION" | "DEPRECATION" | "INTERNAL_REFACTOR", "location": "file:line_range", "description": "What changed and why it is safe." } ] } ## EXAMPLES [EXAMPLES] ## INSTRUCTIONS 1. Parse the diff to identify all public-facing changes. 2. Compare each change against the API specification if provided. 3. Classify each change as BREAKING or NON_BREAKING using the definitions above. 4. Produce the JSON output. Do not include any text outside the JSON object.
To adapt this template, replace the placeholders with your project's concrete details. The [BREAKING_CHANGE_DEFINITIONS] placeholder is the most critical: it should contain a bulleted list of what your team considers a breaking change (e.g., "Removing a public method," "Changing a required field to optional," "Altering the type of a response field"). The [EXAMPLES] placeholder should include one or two few-shot examples showing a diff snippet and the expected JSON output, which dramatically improves classification accuracy. If you maintain an OpenAPI spec, GraphQL schema, or public interface document, paste it into [API_SPEC] to give the model a ground-truth contract to compare against. For CI/CD integration, wrap this prompt in a harness that validates the output JSON against the schema, logs any parse failures, and routes HIGH-risk findings for human review before merge.
Prompt Variables
Inputs the Breaking Change Detection Prompt needs to produce a reliable risk assessment and migration notes. Validate each input before calling the model to prevent false positives and missed detections.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[DIFF] | The raw unified diff of the code change to analyze for breaking changes. | diff --git a/api.py b/api.py --- a/api.py +++ b/api.py @@ -10,7 +10,7 @@ -def get_user(id): +def get_user(user_id): | Parse check: must be a non-empty string containing valid diff syntax. Reject if empty or contains only non-code text. Strip leading/trailing whitespace. |
[PUBLIC_API_SURFACE] | A description or list of the public API surface, including function signatures, class interfaces, exported modules, or schema definitions that are considered stable contracts. | Public functions: get_user, create_order, delete_item Public classes: UserModel, OrderProcessor Exported schemas: UserSchema, OrderSchema | Schema check: must be a non-empty string or structured list. If null, the model will infer the public surface from the diff, increasing false positive risk. Prefer explicit enumeration. |
[CHANGELOG_CONTEXT] | Recent changelog entries or release notes to help the model distinguish intentional breaking changes from accidental ones and to avoid flagging already-documented deprecations. | v2.1.0: Deprecated get_user(id) in favor of get_user(user_id). Scheduled removal in v3.0.0. | Null allowed. If provided, must be a string. If changelog mentions the changed symbol, the model should cross-reference and adjust severity. Parse check: reject if contains only unrelated text. |
[SEMVER_POLICY] | The semantic versioning policy or compatibility contract the project follows, defining what constitutes a breaking change for this codebase. | MAJOR version for incompatible API changes. MINOR for backward-compatible additions. PATCH for backward-compatible fixes. | Null allowed. If null, the model defaults to standard semver. If provided, must be a non-empty string. Validate that the policy is internally consistent and does not contradict standard semver without explicit rationale. |
[LANGUAGE] | The programming language of the diff, used to tailor detection rules for language-specific breaking change patterns. | python | Enum check: must be a supported language identifier. Supported values: python, javascript, typescript, java, go, rust, csharp, ruby, php, kotlin, swift. Reject unsupported values and request clarification. |
[OUTPUT_SCHEMA] | The expected JSON schema for the structured output, defining the shape of the breaking change report including severity levels, affected symbols, and migration notes. | {"breaking_changes": [{"symbol": "string", "change_type": "enum", "severity": "enum", "location": "string", "migration_notes": "string"}], "risk_assessment": "string"} | Schema check: must be a valid JSON Schema object or a concise description of the expected fields. If null, the model uses a default schema. Validate that the schema includes required fields: symbol, change_type, severity, location, migration_notes. |
[CONSTRAINTS] | Additional constraints or instructions for the detection behavior, such as severity thresholds, categories to ignore, or specific patterns to flag. | Ignore whitespace-only changes. Flag any removal of a public function parameter as CRITICAL severity. Do not flag additions of new optional parameters. | Null allowed. If provided, must be a non-empty string. Parse check: ensure constraints do not contradict each other. If constraints conflict with SEMVER_POLICY, the model should prioritize explicit constraints and note the conflict in the output. |
Implementation Harness Notes
How to wire the Breaking Change Detection Prompt into a CI/CD pipeline or code review workflow with validation, retries, and human approval gates.
The Breaking Change Detection Prompt is designed to be called automatically on every pull request that modifies public-facing API surfaces, schemas, or serialization contracts. In a typical CI/CD harness, a webhook triggers the workflow when a PR is opened or updated. The system extracts the diff, packages it with the current API specification (OpenAPI, GraphQL schema, or protobuf definitions) as the [CONTEXT], and sends the assembled prompt to the model. The output must be a structured JSON payload containing a breaking_changes array, each with a severity (MAJOR, MINOR, PATCH), location, description, and migration_notes field. Before the result is posted as a review comment, a validation layer must confirm the JSON schema, verify that every location references a line present in the diff, and check that MAJOR findings include non-empty migration_notes. If validation fails, the harness should retry once with the validation errors appended as [CONSTRAINTS] to help the model self-correct.
For model choice, a capable instruction-following model with strong code understanding is required—GPT-4o, Claude 3.5 Sonnet, or Gemini 1.5 Pro are appropriate baselines. Smaller or local models will produce higher false-negative rates on subtle breaking changes like default value modifications or exception type narrowing. The harness should log every invocation: the PR ID, diff hash, model version, raw response, validation result, and final payload. This log becomes the audit trail for false-positive and false-negative analysis. To evaluate the prompt in production, maintain a golden dataset of known breaking and non-breaking changes from your project's changelog. Run the prompt against this dataset weekly and track precision and recall. A breaking change that the prompt misses (false negative) is more costly than a false positive, so tune the system prompt's [RISK_LEVEL] parameter to err toward over-detection when reviewing APIs with external consumers.
Human review remains mandatory for all MAJOR findings before a PR is merged. The harness should post MINOR and PATCH findings as non-blocking review comments, but MAJOR findings must block the merge and require a maintainer to either accept the breaking change (with a migration plan) or adjust the code to preserve compatibility. Do not use this prompt as a replacement for semantic versioning policy enforcement; it is a detection aid. The prompt cannot reason about undocumented behavioral contracts, performance SLAs, or client-side breakage from response timing changes. For those risks, pair this prompt with contract testing, integration test suites, and a human API design review. When the prompt flags a false positive, add the diff to the golden dataset as a negative example and consider including it as a few-shot counterexample in future prompt iterations.
Expected Output Contract
Defines the structured payload returned by the breaking change detection prompt. Use this contract to validate the model's output before integrating it into CI/CD pipelines or review dashboards.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
breaking_changes | Array of objects | Must be a JSON array. If no breaking changes are detected, the array must be empty, not null or omitted. | |
breaking_changes[].severity | Enum: 'critical', 'high', 'medium', 'low' | Must match one of the four allowed enum values. Reject any output with a missing or invalid severity. | |
breaking_changes[].api_element | String | Must reference a specific public function, class, method signature, endpoint path, or schema field. Reject if the string is empty or contains only a vague module name. | |
breaking_changes[].change_type | Enum: 'signature_change', 'removal', 'type_change', 'contract_change', 'behavior_change' | Must match one of the five allowed enum values. If the model invents a new type, retry with stricter enum instructions. | |
breaking_changes[].diff_reference | String | Must contain a line number or hunk header reference from the provided diff. Validate by checking if the referenced location exists in the original diff input. | |
breaking_changes[].migration_notes | String | Must be a non-empty string providing actionable guidance for downstream consumers. Reject if the string is empty, a generic placeholder, or a verbatim copy of the change_type. | |
risk_assessment | Object | Must contain 'overall_risk' and 'affected_consumers' fields. Reject if the object is missing or if any required sub-field is null. | |
risk_assessment.overall_risk | Enum: 'safe', 'caution', 'breaking' | Must match one of the three allowed enum values. If 'breaking_changes' is non-empty, this field must be 'breaking' or 'caution'; a 'safe' rating with detected breaking changes is a validation failure. | |
risk_assessment.affected_consumers | Array of strings | Must list known internal or external modules, services, or clients that depend on the changed API. An empty array is allowed only if no consumers are known, but the field must be present. | |
false_positive_confidence | Number (0.0-1.0) | If present, must be a float between 0.0 and 1.0 indicating the model's self-assessed risk of a false positive. Values outside the range trigger a warning. Use this field to route low-confidence findings for human review. |
Common Failure Modes
Breaking change detection is a high-stakes classification task. False negatives ship broken contracts to production; false positives create alert fatigue and erode trust. These are the most common failure modes and how to guard against them.
False Negatives on Semantic Changes
What to watch: The prompt misses breaking changes that don't alter the signature but change behavior—stricter validation, different error codes, changed default values, or modified side effects. The model sees the same function name and parameters and declares 'no breaking change.' Guardrail: Include explicit instructions to compare docstrings, error handling, default values, and return type semantics, not just function signatures. Add a dedicated 'behavioral change' check step in the prompt.
Over-Reporting Non-Breaking Additions
What to watch: The model flags every new endpoint, optional parameter, or added field as a breaking change. This floods reviewers with false positives and trains them to ignore the output. Guardrail: Add a strict definition of what constitutes a breaking change (removal, type change, required parameter addition, semantic shift) versus a compatible addition. Include negative examples of non-breaking changes in few-shot demonstrations.
Context Window Truncation on Large Diffs
What to watch: Large PRs with many files exceed the context window. The model reviews only the first portion of the diff and misses breaking changes in truncated files, silently returning an incomplete assessment. Guardrail: Implement a pre-processing harness that splits large diffs by file or module, runs detection independently on each chunk, and merges results. Add a completeness check that verifies every changed file appears in the output.
Schema Validation Failures in Output
What to watch: The model produces a risk assessment that doesn't conform to the expected JSON schema—missing required fields, using wrong severity enum values, or nesting findings incorrectly. Downstream CI/CD tooling rejects the payload. Guardrail: Use strict structured output with a defined JSON schema. Add a post-generation validation step that checks field presence, enum membership, and type correctness. On failure, retry with the validation error message included in the repair prompt.
Missing Migration Guidance for Confirmed Changes
What to watch: The model correctly identifies a breaking change but provides vague or missing migration notes—'update your code' instead of concrete before/after examples with affected call sites. Guardrail: Require migration notes as a mandatory output field for every confirmed breaking change. Include a format constraint: each migration note must contain a 'before' snippet, an 'after' snippet, and a list of affected public symbols.
Deprecation-Without-Removal Misclassification
What to watch: The model treats a newly added deprecation warning as a breaking change, or conversely, ignores a deprecation that will become a removal in the next major version. Both errors cause misaligned release planning. Guardrail: Add a severity tier for deprecations: 'deprecation-notice' (non-breaking, requires documentation), 'deprecation-with-timeline' (breaking in future version, requires migration plan), and 'immediate-breaking' (removal or signature change now). Include the deprecation policy in the system prompt.
Evaluation Rubric
Use this rubric to test the Breaking Change Detection Prompt against a known change log before integrating it into a CI/CD pipeline. Each criterion targets a specific failure mode observed in production.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Breaking Change Recall | All known breaking changes from the golden change log are detected with severity >= HIGH | A known breaking change is classified as NON_BREAKING or omitted entirely | Run prompt against a curated diff with a pre-labeled breaking change log; compare detected list to expected list |
False Positive Rate | Fewer than 10% of detected breaking changes are false positives (non-breaking changes mislabeled as breaking) | A non-breaking change like an internal refactor or additive endpoint is flagged as BREAKING | Run prompt against a diff with zero known breaking changes; count any severity >= HIGH as a false positive |
Severity Calibration | CRITICAL findings map to data loss, auth bypass, or hard contract removal; HIGH maps to signature changes or field removal; MEDIUM maps to deprecation or behavioral edge cases | A deprecation notice is classified as CRITICAL, or a schema deletion is classified as MEDIUM | Review severity labels against a pre-defined severity taxonomy for 10 sample findings |
Migration Note Actionability | Each HIGH or CRITICAL finding includes a migration note with a concrete before/after code example or a specific upgrade step | Migration note is generic (e.g., 'update your code') or missing for a HIGH severity finding | Spot-check migration notes for 5 HIGH findings; verify each contains a code-level instruction or a specific API call change |
Line Reference Accuracy | Every finding references a line number or line range that exists in the provided diff and contains the relevant change | A finding references a line number outside the diff range or points to an unrelated code block | Parse output line references; validate each against the input diff using a script that checks line existence and content match |
Schema Change Detection | All changes to required fields, field types, enum values, or response shapes are detected | A field type change from string to integer or a removed required field is not flagged | Include a diff with 3 schema-breaking changes (type change, required field removal, enum value deletion); verify all 3 are detected |
Deprecation vs. Removal Distinction | Deprecated items are flagged with severity MEDIUM and a deprecation timeline note; removed items are flagged with severity HIGH or CRITICAL | A deprecated-but-still-functional endpoint is flagged as CRITICAL, or a hard removal is flagged as MEDIUM | Include a diff with one deprecation and one removal; verify severity and note content match the distinction |
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 representative diff. Remove structured output requirements initially—ask for a plain-text risk summary instead of JSON. Use a lightweight model call without retries or validation.
codeAnalyze this diff for breaking changes to the public API. Diff: [DIFF] List any breaking changes you find with a severity estimate.
Watch for
- False positives on internal refactors that don't touch public surfaces
- Missing severity calibration without a rubric
- Overly verbose output when the diff is large; consider truncating the diff input

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