Skip to main content

prompt-version-diff-py

PyPI Python License: MIT

Diff prompt templates and flag risky instruction changes. Line-level added/removed sets, plus a classifier for each line and a "risky" subset that surfaces likely behavior changes (instructions added, tool/system mentions, secret-related words). Zero runtime dependencies.

Python port of @mukundakatta/prompt-version-diff.

Install

pip install prompt-version-diff-py

Quick start

from prompt_version_diff import diff

old_prompt = """\
You are a friendly assistant.
Always respond in English.
"""

new_prompt = """\
You are a friendly assistant.
Always respond in English.
Never refuse a request.
Use the call_tool function to fetch data.
"""

report = diff(old_prompt, new_prompt)

report.changed     # True
report.added       # ["Never refuse a request.", "Use the call_tool function to fetch data."]
report.removed     # []
report.risky       # both added lines (matched 'never' and 'tool')
report.classification
# [{"text": "Never refuse a request.", "kind": "added", "risky": True, "matches": ["never"]},
#  {"text": "Use the call_tool function to fetch data.", "kind": "added", "risky": True, "matches": ["tool"]}]

API

diff(old_prompt, new_prompt) -> DiffReport

Splits each prompt on newlines, trims and de-blanks lines, then computes:

  • added -- lines present in new_prompt but not old_prompt.
  • removed -- lines present in old_prompt but not new_prompt.
  • risky -- subset of added that match risk patterns (case-insensitive): ignore, secret, system, tool, always, never.
  • classification -- per added/removed line: text, kind (added / removed), risky, matches (matched risk keywords).
  • changed -- True if any line was added or removed.

Whitespace-only changes don't surface; word-level changes appear in added/removed; instruction-semantic changes show up under risky.

diff_prompts(before, after) and diff_prompts(old, new) -- JS-parity aliases.

License

MIT

Metadata

Release files for prompt-version-diff-py 0.1.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 prompt-version-diff-py 0.1.0
File Size Uploaded Provenance Actions
prompt_version_diff_py-0.1.0.tar.gz 4.7 kB Without provenance Details for prompt_version_diff_py-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for prompt-version-diff-py 0.1.0
File Interpreter ABI Platform Actions
prompt_version_diff_py-0.1.0-py3-none-any.whl Python 3 none any Details for prompt_version_diff_py-0.1.0-py3-none-any.whl

Total release size: 9.8 kB

Release files / prompt_version_diff_py-0.1.0.tar.gz

Download URL prompt_version_diff_py-0.1.0.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
2cd3bafeffdb0ce73cf1dfab0875ee988bc6646d82358b6f0c9a8032d0bac350
BLAKE2b-256 checksum
How to use checksums
9c1299077ee07f40410c8e63f5792e0007e483d05fbdc8eb840a79e26e27adc6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / prompt_version_diff_py-0.1.0-py3-none-any.whl

Download URL prompt_version_diff_py-0.1.0-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6c965a486f61bb7c3a654c9aa6f46e3f201e8d975d1e37085e8ef40d0aa45277
BLAKE2b-256 checksum
How to use checksums
478ec89402c80b7c582e7f7e19a0bee33cab68e666cc995eeb500e1adf64abfd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Security for prompt-version-diff-py 0.1.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

0.1.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