Inferensys

Prompt

Breaking Change Detection Prompt for Interface Contracts

A practical prompt playbook for using Breaking Change Detection Prompt for Interface Contracts 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

Identify the right moment to run a breaking change detection pass on an API contract diff before it reaches consumers.

This prompt is built for platform and backend engineering teams that need to compare two versions of an API contract—OpenAPI, gRPC proto, GraphQL schema, or JSON Schema—and produce a categorized, actionable list of changes. The core job-to-be-done is preventing silent breaking changes from reaching production consumers. Use it during pull request review when a contract file changes, as a gate in your CI pipeline before merging a spec update, or when generating a migration guide for external developers. The ideal user is an API designer, service owner, or release engineer who has access to the old and new contract snapshots and needs a structured diff analysis faster than manual line-by-line review.

The prompt assumes you have either a structured diff (unified diff, git diff) or two complete contract snapshots. It classifies each change as breaking, additive, or compatible, and attaches a consumer impact analysis that explains what will fail and for whom. Breaking changes include removed fields, changed types, narrowed validation constraints, removed endpoints, and altered authentication requirements. Additive changes include new optional fields, new endpoints, and relaxed constraints. Compatible changes include documentation updates, description clarifications, and reordering of fields. The prompt is not a replacement for integration tests, consumer-driven contract testing, or runtime compatibility gates—it is a design-time safety net that catches obvious breaks before they reach downstream systems.

Do not use this prompt when you lack a complete before-and-after contract snapshot, when the contract is defined only in prose or tribal knowledge, or when the change involves runtime behavior that isn't expressed in the contract (e.g., rate limit changes, latency SLO shifts, or backend logic modifications). It also won't detect semantic breaks where the contract is unchanged but the implementation behavior has changed. For those cases, pair this prompt with integration tests and consumer-driven contract verification. If your API uses multiple contract formats simultaneously (e.g., gRPC proto plus a JSON Schema gateway), run the prompt separately for each format and cross-reference the results.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Breaking Change Detection Prompt works well, where it fails, what inputs it requires, and the operational risks to plan for before integrating it into a CI pipeline or design review workflow.

01

Good Fit: Structured Contract Diffs

Use when: you have two machine-readable versions of an API contract (OpenAPI, GraphQL schema, gRPC proto, JSON Schema) and need a categorized change list. Guardrail: pre-process diffs into a structured format (added, removed, modified paths/fields/types) before sending to the model; raw text diffs produce inconsistent classifications.

02

Bad Fit: Semantic Behavior Changes

Avoid when: the change is purely behavioral (different validation logic, changed rate limits, new business rules) with no contract surface modification. Guardrail: pair this prompt with a separate behavioral change review prompt; contract diff alone cannot detect semantic drift that preserves the schema.

03

Required Input: Consumer Impact Context

Risk: without knowing which fields consumers actually use, the prompt over-flags additive changes as safe or misses breaking changes that affect real usage patterns. Guardrail: supply a consumer field usage manifest or telemetry summary alongside the diff; treat classifications without consumer context as preliminary only.

04

Required Input: Versioning Policy Rules

Risk: the model applies generic semver or compatibility rules that may not match your organization's specific versioning policy (e.g., some teams treat new required fields as breaking, others don't). Guardrail: include your explicit versioning policy as a [CONSTRAINTS] block in the prompt; test against known policy-edge cases before production use.

05

Operational Risk: False-Positive Noise

Risk: over-flagging compatible changes as breaking erodes trust and causes alert fatigue in CI pipelines. Guardrail: implement a suppression list for known false-positive patterns (e.g., adding optional fields, deprecating without removal); run the prompt against a golden set of known-safe diffs and tune the classification rules before blocking merges.

06

Operational Risk: Silent Breaking Changes

