Skip to main content

Doctrine

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

Docs · Versioning · Changelog · Rally

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

For a configured team target, build its home tree and check its rules and budgets:

doctrine build .
doctrine check
doctrine load

Teams keep shared text in their own folders. Members load those levels above their own file. Put longer cases in details to keep the always-on text small. See the home-tree guide.

To start porting a Markdown file, print its Doctrine source:

doctrine import old/guide.md --name Guide --kind workflow

First change relative links to paths from the repository root. Imported text does not follow the Markdown file when it moves.

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 examples through examples/206_passage_values

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.

Questions and contributions

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

Metadata

Release files for doctrine-agents 6.1.1

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 6.1.1
File Size Uploaded Provenance Actions
doctrine_agents-6.1.1.tar.gz 720.3 kB With provenance Details for doctrine_agents-6.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 1.3 MB

Release files / doctrine_agents-6.1.1.tar.gz

Download URL doctrine_agents-6.1.1.tar.gz
Size 720.3 kB
Tags Source
SHA-256 checksum
How to use checksums
11d8196d7b51dbe4fef8d1c62cf0735e2ba0ab17857aeca47422a3f0fa5ae0cf
BLAKE2b-256 checksum
How to use checksums
27f3293e6e4fdb961300534051c7def04b1e2dd4b422dbea211c9d0b8c4aa63f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 22, 2026.

Transparency log

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

Download URL doctrine_agents-6.1.1-py3-none-any.whl
Size 614.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0c1c34e3fc79a74f02254a45f4158a0402e48775c477bc42c7a62f8ccd5d7d10
BLAKE2b-256 checksum
How to use checksums
a9f59011b85ee5553ff331d65d007395a9b0a29c95666553213cae837da0203d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 22, 2026.

Transparency log

Security for doctrine-agents 6.1.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for doctrine_agents-6.1.1.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 Nov 22, 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