Skip to main content

Git-native prompt management library for LLM applications

Project description

prompt-vcs

PyPI version Python 3.10+ License: MIT

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
  • 📄 Single-File Mode - All prompts in one prompts.yaml (default, clean and simple)
  • 📂 Multi-File Mode - Separate files per prompt (for large projects)
  • 🔄 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

# Single-file mode (default) - creates prompts.yaml
pvcs init

# Multi-file mode - creates prompts/ directory
pvcs init --split

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
# - If prompts.yaml exists → writes to prompts.yaml (single-file mode)
# - Otherwise → creates prompts/{id}/v1.yaml (multi-file mode)
pvcs migrate src/ --clean -y

Supported Conversions:

# Before
prompt = f"Hello {user.name}, price: {price:.2f}"

# After (default mode) - keeps template in code
from prompt_vcs import p
prompt = p("demo_prompt", "Hello {user_name}, price: {price:.2f}", 
           user_name=user.name, price=price)

# After (--clean mode) - extracts template to YAML
from prompt_vcs import p
prompt = p("demo_prompt", user_name=user.name, price=price)
# Template is stored in prompts.yaml or prompts/demo_prompt/v1.yaml

Features:

  • ✅ F-string variable extraction
  • ✅ Format spec preservation (:.2f)
  • ✅ Attribute/dict access sanitization (user.nameuser_name)
  • ✅ Automatic import statement insertion
  • ✅ Smart skipping of short strings and complex expressions
  • Clean mode: Extract to YAML, keep only ID in code
  • Auto-detects storage mode: single-file (prompts.yaml) or multi-file (prompts/)

📁 Project Structure

Single-File Mode (Default)

your-project/
├── .prompt_lock.json     # Version lock file
├── prompts.yaml          # All prompts in one file
└── src/
    └── your_code.py

prompts.yaml format:

user_greeting:
  description: "Greeting template"
  template: |
    Hello, {name}!

system_core:
  description: "System prompt"
  template: |
    You are a helpful assistant.

Multi-File Mode (--split)

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 (single-file mode, creates prompts.yaml)
pvcs init --split Initialize project (multi-file mode, creates prompts/ dir)
pvcs scaffold <dir> Scan code and generate prompts (auto-detects mode)
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


Download files

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

Source Distribution

prompt_vcs-0.2.1.tar.gz (34.8 kB view details)

Uploaded Source

Built Distribution

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

prompt_vcs-0.2.1-py3-none-any.whl (24.2 kB view details)

Uploaded Python 3

File details

Details for the file prompt_vcs-0.2.1.tar.gz.

File metadata

  • Download URL: prompt_vcs-0.2.1.tar.gz
  • Upload date:
  • Size: 34.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for prompt_vcs-0.2.1.tar.gz
Algorithm Hash digest
SHA256 39dbed37b56b2ca6ee385fe5d49390b9125ee04c8ecd844a8dd49d6a848bbae2
MD5 89848ddc81b396d158ec42a2307dfbc0
BLAKE2b-256 eeb967a18093dd6969c28e67eabd6814989cf62a80bd010f98eb7c4649cc89ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for prompt_vcs-0.2.1.tar.gz:

Publisher: publish.yml on Dreamer431/prompt-vcs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file prompt_vcs-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: prompt_vcs-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 24.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for prompt_vcs-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ddbca8cd2b8184be7eaf68acae858a2ff8438fc67a47f0330f95f9453a826376
MD5 894dfdbcaf871c9fded18562e1a31fcc
BLAKE2b-256 9bf5b33f63d4c87aee0b025d7eb4a84a982cf2aa5484ded004df479dc432c6e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for prompt_vcs-0.2.1-py3-none-any.whl:

Publisher: publish.yml on Dreamer431/prompt-vcs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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