Inferensys

Prompt

Semantic Versioning Rule Enforcement Prompt

A practical prompt playbook for using Semantic Versioning Rule Enforcement Prompt in production AI workflows to validate version bumps against API changes.
Operations team reviewing AI workflow automation on laptop, workflow builder visible, casual office setup.
PROMPT PLAYBOOK

When to Use This Prompt

Understand the release engineering workflow this prompt supports and where it should not be applied.

This prompt is designed for release engineering teams and CI/CD pipelines that need a mechanical, rule-based verdict on whether a proposed version increment (MAJOR, MINOR, or PATCH) correctly reflects the magnitude of API changes between two specification versions. The ideal user is a platform engineer, release manager, or API governance lead who already has a structured diff of API changes and needs an automated gate that enforces the Semantic Versioning 2.0.0 specification before a release candidate is published. The prompt does not interpret raw OpenAPI or protobuf files directly—it expects a pre-processed change list as input, which means you must pair it with a diffing tool or schema comparison step upstream in your pipeline.

Use this prompt when the decision is purely mechanical: you have a list of added, removed, or modified endpoints, fields, parameters, or types, and you need a deterministic answer about whether the change is breaking, additive, or a fix. The prompt works best as a release gate in CI/CD, where an incorrect version bump should block the pipeline and require human review. It is also useful in API governance workflows where multiple teams propose version changes and you need consistent, spec-cited justification for accepting or rejecting those proposals. However, this prompt does not replace human release sign-off for critical paths, nor does it evaluate the business impact of changes—it strictly enforces the mechanical rules of semantic versioning against the provided change list. If a change is technically additive but represents a significant shift in API behavior that might break client assumptions, the prompt will not flag it unless the structural contract is violated.

Do not use this prompt when the change list is incomplete, when changes involve undocumented behavioral semantics (e.g., performance degradation, rate limit changes, or altered side effects), or when the version decision requires business context about client impact and migration cost. The prompt also should not be used as the sole approval mechanism for releases that affect regulated systems, safety-critical infrastructure, or financial transactions—always pair its output with a human review step in those contexts. For best results, combine this prompt with a structured diff generator, validate the output against a known set of versioning test cases, and log every verdict for auditability.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works, where it fails, and what you need before running it.

01

Good Fit: Structured Spec Diffs

Use when: you have two machine-readable API specifications (OpenAPI, gRPC proto, GraphQL schema) and need a versioning verdict. Guardrail: pre-parse the diff into a structured change list before sending it to the prompt. Raw spec files produce inconsistent results.

02

Bad Fit: Ambiguous or Undocumented Changes

Avoid when: the change lacks a formal spec or the diff is purely behavioral (latency, error rate, data semantics). Guardrail: route behavioral changes to a separate regression test prompt. This prompt only judges structural contract changes against semver rules.

03

Required Input: Parsed Change Manifest

What to watch: sending raw JSON diffs or full spec files causes the model to miss subtle breaking changes like enum value removal or field type narrowing. Guardrail: pre-process the diff into a structured manifest listing each changed endpoint, field, type, and constraint before invoking the prompt.

04

Operational Risk: False MAJOR Verdicts

Risk: the model over-classifies additive changes as breaking, especially when new required fields appear in request bodies or when response fields are reordered. Guardrail: add eval test cases that verify MINOR bumps for additive-only changes and PATCH bumps for doc-only changes. Flag MAJOR verdicts for human review when confidence is below threshold.

05

Operational Risk: Missed Breaking Changes

Risk: the model misses breaking changes in complex type hierarchies, particularly when a field type changes deep in a nested object or when a union discriminator is modified. Guardrail: run a complementary schema diff tool alongside the prompt and cross-reference findings. Escalate any disagreement to manual review.

06

Integration Point: CI/CD Release Gate

