Inferensys

Prompt

Breaking Change Detection Prompt for OpenAPI Specs

A practical prompt playbook for using Breaking Change Detection Prompt for OpenAPI Specs in production AI workflows.
Developer doing prompt engineering on laptop, prompt variations visible on screen, casual coding session.
PROMPT PLAYBOOK

When to Use This Prompt

Define the job, reader, and constraints for the Breaking Change Detection Prompt.

This prompt is designed for API platform teams, backend engineers, and CI/CD pipeline maintainers who need to automatically detect breaking changes between two versions of an OpenAPI specification. The core job-to-be-done is preventing accidental contract violations from reaching production by surfacing a structured, severity-rated diff before a pull request is merged. The ideal user is an engineering lead or platform architect who understands OpenAPI semantics and needs a reliable, repeatable signal—not a vague summary—to gate a deployment or trigger a manual review. The required context includes the full text of both the old and new OpenAPI specs, and optionally a set of organizational rules (e.g., 'enum value removal is always breaking') to override default heuristics.

Do not use this prompt when you need a human-readable changelog for external developers, when you are reviewing a single spec in isolation without a baseline, or when the change is purely cosmetic (e.g., description text updates). This prompt is also inappropriate for non-OpenAPI contracts like GraphQL schemas or gRPC proto files, which have different breaking change semantics. For high-risk regulated environments, the structured output from this prompt should be treated as a triage aid, not a final verdict; always pair it with a human approval step for changes that touch authentication, payment, or health-data endpoints. The prompt works best when integrated into a CI harness that can cache the previous spec version and feed both into the model as the [OLD_SPEC] and [NEW_SPEC] inputs.

Before wiring this into a production pipeline, validate the prompt against a golden dataset of known breaking and non-breaking changes. Common failure modes include false positives on additive field introductions (which are safe by default) and false negatives on enum value removals (which are always breaking). After reading this section, copy the prompt template, adapt the placeholders to your spec sources, and run it against your last three production spec changes to calibrate severity thresholds before blocking any merges.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Breaking Change Detection Prompt delivers reliable results and where it introduces risk. Use these cards to decide whether this prompt fits your workflow before wiring it into CI.

01

Good Fit: Structured Spec Diffs in CI

Use when: you have two complete OpenAPI specification versions (JSON or YAML) and need a structured, machine-readable change report before merge. Guardrail: validate that both input specs parse successfully before calling the prompt; feed the prompt only the relevant diff paths to keep context focused.

02

Bad Fit: Ambiguous or Undocumented Changes

Avoid when: the spec change includes undocumented intent, such as a field removal without a deprecation window or an enum change with no migration guide. Guardrail: require a human-readable changelog or migration note as a required input alongside the spec diff; if missing, escalate for human review before the prompt runs.

03

Required Inputs: Parsed Specs and Diff Context

Risk: incomplete inputs produce false negatives. The prompt needs both the old and new OpenAPI specs, plus a structured diff (path-level changes). Guardrail: pre-process specs through a parser to extract endpoint, schema, and parameter trees; supply only the changed nodes to the prompt to reduce noise and token waste.

04

Operational Risk: False Positives on Additive Changes

Risk: the model may flag new optional fields or additive enum values as breaking, causing unnecessary release blocks. Guardrail: add a post-processing validation rule that checks whether flagged changes are strictly additive (new optional field, new enum value) and downgrades severity before the report is surfaced.

05

Operational Risk: False Negatives on Type Narrowing

Risk: changing a field type from string to string | null or widening constraints may be missed as a breaking change for clients that don't handle null. Guardrail: include explicit test cases for type narrowing, constraint tightening, and default value removal in your eval harness; run these before trusting the prompt in CI.

06

Scale Limit: Large Specs with Many Endpoints

Risk: multi-thousand-line specs exceed context windows or cause the model to skip endpoints. Guardrail: shard the spec by endpoint or schema group; run the prompt per shard and merge results. Set a hard token budget per shard and fail loudly if a shard exceeds it rather than silently truncating.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for comparing two OpenAPI specifications and producing a structured breaking change analysis with severity ratings.

The following prompt template is designed to be dropped into your CI pipeline, API governance tool, or review workflow. It accepts two OpenAPI specification versions and a set of configurable constraints, and it returns a structured JSON report classifying each change as breaking, additive, or compatible. Use the square-bracket placeholders to inject your own spec content, output schema requirements, and organizational policies before sending the prompt to the model.

text
You are an API contract reviewer. Your task is to compare two OpenAPI specification versions and produce a structured breaking change analysis.

## INPUTS

### Previous OpenAPI Specification (v1)
[PREVIOUS_SPEC]

### Current OpenAPI Specification (v2)
[CURRENT_SPEC]

## OUTPUT SCHEMA

