Inferensys

Prompt

API Changelog Generation Prompt from Diffs

A practical prompt playbook for using API Changelog Generation Prompt from Diffs 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 API Changelog Generation Prompt from Diffs.

This prompt is designed for developer relations engineers and API platform teams who need to convert raw OpenAPI or JSON Schema diffs into structured, human-readable changelogs. The core job-to-be-done is transforming a machine-readable specification delta into a versioned release document that developers can use to understand what changed, whether their integration will break, and exactly what code they need to modify. The ideal user has access to a diff between two API specification versions and needs to produce release notes organized by impact category—breaking, deprecated, added, fixed, and security—with migration guidance attached to each breaking or deprecated change.

Use this prompt when you have a concrete spec diff as input and need a consistent, categorized changelog that follows semantic versioning expectations. It is appropriate for CI/CD pipelines that generate release notes automatically on spec changes, for developer portal updates where changelogs must be accurate and complete, and for internal API governance workflows where platform teams need to communicate changes to consuming service teams. The prompt assumes the input diff is accurate and complete; it does not validate the diff itself or detect missing changes. It also assumes you have a target version number and release date to anchor the changelog. Do not use this prompt when the diff is incomplete, when you need to explain the business rationale behind changes, or when you are generating marketing-facing release announcements that require a different tone and level of technical detail.

This prompt is not a replacement for API review judgment. It classifies and describes changes but does not assess whether a breaking change was intentional, whether a deprecation window is sufficient, or whether migration guidance is safe. Always pair the generated changelog with human review for breaking changes, especially those affecting authentication, authorization, data integrity, or payment flows. The prompt also does not generate SDK migration code or update client libraries—it produces documentation that points developers toward the changes they need to make. For teams with multiple API surfaces, run this prompt per spec to keep changelogs scoped and avoid cross-contamination between unrelated services.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works, where it fails, and what you must provide before running it in a production changelog pipeline.

01

Good Fit: Structured Diff Input

Use when: you have a machine-readable diff between two OpenAPI, GraphQL, or JSON Schema versions. The prompt excels at categorizing changes when the input is a structured spec diff, not a freeform commit log. Guardrail: validate that your diff tool outputs a deterministic, parseable format before piping it into the prompt.

02

Bad Fit: Unstructured Commit Messages

Avoid when: the only input is git log output, Slack threads, or engineer notes. The prompt relies on structural change evidence to categorize breaking vs. additive changes. Guardrail: run a spec-diff tool first; if only unstructured input exists, use a separate summarization prompt before this one.

03

Required Inputs

Must provide: the previous API spec version, the new API spec version, and a structured diff between them. Optional but recommended: consumer impact data, deprecation policy rules, and target audience persona. Guardrail: if any required input is missing, the prompt should refuse generation rather than hallucinate change descriptions.

04

Operational Risk: Miscategorization

What to watch: the prompt may classify a non-breaking additive field as breaking, or miss a breaking enum removal. Miscategorization erodes developer trust in your changelog. Guardrail: run eval tests with known breaking and non-breaking changes before publishing; implement a human review step for any change flagged as BREAKING.

05

Operational Risk: Incomplete Migration Guidance

What to watch: the prompt may list a breaking change without actionable migration steps, leaving API consumers blocked. Guardrail: add a post-generation validation check that every BREAKING entry has a non-empty migration guidance field; if missing, route to a developer relations engineer for manual completion.

06

Scale Limit: Large Spec Diffs

What to watch: diffs spanning hundreds of endpoints may exceed context windows or cause the model to skip low-severity changes. Guardrail: split large diffs by endpoint group or change type; run the prompt per batch and merge results with a deduplication pass.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template with square-bracket placeholders that converts API spec diffs into structured, human-readable changelogs.

The following prompt template is designed to be dropped into your changelog generation pipeline. It expects a structured diff input, a target audience context, and an output schema that your documentation system can consume. Every placeholder is marked with square brackets and must be populated by your application before the prompt is sent to the model. Do not modify the core instruction structure unless you also update the corresponding eval assertions and validation logic.

text
You are an API changelog generator for developer relations. Your task is to convert a structured API specification diff into a versioned, human-readable changelog organized by impact category.

## INPUT
[DIFF_INPUT]

## CONTEXT
- API Name: [API_NAME]
- Previous Version: [PREVIOUS_VERSION]
- New Version: [NEW_VERSION]
- Release Date: [RELEASE_DATE]
- Target Audience: [TARGET_AUDIENCE] (e.g., external developers, internal service teams, SDK maintainers)

