🤖 Zrb: A Coding Agent With a Build System Inside
Zrb is a terminal coding agent you can wire into a build pipeline.
The agent part you already know: zrb llm chat is a full coding session in your terminal.
The other half is why Zrb exists. A skill can tell an agent to run the tests before deploying; a DAG makes it impossible not to. Zrb ships both — same file, same language, one pip install.
Contribution Guidelines | Report an Issue
📑 Table of Contents
- 🏁 Getting Started
- 🔥 Why Zrb?
- 🖥️ Try the Web UI
- 🧩 Program Your AI Agent
- ⚙️ Installation & Configuration
- 🤝 CI/CD Integration
- 🗺️ Documentation Directory
- 🎥 Demo Video
- 💖 Support Zrb
- 🎉 Fun Fact
1. Start where you'd start with any coding agent
pip install zrb
export OPENAI_API_KEY="your-key-here" # or Anthropic, Gemini, Ollama, OpenRouter, ...
zrb llm chat
That's a full agent session: it reads and writes files, runs commands behind a permission gate, searches the web, and remembers the conversation across restarts. If you already have .claude/skills/ or CLAUDE.md in the repo, it picks them up.
For most days, this is the whole product. Stop reading here if that's what you came for.
2. Then you hit the thing prompting can't fix
You write a skill: "always run the tests before deploying." It works. Usually.
Then one run the model decides the tests are unrelated to the change. Another run it runs them, misreads a green summary under a red failure, and deploys anyway. A third run it deploys to staging because the prompt didn't say which environment. Nothing crashed — the agent did what it thought you meant, and you find out on Monday.
The problem isn't prompt quality. It's that a skill is advice, and some steps need to be a guarantee. So write those as a graph instead:
# zrb_init.py
from zrb import cli, CmdTask, LLMTask
write_fix = LLMTask(
name="write-fix",
message="Read the failing test output and fix the bug in src/.",
)
run_tests = CmdTask(name="run-tests", cmd="pytest -x")
deploy = CmdTask(name="deploy", cmd="./deploy.sh production")
cli.add_task(deploy)
write_fix >> run_tests >> deploy # the agent proposes; the pipeline decides
zrb deploy
run-tests is not a suggestion the model can reason its way around. It is an edge in a graph. If pytest exits non-zero, deploy never starts, and zrb deploy exits with pytest's own exit code — which is what your CI actually branches on.
This is the part no amount of prompt engineering reaches, and it's why the agent lives inside an automation framework instead of the other way around:
- The agent is one node, not the administrator. Its answer flows downstream through XCom and gets checked by the next step.
- Readiness is a loop, not a request.
HttpCheck/TcpCheckwait for a service to actually come up. "Wait until it's ready" is not a prompt-able behavior. - Failure is a number. Tasks exit with the underlying command's code, so CI can tell a lint failure from a deploy failure.
- Scheduled and triggered runs have no one to ask. At 3am there is nobody to approve a tool call, so the boundaries have to be structural.
3. And sometimes you just want the one command
No session, no pipeline, no config:
zrb please "find every file over 100MB in this repo"
find . -type f -size +100M
📋 Copied to clipboard
It runs on the small model, answers in a couple of seconds, and puts the result on your clipboard instead of running it. Same install, same API key, none of the ceremony.
4. A fuller example: let the agent draw your codebase
Same shape as section 2, with a real payoff: an LLMTask reads your source and writes a Mermaid diagram, then a CmdTask renders it to PNG. The agent does the part that needs judgment; the shell does the part that needs to be exact.
Prerequisites
- An LLM API Key: Zrb needs an API key to talk to an AI model (OpenAI is default, but others are supported).
export OPENAI_API_KEY="your-key-here"
- Mermaid CLI: This tool converts Mermaid diagram scripts into images. Install it via npm:
npm install -g @mermaid-js/mermaid-cli
Define the pipeline
Add the following to your existing zrb_init.py file (or create a new one if you prefer to keep examples separate):
# zrb_init.py (continued)
from zrb import cli, LLMTask, CmdTask, StrInput, Group, Tpl
from zrb.llm.tool.code import analyze_code
from zrb.llm.tool.file import write_file
# Create a group for Mermaid-related tasks
mermaid_group = cli.add_group(Group(
name="mermaid",
description="🧜 Mermaid diagram related tasks"
))
# Task 1: Generate a Mermaid script from your source code using an LLM
make_mermaid_script = mermaid_group.add_task(
LLMTask(
name="make-script",
description="Create a mermaid diagram from source code in the current directory",
input=[
StrInput(name="dir", default="./"),
StrInput(name="diagram", default="state-diagram"),
],
message=(
"Read all necessary files in {ctx.input.dir}, "
"make a {ctx.input.diagram} in mermaid format. "
"Write the script into `{ctx.input.dir}/{ctx.input.diagram}.mmd`"
),
tools=[analyze_code, write_file],
)
)
# Task 2: Convert the Mermaid script into a PNG image using CmdTask
make_mermaid_image = mermaid_group.add_task(
CmdTask(
name="make-image",
description="Create a PNG from a mermaid script",
input=[
StrInput(name="dir", default="./"),
StrInput(name="diagram", default="state-diagram"),
],
cmd=Tpl("mmdc -i '{ctx.input.diagram}.mmd' -o '{ctx.input.diagram}.png'"),
cwd=Tpl("{ctx.input.dir}"),
)
)
# Set up the dependency: the image task runs after the script is created
make_mermaid_script >> make_mermaid_image
Run it
Navigate to any project with source code (e.g., a Python project). For instance, if you've cloned a repository:
git clone https://github.com/someuser/my-python-project.git
cd my-python-project
Now, run your new task:
zrb mermaid make-image
Zrb will interactively ask for the directory and diagram name. Just press Enter to accept the defaults (./ and state-diagram). The AI will analyze your code, generate the Mermaid script, and mmdc will convert it to a PNG. In moments, you'll have a beautiful diagram of your code!
🔥 Why Zrb?
- 🤖 A coding agent you program in Python. Tools, hooks, prompts, permission policies and history processors are plain Python in your
zrb_init.py— not a config format, not a separate SDK. - 🔒 Determinism where it matters. Put the model between deterministic steps and keep approvals, sandboxing and ordering under your control instead of the model's judgment.
- 🐍 Pure Python, no DSL. Tasks are objects;
>>is the dependency operator. - 💻 Terminal, web UI, or CI. The same task definition runs in all three.
- 🧩 Bring your Claude Code assets. Skills, hooks and MCP servers work as-is.
- 🌍 Open source, and white-labelable into your own branded CLI.
🖥️ Try the Web UI
Prefer a graphical interface? Zrb has you covered. Explore the full details in the Web UI Guide.
zrb server start
By default, the server binds to 127.0.0.1, so the UI is reachable only from the local machine. Then open your browser to http://localhost:21213 to see your tasks in a clean, user-friendly interface.
Safety boundary: Zrb's web UI can start and control automation tasks, so it is not intended to be exposed publicly without deliberate hardening. If you set
ZRB_WEB_HTTP_HOSTto a non-loopback address, enable authentication and replace the documented default admin password and secret key with unique values. Startup warnings call out unsafe network-exposed configurations; see the Web UI Guide before using a shared or public bind.
🧩 Program Your AI Agent
zrb llm chat works out of the box — but the moment you need it to do something specific, you don't reach for a config file or a separate SDK. You write Python, in the same file where you define the rest of your automation.
Every part of the agent is a value you can supply or a callable you can register:
| You want to… | You write a… |
|---|---|
| Give the agent abilities | custom tool — a plain Python function it can call in-process |
| React to what it does | lifecycle hook — fires on tool calls, prompts, session start/end |
| Gate dangerous actions | permission policy / async approval channel |
| Inject live context into the prompt | dynamic prompt section — a lambda ctx: ... evaluated per request |
| Keep long conversations affordable | history processor — prune, redact, or summarize the message history |
| Route by cost or task | a model callable — pick the model per request |
Example: a custom tool the agent calls in-process
from zrb import cli, LLMChatTask
# A normal Python function becomes a tool — typed args + docstring are the spec.
async def get_open_incidents(team: str) -> str:
"""Return the current open incidents for a given team."""
return my_oncall_db.query(team) # your code, running in-process
chat = LLMChatTask(name="ops-chat", tools=[get_open_incidents])
cli.add_task(chat)
The part nothing else does: the agent is a pipeline node
Because an LLMTask is just a Zrb task, you can wire it between deterministic steps. Its answer flows downstream through XCom, and your tools can call straight into your codebase:
fetch_ticket >> triage_with_llm >> route_to_team
👉 Full walkthrough and every hook in one place: Programming the Agent. Runnable example: examples/agent-in-pipeline.
⚙️ Installation & Configuration
Ready to dive deeper into getting Zrb set up and customized? Our comprehensive guides cover everything you need:
- Installation Guide: Details on
pipinstall, the automatedinstall.shscript, Docker images, and even running Zrb on Android (Termux/Proot). - Environment Variables & Overrides: An exhaustive list of all general environment variables to customize Zrb's behavior.
- LLM & Rate Limiter Configuration: Everything you need to configure your LLM provider, manage token budgets, and fine-tune AI behavior.
🤝 CI/CD Integration
Integrate Zrb into your Continuous Integration/Continuous Deployment pipelines for robust, automated workflows. See the CI/CD Integration Guide for examples with GitHub Actions, GitLab CI, and Bitbucket Pipelines.
🗺️ Documentation Directory
Zrb scales from a one-line zrb please to a hundred-node pipeline with an agent in the middle.
Here for the agent? Programming the Agent → Extending the LLM → Permission Policy.
Here to write pipelines? Tasks & Execution Lifecycle → CLI and Groups → Inputs.
Prefer copy-pasting a working example? See
examples/.
docs/adr/anddocs/technical-specs/are maintainer-facing design history, not part of the reading path below.
I. The Agent
Shaping zrb llm chat and the LLM task types.
- Choosing Between Agent Harnesses — zrb
llm chatvs Claude Code, opencode, DeepSeek Harness, and Pi: when each is the right tool - Programming the Agent — the overview: every way to shape agent behavior in Python (tools, hooks, dynamic prompts, history processors, agent-as-pipeline-node)
- Programming the Prompt — the ladder from a plain-string
messageup to a composedPromptManager; feeding aCmdTask's output intoLLMTask/LLMChatTask - LLM Assistant & AI Tasks — interactive chat,
LLMTask/LLMChatTaskusage, troubleshooting - Extending the LLM — built-in tools, custom tools, sub-agents, model capabilities, context management
- Custom UI — build a TUI, web/SSE, or chat-bot front end for
LLMChatTask - Permission Policy System — fine-grained tool control & security gates
- Sandbox — filesystem containment for LLM tool calls
- Plan Mode — read-only discovery & strategy phase
- LLMChatTask API Reference — builder API, TUI configuration
- LLM Chat Request Lifecycle — end-to-end tour: CLI → agent run → UI → history persistence
- Hook System (Claude Code Compatible)
- MCP Support (Model Context Protocol)
- LSP Support (Language Server Protocol)
- Technical Spec: LLM Journal System
- Claude Code Compatibility
II. Core Concepts
The foundational pillars of the framework.
- Tasks & Execution Lifecycle
- CLI and Groups
- Inputs
- Environments (Envs)
- Session, Context & XCom
- The
@make_taskDecorator — (advanced) full parameter reference - XCom Deep Dive — (advanced) patterns & pitfalls
III. Task Types
All task types available in Zrb, from basic to advanced.
- Task & CmdTask — Python actions and shell commands
- Custom Tasks — subclassing
BaseTaskwith async patterns - Readiness: HttpCheck & TcpCheck
- Automation: Triggers & Schedulers
- File Ops: Scaffolder & RsyncTask
- Built-in Helper Tasks (Git, Base64, UUID, HTTP, etc.)
IV. Advanced Topics
- Web UI Guide
- White-labeling: Create a Custom CLI
- CI/CD Integration
- Logging — Python logging vs. task-level context logging
- Testing Zrb Tasks — mocking context, testing pipelines
- Upgrading Guide
V. Contributing
- Which pattern do I reach for? — lookup table for the pattern zrb expects when adding new code
- Architecture & Conventions — for maintainers and contributors
- Framework Conventions — the enforced R1–R12 rules
- Maintainer Guide — start here to contribute code
VI. Configuration
- Environment Variables & Overrides
- LLM & Rate Limiter Configuration
- LLM Component Collections — registries, managers, and the three configuration channels for skills, agents, hooks, prompts, and tools
VII. Examples
examples/— runnablezrb_init.pyfor every topic above, grouped by category
VIII. Changelog
- Changelog — full release history
🎥 Demo Video
Watch a video demonstration of Zrb in action:
💖 Support Zrb
If you find Zrb valuable, please consider showing your support:
🎉 Fun Fact
Did you know? Zrb is named after Zaruba, a powerful, sentient Madou Ring that acts as a guide and support tool in the Garo universe.
Madou Ring Zaruba (魔導輪ザルバ, Madōrin Zaruba) is a Madougu which supports bearers of the Garo Armor. (Garo Wiki | Fandom)
Release files for zrb 3.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| zrb-3.6.0.tar.gz | 2.3 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| zrb-3.6.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:4.9 MB
Release files / zrb-3.6.0.tar.gz
| Download URL | zrb-3.6.0.tar.gz |
|---|---|
| Size | 2.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9ad03663e7662b366625f17cac19babfd07c12a8ed07e058f6b843dd8dec44cc
|
|
BLAKE2b-256 checksum How to use checksums |
be8916c7ed06d8d1bb995ec100d734ae038c3efa25d01356df8758a886a74a77
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.3 CPython/3.14.0 Linux/5.15.153.1-microsoft-standard-WSL2+
|
Release files / zrb-3.6.0-py3-none-any.whl
| Download URL | zrb-3.6.0-py3-none-any.whl |
|---|---|
| Size | 2.6 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
40f373bd4a09214075e2f6cd65abfb027deedc5ecd9b9152df9f4127772d6a07
|
|
BLAKE2b-256 checksum How to use checksums |
c3cba8fda93dd9e47451ba2c643845b3387acf1f5ff6e109f9d5711afb6ad889
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.3 CPython/3.14.0 Linux/5.15.153.1-microsoft-standard-WSL2+
|