Return a JSON object with this exact structure:
{
  "summary": {
    "breaking_changes_count": <integer>,
    "additive_changes_count": <integer>,
    "compatible_changes_count": <integer>,
    "total_endpoints_affected": <integer>
  },
  "changes": [
    {
      "id": "<string, unique change identifier>",
      "category": "<breaking | additive | compatible>",
      "severity": "<critical | high | medium | low>",
      "change_type": "<e.g., path-removed, parameter-required-added, enum-value-removed, schema-type-changed, response-body-field-removed, field-nullable-changed, operation-deprecated>",
      "location": "<JSON path or endpoint and method, e.g., GET /users/{id} -> response.200.schema.properties.email>",
      "description": "<human-readable explanation of what changed>",
      "before": "<previous value or state>",
      "after": "<current value or state>",
      "affected_clients": ["<list of client types or names if identifiable, otherwise empty array>"],
      "migration_guidance": "<specific fix or upgrade step for consumers>"
    }
  ]
}

## CONSTRAINTS

[CONSTRAINTS]

## CLASSIFICATION RULES

### Breaking Changes (severity: critical or high)
- Removing or renaming a path, operation, or parameter
- Changing a parameter from optional to required
- Removing an enum value from a request or response
- Changing a field type (e.g., string to integer)
- Removing a response body field that was previously present
- Changing a field from nullable to non-nullable
- Adding a new required parameter without a default
- Changing authentication or security scheme requirements
- Removing a supported content type or response code

### Additive Changes (severity: low)
- Adding a new endpoint or operation
- Adding an optional parameter
- Adding a new enum value
- Adding a new response body field
- Adding a new response code
- Adding a new content type

### Compatible Changes (severity: low)
- Description or documentation updates
- Changing a parameter from required to optional
- Adding a default value to a parameter
- Deprecation annotations without removal
- Example updates

## EXAMPLES

[EXAMPLES]

## INSTRUCTIONS

1. Parse both specifications completely before comparing.
2. Compare every path, operation, parameter, request body, response, and schema definition.
3. For each change, assign exactly one category and one severity.
4. If a change affects multiple endpoints, list it once with all affected locations noted.
5. Do not flag cosmetic differences such as whitespace, comment changes, or example value updates as breaking changes.
6. If you are uncertain whether a change is breaking, classify it as breaking with severity medium and note the uncertainty in the description.
7. Return only the JSON object. No additional text, markdown fences, or commentary.

To adapt this template for your environment, replace [PREVIOUS_SPEC] and [CURRENT_SPEC] with the raw YAML or JSON content of your OpenAPI documents. The [CONSTRAINTS] placeholder should contain your organization's specific policies, such as "enum additions to closed enums are breaking" or "deprecation without a sunset header is a medium-severity finding." Use [EXAMPLES] to inject one or two few-shot demonstrations of correct classification, especially for ambiguous cases like field reordering in allOf schemas or discriminator mapping changes. If your pipeline already has a preferred output schema, replace the schema block entirely rather than layering additional fields on top.

Before deploying this prompt into a CI check, run it against a golden dataset of known spec diffs that includes false-positive risks: non-breaking field additions, optional parameter introductions, and description-only changes. Measure precision and recall per change category. If the model flags description updates as breaking or misses enum value removals, add counterexamples to [EXAMPLES] and tighten the classification rules. For production use, always pair this prompt with a JSON schema validator on the output and a human-approval gate for any change classified as critical severity.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Breaking Change Detection Prompt. Each placeholder must be populated before the prompt is sent. Validation notes describe how to verify the input is well-formed and safe to use.

PlaceholderPurposeExampleValidation Notes

[OLD_OPENAPI_SPEC]

The baseline OpenAPI specification (previous version) against which changes are compared.

openapi: 3.0.3 info: version: 1.2.0 paths: /users: get: ...

Parse as valid YAML or JSON. Must contain an openapi version field, at least one paths entry, and a valid info.version. Reject if the spec fails to parse or is missing required top-level keys.

[NEW_OPENAPI_SPEC]

The candidate OpenAPI specification (new version) to evaluate for breaking changes.

openapi: 3.0.3 info: version: 1.3.0 paths: /users: get: ...

Parse as valid YAML or JSON. The info.version must be different from [OLD_OPENAPI_SPEC]. Reject if the spec is identical to the old spec or fails schema validation.

[CHANGE_CONTEXT]

Optional natural language description of the intended change, release notes, or migration intent to help the model distinguish intentional breaking changes from accidents.

Removed the deprecated middle_name field from the User response. Added phone_number as an optional field.

Null allowed. If provided, check for length under 2000 characters. If null, the model relies solely on spec diff analysis. Do not include confidential or unreleased product plans.

[SEVERITY_THRESHOLD]

