<div align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="assets/logo-dark.svg">
<img src="assets/logo.svg" alt="agengo" height="96">
</picture>
**Run AI coding agents like Claude Code on your own machine, under control. Each task is built, verified, independently reviewed and integrated in its own Git worktree, and the result is handed over only when every check passes.**
[](https://www.rust-lang.org)
[](https://github.com/nguyentan510/agengo/actions/workflows/ci.yml)
[](#requirements)
[](https://claude.com/claude-code)
[](CHANGELOG.md)
[Features](#features) · [How it works](#how-it-works) · [Quick start](#quick-start) · [Docs](docs/README.md) · [FAQ](#faq) · [Tiếng Việt](README.vi.md)
</div>
---
**agengo** is an open-source command-line tool, written in Rust, for running **AI coding agents** under control. You write a plan made of small tasks. For each task, agengo:
1. dispatches a **Builder** agent,
2. runs *your* verification commands,
3. has an independent **Reviewer** check the exact commit against the acceptance criteria,
4. merges the result into a dedicated Git branch.
You end up with a verified `af/<run-id>` branch that is ready to inspect and merge. Your `main` branch is never touched.
> Use it when you want Claude Code, or any other coding agent, to work on **several tasks at once** while keeping **clear file scopes, mandatory tests, independent review, and a human in the loop** for the decisions that matter.
## Why agengo?
Running an agent directly on your repository is fast but hard to control. It may edit unrelated files, report "done" while tests are still red, or leave your working branch in a mess. agengo adds a verified orchestration layer around the agent:
| Running an agent directly | Running it through agengo |
|---|---|
| The agent may edit any file | Each task may only change the paths listed in its `owns` scope; anything else is rejected |
| "Done" means the agent says so | "Done" means your `verify` commands pass in a clean worktree |
| The agent reviews its own work | A separate Reviewer must attest the exact commit SHA it was given |
| Work happens on your current branch | Every attempt gets its own worktree; results merge into `af/<run-id>` |
| An interruption loses track of progress | State lives in SQLite; `resume` continues where it stopped, even after Ctrl‑C |
| Questions get lost in chat | A decision inbox lists each `Y-xx` request together with the command that answers it |
## Features
- 🤖 **Multi-agent workflow:** Builder → verification → Reviewer → integration → final checks. Claude Code works out of the box; any other agent can plug in through a [JSON adapter](#adapter-protocol).
- 🌳 **Git worktree isolation:** every build, review and integration attempt runs in its own worktree, and worktrees are cleaned up automatically.
- ⚡ **Safe parallelism:** `--jobs N` runs independent tasks concurrently; tasks with overlapping file scopes are serialized, and `depends` ordering is enforced.
- ✅ **Mandatory verification:** each task's `verify` commands, `integration_verify` after every merge, and `final_verify` before hand-off.
- 🔍 **Tracked review findings:** findings (`F-01`, …) are tied to acceptance criteria and followed across fix rounds. An optional whole-branch review is available.
- 🧑⚖️ **Human in the loop:** approve plans before they run, choose between options A and B, amend the plan as a new revision, and pause or resume individual tasks.
- 🧬 **Quality gates:** tree-sitter–based detection of duplicated Python functions (`off`/`warn`/`block`), plus any lint or test commands you add.
- 💾 **Crash-safe:** transactional SQLite state, a per-run lock, and timeouts and output limits for agent processes.
- 📊 **Cost transparency:** `status --json` records every attempt's request, result, duration, tokens and cost; `agengo metrics` totals tokens and cost per role and per task, for Claude Code or any adapter that reports [`usage`](#token-and-cost-usage).
## How it works
<picture>
<source media="(prefers-color-scheme: dark)" srcset="assets/workflow.en-dark.svg">
<img src="assets/workflow.en.svg" alt="agengo workflow: plan, build, verify, review, integrate, deliver, with a decision inbox for people">
</picture>
Tasks move through `pending → building → ready_review → reviewing → passed → integrated`. When a task gets stuck — the review limit is reached, the agent crashes, or a prerequisite is missing — it becomes `blocked` and agengo asks you through a `Y-xx` request. Independent tasks keep running.
## Requirements
- Linux or macOS. Windows is not supported natively; use WSL.
- Node.js 14.18+ for the npm package, or Rust/Cargo 1.90+ and a C compiler to build from source. Prebuilt binaries need neither.
- Git 2.31+ with `user.name` and `user.email` configured.
- Either [Claude Code](https://claude.com/claude-code) on `PATH` and logged in, or your own adapter passed with `--agent <executable>`.
## Installation
Prebuilt binaries are available for Linux and macOS (x64 and arm64).
```bash
npm install -g agengo # or try it without installing: npx agengo --help
```
```bash
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/nguyentan510/agengo/releases/latest/download/agengo-installer.sh | sh
```
```bash
cargo install agengo --locked # builds from source
```
Binaries and checksums for each version are on the [Releases](https://github.com/nguyentan510/agengo/releases) page.
## Quick start
```yaml
# plan.yaml
schema_version: 1
goal: Add a greeting helper
tasks:
- id: greet
goal: Add greet(name) to src/greet.py returning "Hello, <name>!".
owns: [src/greet.py, tests/test_greet.py]
acceptance: ["greet('An') returns 'Hello, An!'"]
verify: [["python3", "-m", "pytest", "-q", "tests/test_greet.py"]]
final_verify: [["python3", "-m", "pytest", "-q"]]
```
```bash
agengo plan --file plan.yaml --brief # validate the plan without calling an agent
agengo run plan.yaml --id demo # build → review → integrate → deliver
agengo status demo # progress
agengo inbox demo # pending requests, each with the command that answers it
git log --oneline main..af/demo # inspect the result before merging
```
<img src="assets/demo-terminal.png" alt="Real agengo output after a Claude Code run: delivered branch, per-role tokens and cost, and the merge graph" width="100%">
No plan yet? Let the agent draft one: `agengo plan --goal "Add a login API" --format yaml > plan.yaml`.
Exit codes: `0` delivered · `2` waiting for your answer (then run `resume`) · `1` error · `130` interrupted (run `resume`).
## Plan format
A plan is YAML or JSON, validated against [specs/plan.schema.json](specs/plan.schema.json). agengo rejects unknown fields, dependency cycles and paths outside the repository.
| Field | Required | Meaning |
|---|---|---|
| `goal` | ✔ | Overall goal of the run |
| `tasks[].id` | ✔ | 1–64 characters from `A-Z a-z 0-9 _ -`, unique |
| `tasks[].goal` / `title` | goal ✔ | Instructions for the agent / short title for humans |
| `tasks[].owns` | ✔ | Files or directories the Builder may change. Tasks with overlapping scopes never run in parallel |
| `tasks[].acceptance` | ✔ | Acceptance criteria, as strings or `{id, text}` |
| `tasks[].verify` | ✔ | argv commands run on the candidate before review and again at integration |
| `tasks[].depends` | | Tasks that must be integrated first |
| `tasks[].setup`, `setup` | | Commands that prepare each worktree, e.g. `[["npm","ci"]]` |
| `integration_verify` | | Commands run after every merge |
| `final_verify` | ✔ | Commands run on the final branch before delivery |
| `quality` | | `python_duplicates: off \| warn \| block`, `ignore_paths`, extra `checks`, `review: true` for a whole-branch review |
Commands are argv arrays and never go through a shell. Use `["sh", "-c", "..."]` if you need shell syntax.
## Commands
| Command | Purpose |
|---|---|
| `plan --file F` / `--goal G` / `--from F` | Validate a plan, or have the agent draft one |
| `run PLAN [--id ID] [--jobs N] [--base REV]` | Start a run (`--review-limit`, `--gate-limit`, `--timeout`, `--builder-handoff worktree\|commit`, `--agent`, `--await-approval`) |
| `resume ID` / `resume ID --task T` / `pause ID --task T` | Continue a run, unpause a task, pause a task |
| `status ID [--json]` · `inbox ID [--json]` · `metrics ID [--json]` | Progress, pending requests, timing, tokens and cost |
| `respond ID Y-xx --choice A\|B\|approve\|reject --note N [--plan F]` | Answer a request |
| `resolve ID TASK --note N` · `amend ID PLAN --note N` | Reopen a blocked task · approve a new plan revision |
| `clean ID` | Remove the run's worktrees (and its temporary refs once delivered) |
## Adapter protocol
With `--agent <exe>`, agengo runs the executable once per assignment, inside the assigned worktree:
- **Input:** a request JSON on **stdin**, following [specs/request.schema.json](specs/request.schema.json). It includes `role`, `task`, `head`, `base`, `context` with acceptance criteria and open findings, `decisions` and `relationships`.
- **Output:** one result JSON on **stdout**, following [specs/outcome.schema.json](specs/outcome.schema.json):
```json
{"status": "done", "head": "<sha>", "summary": "…", "blocker": null,
"findings": [], "finding_resolutions": [], "resolved_conflicts": []}
```
### Token and cost usage
An adapter may add an optional top-level `usage` object, following [specs/usage.schema.json](specs/usage.schema.json): `input_tokens` (uncached input), `output_tokens`, `cache_read_tokens`, `cache_write_tokens`, `cost_usd` and `model`. Malformed fields are dropped and never fail an attempt. agengo does not price tokens itself. For Claude Code, usage and `total_cost_usd` are read automatically. Mappings for the Anthropic, OpenAI, Gemini and Ollama APIs are in the [user guide](docs/guide.md#token-and-cost-usage-optional).
The Builder returns `done` (commit handoff) or `ready` (worktree handoff). The Reviewer returns `pass` or `changes_requested`. Any role may return `blocked` with a `blocker` (`action`, `decision` or `information`). A non-zero exit, output that is not JSON, or a timeout becomes a `Y-xx` decision. A complete reference adapter lives in [tests/support/mod.rs](tests/support/mod.rs).
## FAQ
**Does agengo merge into `main` or push to a remote?**
No. It only creates and updates the local branch `af/<run-id>` and never pushes. Merging is your decision.
**Can I use an agent other than Claude Code?**
Yes. Any executable that speaks the [JSON adapter protocol](#adapter-protocol) works.
**What happens if the agent hangs or crashes?**
Each attempt has a timeout (`--timeout`, 900 s by default). Failures turn into `Y-xx` requests. Answer with `agengo respond`, then run `agengo resume`.
**Where is data stored?**
State is kept in `.git/agent-flow/state.sqlite3`. Temporary worktrees live under `~/.cache/agengo/worktrees` (override with `AGENGO_WORKTREES`) and are removed after delivery or by `agengo clean <run>`.
**Is it a sandbox?**
No. agengo checks file scope, commit SHAs, the index and branches after every attempt, but agents can run Bash. For untrusted code or agents, run agengo inside a container or VM.
**What does it cost?**
agengo itself is free. You pay for the agent you use, such as Claude Code. Every task needs at least one build attempt and one review attempt, and on small tasks the review can cost nearly as much as the build. `agengo metrics` reports real tokens and cost per role and per task. Recording them adds about 1 ms per attempt and makes no extra API calls.
## Documentation
- [User guide](docs/guide.md): full reference.
- [Glossary](docs/glossary.md): canonical terms and CLI output labels.
- [Documentation index](docs/README.md).
- [CHANGELOG](CHANGELOG.md).
- [specs/](specs/): JSON Schemas and role prompts.
## Development
```bash
cargo test --locked # unit + system tests with a simulated agent
AGENGO_CLAUDE_E2E=1 cargo test --locked --test system # plus one real Claude Code run (uses API credits)
```
---
<sub>Keywords: AI coding agent orchestrator · Claude Code automation · multi-agent software development · git worktree · automated code review · human-in-the-loop · Rust CLI</sub>