CLI + library for managing versioned prompts
Project description
promptorium
CLI and Python library for managing versioned prompts: add, update, list, diff, load, and delete prompt versions on your filesystem.
Table of Contents
- About the Project
- Getting Started
- Usage (CLI)
- Usage (Library)
- Data Layout & Conventions
- Development
- Roadmap
- Contributing
- License
- Acknowledgments
About the Project
promptorium-python helps you keep your prompts versioned alongside your code. It stores each prompt as an incrementing Markdown file and gives you a clean CLI to add, edit, list, diff, load, and delete versions. You can use a repo-local .prompts folder or map each key to a custom directory you control.
Features
- Versioned prompt storage with simple, readable files
- Default-managed:
.prompts/<key>/<n>.md - Custom-managed:
<custom_dir>/<key>-<n>.md
- Default-managed:
- Human-friendly keys (e.g.,
battery-horse-staple) with validation - Update via file, STDIN, or your
$EDITOR(VISUAL/EDITORrespected) - Inline diffs with colorized output (word or character granularity)
- Safe, atomic writes to avoid partial files
- Repository-root detection (works anywhere inside your project tree)
How it works
- Storage is provided by a filesystem backend that keeps a small metadata file at
.prompts/_meta.jsonmapping keys to custom directories. - Default-managed keys live under
.prompts/<key>/<n>.mdand are removed entirely on--alldeletion. - Custom-managed keys write as
<custom_dir>/<key>-<n>.md; deleting--allversions preserves the directory and removes only the metadata mapping.
Getting Started
Prerequisites
- Python 3.12+
- Optional:
uvfor fast environments and installs
Installation
Using pip (from source):
python -m venv .venv && source .venv/bin/activate
pip install -e .[dev]
Using uv:
uv venv --python 3.12
uv sync --extra dev
uv run pre-commit install
Verify the CLI is available:
prompts --help
Usage (CLI)
Common workflows:
# 1) Add a new prompt. Omit --key to auto-generate a human-readable key.
prompts add --key onboarding --dir prompts/system
# 2) Create versions
prompts update onboarding --file docs/onboarding_v1.md # from file
echo "hello world" | prompts update onboarding # from STDIN
prompts update onboarding --edit # open $EDITOR
# 3) Inspect and read
prompts list
prompts load onboarding --version 2
# 4) Compare versions
prompts diff onboarding 1 2 --granularity word # or: --granularity char
# 5) Delete
prompts delete onboarding # removes latest version only
prompts delete onboarding --all # removes all versions
Notes:
- Keys must match
^[a-z0-9]+(?:-[a-z0-9]+)*$(lowercase slug with hyphens). updateflags--fileand--editare mutually exclusive; using both exits with code 64.- Errors like missing keys or versions exit with code 1 and a helpful message.
$VISUAL/$EDITORis respected for--edit(defaults tonanoon Unix,notepadon Windows).
Usage (Library)
Common use case: Load a prompt in your codebase
from openai import OpenAI
from promptorium import load_prompt
client = OpenAI()
onboarding_instructions = load_prompt("onboarding-instructions")
response = client.responses.create(
model="gpt-5",
input=onboarding_instructions
)
print(response.output_text)
Advanced use case: Manage prompts via code instead of CLI
from promptorium.services import PromptService
from promptorium.storage.fs import FileSystemPromptStorage
from promptorium.util.repo_root import find_repo_root
storage = FileSystemPromptStorage(find_repo_root())
svc = PromptService(storage)
# Ensure a key exists (create with custom directory or default .prompts)
ref = storage.add_prompt("onboarding", custom_dir=None)
# Write versions
v1 = svc.update_prompt("onboarding", "hello")
v2 = svc.update_prompt("onboarding", "hello world")
# Read latest or specific version
latest_text = svc.load_prompt("onboarding")
v1_text = svc.load_prompt("onboarding", version=1)
# Build an inline diff result (rendered by CLI with rich colors)
res = svc.diff_versions("onboarding", 1, 2, granularity="word")
Data Layout & Conventions
- Default-managed keys live at:
.prompts/<key>/<n>.md(e.g.,.prompts/onboarding/1.md). - Custom-managed keys live at:
<custom_dir>/<key>-<n>.md(e.g.,prompts/system/onboarding-1.md). - Metadata file:
.prompts/_meta.jsonwith schema1containing{ "custom_dirs": { "<key>": "<dir>" } }. - Deletion semantics:
prompts delete <key>removes only the latest version.prompts delete <key> --allremoves all versions and:- For default-managed keys, attempts to remove the now-empty directory.
- For custom-managed keys, preserves the directory and removes the metadata entry.
Development
Run tests:
pytest -q
Project configuration highlights:
Roadmap
- Additional storage backends (e.g., Git-backed, SQLite)
- Interactive prompt improvement
Contributing
Contributions are welcome!
- Fork the repo
- Create a feature branch (
git checkout -b feat/your-feature) - Install dev deps and run tests
- Submit a PR with a clear description and rationale
License
Distributed under the MIT License. See LICENSE for details.
Acknowledgments
- README structure inspired by the excellent Best-README-Template by Othneil Drew (link).
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file promptorium_python-0.1.1.tar.gz.
File metadata
- Download URL: promptorium_python-0.1.1.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f08b162e1a75b18adfbeff9a10576d9235b09eb6ca44067ea076e109e61d0139
|
|
| MD5 |
29587ab0e9cdb1e3083ee5b1f62ab160
|
|
| BLAKE2b-256 |
836e5cef4b62000c93dca2230cab4bb6bf619fd7cfeaf37cc0e22c2d73692c47
|
File details
Details for the file promptorium_python-0.1.1-py3-none-any.whl.
File metadata
- Download URL: promptorium_python-0.1.1-py3-none-any.whl
- Upload date:
- Size: 17.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7baaa3626b39a31c09779cdf14a89b479050560783bd1133d92d07233b5fc57e
|
|
| MD5 |
78fa4d85f5f5fd01ad2c08b6c56adb4f
|
|
| BLAKE2b-256 |
7e796b6de874895852f0fd9fc6007442bcd65ee575a21cec93d7da04def0fbbc
|