Typed DSL and compiler for reusable AI agent instructions and workflows that compile to AGENTS.md.
Project description
Doctrine
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.
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
agentdeclarations - reusable and inherited
workflowdeclarations - first-class
reviewandabstract reviewdeclarations - typed
skills,inputs,outputs, directoutput[...]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/146_declarative_project_lint_rule - a repo-local VS Code extension for
.promptfiles
Workflow visualizer
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
- docs/README.md
- docs/VERSIONING.md
- CHANGELOG.md
- docs/WHY_DOCTRINE.md
- PRINCIPLES.md
- docs/LANGUAGE_REFERENCE.md
- docs/AUTHORING_PATTERNS.md
- docs/EMIT_GUIDE.md
- examples/README.md
- editors/vscode/README.md
- CONTRIBUTING.md
Questions and contributions
- Use Discussions for questions and design talk.
- Use Issues for clear bugs or scoped proposals.
- See CONTRIBUTING.md for setup and proof commands.
- See SUPPORT.md for help paths, SECURITY.md for private vulnerability reports, and CODE_OF_CONDUCT.md for collaboration rules.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file doctrine_agents-5.0.0.tar.gz.
File metadata
- Download URL: doctrine_agents-5.0.0.tar.gz
- Upload date:
- Size: 468.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d9f2906573eed51bbcff5622517aa0c7ff49b382406bc505e49e0a377998e6f
|
|
| MD5 |
ce098fb96d79e1bc4d1c8b08a94fedf1
|
|
| BLAKE2b-256 |
4326ffb5880f8d1a83db4473136a0622a6e590ec4f3252d9237f30f31d28ca5f
|
Provenance
The following attestation bundles were made for doctrine_agents-5.0.0.tar.gz:
Publisher:
publish.yml on aelaguiz/doctrine
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
doctrine_agents-5.0.0.tar.gz -
Subject digest:
9d9f2906573eed51bbcff5622517aa0c7ff49b382406bc505e49e0a377998e6f - Sigstore transparency entry: 1342715224
- Sigstore integration time:
-
Permalink:
aelaguiz/doctrine@c67883b502b8afe7446d6b0707b3e38d0143ff6d -
Branch / Tag:
refs/tags/v5.0.0 - Owner: https://github.com/aelaguiz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c67883b502b8afe7446d6b0707b3e38d0143ff6d -
Trigger Event:
release
-
Statement type:
File details
Details for the file doctrine_agents-5.0.0-py3-none-any.whl.
File metadata
- Download URL: doctrine_agents-5.0.0-py3-none-any.whl
- Upload date:
- Size: 439.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c63c664aa9c6a8b4036f73091aaec3e97e71e01e98bae54c11a8d960d4b53cda
|
|
| MD5 |
badf2efc47ed20a4590a69402ad17cbd
|
|
| BLAKE2b-256 |
60ca1fadd6736f6b8c76a070af71223139c4feb88249d2edccfa0346ab7b40a9
|
Provenance
The following attestation bundles were made for doctrine_agents-5.0.0-py3-none-any.whl:
Publisher:
publish.yml on aelaguiz/doctrine
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
doctrine_agents-5.0.0-py3-none-any.whl -
Subject digest:
c63c664aa9c6a8b4036f73091aaec3e97e71e01e98bae54c11a8d960d4b53cda - Sigstore transparency entry: 1342715230
- Sigstore integration time:
-
Permalink:
aelaguiz/doctrine@c67883b502b8afe7446d6b0707b3e38d0143ff6d -
Branch / Tag:
refs/tags/v5.0.0 - Owner: https://github.com/aelaguiz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c67883b502b8afe7446d6b0707b3e38d0143ff6d -
Trigger Event:
release
-
Statement type: