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.

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> Scaffold a new project (--lang ts, python or rust).

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

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.0.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.0.1
File
promptex_py-1.0.1-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details
promptex_py-1.0.1-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
promptex_py-1.0.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
promptex_py-1.0.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
promptex_py-1.0.1-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
promptex_py-1.0.1-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 9.6 MB

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

Download URL promptex_py-1.0.1-cp310-abi3-win_arm64.whl
Size 1.3 MB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
696a4e2a85bf13dda2d65062d925d33d12d4488cab6f9c063c996291461ef4e9
BLAKE2b-256 checksum
How to use checksums
c77c9e8ee5bd294a11d351af2eecaa49027285b53debc07666bb7874e64f353b
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.0.1-cp310-abi3-win_amd64.whl

Download URL promptex_py-1.0.1-cp310-abi3-win_amd64.whl
Size 1.4 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
e6d156e865e75e90817d43a5e7f2fe7ddb46e3d2487d686f14cc91d37960ecc4
BLAKE2b-256 checksum
How to use checksums
e62a893341b117da7ce0e21147c0753988db47fecf1c4729b3d075fddeada9e1
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.0.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL promptex_py-1.0.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.5 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
2bf09f378e6c99713619f22bc8fbcb9dff3e60279cdba15efa237eadd34aafde
BLAKE2b-256 checksum
How to use checksums
2b69616815066f6a02c8020f629e9cdc46d520d6831915ef22191dae86f4bcf1
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.0.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL promptex_py-1.0.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 1.4 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
21573abd082c56fb682b4215478ea12426e6318d2703b7e10f9529f1d40be466
BLAKE2b-256 checksum
How to use checksums
a383638b91da9def665f9695c96d6464a834cfa1f67ce3fbe1eaca84e3af3357
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.0.1-cp310-abi3-macosx_11_0_arm64.whl

Download URL promptex_py-1.0.1-cp310-abi3-macosx_11_0_arm64.whl
Size 2.0 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
6e63333cd9dca314fe62075eb278b988bf098d8d3a54371d975fa8e4a2e76b84
BLAKE2b-256 checksum
How to use checksums
ca90ba9462f719efb800c3c65ad7fd480d68dbcb445754806ed2bb3fa20520c8
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.0.1-cp310-abi3-macosx_10_12_x86_64.whl

Download URL promptex_py-1.0.1-cp310-abi3-macosx_10_12_x86_64.whl
Size 2.0 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
9eb06bf40ff741c3fe0458620e5836415b7011ad03fa79d9ccb97aaea9534cc4
BLAKE2b-256 checksum
How to use checksums
95aed5aebc7ea4af39a9bc17925cd7c22ac84650eda137ffdb071eed2f76691f
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.0.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.

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