Risk: the prompt misses a breaking change because the diff format obscures the impact (e.g., enum value removal hidden in a large schema restructure). Guardrail: always pair automated detection with a manual review step for changes classified as 'compatible'; run complementary checks for enum member removal, type narrowing, and field relocation that diffs can mask.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

Paste this prompt into your AI harness to compare two API contract versions and produce a categorized change report.

The prompt below is designed to be dropped into your AI harness with minimal adaptation. It accepts two versions of an interface contract—typically OpenAPI specs, gRPC protobufs, or GraphQL schemas—and a set of classification rules. The model's job is to produce a structured diff report that separates breaking changes from additive and compatible changes, with consumer impact analysis for each finding. Replace every square-bracket placeholder with your actual contract versions, classification rules, and output schema before use.

text
You are an API contract reviewer specialized in detecting breaking changes between two versions of an interface contract.

## INPUT
[CONTRACT_VERSION_A]
[CONTRACT_VERSION_B]

## CLASSIFICATION RULES
[CLASSIFICATION_RULES]

## CONSTRAINTS
- Classify every detected change as BREAKING, ADDITIVE, or COMPATIBLE.
- For each BREAKING change, explain the consumer impact and which existing clients would fail.
- Do not flag cosmetic changes (whitespace, comment reordering, description rewording) unless they alter generated code or runtime behavior.
- If a change is ambiguous, mark it as REQUIRES_HUMAN_REVIEW and explain why.
- Ignore changes to [IGNORE_PATHS_OR_FIELDS] unless they affect contract semantics.

## OUTPUT SCHEMA
Return a single JSON object with this structure:
{
  "summary": {
    "breaking_count": <int>,
    "additive_count": <int>,
    "compatible_count": <int>,
    "requires_review_count": <int>
  },
  "changes": [
    {
      "id": "<string>",
      "location": "<path or field reference>",
      "type": "BREAKING | ADDITIVE | COMPATIBLE | REQUIRES_HUMAN_REVIEW",
      "description": "<what changed>",
      "consumer_impact": "<who breaks and how, or null for non-breaking>",
      "confidence": "HIGH | MEDIUM | LOW"
    }
  ]
}

## EXAMPLES
[FEW_SHOT_EXAMPLES]

## RISK LEVEL
[RISK_LEVEL]

Analyze the two contract versions and return only the JSON object.

Adapt this template by filling in the placeholders with concrete values. [CONTRACT_VERSION_A] and [CONTRACT_VERSION_B] should contain the full text of your old and new contract specifications. [CLASSIFICATION_RULES] is where you encode your team's specific definition of breaking versus non-breaking changes—for example, whether adding a required field is breaking, or whether enum value removal counts. [IGNORE_PATHS_OR_FIELDS] lets you suppress noise from known internal-only fields or deprecated paths. [FEW_SHOT_EXAMPLES] should include 2–4 annotated examples of changes with correct classifications to anchor the model's behavior. [RISK_LEVEL] can be set to HIGH, MEDIUM, or LOW to adjust the model's conservatism—at HIGH, the model should err toward flagging ambiguous changes as REQUIRES_HUMAN_REVIEW.

Before wiring this into a production pipeline, validate the output against your expected schema. Common failure modes include the model collapsing additive and compatible changes into a single category, missing changes in deeply nested schema components, or producing consumer impact descriptions that are too vague to act on. Run this prompt against a golden dataset of known contract diffs with labeled breaking changes and measure precision and recall before trusting it in a CI gate. For high-risk APIs where a missed breaking change could cause an outage, always route REQUIRES_HUMAN_REVIEW and LOW-confidence findings to a human reviewer before merging.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Breaking Change Detection Prompt. Each variable must be populated before the prompt is assembled and sent. Missing or malformed inputs are the most common cause of false positives and missed breaking changes.

PlaceholderPurposeExampleValidation Notes

[OLD_CONTRACT]

The baseline API specification against which changes are measured

openapi: 3.0.3 info: version: 1.4.0 paths: /users/{id}: get: parameters: - name: id in: path required: true schema: type: string

