Installation¶
Requirements¶
- Python: 3.10, 3.11, or 3.12
- pytest: 7.0 or newer (already a runtime dependency)
Install from PyPI¶
Installs the pytest plugin, AgentTestClient, the markdown renderer, the
agent-grammar CLI, and a Starlette-based GrammarRouter for serving the
compiled workflows.
Adds FastAPI as a hard dependency. Use this if your service is FastAPI-
based and you want to mount GrammarRouter directly into your app.
Verify the install¶
Check that the CLI is on your PATH:
Confirm the pytest plugin auto-loaded:
You should see the --agent-grammar-output and --agent-grammar-disable
options listed. The plugin is registered through the
pytest11 entry point and is discovered automatically once agent-grammar
is installed — no conftest.py change required.
Smoke-test the import:
What gets installed¶
| Component | Provided by | Used for |
|---|---|---|
agent_grammar.workflow |
Python API | Decorate pytest tests to mark them as workflows. |
agent_grammar.step_boundary |
Python API | Annotate non-HTTP steps inside a workflow. |
agent_grammar.AgentTestClient |
Python API | Drop-in replacement for Starlette's TestClient that captures HTTP traffic. |
agent_grammar.serve.fastapi.GrammarRouter |
Python API | Mount the compiled workflows.md on a versioned route. |
agent_grammar.serve.fastapi.AgentTelemetryMiddleware |
Python API | Detect agent-driven requests via the X-Agent-Grammar-Workflow header. |
agent-grammar CLI |
Console script | Export Claude/Cursor/Copilot/Gemini system-prompt files. |
| pytest plugin | Entry point | Adds --agent-grammar-output / --agent-grammar-disable and writes the markdown after the session. |
Next step¶
Head to the Walkthrough to clone the demo project, generate
a workflows.md, and see the end-to-end loop.