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 flows as code. Compile them to AGENTS.md.

Doctrine is a typed DSL and compiler for reusable agent instructions, workflows, reviews, skills, and I/O contracts. Instead of hand-editing giant AGENTS.md files, you author small .prompt files and compile deterministic runtime artifacts that current coding-agent tools can already read today.

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

Why teams reach for Doctrine:

  • one shared rule changes once
  • 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

Doctrine and Rally

  • Use Doctrine when you want to author and validate the flow.
  • Use Rally when you want to run that flow with repo-local state, resumability, and strict turn routing.
  • The split is deliberate: Doctrine is the authoring layer, Rally is the runtime layer.

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

Source checkout is still the full setup path for contributor proof, the example corpus, and emit_flow.

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

Want the packaged compiler instead of a source checkout?

python -m pip install doctrine-agents
git clone https://github.com/aelaguiz/doctrine.git
cd doctrine
uv sync
npm ci
make check

Want a smaller first proof?

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

Want generated output right away?

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, and JSON-schema-backed contracts
  • imports, readable refs, interpolation, enums, and workflow law
  • emit_docs, emit_flow, and emit_skill
  • manifest-backed verification through examples/106_review_split_final_output_json_schema_partial
  • 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-1.0.2.tar.gz (241.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-1.0.2-py3-none-any.whl (292.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: doctrine_agents-1.0.2.tar.gz
  • Upload date:
  • Size: 241.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-1.0.2.tar.gz
Algorithm Hash digest
SHA256 eacead2023cfde3a06618908bc4dd0a5d49cb545a3f97e201e7d53b75b8f251e
MD5 98777d75e4a70e56762a066c76e32208
BLAKE2b-256 a7c71b3acf73806f123f74e9f606cd104229234f4e6517d474b842ee8de78842

See more details on using hashes here.

Provenance

The following attestation bundles were made for doctrine_agents-1.0.2.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-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: doctrine_agents-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 292.4 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-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 634c501bca2635a0cdd0b540b6b4b470707842437106e54b1190e7b4505c365e
MD5 7d943143b7d955ed1475d17704299ec2
BLAKE2b-256 b8d4742153c45eec87708f895304f0caa56f50343573b75c5e5c848e06f604d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for doctrine_agents-1.0.2-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