Must be a valid OpenAPI 3.x, GraphQL SDL, gRPC proto, or JSON Schema document. Parse check required before prompt assembly. Reject if spec fails to parse.

[NEW_CONTRACT]

The proposed or updated API specification to compare against the baseline

openapi: 3.0.3 info: version: 1.5.0 paths: /users/{id}: get: parameters: - name: id in: path required: true schema: type: integer

Same format requirement as [OLD_CONTRACT]. Version field should differ. If versions are identical, warn that no structural diff is expected but proceed.

[CONTRACT_FORMAT]

Explicit format declaration so the model applies correct parsing and comparison rules

openapi-3.0

Must be one of: openapi-3.0, openapi-3.1, graphql-sdl, grpc-proto, json-schema-draft7, json-schema-2020-12. Enum check before prompt assembly. Reject unknown values.

[CHANGE_CLASSIFICATION_RULES]

Custom severity thresholds and classification overrides for the team's compatibility policy

breaking: removed-field, changed-type, added-required, removed-endpoint, changed-auth additive: added-optional-field, added-endpoint, added-enum-value compatible: added-description, reordered-fields, added-example

Must be a structured mapping of change categories to severity levels. If null, use default classification rules. Validate that every category maps to exactly one severity.

[CONSUMER_REGISTRY]

Known consumers of the API to include in impact analysis. Empty array is valid for greenfield APIs.

[{"name": "mobile-app-v2", "contact": "mobile-team@example.com", "known_usage": ["GET /users/{id}", "PATCH /users/{id}"]}]

Array of objects with name, contact, and known_usage fields. Null allowed if no consumer data exists. If provided, each known_usage entry must match a path in [OLD_CONTRACT].

[FALSE_POSITIVE_SUPPRESSION]

Patterns the team has previously identified as safe changes that should not be flagged

[{"pattern": "added-optional-field to response body", "reason": "Team policy allows additive response fields without version bump"}]

Array of objects with pattern and reason fields. Null allowed. If provided, each pattern must match a change type from [CHANGE_CLASSIFICATION_RULES]. Used to suppress known-safe findings.

[OUTPUT_SCHEMA]

Expected JSON schema for the structured output. Required for schema-first prompting.

{"type": "object", "properties": {"changes": {"type": "array", "items": {"type": "object", "properties": {"location": {"type": "string"}, "change_type": {"type": "string"}, "severity": {"type": "string", "enum": ["breaking", "additive", "compatible"]}, "consumer_impact": {"type": "array"}, "migration_notes": {"type": "string"}}, "required": ["location", "change_type", "severity"]}}}, "summary": {"type": "object"}}, "required": ["changes", "summary"]}

Must be a valid JSON Schema. Parse check required. Severity enum must align with [CHANGE_CLASSIFICATION_RULES] values. Reject if schema is malformed or missing required fields.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the breaking change detection prompt into a CI/CD pipeline or API governance workflow with validation, retries, and human review gates.

The breaking change detection prompt is designed to operate as a gate in a CI/CD pipeline, triggered on pull requests that modify API specification files (OpenAPI, gRPC protobufs, GraphQL schemas, or custom contract formats). The harness should extract the base and target contract versions, compute a structural diff, and pass both the diff and the full contracts to the prompt. Do not rely on the model to compute the diff itself—pre-compute it using a deterministic tool (e.g., openapi-diff, buf breaking, or a custom JSON Schema differ) and include it as the [DIFF] input. This ensures the model focuses on classification and impact analysis rather than mechanical comparison, which reduces hallucination risk and token waste.

