Skip to main content

Local-first prompt version control for developers

Project description

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 unified diffs via difflib
  • Metadata support: reason, author, tags, env, metrics
  • Label support for release-style pointers to versions
  • 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 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 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))

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.

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

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.1.0.tar.gz (16.9 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.1.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for promptledger-0.1.0.tar.gz
Algorithm Hash digest
SHA256 85b11750fa92140ad74f7ab2dc5c0c1c0de3aa67a849d57d4554b47e5abbbbc6
MD5 f196b19899803b791d43960a03ebb1ef
BLAKE2b-256 171a7205a3824274c995ffddde26d65a930af7b8ef4bde94753c1268f987aed6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: promptledger-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.0 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bd4264366360c05673af9769b62f5a3688e494fe09c04c6252c27c7f29eb4b71
MD5 b01118caaa0f8807d443390f9a64f806
BLAKE2b-256 ac858e31ebb8e46bc896f96f0d467861c35a50b628ad7e8ccfbec674c0ef13f4

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