YAML-powered prompt manager with multi-backend support
Project description
Prompt Gear
🧠 YAML-powered prompt manager with multi-backend support
Prompt Gear is a flexible prompt management tool that can be embedded into any Python application (LangGraph, LangChain, FastAPI, etc.). It supports multiple storage backends and provides both CLI and Python SDK interfaces.
✨ Features
- ✅ Multi-backend storage: Filesystem (YAML), SQLite, PostgreSQL
- ✅ YAML-based prompt format: Human-readable and version-controllable
- ✅ Advanced version management: Sequence-based versioning with explicit latest tracking
- ✅ Dual interface: CLI tool + Python SDK
- ✅ Flexible configuration: System prompts, user prompts, and custom config
- ✅ Environment-based config: Use
.envfiles for backend configuration - ✅ Robust data integrity: Transaction-based operations with automatic rollback
- ✅ uv + pyproject.toml: Modern Python packaging ready for PyPI
🚀 Quick Start
Installation
pip install prompt-gear
Initialize in your project
# Initialize with filesystem backend (default)
promptgear init --backend filesystem
# Initialize with SQLite backend
promptgear init --backend sqlite
# Initialize with PostgreSQL backend
promptgear init --backend postgres
Create a prompt
promptgear create chatbot_greeting --version v1 \
--system "You are a helpful assistant that speaks politely." \
--user "Hello! How can I help you? {{user_input}}" \
--config '{"temperature": 0.7, "max_tokens": 512}'
Use in Python
from promptgear import PromptManager
pm = PromptManager()
prompt = pm.get_prompt("chatbot_greeting", "v1")
print(prompt.system_prompt)
print(prompt.user_prompt)
print(prompt.config["temperature"])
📁 YAML Format
Prompts are stored in YAML format:
name: chatbot_greeting
version: v1
system_prompt: >
You are a helpful assistant that speaks politely.
user_prompt: >
Hello! How can I help you? {{user_input}}
config:
temperature: 0.7
max_tokens: 512
🔧 Configuration
Configure via .env file:
# Filesystem backend
PROMPT_GEAR_BACKEND=filesystem
PROMPT_GEAR_PROMPT_DIR=./prompts
# SQLite backend
PROMPT_GEAR_BACKEND=sqlite
PROMPT_GEAR_DB_URL=sqlite:///prompts.db
# PostgreSQL backend
PROMPT_GEAR_BACKEND=postgres
PROMPT_GEAR_DB_URL=postgresql://user:pass@localhost/prompts
� Version Management
Prompt Gear uses an advanced sequence-based versioning system:
Version Sequence Numbers
- Each prompt version gets an auto-incrementing sequence number
- Sequence numbers are maintained independently per prompt name
- Deleted versions don't affect sequence numbering (e.g., v1→v2→v4 after deleting v3)
Latest Version Tracking
- Each prompt has exactly one version marked as "latest"
- Creating a new version automatically updates the latest flag
- Deleting the latest version automatically promotes the highest sequence number version
Examples
# Create versions - sequence numbers auto-assigned
v1 = pm.create_prompt("example", "v1", "System v1", "User v1") # seq=1, latest=True
v2 = pm.create_prompt("example", "v2", "System v2", "User v2") # seq=2, latest=True
# v1 is automatically marked as not latest
v1_updated = pm.get_prompt("example", "v1") # seq=1, latest=False
# Get latest version without specifying version
latest = pm.get_prompt("example") # Returns v2
# Delete latest version
pm.delete_prompt("example", "v2")
new_latest = pm.get_prompt("example") # Returns v1 (automatically promoted)
�📚 CLI Commands
promptgear init- Initialize Prompt Gear with backend selectionpromptgear create- Create a new prompt (automatically becomes latest)promptgear get- Get a prompt (latest version if version not specified)promptgear list- List all prompts with their latest versionspromptgear delete- Delete a prompt version (auto-promotes new latest)promptgear versions- List all versions of a promptpromptgear status- Show backend status and statistics
🧩 Python SDK
from promptgear import PromptManager
# Initialize
pm = PromptManager()
# Create prompt (automatically gets sequence number and latest flag)
prompt = pm.create_prompt(
name="my_prompt",
version="v1",
system_prompt="You are helpful.",
user_prompt="{{user_input}}",
config={"temperature": 0.8}
)
# Get latest version (no version specified)
latest = pm.get_prompt("my_prompt")
# Get specific version
specific = pm.get_prompt("my_prompt", "v1")
# List prompts (returns latest versions)
prompts = pm.list_prompts()
# List all versions of a prompt
versions = pm.list_versions("my_prompt")
# Update prompt
pm.update_prompt("my_prompt", "v1", system_prompt="Updated system prompt")
# Delete prompt version
pm.delete_prompt("my_prompt", "v1") # Latest flag auto-managed
🏗️ Development Status
Currently in Phase 3 development:
- ✅ Basic schema and filesystem backend
- ✅ Core PromptManager functionality
- ✅ CLI interface with backend selection
- ✅ SQLite backend with structured storage
- ✅ PostgreSQL backend with connection pooling
- ✅ Advanced version management with sequence numbers
- ✅ Robust data integrity and transaction support
- ✅ Comprehensive test coverage across all backends
- ⏳ Advanced features and optimizations (Phase 4)
- ⏳ PyPI packaging (Phase 4)
📄 License
MIT License
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_gear-0.1.0a1.tar.gz.
File metadata
- Download URL: prompt_gear-0.1.0a1.tar.gz
- Upload date:
- Size: 61.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04414f05e7e20ceca947fd018831476520890d94b7cec58bf4996caa56adcc67
|
|
| MD5 |
a6bcf494a632608fc8f146b62f65752e
|
|
| BLAKE2b-256 |
995c127823d7038693fbdb17bfa20a7af183865b573456213ff31eb1e0473373
|
File details
Details for the file prompt_gear-0.1.0a1-py3-none-any.whl.
File metadata
- Download URL: prompt_gear-0.1.0a1-py3-none-any.whl
- Upload date:
- Size: 23.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34659749df8a6613cdbc4cc6dfc7b4e0e5e6960d9f4dc9091012c447145ef60a
|
|
| MD5 |
18b0dedd06b95f9c61d60d2e31fd9233
|
|
| BLAKE2b-256 |
29c7961d068f008021885338bf3b05182e184c3a793fc90280763372a3e67cef
|