The implementation should wrap the LLM call in a validation layer that parses the structured output against the expected [OUTPUT_SCHEMA]. Each detected change must include a change_type field constrained to the enum ['breaking', 'additive', 'compatible', 'deprecation', 'unknown']. If the model output fails schema validation, retry once with the validation error appended to the prompt as a correction hint. If the second attempt also fails, fail the pipeline step and flag for human review. For high-risk APIs (auth, payments, data deletion), configure the harness to require explicit human approval on any change classified as breaking or unknown before the pipeline can proceed. Log every run with the contract versions, diff, model response, validation result, and reviewer decision to an audit store for governance traceability.

Model choice matters here. Use a model with strong structured output support and a large context window if your API specs are verbose. For OpenAPI specs over 10,000 lines, truncate to the changed paths and their referenced schemas rather than passing the entire spec. Implement a false-positive suppression registry: maintain a JSON file of known false positives (e.g., reordering of enum values that are explicitly documented as unordered) and filter them from the diff before passing to the prompt. After deployment, monitor the ratio of human-overridden classifications to total classifications. If the override rate exceeds 15%, review the prompt's classification rules and the false-positive registry for gaps. Do not use this prompt as the sole gate for regulatory compliance; always pair it with a deterministic contract compatibility check and a human review step for regulated surfaces.

IMPLEMENTATION TABLE

Expected Output Contract

Fields, format, and validation rules for the model response when comparing two API contract versions. Use this table to build your output parser and validation logic.

Field or ElementType or FormatRequiredValidation Rule

change_classification

string enum: breaking, additive, compatible, annotation

Must be exactly one of the four allowed values. Reject any response containing unclassified changes.

change_summary

string (<=280 chars)

Must be present and non-empty. Length must not exceed 280 characters. Must reference the specific endpoint or field affected.

consumer_impact

string enum: immediate_failure, silent_corruption, deprecation_notice, none, informational

Must be present for every change. If classification is 'breaking', impact must not be 'none' or 'informational'.

affected_endpoint

string (path template)

Must match the pattern ^/[a-zA-Z0-9_{}/-]+$. Must be extractable from the diff context. Reject if endpoint is not present in either the old or new spec.

diff_location

object

Must contain 'old_spec_line' and 'new_spec_line' integer fields. Both must be >= 0. If the change is an addition, old_spec_line must be 0. If a removal, new_spec_line must be 0.

migration_guidance

string or null

If classification is 'breaking', this field must be a non-null string with actionable consumer steps. If classification is 'additive', null is allowed.

confidence_score

number (0.0-1.0)

Must be a float between 0.0 and 1.0 inclusive. If below 0.7, the change must be flagged for human review regardless of classification.

false_positive_check

boolean

Must be true if the model believes this change is a false positive. If true, classification must be 'annotation' and consumer_impact must be 'informational'. Reject if false_positive_check is true but classification is 'breaking' or 'additive'.

PRACTICAL GUARDRAILS

Common Failure Modes

Breaking change detection is a high-stakes classification task where false negatives (missed breaks) cause outages and false positives (noise) cause alert fatigue. These are the most common failure modes and how to guard against them.

01

False Negatives on Semantic Breaks

What to watch: The model misses breaking changes that aren't structural diffs—tightened validation ranges, changed enum meanings, or altered retry semantics. The diff looks compatible but consumer behavior will break. Guardrail: Include a semantic analysis pass in the prompt that explicitly checks for constraint tightening, behavioral contract changes, and implied compatibility violations beyond structural diffing.

02

False Positives from Additive-Only Changes

What to watch: New optional fields, added enum values, or new endpoints are flagged as breaking. This noise trains teams to ignore the detector. Guardrail: Add explicit additive-change suppression rules in the prompt. Require the model to justify each breaking classification with a consumer impact statement. Flag additive-only changes in a separate category.

03

Deprecation Misclassification

What to watch: Deprecation annotations are classified as breaking changes, or deprecation-without-removal is treated as compatible when consumers need migration time. Guardrail: Define a distinct deprecation category in the output schema. Require the model to report deprecation timeline, sunset date, and replacement path separately from breaking classification.

04

Context Window Truncation on Large Specs

