Skip to main content

YMD Prompt

YMD Prompt is a small Python library + CLI to load, validate, and render
.ymd / .yamd files — a hybrid format where YAML holds metadata and Markdown holds prompt text.


✨ Features

  • ✅ Pydantic models for strict validation (id, kind, version, title, sections)
  • 📥 Loader: load(path) and loads(text) using yaml.safe_load
  • 🧩 Rendering with Jinja2: render(prompt, context) replaces {{var}}
  • 🔎 Placeholder discovery: list_placeholders()
  • 🔒 strict_placeholders=True to enforce completeness
  • 🖥️ CLI: ymd for rendering and placeholder inspection

🚀 Install

pip install ymd

📚 Library usage

from ymd import load, render, list_placeholders

p = load("examples/sample.ymd")
needed = list_placeholders(p.sections())
print("placeholders:", needed)

out = render(p, {"diff": "+++ simulated diff +++"})
print(out["user"])

🖥️ CLI usage

# Render and print JSON with all sections
ymd render examples/sample.ymd --var diff="@examples/diff.txt"

# Render a single section to stdout
ymd render examples/sample.ymd --var diff="+++diff+++" --section user

# Render all sections into separate files under out/
ymd render examples/sample.ymd --var diff="+++diff+++" --outdir out

# List placeholders
ymd placeholders examples/sample.ymd

Options

--var KEY=VALUE         # add a single variable (use @path to read from file)
--vars-json PATH        # load a JSON file with variables
--section NAME          # only print given section (system|instructions|user...)
--outdir DIR            # write rendered sections to files (NAME.md)
--no-strict             # allow missing placeholders (render empty string)
--format json|md        # output format (default: json; md prints a combined document)

📂 Example

See examples/sample.ymd.


⚖️ License

MIT

Release files for ymd-prompt 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ymd-prompt 0.3.0
File Size Uploaded
ymd_prompt-0.3.0.tar.gz 14.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ymd-prompt 0.3.0
File Interpreter ABI Platform
ymd_prompt-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 32.3 kB

Release files / ymd_prompt-0.3.0.tar.gz

Download URL ymd_prompt-0.3.0.tar.gz
Size 14.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b76a941705b0ae91ca2fea925a9f6d627f35aafa746eee8f0baba803ffa58626
BLAKE2b-256 checksum
How to use checksums
1575e298243c387ffc6dfe4e90278458f9261436d8dca0bedb83c4e4013b3264
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 Sep 15, 2025.

Transparency log

Release files / ymd_prompt-0.3.0-py3-none-any.whl

Download URL ymd_prompt-0.3.0-py3-none-any.whl
Size 17.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d108b3b902509f80fc297745111df821a5c52f342199b687c6dcab01e0a5486c
BLAKE2b-256 checksum
How to use checksums
168d41aa1df6b90b13bfb1b2796325e165d543a48267003bae1fe7968eb27f55
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 Sep 15, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page