Skip to main content

Typed DSL and compiler for reusable AI agent instructions and workflows that compile to AGENTS.md.

Project description

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 Doctrine skill from this repo?

npx skills add .

Run that from the Doctrine repo root. That one line installs the checked-in agent-linter skill from this repo. If the CLI asks where to install it, pick the agent you use.

Want a no-prompt Codex install?

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, and structured-output schema validation helpers
  • manifest-backed verification through examples/115_runtime_agent_packages
  • 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

doctrine_agents-2.0.0.tar.gz (417.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

doctrine_agents-2.0.0-py3-none-any.whl (395.0 kB view details)

Uploaded Python 3

File details

Details for the file doctrine_agents-2.0.0.tar.gz.

File metadata

  • Download URL: doctrine_agents-2.0.0.tar.gz
  • Upload date:
  • Size: 417.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for doctrine_agents-2.0.0.tar.gz
Algorithm Hash digest
SHA256 97e288d58399342d8b9f6285af8c0a428df55d727a7c44529623f68a651d87cf
MD5 d3efb0d5844fd5b0803421fa66d6c0d0
BLAKE2b-256 0e64f7ecc76c12e6854dca2c6a418e7bde7e9bb0bb83cca9d0dea13196ebc4e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for doctrine_agents-2.0.0.tar.gz:

Publisher: publish.yml on aelaguiz/doctrine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file doctrine_agents-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: doctrine_agents-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 395.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for doctrine_agents-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c5d28d5d63c5bd417195e0a6b431c79fd4b4046fb71d79963fc74d6b7e06970d
MD5 e70726082844b4ec22fed58e10fabac1
BLAKE2b-256 5be214e49e6cf473024c2bf4330ad2c34be6d2e3dc398490886efa3aaf0985b6

See more details on using hashes here.

Provenance

The following attestation bundles were made for doctrine_agents-2.0.0-py3-none-any.whl:

Publisher: publish.yml on aelaguiz/doctrine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page