## OUTPUT SCHEMA
Return a JSON object with the following structure:
{
  "changelog": {
    "api_name": "string",
    "previous_version": "string",
    "new_version": "string",
    "release_date": "string",
    "summary": "string (1-3 sentence plain-English summary of this release)",
    "categories": [
      {
        "impact": "breaking|deprecated|added|fixed|changed|security",
        "changes": [
          {
            "endpoint": "string (affected endpoint path or resource name)",
            "description": "string (what changed, in plain language)",
            "before": "string or null (previous behavior or payload snippet)",
            "after": "string or null (new behavior or payload snippet)",
            "migration_guidance": "string or null (actionable steps for affected consumers)",
            "affected_clients": ["string"] (list of client types or SDKs affected, empty array if unknown)
          }
        ]
      }
    ]
  }
}

## CONSTRAINTS
- Only include changes present in [DIFF_INPUT]. Do not invent or assume changes not listed.
- Classify each change into exactly one impact category. Use "breaking" for changes that will cause existing client code to fail without modification. Use "deprecated" for features still functional but scheduled for removal. Use "added" for net-new functionality. Use "fixed" for bug fixes. Use "changed" for non-breaking modifications. Use "security" for vulnerability fixes or security-related changes.
- If a change affects multiple endpoints, list it once per affected endpoint.
- Migration guidance must be specific and actionable. Do not write generic advice like "update your code."
- If the diff contains no changes in a category, omit that category from the output.
- If [DIFF_INPUT] is empty or unparseable, return {"error": "No parseable diff provided."}

## EXAMPLES
[FEW_SHOT_EXAMPLES]

## RISK LEVEL
[RISK_LEVEL] (one of: low, medium, high, critical)
- If RISK_LEVEL is "high" or "critical", flag any breaking change with an additional "urgent_action_required": true field and include a recommended communication channel (e.g., email, status page, direct outreach).

After copying this template, replace each placeholder with data from your pipeline. [DIFF_INPUT] should be a structured diff format your model understands—OpenAPI JSON diff, a unified text diff with context, or a pre-parsed change list. [FEW_SHOT_EXAMPLES] should contain 2-4 example input-output pairs that demonstrate correct categorization, especially for ambiguous cases like field additions that are additive versus field additions that are breaking due to strict client validation. [RISK_LEVEL] should be set by your CI/CD system based on the number of breaking changes detected or the blast radius of affected endpoints. Before deploying, run this prompt against a golden dataset of known diffs and verify that categorization accuracy exceeds your threshold, that no changes are dropped, and that migration guidance is non-empty for every breaking and deprecated change.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the API Changelog Generation Prompt. Each placeholder must be populated before the prompt is assembled and sent to the model. Missing or malformed inputs are the most common cause of miscategorized changes and incomplete migration guidance.

PlaceholderPurposeExampleValidation Notes

[SPEC_DIFF]

The raw diff output between two API specification versions (OpenAPI, AsyncAPI, gRPC proto, or GraphQL schema)

diff --git a/openapi-v2.yaml b/openapi-v3.yaml ...

Must be non-empty text. Validate that diff contains at least one change hunk. Reject if only whitespace or comment changes are present.

[SPEC_FORMAT]

Identifier for the specification format so the model applies correct change-detection rules

openapi-3.1

Must match one of: openapi-3.0, openapi-3.1, asyncapi-2.x, graphql, proto3, json-schema-draft-2020-12. Reject unknown formats before prompt assembly.

[PREVIOUS_VERSION]

Semantic version string of the spec before changes were applied

2.4.1

Must be valid semver (MAJOR.MINOR.PATCH). Used to anchor the changelog header and version comparison. Reject if format does not parse.

[NEW_VERSION]

Semantic version string of the spec after changes were applied

3.0.0

Must be valid semver and must differ from [PREVIOUS_VERSION]. If versions are identical, abort prompt assembly and return an error.

[CHANGE_DATE]

ISO 8601 date when the changes were introduced or the release was cut

2025-06-15

Must parse as a valid ISO 8601 date (YYYY-MM-DD). Used in changelog header. Reject if date is in the future by more than 7 days.

[KNOWN_CONSUMERS]

List of client applications, services, or SDKs known to consume the affected API endpoints

["mobile-app-v3", "partner-portal", "ios-sdk-2.x"]

Must be a JSON array of strings. Empty array is allowed but triggers a warning. Each entry should match a registered consumer ID if a consumer registry exists.

[MIGRATION_NOTES_TEMPLATE]