The minimum severity level to include in the output. Changes below this threshold are omitted from the report.

warning

Must be one of: info, warning, error, critical. Default to warning if not provided. Reject values outside the enum. Controls output verbosity and CI pass/fail gating.

[CONSUMER_MANIFEST]

Optional list of known API consumers, SDKs, or client teams to include in per-consumer impact estimates.

[{"name": "iOS App v3", "endpoints": ["/users", "/orders"]}, {"name": "Partner Webhook", "endpoints": ["/webhooks/orders"]}]

Null allowed. If provided, parse as a JSON array of objects with name (string) and endpoints (array of strings). Validate that endpoint paths exist in [OLD_OPENAPI_SPEC]. Flag unknown paths as a warning but do not reject.

[DEPRECATION_POLICY]

Optional policy document describing required deprecation windows, Sunset header rules, and migration guide requirements.

All breaking changes require a 90-day deprecation notice and a Sunset header. Additive changes require a changelog entry.

Null allowed. If provided, check for length under 1000 characters. The model uses this to flag policy violations in addition to technical breaking changes. Do not embed legal advice.

[OUTPUT_FORMAT]

The desired output structure for the breaking change report.

json

Must be one of: json, markdown, junit. Default to json if not provided. json returns structured data for CI integration. markdown returns a human-readable report. junit returns test-suite XML for CI pass/fail gating.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the breaking change detection prompt into a CI pipeline with validation, retries, and human review gates.

This prompt is designed to run as a gate in your CI/CD pipeline, triggered on every pull request that modifies an OpenAPI specification file. The harness should extract the base and head spec versions from the PR (typically the target branch and the feature branch), format them as the [OLD_SPEC] and [NEW_SPEC] inputs, and invoke the model. Because API breaking changes can cause cascading production failures, the harness must treat this as a high-stakes workflow with structured output validation, deterministic retry logic, and a clear human approval path for any detected breaking changes.

Start by implementing a strict output validator that parses the model's JSON response against the expected schema before the CI check reports a result. The validator must confirm that every change entry includes the required fields: location (path and method), change_type (breaking, additive, compatible), severity (critical, high, medium, low), description, and migration_suggestion. If the output fails schema validation, retry once with the same inputs and a stronger constraint instruction appended to the prompt. If the second attempt also fails, fail the CI check with an UNPARSEABLE_OUTPUT status and notify the platform team—do not silently pass. For model choice, use a model with strong structured output capabilities and a context window large enough to hold both full specs; if the specs exceed the context window, preprocess them to include only the paths, schemas, and components that differ between versions rather than truncating arbitrarily.

Wire the validated output into your review workflow. If the model reports zero breaking changes, the CI check can pass automatically. If any breaking change is detected, the CI check should post a structured comment on the PR with the full change list and require an explicit approval from an API platform team member before merge. Log every invocation with the spec versions, model response, validation result, and reviewer action for auditability. Avoid the common failure mode of treating this prompt as a fully automated gate—false negatives on enum value removals and type narrowing are possible, so the harness should always flag breaking changes for human review rather than blocking the PR outright without oversight.

IMPLEMENTATION TABLE

Expected Output Contract

Each field the prompt must return, its expected type, whether it is required, and the validation rule to apply before accepting the output.

Field or ElementType or FormatRequiredValidation Rule

change_id

string (kebab-case)

Must match pattern ^change-[a-z0-9-]+$ and be unique per diff

change_type

enum: breaking | additive | compatible

Must be one of three allowed values; reject any other string

severity

enum: critical | high | medium | low

Must be one of four allowed values; map 'major' or 'severe' to 'critical' in repair

affected_path

string (JSONPath or endpoint path)

Must start with '/' or '$.' and resolve to a valid spec location in the input

previous_state

string or null

Must be null for additive changes; must be non-null for breaking and compatible changes

current_state

string

Must be non-null; must differ from previous_state when change_type is not compatible

client_impact

string

Must be non-empty; must reference at least one affected HTTP method or consumer path

migration_action

string or null

Required when change_type is breaking; must be null or a non-empty actionable sentence

PRACTICAL GUARDRAILS

Common Failure Modes

Breaking change detection prompts fail in predictable ways. These cards cover the most common failure modes when comparing OpenAPI specs with LLMs and how to guard against them before they reach CI or production.

01

False Negatives on Enum Value Removal

What to watch: The model treats enum value removal as a cosmetic change rather than a breaking change, missing that existing clients sending the removed value will receive errors. This is the most dangerous failure mode because it silently passes a breaking change. Guardrail: Include explicit few-shot examples showing enum value removal classified as BREAKING with severity HIGH. Add a post-processing validation rule that flags any enum array reduction as breaking regardless of model output.

02

False Positives on Additive Field Changes

