Skip to main content

promptex-py

Declare prompt resources in Python, compile them into whatever your AI coding tool expects on disk.

Skills, rules, agents, hooks, MCP servers and permissions are ordinary files in a directory tree, and every tool wants that tree laid out its own way. This package lets you declare each resource once and project the result onto a target platform. It ships the Python SDK, a precompiled native extension bound to the shared core, and the promptex command line tool.

Install

pip install promptex-py

Requires Python 3.10 or newer. Wheels carry the native extension, so there is no Rust toolchain to install.

To start a new project, or to add promptex to an existing one, use create-promptex-py. It writes the config file and an example, and leaves your existing files alone:

uvx create-promptex-py .
uv add promptex-py
uv run promptex build --install

Minimal example

Declarations live in a prompts/ directory. Anything you define_* at module scope is registered when the file is evaluated.

# my_project/prompts/review.py
from promptex import define_skill

define_skill(
    id="code-review",
    name="Code Review",
    description="Reviews a pull request for correctness and readability",
    config={"whenToUse": "Reviewing a pull request"},
    content="Check correctness first, then readability.",
)

Point the command line tool at the directory that contains prompts/:

$ promptex build --install my_project --out my_project --platform claude
✓ Metadata written (graph + content)
  wrote .claude/skills/code-review/SKILL.md
Install report (claude)
  Projected artifacts, 1: .claude/skills/code-review/SKILL.md

Which writes:

my_project/.claude/skills/code-review/SKILL.md
---
name: code-review
description: Reviews a pull request for correctness and readability
when_to_use: Reviewing a pull request
---

Check correctness first, then readability.

Switch --platform codex and the same declaration lands in Codex's layout instead.

Commands

Command What it does
promptex build <dir> Compile and refresh the framework metadata under .promptex/. No platform artifacts, no ownership registry, no pruning.
promptex build --install <dir> Compile, write the platform artifacts, record ownership, and prune what you deleted. This is the one to use for real installs.
promptex build --install --dry-run <dir> Show what --install would change, without writing anything. Add --content --json to get the bytes it would write.
promptex build --export <export-dir> <dir> Write the exact tree --install would write under <export-dir>/<unit>/, with no registry. The unit subtree is cleared first.
promptex build --watch <dir> Rerun the same flags (build alone, --install or --export) as sources change.
promptex manifest <dir> Answer registry queries from the current projection.
promptex init <dir> Deprecated, removed in 2.0. Use uvx create-promptex-py <dir> instead.
promptex version Report the package version, the language and the flags each command supports (--json for the machine-readable form).

Common flags: --out <install root> (single-directory mode), --platform <name> (manifest only), --unit <unit name>, --json, --locale <tag>.

Machine-readable output

--json makes a command print one JSON document on stdout. Every document, and every file the tool writes under .promptex/, carries formatVersion (currently "1.2"). Within 1.x the version only gains keys, so read the keys you know and ignore the rest.

promptex version --json reports the package, the language and what this CLI supports, so a caller can check a feature before using it:

{"formatVersion":"1.2","package":{"name":"promptex-js","version":"1.0.1"},"language":"ts",
 "capabilities":{"verbs":{"build":{"flags":["--install","--dry-run","…"]},"version":{"flags":[]}},
                 "globalFlags":["--json","--locale"]}}

A failing command with --json prints an error document on stdout and the same message on one line of stderr:

{"formatVersion":"1.2","error":{"code":"USAGE_UNKNOWN_FLAG","message":"Unknown flag: --foo","details":{"flag":"--foo","usage":"…"}}}
  • code is stable. A USAGE_ code means the call was wrong. A RUN_ code means the call was fine and the work failed. Branch on code, never on message, which is localized and may change.
  • details is always an object. Its keys are fixed per code and identical in all three languages. Its values (paths, usage text) may differ.
  • Exit code is 1 for every failure of the existing commands, usage errors included, as before. A usage error of version exits with 2.
  • config always prints a JSON document, with or without --json. When it fails, that document is the error document. A config write that is refused is a result, not an error: the result document is printed and the exit code is 1.
  • build --watch prints each failed round for a person to read and emits no error document, because watching is a long-running loop.

What you can declare

define_skill, define_rule, define_agent, define_instruction, define_resource, define_hook, define_mcp, define_permission, define_asset, define_dir.

Each define_* takes either keyword arguments or one spec object from the promptex.kinds module (SkillDef, RuleDef, AgentDef, InstructionDef, ResourceDef, HookDef, McpDef, PermissionDef, AssetDef, DirDef). The two forms produce byte-identical intermediate representations. Spec objects are for shared packages: a pure function returns the spec, and each unit calls define_rule(rule_def(...)) in its own source file, so the node's recorded source location is the caller's line, not the package's.

from promptex import RuleDef, define_rule

def lint_rule_def(spec) -> RuleDef:
    return RuleDef(id=spec.id, name=spec.name, content=spec.statement)

define_rule(lint_rule_def(spec))

Per-platform native settings are not declared in your sources: they belong to the target, so you write them as claude(settings={…}) in promptex.config.py. Keys pass through verbatim into that platform's own settings file and the framework keeps no allowlist.

Larger projects add a promptex.config.py with define_config to split the tree into units, and register third-party platforms with define_target.

Notes

The SDK's evaluation path depends on nothing outside the standard library: writing and evaluating declarations never touches the native extension. The extension is loaded only once work moves past evaluation, which is also why the test suite runs with no build step.

Everything past evaluation — projection, install, registry, graph, diagnostics — happens in a shared Rust core called in-process, not as a subprocess. The TypeScript and Rust packages call the same core, so identical declarations produce byte-identical output across all three.

License

Dual-licensed under either of MIT or Apache-2.0, at your option. See LICENSE-MIT and LICENSE-APACHE.

Metadata

Release files for promptex-py 1.5.1

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

Built distributions (wheels)

Table of built distributions (wheels) for promptex-py 1.5.1
File Actions
promptex_py-1.5.1-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details for promptex_py-1.5.1-cp310-abi3-win_arm64.whl
promptex_py-1.5.1-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for promptex_py-1.5.1-cp310-abi3-win_amd64.whl
promptex_py-1.5.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for promptex_py-1.5.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
promptex_py-1.5.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for promptex_py-1.5.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
promptex_py-1.5.1-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for promptex_py-1.5.1-cp310-abi3-macosx_11_0_arm64.whl
promptex_py-1.5.1-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for promptex_py-1.5.1-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 10.6 MB

Release files / promptex_py-1.5.1-cp310-abi3-win_arm64.whl

Download URL promptex_py-1.5.1-cp310-abi3-win_arm64.whl
Size 1.5 MB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
6d0817cdf1493b8c42299ab33f7ec1820bbe53f94b9c73821106078d9fa0763c
BLAKE2b-256 checksum
How to use checksums
c905b432b7e3ffc6b765464360fe893755ed1c837a31ffb04144048a529fd4d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / promptex_py-1.5.1-cp310-abi3-win_amd64.whl

Download URL promptex_py-1.5.1-cp310-abi3-win_amd64.whl
Size 1.6 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
d1b15dbb806310425e04cb71d1fec9a9260a94145a5fa3d236efe3366c12d490
BLAKE2b-256 checksum
How to use checksums
78e62dc55916712f352acb89b38210e6c4145107e360652b73baf8f5cc7c1a28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / promptex_py-1.5.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL promptex_py-1.5.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.6 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
99fd99f08a9d8a9e62dd493ad21e8e2c8db191b7762c8eeb2b3fe448321a8afd
BLAKE2b-256 checksum
How to use checksums
f460a019611e67a571be0440dac22dabbfaed650f7394d22552344852b86313f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / promptex_py-1.5.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL promptex_py-1.5.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 1.5 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
4f25240a82a9c7f26179c961ab28713bc5d6412a01ed882a80eb24a1e7c7401b
BLAKE2b-256 checksum
How to use checksums
1d08f786ff6f8856653876a5669b582dace2b4324eef6039b8110324e0142349
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / promptex_py-1.5.1-cp310-abi3-macosx_11_0_arm64.whl

Download URL promptex_py-1.5.1-cp310-abi3-macosx_11_0_arm64.whl
Size 2.1 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
287aa69a3d346eb4ac32ffbca6f9c0f8944e665fb66adf2a20dfa0c316f62213
BLAKE2b-256 checksum
How to use checksums
6aa7ea305c5b898085aa27a140f6e50e3f2b085fe0630c40506b145f017355d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / promptex_py-1.5.1-cp310-abi3-macosx_10_12_x86_64.whl

Download URL promptex_py-1.5.1-cp310-abi3-macosx_10_12_x86_64.whl
Size 2.2 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
8bd4d51a2201b8d9cf2eb7fac090832e3cfb6dd20d3e8e6d45671aedbdbc9266
BLAKE2b-256 checksum
How to use checksums
2976d6243285d831f4589ffd41e9ce374c8dbcb361dcca1aea6b4915924b8aeb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Security for promptex-py 1.5.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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