What to watch: Large OpenAPI specs or multi-file contracts exceed context limits, causing the model to miss changes in truncated sections. Guardrail: Implement spec chunking by endpoint or resource before diffing. Run breaking change detection per chunk and aggregate results. Add a completeness check that verifies every endpoint from both versions was analyzed.

05

Version Comparison Order Reversal

What to watch: The model compares old-to-new correctly for structural diffs but reverses the direction for behavioral changes, flagging relaxations as breaking and tightenings as compatible. Guardrail: Anchor the prompt with explicit version labels (FROM version vs TO version) and include a directional check instruction. Add a validation step that spot-checks a sample of classifications for direction correctness.

06

Custom Extension and Vendor Field Blindness

What to watch: The model ignores x-* vendor extensions, custom headers, or non-standard fields that carry breaking changes for specific consumers. Guardrail: Include an extension-awareness instruction that treats custom fields as first-class contract elements. If a consumer registry is available, cross-reference extensions against known consumer dependencies.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the quality of the breaking change detection output before integrating it into a CI pipeline or design review workflow. Each criterion targets a specific failure mode common to contract diff analysis.

CriterionPass StandardFailure SignalTest Method

Change Classification Accuracy

All changes in the diff are assigned exactly one correct classification: breaking, additive, compatible, or deprecated.

A field addition is classified as breaking; a type narrowing is classified as compatible.

Run against a golden diff set with known classifications. Assert F1 score > 0.95.

False-Positive Suppression

No breaking change is reported for additions of optional fields, new enum values, or new response headers.

Adding an optional request field is flagged as a breaking change.

Inject diffs containing only additive changes. Assert zero breaking change findings.

Consumer Impact Statement

Every breaking change includes a specific consumer impact description referencing the affected client behavior.

A breaking change is listed with no impact description or a generic statement like 'may affect clients'.

Parse output for each breaking change entry. Assert [IMPACT] field is non-empty and contains a client-facing verb.

Semantic Versioning Alignment

The summary recommendation for version bump (MAJOR, MINOR, PATCH) matches the most severe change classification found.

A diff containing a breaking change recommends a MINOR version bump.

Compare the recommended bump in [VERSION_RECOMMENDATION] against the highest severity in the change list. Assert exact match.

Output Schema Compliance

The output is valid JSON matching the [OUTPUT_SCHEMA] with all required fields present and no extra top-level keys.

The output is missing the [CHANGE_CATEGORIES] array or contains an unlisted field.

Validate output with a JSON Schema validator. Assert no schema violations.

Deprecation Detection

Changes that add a 'deprecated' flag or annotation are classified as 'deprecated' with a migration path note.

A deprecated field is classified as 'compatible' with no migration guidance.

Include a deprecation annotation in the diff input. Assert classification is 'deprecated' and [MIGRATION_PATH] is populated.

Multi-Version Diff Handling

When provided with a diff spanning multiple versions, the output summarizes changes per version transition.

Changes from v1 to v3 are reported as a single undifferentiated list.

Provide a three-version diff input. Assert the output contains per-transition breakdowns in [VERSION_TRANSITIONS].

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Add a strict JSON output schema with change_type, severity, location, consumer_impact, and migration_notes fields. Include retry logic for malformed outputs and log every classification for audit. Wire in a diff preprocessor that normalizes formatting before the prompt sees the input. Add eval cases covering known breaking changes, false positives, and edge cases like enum value removal.

code
Classify each diff entry using [CLASSIFICATION_RULES]. Output only valid JSON matching [OUTPUT_SCHEMA]. If confidence is below [CONFIDENCE_THRESHOLD], flag for human review. Suppress false positives using [SUPPRESSION_RULES].

Watch for

  • Silent format drift when the model changes output structure between versions
  • False negatives on semantic breaking changes (e.g., changed validation logic not visible in schema diff)
  • Missing human review flags for ambiguous changes like tightened constraints
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.