Optional template for per-change migration guidance sections. If null, the prompt uses a default structure.

null

If provided, must be a valid string with optional [ENDPOINT] and [IMPACT] placeholder tokens. If null, the default template is used. Validate template token syntax before injection.

[OUTPUT_FORMAT]

Desired output structure for the generated changelog

markdown

Must be one of: markdown, json, yaml. Markdown is the default for developer portal publishing. JSON is preferred for programmatic consumption or CI integration.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the API changelog generation prompt into a CI pipeline or developer workflow with validation, retries, and human review gates.

The API Changelog Generation Prompt from Diffs is designed to run as a post-diff step in a CI pipeline or as a developer CLI tool invoked after spec changes are committed. The primary input is a structured diff between two OpenAPI, GraphQL, or gRPC specification versions. The harness must preprocess raw git diff output into a format the model can reason over—typically a side-by-side summary of added, removed, and modified paths, operations, parameters, schemas, and enum values. Do not pass raw unified diffs directly; the model performs better when the diff is pre-parsed into a change inventory with explicit before/after values for each affected element.

Wire the prompt into an application by building a thin orchestration layer that: (1) parses the spec diff into a structured change list using a spec-aware tool like openapi-diff, graphql-inspector, or a custom buf breaking wrapper; (2) injects the change list into the [DIFF_INVENTORY] placeholder along with the [SPEC_TYPE], [VERSION_OLD], [VERSION_NEW], and [OUTPUT_FORMAT] variables; (3) calls the model with response_format set to json_object and a JSON Schema that enforces the expected changelog structure (arrays of breaking, deprecated, added, fixed, and changed entries, each with title, description, migration_guidance, affected_paths, and severity fields); (4) validates the output against that schema and retries once on validation failure with the error message appended to the prompt; (5) writes the validated changelog to a versioned file and posts it as a PR comment or release note draft. For high-risk API surfaces, add a human approval gate: the harness should create a draft changelog, flag any severity: critical entries, and require a platform team reviewer to approve before the changelog is published to external developer portals.

Model choice matters here. Use a model with strong structured output support and long-context reasoning for large specs—GPT-4o or Claude 3.5 Sonnet work well for OpenAPI specs up to ~5,000 lines. For larger specs, chunk the diff by endpoint group and run the prompt per chunk, then merge results with a deduplication pass. Log every generation with the input diff hash, model version, output validation status, and reviewer decision. This creates an audit trail for changelog accuracy disputes. Avoid running this prompt on every commit; trigger it only on spec file changes in designated paths (e.g., specs/**/*.yaml) and gate on PR merge to main to prevent changelog noise from work-in-progress branches.

IMPLEMENTATION TABLE

Expected Output Contract

Defines the structure, types, and validation rules for the changelog JSON object. Use this contract to parse and validate the model's output before publishing or feeding it into a release pipeline.

Field or ElementType or FormatRequiredValidation Rule

changelog.version

string (semver)

Must match the target release version exactly. Regex: ^\d+.\d+.\d+(-.*)?$

changelog.release_date

string (ISO 8601)

Must be a valid date in YYYY-MM-DD format. Cannot be a future date.

changelog.sections

array of objects

Must contain at least one section. Array must not be empty.

sections[].category

enum string

Must be one of: Breaking, Deprecated, Added, Fixed, Security, Changed. No custom values allowed.

sections[].changes

array of objects

Must contain at least one change object per section. Array must not be empty.

changes[].description

string

Must be non-empty. Must describe the change in user-facing language. Must not contain raw diff syntax or unresolved placeholders.

changes[].migration_guidance

string or null

If present, must be a non-empty string with actionable steps. If null, the change requires no migration action. Required when category is Breaking or Deprecated.

changes[].affected_endpoints

array of strings

If present, each string must match a valid API path pattern (e.g., /v1/users/{id}). Null or empty array allowed for non-endpoint changes.

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when generating API changelogs from diffs, and how to guard against it before the changelog reaches a developer.

01

Missed Breaking Changes

What to watch: The model overlooks a removed enum value, narrowed type, or new required field buried in a large diff. The changelog looks complete but omits a change that will break client builds. Guardrail: Pre-process the diff to extract all schema-level changes (types, enums, required fields) into a structured checklist. Instruct the model to explicitly mark each item as 'covered' or 'not applicable' in its output, and fail validation if any checklist item is unaddressed.

02

Incorrect Severity Classification

