Skip to main content

Doctrine

License: MIT Python 3.14%2B CI PyPI OpenSSF Scorecard Output: AGENTS.md

Docs · Versioning · Changelog · Rally · VS Code extension

Write agent workflows in a code-like DSL. Compile them to portable instructions.

Doctrine is a typed DSL and compiler for agent instructions, workflows, reviews, skills, and I/O contracts that coding agents are actually good at writing and maintaining. Instead of hand-editing giant AGENTS.md files, letting coding agents generate markdown sprawl, or locking yourself into a proprietary Python agent framework, you author small .prompt files and compile deterministic runtime artifacts that current coding-agent tools can already read today.

If Rally is how you run the workflow, Doctrine is how you author it. Rally gets attention through strong, stable workflow execution. Doctrine is the reason those workflows stay coherent under the hood.

Side-by-side view of Doctrine source on the left and compiled AGENTS.md output on the right.

Why teams reach for Doctrine:

  • instructions read like code instead of text sludge
  • coding agents can change shared rules without duplicating markdown
  • compile-time failures catch drift before runtime
  • humans can review source and emitted runtime side by side
  • flow diagrams, verification, and editor support ship today
  • output stays portable across current agent tools and harnesses

Runtime boundary

Doctrine is the authoring and compile layer. It turns typed .prompt source into deterministic runtime Markdown such as AGENTS.md. That output is meant for the agent runtime that fits your stack. Doctrine does not try to be the runtime, scheduler, or state store.

If you want the split in one glance:

  • Use Doctrine when you want to author and validate the flow.
  • Use Rally when you want to run a strong, stable workflow with repo-local state, resumability, and strict turn routing.
  • The split is deliberate: Doctrine is how you author it. Rally is how you run it.

Why Doctrine exists

Serious agent systems drift fast when the source of truth is copied Markdown:

  • shared sections get duplicated and then edited out of sync
  • one policy fix turns into search-and-hope edits
  • large prompt trees become hard to review
  • runtime Markdown is the delivery format, not the right authoring surface

Doctrine turns that into a language and compiler problem.

Quick example

workflow SharedTurn: "How To Take A Turn"
    "Read the current brief before you act."
    "Leave one honest handoff and stop."

skill RepoSearchSkill: "repo-search"
    purpose: "Find the right repo surface for the current job."

abstract agent ReviewRole:
    read_first: SharedTurn

agent BriefReviewer[ReviewRole]:
    role: "Core job: review the current brief and route the same issue honestly."

    inherit read_first

    skills: "Skills"
        can_run: "Can Run"
            skill search: RepoSearchSkill
                requirement: Advisory

That compiles to runtime Markdown:

Core job: review the current brief and route the same issue honestly.

## How To Take A Turn

Read the current brief before you act.
Leave one honest handoff and stop.

## Skills

### Can Run

#### repo-search

Quickstart

Want the first-party Doctrine skills from this source checkout?

make skills

Run that from the Doctrine repo root after uv sync and npm ci. That emits the public install trees under skills/.curated/, then runs npx skills add .. If the CLI asks where to install them, pick the agent you use.

Want a no-prompt Codex install?

uv run --locked python -m doctrine.emit_skill --target doctrine_agent_linter_public_skill
uv run --locked python -m doctrine.emit_skill --target doctrine_learn_public_skill
npx skills add . -g -a codex -y

When Doctrine is installed from a package index, the distribution name is doctrine-agents. The Python module name stays doctrine.

Want the packaged compiler?

python -m pip install doctrine-agents

Need the example corpus, repo proof, or emit_flow?

git clone https://github.com/aelaguiz/doctrine.git
cd doctrine
make setup

Use CONTRIBUTING.md for the full source-checkout proof path. make setup owns the repo bootstrap commands. Use docs/VERSIONING.md for release rules and CHANGELOG.md for the public release record.

Want a smaller first proof from a source checkout?

uv run --locked python -m doctrine.verify_corpus --manifest examples/01_hello_world/cases.toml

Want generated output right away from a source checkout?

uv run --locked python -m doctrine.emit_docs --target example_07_handoffs
uv run --locked python -m doctrine.emit_flow --target example_73_flow_visualizer_showcase

What ships today

  • concrete and abstract agent declarations
  • reusable and inherited workflow declarations
  • first-class review and abstract review declarations
  • typed skills, inputs, outputs, direct output[...] inheritance, output schema, and generated schema contracts
  • imports, directory-backed runtime packages, readable refs, interpolation, enums, and workflow law
  • emit_docs, emit_flow, emit_skill, skill source receipts, and structured-output schema validation helpers
  • manifest-backed verification through examples/149_external_skill_source_target
  • a repo-local VS Code extension for .prompt files

Workflow visualizer

Generated Doctrine workflow diagram showing shared inputs, a route-first handoff lane, and compiler-owned flow output.

The checked-in showcase above comes from examples/73_flow_visualizer_showcase. It proves that Doctrine can emit human-readable runtime docs and compiler-owned flow diagrams from the same source graph.

Read next

Questions and contributions

If this direction is useful, star the repo and watch releases.

Metadata

Release files for doctrine-agents 5.1.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 doctrine-agents 5.1.0
File Size Uploaded Provenance Actions
doctrine_agents-5.1.0.tar.gz 479.4 kB With provenance Details for doctrine_agents-5.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for doctrine-agents 5.1.0
File Interpreter ABI Platform Actions
doctrine_agents-5.1.0-py3-none-any.whl Python 3 none any Details for doctrine_agents-5.1.0-py3-none-any.whl

Total release size: 926.7 kB

Release files / doctrine_agents-5.1.0.tar.gz

Download URL doctrine_agents-5.1.0.tar.gz
Size 479.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b22abdfb29996c63dab77114d5c6a9bab27f8ba3b5a7f0dbfe585a9b19c3c102
BLAKE2b-256 checksum
How to use checksums
2767210b35967210c884cedd0475001c7056335eb1d71efd8b194002f9e67031
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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 Apr 24, 2026.

Transparency log

Release files / doctrine_agents-5.1.0-py3-none-any.whl

Download URL doctrine_agents-5.1.0-py3-none-any.whl
Size 447.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c318be2a23d93045545bfac31daa440e7d3f33ec67bf4527499e6e07f443a28c
BLAKE2b-256 checksum
How to use checksums
641d4e2e45fee3d4109224201b766a3fdc16a938db62c3126cc0a16f7322b0b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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 Apr 24, 2026.

Transparency log

Security for doctrine-agents 5.1.0

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for doctrine_agents-5.1.0.tar.gz

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 Apr 24, 2026.

Transparency log

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