Use when: blocking a release pipeline on versioning correctness. Guardrail: this prompt should run as a non-blocking check with a human approval override. A false MAJOR verdict blocking a PATCH release causes more operational pain than a missed MINOR bump. Design the harness to warn, not block, until eval precision exceeds 95%.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A ready-to-use prompt that enforces semantic versioning rules by analyzing API spec diffs and producing a versioning verdict with rule citations.

This prompt template is designed to be dropped into your release engineering pipeline. It takes a structured diff between two API specification versions and applies strict semantic versioning rules to determine whether the change magnitude matches the proposed version increment. The prompt forces the model to reason from explicit rules rather than intuition, which reduces inconsistent versioning calls across releases.

text
You are a semantic versioning enforcement engine. Your task is to analyze an API specification diff and determine whether the proposed version increment is correct according to the Semantic Versioning 2.0.0 specification.

## INPUTS
- [SPEC_DIFF]: A structured diff between the old and new API specification versions. Include changed endpoints, fields, types, enums, required parameters, response schemas, and headers.
- [PROPOSED_VERSION]: The version increment being proposed, formatted as MAJOR.MINOR.PATCH (e.g., 2.1.0 to 2.2.0).
- [CHANGE_CONTEXT]: Optional notes about the change intent, affected clients, and any migration plans.

## RULES
Apply the following rules in order. If any rule triggers a higher severity, that severity overrides lower ones.

### MAJOR version increment required when:
- Removing or renaming an endpoint, field, enum value, or response property
- Changing a field type (e.g., string to integer, object to array)
- Making a previously optional request parameter required
- Adding a new required request parameter without a default
- Narrowing a response field from nullable to non-nullable
- Removing support for a previously supported HTTP method on an endpoint
- Changing authentication or authorization requirements
- Changing rate limiting behavior in a way that reduces allowed requests

### MINOR version increment required when:
- Adding a new endpoint
- Adding a new optional request parameter
- Adding a new response field
- Adding a new enum value
- Adding a new HTTP method to an existing endpoint
- Deprecating an endpoint or field with a Sunset header and migration path

### PATCH version increment required when:
- Fixing a bug that aligns behavior with the documented contract
- Changing error message text without changing error structure
- Performance improvements that don't change the contract
- Documentation updates
- Internal refactoring with zero contract changes

## OUTPUT SCHEMA
Return a JSON object with this exact structure:
{
  "verdict": "APPROVED" | "REJECTED",
  "required_version": "MAJOR" | "MINOR" | "PATCH",
  "proposed_version": "MAJOR" | "MINOR" | "PATCH",
  "findings": [
    {
      "change_description": "string describing the specific change",
      "location": "path.to.affected.element in the spec",
      "severity": "BREAKING" | "ADDITIVE" | "PATCH",
      "rule_citation": "The specific rule from the RULES section that applies",
      "client_impact": "How this change affects existing API consumers"
    }
  ],
  "migration_guidance": "If breaking changes exist, provide a brief migration path. Otherwise null.",
  "confidence": "HIGH" | "MEDIUM" | "LOW",
  "uncertainty_notes": "If confidence is not HIGH, explain what information is missing or ambiguous."
}

## CONSTRAINTS
- Do not guess about change intent. If the diff is ambiguous, flag it as LOW confidence and explain what clarification is needed.
- Enum value additions are MINOR unless the enum is documented as closed, in which case they are MAJOR.
- Field deprecation without removal is MINOR, not MAJOR.
- If a change could be interpreted multiple ways, list all interpretations and flag for human review.
- Never approve a MAJOR change as PATCH, even if the change seems small.

## EXAMPLES

Example 1: Adding an optional field
Input: Added optional "middleName" field to User response object. Proposed: 1.2.0 to 1.3.0.
Output: {"verdict": "APPROVED", "required_version": "MINOR", "proposed_version": "MINOR", "findings": [{"change_description": "Added optional middleName field to User response", "location": "User.middleName", "severity": "ADDITIVE", "rule_citation": "Adding a new response field requires MINOR", "client_impact": "Existing clients ignore unknown fields; no breakage"}], "migration_guidance": null, "confidence": "HIGH", "uncertainty_notes": null}

