Fast, dev-friendly prompt management for Python.
Project description
tmpt
Fast, file-based prompt management for Python.
tmpt lets you write LLM prompts as plain Markdown files, version them, compose them, and render them with typed variables — all with zero runtime dependencies.
- 📝 Write prompts as plain Markdown files with YAML frontmatter
- 🔀 Variables
{{ var }}, defaults{{ var:default }}, and conditionals{{ ? var }} - 🧩 Compose prompts can include other prompts
{{#other.id}} - 📦 Version prompts with multiple variants per file
- 🗂️ Registry auto-discovery, auto-reload
- ⚡ Zero runtime dependencies — stdlib only, Python 3.10+
- 🔌 Extensible add own processing steps
- 🖥️ CLI for discovery, validation, and rendering
- 🎨 Optional Rich output for colorful terminal and notebook display
Table of contents
- Install
- Quick start
- Template syntax
- File format
- Multiple variants in one file
- Registry & loading
- Python API
- CLI
- Extensible pipeline
- Optional rich output
Install
pip install tmpt
No runtime dependencies. Python 3.10+ required.
Quick start
1. Write a prompt file (prompts/summarize.md):
---
id: summarize
tone: concise
---
Summarize the following in {{ tone }} tone.
{{ ? topic }}
Topic: {{ topic }}
{{#shared_context}}
2. Render it in Python:
from tmpt import Tmpt
Tmpt("./prompts")
prompt = Tmpt["summarize"]
text = prompt(topic="climate change")
print(text)
Or load and render in one line:
from tmpt import Tmpt
text = Tmpt("./prompts/summarize.md")(topic="climate change")
print(text)
Template syntax
| Syntax | Description |
|---|---|
{{ var }} |
Substitute variable var |
{{ var:default }} |
Substitute var, fall back to default if not provided |
{{ ? var }} ... # |
Include block only when var is set and non-empty |
{{ ! var }} ... # |
Include block only when var is not set or empty |
{{#other_prompt}} |
Inline-include another registered prompt by ID |
// comment |
Line comment — stripped from rendered output |
Variable substitution
Hello {{ name }}!
Using {{ model:gpt-4o }} today.
Calling prompt(name="Alice") renders:
Hello Alice!
Using gpt-4o today.
Conditional blocks
Conditionals occupy their own line and close with a bare # line:
{{ ? topic }}
Our topic is {{ topic }}.
#
{{ ! topic }}
No topic provided.
#
Includes
Embed another registered prompt by ID:
{{#shared_checklist}}
Recurrent rendering allows powerful, multi-stage composing.
Comments
// This line is stripped from the final output.
File format
Prompt files are plain Markdown with an optional YAML frontmatter block to include variable defaults or metadata:
---
id: summarize
tone: concise
tags: [summarization, text]
---
Summarize the following in {{ tone }} tone.
{{ ? topic }}
Topic: {{ topic }}
Multiple variants in one file
A single file can hold multiple prompt variants separated by ---:
---
id: summarize.1
---
Short summary of {{ topic }}.
---
Detailed summary of {{ topic }}.
Steps:
1. Understand impact
2. Isolate issue
3. Communicate status
Each variant is registered independently and accessible by its own ID with common root name: prompt.1, prompt.2
Registry & loading
from tmpt import Tmpt
# Load all prompts from a folder (recursive)
Tmpt("./prompts")
# Load a single file
Tmpt("./prompts/summarize.md")
# Inline prompts
Tmpt("Hi, {{ name }}!", name="John")
# Register inline from a string
Tmpt["greeting"] = "Hello {{ name }}!"
# Access by ID
prompt = Tmpt["summarize"]
CLI
tmpt ships with a command-line interface. Default command is validate.
Validate
Discover and inspect all prompt files in a directory:
tmpt validate ./prompts
Validate a single file:
tmpt validate ./prompts/summarize.md
Look up a specific prompt ID (from the current directory):
tmpt validate summarize.last
Render
Render a prompt with variables and print both the raw template and the output:
tmpt render summarize --variable topic="incident response"
tmpt render release_notes.last --variable product="tmpt" --variable version="0.2.0"
Discover
List all prompts and their aliases discovered in a path:
tmpt discover ./prompts
Optional rich output
tmpt works with the standard library only. Install rich to get syntax-highlighted CLI output:
pip install "tmpt[rich]"
Examples
See the examples/ directory for runnable notebooks and scripts.
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 tmpt-0.1.0.tar.gz.
File metadata
- Download URL: tmpt-0.1.0.tar.gz
- Upload date:
- Size: 169.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22df0062bea8089a583a35d0d4cd8c6249e36952ba30d840143497036e164ff9
|
|
| MD5 |
387628df5c27397a12fe38cf73b63c66
|
|
| BLAKE2b-256 |
a0accd0dfbe511010b2aecbfbe76fdf1db1e97177a06059d5901cecc1f5b085d
|
File details
Details for the file tmpt-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tmpt-0.1.0-py3-none-any.whl
- Upload date:
- Size: 33.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b75abe230fb7a5b87befc6e41e8945529d7969a29688812173ffa7a09eb91880
|
|
| MD5 |
ec4254fbbafc494a5b7b1ebe9ab94fbe
|
|
| BLAKE2b-256 |
3e149d99f5e3d331973e64a147945c293de4db263841c85c715333c24fd0a628
|