What to watch: The model labels a field addition as 'breaking' (false positive) or classifies a type change from string to string | null as 'fixed' when it is actually a behavioral change. Guardrail: Provide explicit definitions for each severity level with examples in the prompt. Add a post-generation validation step that checks for known misclassification patterns (e.g., additive-only changes flagged as breaking) and requests re-classification with reasoning.

03

Hallucinated Migration Examples

What to watch: The model invents before/after code snippets that don't match the actual API surface, suggesting function signatures or endpoint paths that never existed. Guardrail: Constrain the prompt to generate migration guidance as structured steps (what changed, what to do) rather than freeform code examples. If code examples are required, ground them by requiring the model to reference only symbols and paths present in the input diff.

04

Changelog Drift Across Versions

What to watch: When generating changelogs for sequential versions, the model inconsistently formats entries, changes terminology, or drops sections that appeared in prior versions. Guardrail: Include the previous version's changelog as a formatting reference in the prompt. Use a strict output schema with required sections (Breaking, Deprecated, Added, Fixed) and validate that all required sections are present and non-empty when relevant.

05

Diff Context Misinterpretation

What to watch: The model misreads a diff hunk, confusing which lines were added vs removed, or interprets a refactor as a behavioral change when the external contract is unchanged. Guardrail: Use a structured diff format (unified diff with clear headers) and instruct the model to only report changes that affect the external API contract. Add an eval check that compares the generated changelog against a known set of actual contract changes for the diff.

06

Missing Deprecation Timeline

What to watch: The model notes a deprecation but omits the sunset date, migration deadline, or replacement endpoint, leaving consumers without actionable guidance. Guardrail: Require a structured deprecation block in the output schema with fields for deprecated_item, replacement, sunset_date, and migration_deadline. Validate that any detected deprecation has all fields populated or explicitly marked as 'not specified in source'.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to evaluate the quality of generated API changelogs before shipping. Each criterion targets a specific failure mode common in diff-to-changelog generation. Run these checks against a golden set of known diffs with expected changelog entries.

CriterionPass StandardFailure SignalTest Method

Breaking Change Completeness

Every breaking change in the diff appears in the changelog with correct severity

Breaking change present in diff but missing from changelog output

Diff-to-changelog comparison on 10 known breaking diffs; recall must be 1.0

Categorization Accuracy

Each entry is placed in exactly one correct category: breaking, deprecated, added, fixed, or security

Entry appears in wrong category (e.g., field removal under 'added') or in multiple categories

Parse output categories; compare against human-labeled ground truth for 20 mixed-change diffs; F1 >= 0.95

Migration Guidance Presence

Every breaking and deprecated entry includes a concrete migration step with before/after example

Breaking entry lacks migration guidance or contains only generic placeholder text like 'update your code'

Regex check for migration section per breaking entry; manual spot-check 5 entries for actionable specificity

No Hallucinated Changes

Changelog contains zero entries for changes not present in the input diff

Entry describes a field rename, type change, or endpoint removal not found in the diff

Diff against input spec; flag any changelog entry with no corresponding diff hunk; false positive rate must be 0

Version and Date Correctness

Changelog header includes the correct version string and release date from [VERSION] and [RELEASE_DATE] inputs

Version mismatch, missing date, or date format inconsistent with ISO 8601

Schema validation on header fields; exact string match on version; date parse check with regex

Endpoint-Level Granularity

Each entry references the specific affected endpoint path and HTTP method

Entry describes a change at the resource level without specifying the endpoint (e.g., 'changed user object')

Parse each entry for path and method pattern; flag entries missing both; pass if >= 95% of entries have endpoint specificity

Consumer Impact Statement

Each breaking entry includes which client types are affected (SDK, webhook, direct REST, GraphQL)

Breaking entry states the change but omits who is impacted or how they consume the affected endpoint

Keyword check for consumer type mentions per breaking entry; manual review of 5 entries for meaningful impact description

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a single diff input and relaxed output validation. Focus on getting the categorization logic right before adding strict schema enforcement. Test with 3-5 known diffs covering breaking, deprecated, added, and fixed changes.

Prompt modification

  • Remove strict JSON schema constraints; accept markdown or structured text output
  • Simplify [OUTPUT_SCHEMA] to a basic template: ## [VERSION] - [DATE]\n### Breaking\n- [change description]
  • Replace [MIGRATION_GUIDANCE_REQUIRED] with Include migration notes only for breaking changes
  • Set [REQUIRE_COMPLETENESS_CHECK] to false

Watch for

  • Missing changes in the output that were present in the diff
  • Misclassification of additive changes as breaking
  • Overly verbose descriptions that bury the action required
  • Inconsistent formatting between changelog sections
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.