Skip to main content

promptdiff

Semantic diff for LLM prompt changes. Part of the prompttools suite.

Unlike generic text diffing, promptdiff understands prompt structure: messages, variables, metadata, and token counts. It classifies changes as breaking or non-breaking and outputs structured reports suitable for CI/CD pipelines and GitHub PR comments.

Installation

pip install promptdiff-ai

Quick Start

# Compare two prompt files
promptdiff old_prompt.yaml new_prompt.yaml

# JSON output for CI pipelines
promptdiff old.yaml new.yaml --format json

# Markdown output for GitHub PR comments
promptdiff old.yaml new.yaml --format markdown

# Exit with code 1 if breaking changes are found (CI gate)
promptdiff old.yaml new.yaml --exit-on-breaking

# Show per-message token breakdowns
promptdiff old.yaml new.yaml --token-detail

What It Detects

Message-Level Changes

  • Added, removed, or modified messages
  • Per-message token deltas
  • Unified content diffs within modified messages

Variable Changes

  • New variables (with or without defaults)
  • Removed variables
  • Modified default values

Metadata Changes

  • Model changes
  • Added/removed/modified metadata keys

Token Deltas

  • Total token count comparison
  • Percentage change
  • Per-message breakdowns (with --token-detail)

Breaking Change Classification

Breaking (High Severity)

  • New required variable -- a variable added without a default value; existing callers will fail
  • Removed variable -- callers referencing this variable will break
  • Removed message -- changes the prompt structure

Breaking (Medium Severity)

  • Model change -- may affect behavior, pricing, and capabilities
  • Role ordering change -- may affect model behavior

Non-Breaking

  • Added variable with a default value
  • Added messages (extends the prompt)
  • Content modifications within existing messages
  • Metadata changes (except model)

Output Formats

Text (default)

Rich terminal output with color-coded diffs:

Prompt Diff: new_prompt.yaml
  old: a1b2c3d4e5f6  new: f6e5d4c3b2a1

BREAKING CHANGES (2):
  HIGH [variable] Variable 'tone' was removed
  MEDIUM [model] Model changed from 'gpt-4' to 'gpt-4o'

Token Delta:
  150 -> 165 (+15, +10.0%)

Messages (1 changed):
  ~ system
      System message content modified

JSON

Structured JSON for programmatic consumption:

promptdiff old.yaml new.yaml --format json

Markdown

GitHub-flavored Markdown for PR comments:

promptdiff old.yaml new.yaml --format markdown

Python API

from promptdiff import diff_files, format_text, format_json

# Compare two files
result = diff_files("prompts/v1.yaml", "prompts/v2.yaml")

# Check for breaking changes
if result.is_breaking:
    for bc in result.breaking_changes:
        print(f"[{bc.severity}] {bc.description}")

# Get token delta
print(f"Tokens: {result.token_delta.old_total} -> {result.token_delta.new_total}")

# Format output
print(format_text(result))

CLI Reference

Usage: promptdiff [OPTIONS] FILE_A FILE_B

Arguments:
  FILE_A  Path to the old prompt file
  FILE_B  Path to the new prompt file

Options:
  -f, --format [text|json|markdown]  Output format (default: text)
  --exit-on-breaking                 Exit with code 1 if breaking changes found
  --token-detail                     Show per-message token breakdowns
  -e, --encoding TEXT                tiktoken encoding (default: cl100k_base)
  -V, --version                      Show version and exit
  --help                             Show this message and exit

Supported File Formats

All formats supported by prompttools-core:

  • YAML (.yaml, .yml)
  • JSON (.json)
  • Markdown (.md)
  • Text (.txt)

License

MIT

Metadata

Release files for promptdiff-ai 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for promptdiff-ai 1.0.0
File Size Uploaded Provenance Actions
promptdiff_ai-1.0.0.tar.gz 15.9 kB Without provenance Details for promptdiff_ai-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for promptdiff-ai 1.0.0
File Interpreter ABI Platform Actions
promptdiff_ai-1.0.0-py3-none-any.whl Python 3 none any Details for promptdiff_ai-1.0.0-py3-none-any.whl

Total release size: 28.4 kB

Release files / promptdiff_ai-1.0.0.tar.gz

Download URL promptdiff_ai-1.0.0.tar.gz
Size 15.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2eb7ff2fcc009d43a18ac9c6c325795ef186c006d94dab77fa5062ef5d6d0dcd
BLAKE2b-256 checksum
How to use checksums
fa7f16cb19f09aea69cab2ffd06343582e4a0084f14633b6356eb3825e6baa7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / promptdiff_ai-1.0.0-py3-none-any.whl

Download URL promptdiff_ai-1.0.0-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9cdcb290c19783cfc677a420998863226a5d9237e7e937e47f370782a0681b15
BLAKE2b-256 checksum
How to use checksums
00ca9256e5ee434138ab91f4eb0d704d704bdbab6e4ee198e48a2f0ccd3971d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Security for promptdiff-ai 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page