📝 py-prompt-versioner
Stop copy-pasting 500-line f-strings. py-prompt-versioner is a lightweight utility designed for AI engineers who want to treat their prompts like code. Store prompts in Markdown, version them properly, and inject variables with ease.
✨ Features
- Frontmatter Metadata: Store model settings (temperature, model name) directly within the prompt file.
- Jinja2 Templating: Support for complex variable injection, loops, and logic.
- Strict Validation: Powered by Pydantic to ensure your metadata is always correct.
- CLI First: Bootstrap your prompt directory structure in one command.
- Path-Agnostic: Works seamlessly across Windows, Mac, and Linux.
🚀 Installation
Install via pip:
pip install py-prompt-versioner
or using uv for lightning-fast-setup:
uv add py-prompt-versioner
🛠 Quick Start
- Initialize your project Use the CLI to create your prompt directory structure.
# Creates a default /prompts folder
prompt-versioner init
# Or specify a custom path
prompt-versioner init --path ./my_ai_assets
- Create a prompt file Your prompts live in .md files with YAML frontmatter. Example: prompts/sample_task/v1.md
---
version: "v1"
model: "gpt-4o"
temperature: 0.7
---
Act as a professional editor. Summarize the following text: {{ text }}
📖 Usage Guide
Integrate py-prompt-versioner into your Python workflow to load and render prompts dynamically.
from prompt_versioner import PromptManager
# 1. Initialize the manager with your prompts directory
pm = PromptManager(path="./prompts")
# 2. Load and render a specific version with variables
result = pm.get_prompt(
task_name="sample_task",
version="v1",
variables={"text": "The quick brown fox jumps over the lazy dog."}
)
# 3. Use the result
print(f"Using model: {result['metadata'].model}")
print(f"Prompt: {result['content']}")
📂 Project Structure
A typical setup using py-prompt-versioner looks like this:
.
├── prompts/
│ ├── classification/
│ │ ├── v1.md
│ │ └── v2.md
│ └── summarization/
│ └── base.md
├── main.py
└── pyproject.toml
⚙️ How it Works
| Component | Responsibility |
|---|---|
| CLI | Scaffolding and directory management |
| Frontmatter | Parsing metadata (YAML) from Markdown files |
| Pydantic | Validating metadata structure and types |
| Jinja2 | Handling variable injection and logic |
🤝 Contributing
Contributions are welcome! If you have a feature request or found a bug, please open an issue or submit a pull request on GitHub.
- Fork the repo.
- Clone it locally.
- Submit a PR with your changes. Pssss, don't forget to ruff your codes!
🛠 Recommended Naming Convention
| Category | Branch Prefix | Example |
|---|---|---|
| New Features | feature/ |
feature/jinja-filter-support |
| Bug Fixes | fix/ or bugfix/ |
fix/yaml-parsing-error |
| Documentation | docs/ |
docs/update-readme-badges |
| Refactoring | refactor/ |
refactor/pydantic-v2-models |
| Performance | perf/ |
perf/optimize-glob-search |
| Chores / Tools | chore/ |
chore/add-github-actions |
📄 License
Distributed under the MIT License. See LICENSE for more information.# py-prompt-versioner
Metadata
Release files for py-prompt-versioner 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| py_prompt_versioner-1.1.0.tar.gz | 9.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| py_prompt_versioner-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.2 kB
Release files / py_prompt_versioner-1.1.0.tar.gz
| Download URL | py_prompt_versioner-1.1.0.tar.gz |
|---|---|
| Size | 9.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c1e1bc3c4b54ea3742c1bfda77334fab7ac4a6b9d28d98ca6f2bec9821c73d31
|
|
BLAKE2b-256 checksum How to use checksums |
413d5ce2c08881fa44fb236173916bc4bd7e3d3de24f6353e378d527c93e1a55
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 18, 2026.
Transparency logRelease files / py_prompt_versioner-1.1.0-py3-none-any.whl
| Download URL | py_prompt_versioner-1.1.0-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
430d7cb03578f754c879de09f247b324ab49a2851a488e2fe84532968e1f6dfa
|
|
BLAKE2b-256 checksum How to use checksums |
910186109ccc01ab3c73f06d6064aa3e9e7d687ccd36b7e5ceed309ca9880328
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 18, 2026.
Transparency log