Example 2: Removing an enum value
Input: Removed "LEGACY" value from PaymentMethod enum. Proposed: 1.4.0 to 1.5.0.
Output: {"verdict": "REJECTED", "required_version": "MAJOR", "proposed_version": "MINOR", "findings": [{"change_description": "Removed LEGACY value from PaymentMethod enum", "location": "PaymentMethod enum", "severity": "BREAKING", "rule_citation": "Removing an enum value requires MAJOR", "client_impact": "Clients sending LEGACY will receive validation errors"}], "migration_guidance": "Deprecate LEGACY first with a Sunset header, then remove in next MAJOR version", "confidence": "HIGH", "uncertainty_notes": null}

## INSTRUCTIONS
1. Parse [SPEC_DIFF] and identify every contract change.
2. Classify each change against the RULES section.
3. Determine the highest severity across all changes.
4. Compare the required version increment to [PROPOSED_VERSION].
5. If they match, verdict is APPROVED. If not, REJECTED.
6. Output the JSON object following [OUTPUT_SCHEMA] exactly.
7. If [CHANGE_CONTEXT] provides information that clarifies intent, use it. Otherwise, note missing context in uncertainty_notes.

To adapt this prompt for your pipeline, replace [SPEC_DIFF] with a structured representation of your API changes. The diff format can come from OpenAPI comparison tools, git diffs on proto files, or a custom change log. The critical requirement is that each change includes the affected path, the old value, and the new value. If your spec tooling produces unstructured diffs, add a pre-processing step that extracts and normalizes changes before passing them to this prompt. For high-risk releases, always route LOW confidence verdicts to a human reviewer before the version is finalized.

IMPLEMENTATION TABLE

Prompt Variables

Required and optional inputs for the Semantic Versioning Rule Enforcement Prompt. Each placeholder must be populated before the prompt is assembled and sent. Validation notes describe how to check input quality before execution.

PlaceholderPurposeExampleValidation Notes

[PREVIOUS_SPEC]

The prior version of the API specification (OpenAPI, JSON Schema, or proto) used as the baseline for comparison

openapi-v2.1.0.yaml (full file content or structured diff anchor)

Must parse as valid spec format. Reject if empty, unparseable, or missing required spec version field. Compare spec version against [CURRENT_SPEC] to confirm ordering.

[CURRENT_SPEC]

The new or proposed version of the API specification being reviewed for versioning compliance

openapi-v2.2.0.yaml (full file content or structured diff anchor)

Must parse as valid spec format. Reject if identical to [PREVIOUS_SPEC] (no changes to evaluate). Reject if spec version is older than [PREVIOUS_SPEC].

[VERSION_BUMP_TYPE]

The declared version increment applied between the two specs: MAJOR, MINOR, or PATCH

MINOR

Must be one of three enum values: MAJOR, MINOR, PATCH. Case-insensitive normalization applied. Reject if null, empty, or unrecognized value. This is the claim being tested, not the ground truth.

[SEMVER_RULESET]

The semantic versioning rule definitions the model must apply when evaluating the change

semver.org 2.0.0 rules or internal policy document with breaking-change definitions

Must contain explicit definitions for breaking, additive, and fix-level changes. Reject if rules are contradictory or missing MAJOR/MINOR/PATCH criteria. Provide default semver.org ruleset if null.

[CHANGE_CONTEXT]

Optional metadata about the release: intended audience, migration notes, deprecation windows, or known client impact

Deprecating /v1/users limit parameter; clients should migrate to pagination by Q3

Null allowed. If provided, must not contradict spec diffs. Used to resolve ambiguous cases (e.g., intentional breaking change with migration path). Flag if context describes changes not visible in spec diff.

