Skip to main content

Local-first prompt version control for developers

Project description

CI PyPI Python Versions License: MIT

PromptLedger

PromptLedger is a local-first prompt version control system for developers. It keeps a Git-style history of prompt changes in a single SQLite file, with a small CLI, Python API, and a read-only Streamlit viewer.

What it is

  • A local prompt change ledger stored in SQLite
  • Git-style history with multiple diff modes via difflib
  • Metadata support: reason, author, tags, env, metrics
  • Label support for release-style pointers plus label history audit trail
  • CLI and Python API for add/get/list/diff/export workflows
  • Read-only Streamlit UI with timeline, filtering, diff, and side-by-side comparison
  • Newline normalization to avoid CRLF/LF noise

What it is NOT

  • An LLM framework
  • An agent framework
  • A SaaS or hosted service
  • A prompt playground

Why it exists

Prompt iteration is real code work, but most teams track it in scratch files or notebooks. PromptLedger gives you reliable history, diffs, and metadata without standing up a service or changing how you work.

Tested on Windows, macOS, and Linux via CI.

Installation

pip install promptledger
pip install "promptledger[ui]"
  • First command installs core CLI + Python API.
  • Second command installs optional Streamlit UI support.

Quickstart

CLI Quickstart

promptledger init
promptledger add --id onboarding --text "Write a friendly onboarding email." --reason "Initial draft" --tags draft --env dev
promptledger add --id onboarding --file ./prompts/onboarding.txt --reason "Tone shift" --tags draft,marketing --env dev
promptledger list
promptledger list --id onboarding
promptledger show --id onboarding --version 2
promptledger diff --id onboarding --from 1 --to 2
promptledger diff --id onboarding --from prod --to staging
promptledger diff --id onboarding --from 1 --to 2 --mode context
promptledger diff --id onboarding --from 1 --to 2 --mode ndiff
promptledger diff --id onboarding --from 1 --to 2 --mode metadata
promptledger export --format jsonl --out prompt_history.jsonl
promptledger export --format csv --out prompt_history.csv
promptledger search --contains "friendly" --id onboarding --tag draft --env dev
promptledger label set --id onboarding --version 2 --name prod
promptledger label get --id onboarding --name prod
promptledger label list --id onboarding
promptledger label history --id onboarding
promptledger status
promptledger ui

Notes:

  • promptledger list lists all prompt versions across all prompts.
  • promptledger list --id onboarding lists versions of a single prompt.
  • promptledger search exits 0 even with no matches and prints 0 results.
  • promptledger ui launches a read-only Streamlit UI.

Python API Quickstart

from promptledger import PromptLedger

ledger = PromptLedger()
ledger.init()
ledger.add(
    "summary",
    "Summarize the doc in 3 bullets.",
    tags=["draft"],
    env="dev",
    metrics={"accuracy": 0.92},
)
ledger.add(
    "summary",
    "Summarize the doc in 5 bullets.",
    tags=["draft"],
    env="dev",
    metrics={"accuracy": 0.94},
)
latest = ledger.get("summary")
print(latest.version, latest.content)
print(ledger.diff("summary", 1, 2))
print(ledger.diff_labels("summary", "prod", "staging"))

Example Workflow

promptledger init
promptledger add --id demo --text "Hello"
promptledger add --id demo --text "Hello World"
promptledger diff --id demo --from 1 --to 2

Metadata

Each prompt version can store:

  • reason
  • author
  • tags
  • env (dev, staging, prod)
  • metrics (e.g. accuracy, latency, cost)

Labels

Labels are human-readable pointers to specific prompt versions. Use them to track active releases (e.g. prod, staging, latest) without creating new versions. Every label change is recorded in an append-only label history log.

promptledger label set --id onboarding --version 7 --name prod
promptledger label set --id onboarding --version 9 --name staging
promptledger label get --id onboarding --name prod
promptledger label list --id onboarding
promptledger label history --id onboarding --name prod
promptledger status --id onboarding

Newline Normalization

  • Line endings are normalized to LF for hashing and diffs.
  • Content with CRLF vs LF is treated as the same prompt.

Storage

  • Git repo present: <repo_root>/.promptledger/promptledger.db
  • No git repo: <cwd>/.promptledger/promptledger.db
  • Environment override: PROMPTLEDGER_HOME=/custom/path -> /custom/path/promptledger.db
  • Explicit override: PromptLedger(db_path="/abs/path/to.db")

Search

promptledger search --contains "error message"
promptledger search --contains "error message" --id onboarding --author "Ada" --tag draft --env dev

Export Determinism

  • CSV column order is stable.
  • JSONL keys are sorted.
  • Repeated exports of the same data produce identical files.

Review Guide

Use this checklist to review prompt changes like code.

  1. Identify scope
  • promptledger list --id <prompt_id> to see recent versions.
  • promptledger label list --id <prompt_id> to see active releases.
  1. Review the change
  • promptledger diff --id <prompt_id> --from <old> --to <new>
  • Focus on intent, tone, structure, and constraints.
  1. Verify metadata
  • promptledger show --id <prompt_id> --version <new>
  • Confirm reason, author, tags, env, metrics align with the change.
  1. Validate safety
  • Look for accidental secrets or credentials.
  • Ensure sensitive data is not embedded in the prompt text.
  1. Promote with labels
  • promptledger label set --id <prompt_id> --version <new> --name <label>
  • Update prod/staging labels only after review.

Security

Do not store API keys or secrets in prompts. Use --no-secret-warn to suppress the CLI warning.

Development

  • Python >= 3.10
  • Tests with pytest
pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

promptledger-0.2.0.tar.gz (20.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

promptledger-0.2.0-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file promptledger-0.2.0.tar.gz.

File metadata

  • Download URL: promptledger-0.2.0.tar.gz
  • Upload date:
  • Size: 20.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for promptledger-0.2.0.tar.gz
Algorithm Hash digest
SHA256 151a48cc0a4c539a5230ff8779fa3e325233f0c9110c7d39bea65f3bcd069641
MD5 80776ce2a24af8fd08671e3dcc95a0b9
BLAKE2b-256 612628cf6ac5c6c88a7aa7206b6d1a58a82de03d0373e0ed0fd24995a81d6e5a

See more details on using hashes here.

File details

Details for the file promptledger-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: promptledger-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for promptledger-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5ccd77862cc31254ff72e1d17835ab51baf7002af74bb43748c62c1df2a0d618
MD5 9a621f4883a56ed5f61666ce4ffed14a
BLAKE2b-256 b63c25d0a9f7788a1a77e05d1c8ae29530fd07eff713f76f1051b02a20f2bd8f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page