What to watch: The model flags new optional fields or new response properties as breaking changes, generating noise that erodes trust in the detection system and causes review fatigue. Guardrail: Provide explicit schema evolution rules in the system prompt stating that adding new optional fields, new response properties, and new enum values are non-breaking. Include counter-examples in few-shot demonstrations showing these classified as ADDITIVE or COMPATIBLE.

03

Context Window Truncation on Large Specs

What to watch: Large OpenAPI specs with hundreds of endpoints exceed the model's context window, causing the prompt to silently drop schema portions and miss breaking changes in truncated sections. Guardrail: Implement a pre-processing step that splits the diff into per-endpoint or per-schema chunks, runs detection on each chunk independently, and merges results. Set a hard token budget check before the model call and route oversized specs to chunked processing.

04

Severity Inflation on Deprecation-Only Changes

What to watch: The model assigns BREAKING severity to changes that are merely deprecated with a sunset window, causing unnecessary alarm and premature migration pressure on client teams. Guardrail: Define a clear severity taxonomy in the prompt: BREAKING means immediate client failure, DEPRECATED means still functional with a timeline, and ADDITIVE means no impact. Include a post-processing rule that downgrades any finding where the old field or endpoint remains functional.

05

Type Narrowing Misclassification

What to watch: The model fails to recognize that changing a field type from integer to number or from string to string-with-enum is breaking for clients that depend on the narrower type contract. Guardrail: Add explicit rules in the prompt covering type widening vs narrowing: widening is non-breaking, narrowing is breaking. Include test cases for integer-to-number (widening, safe) and string-to-enum (narrowing, breaking) in the eval harness.

06

Required Field Addition Overlooked

What to watch: The model misses that adding a new required field to a request body or making an optional field required is a breaking change because existing clients won't send the field and will receive validation errors. Guardrail: Add a dedicated check instruction in the prompt: 'For every schema object, compare required arrays between versions. Any field added to required is BREAKING.' Implement a deterministic post-processing diff on required arrays as a safety net independent of the model output.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the Breaking Change Detection Prompt before shipping. Each criterion targets a known failure mode for OpenAPI diff analysis. Run these checks against a golden dataset of spec diffs with known breaking, additive, and compatible changes.

CriterionPass StandardFailure SignalTest Method

Breaking change recall

All known breaking changes in the golden diff set are detected and flagged with severity HIGH or CRITICAL

Enum value removal, required field addition, or type narrowing is classified as additive or compatible

Run prompt against 10+ spec diffs with labeled breaking changes; compare detected vs expected breaking change count

Additive change false positive rate

Zero additive changes (new optional field, new endpoint, new enum value) are classified as breaking

Adding an optional response field triggers a breaking change severity rating

Feed diffs containing only additive changes; assert zero HIGH or CRITICAL severity outputs

Enum change classification

Enum value removal is flagged as breaking; enum value addition is flagged as additive or compatible

Removed enum value is marked as compatible or not mentioned in output

Test with a diff that removes one enum value and adds another; verify correct per-change classification

Required vs optional field distinction

New required field is flagged as breaking; new optional field is flagged as additive or compatible

New optional field is classified as breaking or new required field is classified as additive

Test with a diff adding one required field and one optional field; verify severity differs

Type narrowing detection

Field type change from string to enum, integer to number subset, or object to more specific object is flagged as breaking

Type narrowing is classified as compatible or not reported

Test with a diff that narrows a response field type; verify breaking severity and correct change description

Deprecation vs removal distinction

Deprecated-but-still-present fields are flagged as additive or compatible with deprecation note; removed fields are flagged as breaking

Deprecated field is classified as breaking removal

Test with a diff that deprecates one field and removes another; verify removal is breaking and deprecation is not

Output schema compliance

Every change entry contains all required fields: change_type, location, severity, before_state, after_state, client_impact

Output omits location path, severity rating, or client_impact for one or more detected changes

Validate output JSON against the defined output schema; assert all required fields present and non-null for every change entry

Path and operation specificity

Each detected change references the exact JSON path and HTTP operation affected, not a vague endpoint summary

Change location is reported as /users endpoint instead of /users/{id} response body field email type

Parse output location fields; assert each contains a valid JSON Pointer path or operationId + field path

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base prompt and a single spec pair. Use a frontier model (GPT-4o, Claude Sonnet) with no additional tooling. Pass both OpenAPI specs as inline text in [OLD_SPEC] and [NEW_SPEC] placeholders. Skip severity scoring initially—just classify changes as breaking, additive, or compatible.

Watch for

  • Large specs exceeding context windows; truncate to changed paths only
  • Enum removal false negatives when the model treats enum changes as string type changes
  • No validation of output structure; wrap in a simple JSON schema check before trusting results
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.