[OUTPUT_FORMAT]

The expected structure for the versioning verdict: verdict, rule citations, change classification, and confidence

JSON object with fields: verdict, confidence, breaking_changes, additive_changes, fix_changes, rule_citations, recommendation

Must be a valid output schema definition. Default to structured JSON if null. Reject if schema requires fields the prompt cannot produce from available inputs.

[CONFIDENCE_THRESHOLD]

Minimum confidence score (0.0-1.0) required for an automated verdict; below this threshold, escalate for human review

0.85

Must be a float between 0.0 and 1.0. Default to 0.80 if null. Used to gate automated decisions: verdicts below threshold trigger human-review escalation path rather than automatic enforcement.

[ESCALATION_POLICY]

Instructions for what happens when the verdict is LOW confidence, CONFLICT, or requires human judgment

Route to API governance Slack channel with verdict summary and diff link

Null allowed (defaults to flag-only behavior). If provided, must specify a concrete action: notification target, ticket creation, or blocking behavior. Reject if policy describes impossible or circular escalation paths.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Semantic Versioning Rule Enforcement Prompt into a CI pipeline or release workflow with validation, retries, and human review gates.

The Semantic Versioning Rule Enforcement Prompt is designed to run as a gate in your release pipeline, not as a one-off chat interaction. The prompt expects a structured diff between two API specification versions (OpenAPI, AsyncAPI, gRPC proto, or JSON Schema) and a claimed version bump. It returns a verdict (APPROVED, REJECTED, or NEEDS_REVIEW) with rule citations. The harness around the prompt is what makes this reliable enough to block a release.

Wire the prompt into your CI system (GitHub Actions, GitLab CI, Jenkins) as a required check on release branches or tags. The input assembly step must produce a machine-readable diff of the spec change. For OpenAPI, use oasdiff or a custom JSON diff that captures added, removed, and changed paths, parameters, schemas, and enum values. Pass the diff and the claimed version bump as [SPEC_DIFF] and [VERSION_BUMP] placeholders. The model should return a JSON object with verdict, rule_violations, and confidence fields. Validate this output with a JSON schema before acting on it—if the model returns malformed JSON, retry once with a repair prompt. If the verdict is REJECTED with high confidence, fail the CI check and block the release. If NEEDS_REVIEW, create a ticket in your review queue with the full model output attached.

Model choice matters here. Use a model with strong structured output support (GPT-4o, Claude 3.5 Sonnet, or equivalent) and set response_format to json_object with a strict schema. Temperature should be low (0.0–0.1) to maximize consistency on rule application. Implement a retry layer: if the output fails JSON schema validation, retry with the validation error message appended to the prompt as [PREVIOUS_ERROR]. After two failed retries, escalate to human review. Log every invocation—input diff hash, model, version bump, verdict, rule violations, confidence, and latency—so you can audit decisions and tune the prompt over time. For high-risk APIs (payments, auth, healthcare), always require a human to approve NEEDS_REVIEW verdicts before the release proceeds.

Build a regression test suite before you trust this in CI. Collect 20–30 known spec changes with ground-truth versioning verdicts: breaking changes that should be MAJOR, additive changes that should be MINOR, and fixes that should be PATCH. Include tricky cases like enum value additions (usually MINOR), field renames (MAJOR), and type narrowing (MAJOR). Run the prompt against this golden set on every prompt change and flag any verdict that differs from the ground truth. This eval suite is your safety net when you adjust the prompt's rule language or add new examples. Store the eval results alongside your prompt version so you can track regressions over time.

Avoid running this prompt on every commit—it's designed for release-branch or tag-triggered workflows where a version decision is actually being made. Running it on every PR would generate noise and burn tokens on changes that may not ship. If your team practices continuous delivery with frequent minor releases, consider running the prompt only when the version number changes in your manifest. Finally, never let the model write the version number directly into your package manifest or git tag. The prompt advises; your release script applies the version. This separation ensures that even a hallucinated version recommendation cannot corrupt your release artifacts.

