Git-native prompt management library for LLM applications
Project description
prompt-vcs
Git-native prompt management library for LLM applications
A lightweight, code-first Python library for managing LLM prompts using Git and the file system — no external database required.
✨ Features
- 🚀 Zero Configuration - Define prompts directly in code, no extra setup needed
- 📦 Git Native - Version control through file system and Git
- 🔄 Lockfile Mechanism - Lock specific versions for production, use code strings in development
- 🛠️ Auto Migration - One-click conversion of hardcoded prompts to managed format
- 🎯 Type Safe - Full type hints support
📦 Installation
pip install prompt-vcs
🚀 Quick Start
1. Initialize Project
pvcs init
2. Inline Mode
from prompt_vcs import p
# Uses code string by default, switches to locked version when specified
msg = p("user_greeting", "Hello {name}", name="Developer")
3. Decorator Mode
from prompt_vcs import prompt
@prompt(id="system_core", default_version="v1")
def get_system_prompt(role: str):
"""
You are a helpful assistant playing the role of {role}.
"""
pass
4. Extract Prompts to YAML
pvcs scaffold src/
5. Switch Versions
pvcs switch user_greeting v2
6. Auto-Migrate Existing Code
Automatically convert hardcoded prompt strings to p() calls:
# Preview changes
pvcs migrate src/ --dry-run
# Interactive migration (confirm each change)
pvcs migrate src/
# Apply all changes automatically
pvcs migrate src/ --yes
# Clean mode: extract prompts to YAML and remove from code
pvcs migrate src/ --clean -y
Supported Conversions:
# Before
prompt = f"Hello {user.name}, price: {price:.2f}"
# After (default mode)
from prompt_vcs import p
prompt = p("demo_prompt", "Hello {user_name}, price: {price:.2f}",
user_name=user.name, price=price)
# After (--clean mode)
from prompt_vcs import p
prompt = p("demo_prompt", user_name=user.name, price=price)
# + creates prompts/demo_prompt/v1.yaml with the template
Features:
- ✅ F-string variable extraction
- ✅ Format spec preservation (
:.2f) - ✅ Attribute/dict access sanitization (
user.name→user_name) - ✅ Automatic import statement insertion
- ✅ Smart skipping of short strings and complex expressions
- ✅ Clean mode: Extract to YAML, keep only ID in code
📁 Project Structure
your-project/
├── .prompt_lock.json # Version lock file
├── prompts/ # Prompt YAML files
│ ├── user_greeting/
│ │ ├── v1.yaml
│ │ └── v2.yaml
│ └── system_core/
│ └── v1.yaml
└── src/
└── your_code.py
🎯 Core Principles
- No Database - File system is the database
- Git Native - Version control relies on file naming conventions and Git commits
- Code First - Developers define prompts in code first
- Zero Latency Dev - Development mode uses code strings, production reads from Lockfile
📖 CLI Commands
| Command | Description |
|---|---|
pvcs init |
Initialize project (create lockfile and prompts directory) |
pvcs scaffold <dir> |
Scan code and generate YAML files |
pvcs switch <id> <version> |
Switch prompt version |
pvcs status |
View current lock status |
pvcs migrate <path> |
Auto-migrate hardcoded prompts |
pvcs migrate <path> --clean |
Migrate and extract prompts to YAML files |
🤝 Contributing
Issues and Pull Requests are welcome!
📄 License
MIT License - See LICENSE file for details
👤 Author
emerard - @Dreamer431
Project details
Release history Release notifications | RSS feed
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 prompt_vcs-0.1.1.tar.gz.
File metadata
- Download URL: prompt_vcs-0.1.1.tar.gz
- Upload date:
- Size: 26.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9fca77aec46e3e4febec2e4a81267539d49cfc8e92d769ad6ec8f6dcc34056f9
|
|
| MD5 |
0294270d9534a2d1608eff92d4d6cc2e
|
|
| BLAKE2b-256 |
3de3bb047ff5d041010b66ebd8a38ad0673971112b4fff68d0c460523b7ba4af
|
File details
Details for the file prompt_vcs-0.1.1-py3-none-any.whl.
File metadata
- Download URL: prompt_vcs-0.1.1-py3-none-any.whl
- Upload date:
- Size: 22.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c48635da15d3836d4fd9bc2f6c02ab08c2d1a2acbb582d9a9d7359338e9fa5fb
|
|
| MD5 |
5c9b5591259d2d8233580ebe6a53da48
|
|
| BLAKE2b-256 |
bcdef17f261cb2287e7df2b2c9d56daaa1d3aa13bf709e2e570b0ee31d2c10b7
|