IMPLEMENTATION TABLE

Expected Output Contract

Fields, types, and validation rules for the JSON response returned by the Semantic Versioning Rule Enforcement Prompt. Use this contract to build a parser, validator, or retry handler in your release pipeline.

Field or ElementType or FormatRequiredValidation Rule

verdict

string enum: MAJOR | MINOR | PATCH | NO_CHANGE | INCONCLUSIVE

Must match one of the five enum values exactly. Reject any other string.

confidence

number (0.0–1.0)

Must be a float between 0 and 1 inclusive. If confidence < 0.7, verdict must be INCONCLUSIVE.

breaking_changes

array of objects

Each object must contain 'location' (string), 'rule' (string), and 'severity' (string enum: BREAKING | WARNING). Array may be empty.

additive_changes

array of strings

Each string must describe one additive change. Array may be empty. No BREAKING severity allowed here.

fix_changes

array of strings

Each string must describe one backward-compatible fix. Array may be empty. No BREAKING or additive items allowed here.

rule_citations

array of objects

Each object must contain 'rule_id' (string matching semver spec section, e.g., 'semver-2.0.0-8') and 'applies' (boolean). At least one citation required when verdict is not NO_CHANGE.

rationale_summary

string (max 500 chars)

Must be present and non-empty. Summarizes why the verdict was reached. If verdict is INCONCLUSIVE, must state what additional information is needed.

requires_human_review

boolean

Must be true if confidence < 0.9 or verdict is INCONCLUSIVE or any breaking_change has severity BREAKING. Used to gate automated version bumps.

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when enforcing semantic versioning rules with an LLM and how to guard against it.

01

False Positive: Over-Scoring Additive Changes

What to watch: The model flags a new optional field or endpoint as a MAJOR breaking change. This happens when the prompt lacks explicit definitions of backward-compatible additions. Guardrail: Include a strict rule table defining MAJOR (removal, type narrowing, new required), MINOR (new optional field, new endpoint), and PATCH (internal fix, doc update). Use few-shot examples of additive changes scored as MINOR.

02

False Negative: Missing Enum Value Removal

What to watch: The model classifies the removal of an enum value as a PATCH or MINOR change, missing the client-breaking impact on switch statements and deserialization. Guardrail: Add a dedicated rule for enum handling: any removal of a supported enum member is MAJOR. Include a test case in your eval harness specifically for enum value removal across OpenAPI and GraphQL schemas.

03

Context Window Truncation on Large Spec Diffs

What to watch: Large API specs with hundreds of changes exceed the context window, causing the model to miss breaking changes in the truncated portion or hallucinate a verdict from partial data. Guardrail: Pre-process the diff to extract only material changes (paths, schemas, parameters) and chunk by endpoint. Run the prompt per-endpoint and aggregate results with a script, never rely on a single pass over a full multi-thousand-line spec.

04

Inconsistent Rule Application Across Runs

What to watch: The same change receives a MAJOR verdict in one run and MINOR in another due to temperature, phrasing, or model non-determinism. This erodes trust in automated CI gates. Guardrail: Set temperature to 0. Run the prompt three times and require unanimous verdicts for automated blocking. If verdicts diverge, escalate to a human reviewer with the conflicting outputs and the diff evidence.

05

Ignoring Deprecation Window Policy

What to watch: The model correctly identifies a breaking change but fails to check whether the team's deprecation policy (e.g., one minor version before removal) has been satisfied, leading to premature MAJOR bumps or policy violations. Guardrail: Supply the deprecation policy as a structured input. Require the prompt to output a deprecation_compliance field that checks for prior deprecation notices before recommending a MAJOR version.

06

Hallucinated Rule Citations

What to watch: The model invents a semver rule (e.g., "changing a description is a PATCH") that sounds plausible but isn't in the provided spec or the official semver standard, leading to incorrect verdicts. Guardrail: Constrain the output schema to require a rule_source field that must cite either the official semver spec section or your internal policy document. Add a post-generation validation step that rejects any citation not found in the provided source text.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test the Semantic Versioning Rule Enforcement Prompt before shipping. Each criterion targets a known failure mode for versioning verdicts. Run these checks against a golden dataset of spec diffs with known correct version bumps.

CriterionPass StandardFailure SignalTest Method

Breaking change classification

All MAJOR-triggering changes (removed endpoint, removed enum value, new required field, type narrowing) are correctly classified as breaking

A breaking change is classified as MINOR or PATCH; verdict recommends wrong version increment

Run against a test set of 10 known breaking diffs. Assert 100% MAJOR classification recall.

Additive change classification

All MINOR-triggering changes (new optional field, new endpoint, new enum value, additive schema extension) are classified as non-breaking and additive

An additive change is classified as MAJOR (false positive) or PATCH (under-classification)

Run against a test set of 10 known additive diffs. Assert 0% MAJOR classification and >=90% MINOR classification.

Patch-only change classification

All PATCH-triggering changes (description updates, example changes, bug-fix logic with no contract change, documentation-only) are classified as PATCH

A non-contract change is classified as MINOR or MAJOR; version inflation

Run against a test set of 10 known patch-only diffs. Assert >=90% PATCH classification.

Rule citation accuracy

Every verdict includes at least one specific rule citation (e.g., 'per semver spec item 8: new required field is breaking')

Verdict lacks rule citation, cites a non-existent rule, or cites a rule that does not match the change type

Parse output for citation field. Validate each citation against a known rule list. Assert citation present and rule ID valid.

Multi-change diff handling

When a diff contains both breaking and additive changes, the verdict correctly recommends MAJOR (highest severity wins)

Verdict recommends MINOR or PATCH when a breaking change is present in the same diff

Run against 5 mixed diffs containing at least one breaking change each. Assert 100% MAJOR verdict.

Enum change nuance

Enum value removal is classified as MAJOR; enum value addition is classified as MINOR; enum reordering with no add/remove is classified as PATCH or no-change

Enum addition flagged as breaking; enum removal missed or classified as MINOR

Run against a test set of enum-only diffs: 3 additions, 3 removals, 2 reorderings. Assert correct classification per case.

Nullability change detection

Field changing from non-nullable to nullable is classified as MINOR (relaxing constraint); nullable to non-nullable is classified as MAJOR (tightening constraint)

Nullability relaxation flagged as breaking; nullability tightening missed

Run against 4 nullability change diffs: 2 relaxations, 2 tightenings. Assert correct severity per case.

Output schema compliance

Output matches [OUTPUT_SCHEMA]: valid JSON with verdict, severity, rule_citations, and change_summary fields all present and correctly typed

Missing required field, wrong type (e.g., severity as string instead of enum), or malformed JSON

Parse output with schema validator. Assert all required fields present, types match schema, and severity is one of MAJOR|MINOR|PATCH|NO_CHANGE.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Add strict JSON output schema, retry logic on validation failure, and eval cases covering known breaking/additive/patch scenarios. Wire the prompt into a CI step that blocks non-compliant version bumps.

code
You are a semantic versioning enforcement engine. Given an API spec diff, output a JSON verdict.

[SPEC_DIFF]

Output schema:
{
  "recommended_bump": "MAJOR|MINOR|PATCH|NONE",
  "breaking_changes": [...],
  "additive_changes": [...],
  "patch_changes": [...],
  "rule_citations": [...],
  "confidence": 0.0-1.0
}

Rules reference: semver.org spec items 8-11.

Watch for

  • Silent format drift when the model omits optional fields
  • Missing human review gate for MAJOR bump recommendations
  • Confidence scores that don't correlate with actual ambiguity in the diff
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.