agengo 0.5.0

Orchestrate AI coding agents (Claude Code) to build, verify, review and integrate tasks in isolated Git worktrees
# agengo user guide

How to use agengo: install it, run it the first time, turn an idea into a spec, answer requests, connect it to your coding agent, and keep a repository tidy. For exact syntax (every command, the plan format, the adapter protocol, metrics) see the [reference](reference.md). For an overview, start with the [README](../README.md). Terms are defined in the [glossary](glossary.md). A Vietnamese translation is available: [docs/vi/huong-dan.md](vi/huong-dan.md).

**Contents:** [Requirements](#requirements) · [Quick start](#quick-start) · [Clarifying an idea](#clarifying-an-idea) · [Answering requests](#answering-requests) · [Agent integration](#agent-integration) · [Authentication](#authentication) · [Security limits](#security-limits) · [Conventions](#conventions)

## Requirements

- Linux, macOS or Windows 10/11. On Windows, Claude Code needs [Git for Windows](https://git-scm.com/downloads/win), and deep checkouts such as `node_modules` work best with `git config --global core.longpaths true` (agengo sets it for its own Git commands, not for the agents').
- To build from source only: Rust/Cargo 1.90+ and a C compiler (for the bundled SQLite).
- Git 2.31+ with `user.name` and `user.email` configured.
- Under WSL, keep repositories in your Linux home directory rather than `/tmp`: WSL shuts down when it has been idle for a while and may clear `/tmp`, taking the run state in `.git/agent-flow/` with it.
- One of:
  - [Claude Code](https://claude.com/claude-code), Codex or Antigravity on `PATH` and logged in (see [Choosing the agent](reference.md#choosing-the-agent)); or
  - your own adapter passed with `--agent <executable>` (see [Adapter protocol](reference.md#adapter-protocol)).

Install a prebuilt binary (Linux and macOS, x64 and arm64; Windows, x64) with npm, the shell installer or the PowerShell installer, or build from source:

```bash
npm install -g agengo            # Node.js 14.18+; or run without installing: npx agengo --help
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/nguyentan510/agengo/releases/latest/download/agengo-installer.sh | sh
powershell -ExecutionPolicy ByPass -c "irm https://github.com/nguyentan510/agengo/releases/latest/download/agengo-installer.ps1 | iex"  # Windows
cargo install agengo --locked    # from crates.io, builds from source
cargo install --path . --locked  # from a local checkout
agengo --help
```

npm and the shell and PowerShell installers download the binary for your platform from the GitHub Release of that version and check its SHA-256 checksum.

## Quick start

0. Once per repository, run `agengo init` so Claude Code, Codex and other agents working there know when to hand work to agengo (see [Agent integration](#agent-integration)).
1. Write `.agengo/plans/demo.yaml` (one plan file per run, named after the run ID; see [Conventions](#naming)), or let the agent draft one with `agengo plan --goal "..." --format yaml > .agengo/plans/demo.yaml`. `agengo init` creates the `.agengo/plans/` folder. If the goal is still a rough idea, settle it first with `agengo spec` (see [Clarifying an idea](#clarifying-an-idea)).

```yaml
schema_version: 1
goal: Add a greeting command
tasks:
  - id: greet
    title: Greeting helper
    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"]]
  - id: cli
    goal: Expose greet through `python3 -m app NAME`.
    depends: [greet]
    owns: [src/app]
    acceptance: ["python3 -m app An prints Hello, An!"]
    verify: [["python3", "-m", "pytest", "-q"]]
final_verify: [["python3", "-m", "pytest", "-q"]]
```

2. Validate the plan without calling an agent: `agengo plan --file .agengo/plans/demo.yaml --brief`.
3. Run it: `agengo run .agengo/plans/demo.yaml --id demo --jobs 2`. Add `--await-approval` if you want to approve the plan before any agent starts.
4. Follow progress with `agengo status demo` and `agengo inbox demo`. Each request that needs you comes with the exact `agengo respond ...` command.
5. When the run prints `[DELIVERED]`, inspect the result with `git log af/demo`, then merge it yourself.

Exit codes: `0` delivered · `2` waiting for your answer (run `resume` after answering) · `1` error · `130` interrupted with Ctrl‑C (run `resume` to continue).

If the agengo process itself dies (the terminal closes, the machine restarts or runs out of resources), the run stays `running`. `agengo status ID` and `agengo inbox ID` then say that no agengo process drives it, list attempts left marked active as stalled, and print `agengo resume ID`. They never resume it for you.

## Clarifying an idea

A one-line idea leaves the planner guessing, and its guesses are invisible. `agengo spec` turns the idea into `.agengo/spec.yaml`, which states what to build and why without saying how: the problem, the people who use the result, prioritized user stories (P1 is the smallest useful slice) with Given/When/Then scenarios, requirements `FR-n`, measurable success criteria `SC-n`, what will not be built, and the assumptions the agent made, each with what would change if it is wrong.

```sh
agengo spec --idea "a sales app for my clothes shop"      # round 1; exit 2 while questions are open
agengo spec .agengo/spec.yaml --answer Q-1=B --answer Q-2=yes     # answer, and the spec is revised
agengo spec .agengo/spec.yaml --proceed                           # accept every remaining recommendation
agengo spec .agengo/spec.yaml --approve                           # check readiness, lock with a digest
```

- The agent (role `specify`, read-only) proposes questions only where the answer changes scope, privacy or what users experience. Each question has a reason, 2–4 options with their consequences in plain words, and a recommended option. Technical choices are never asked: the agent decides them and records assumptions.
- agengo, not the agent, enforces the limits. It drops questions that break these rules (for example a technology question or a single option), keeps at most **5** open questions (with the default depth), most important first, and numbers them `Q-n` without ever reusing a number. Round **3**, or `--proceed`, is final: remaining uncertainty becomes assumptions.
- Answer with an option key, `yes` for the recommendation, or your own words (`--answer "Q-3=only on weekdays"`). Answers are kept under `clarifications` with their round and source.
- `--depth quick|standard|deep` sets how much to ask: up to 3 questions per round over 2 rounds, 5 over 3 (the default), or 8 over 4. These are ceilings; the agent asks fewer when fewer matter. The depth is kept in the spec, and `agengo spec .agengo/spec.yaml --depth …` changes it.
- The recommended option favours results that can be checked automatically where the agents run, and `feasibility` says which part, if any, you will have to check by hand.
- `agengo spec .agengo/spec.yaml` shows the spec without calling the agent; `--json` prints the open questions and readiness for scripts and agents.
- `--approve` requires: no open high-impact question, at least one P1 story, a scenario for every story, a requirement for every P1 story, a success criterion, a non-empty `out_of_scope`, and a stated problem and actors. It stores `approved: {digest, at}`; any later edit makes the digest stale, and the spec shows as not approved.

The file format is [specs/spec.schema.json](../specs/spec.schema.json). The design is in [docs/design/spec-stage.md](design/spec-stage.md).

### Planning from a spec

```sh
agengo plan --spec .agengo/spec.yaml --format yaml > .agengo/plans/p1-sales.yaml     # the P1 stories
agengo plan --spec .agengo/spec.yaml --stories P2 --format yaml > .agengo/plans/p2-sales.yaml   # or US-3,US-4
```

The planner sees only the chosen stories and their requirements, plus the success criteria, out-of-scope items, constraints, assumptions and feasibility notes. Each acceptance criterion it writes carries `refs` naming the requirements (`FR-n`) and success criteria (`SC-n`) it checks, and the plan records `spec: {path, digest, stories}`. agengo checks the plan against the spec whenever it is drafted, validated (`plan --file`), run, amended or replaced:

| Rule | Check | Result |
|---|---|---|
| C0 | The spec is approved, unchanged since, and is the version the plan was drafted from; the stories exist | error |
| C1 | Every ref names a requirement or success criterion in the spec | error |
| C2 | Every requirement of the chosen stories is in the refs of at least one acceptance criterion | error |
| C3 | A ref names a requirement of another story | warning |
| C4 | An acceptance criterion has no refs | warning |

With a spec, the planner decides technical and verification matters itself. When part of the result cannot be checked where the agents run (a Windows program built on Linux, for example), the plan checks automatically what it can and the task's goal says what you must check by hand. It asks only when the answer would change what you get or how the success criteria are judged. If a draft still has `questions`, `plan --spec` prints the draft, lists the questions on stderr with the next step, and exits with code `2`; `agengo run` refuses such a draft. Record the answer in the spec, so the approved spec stays the one place where decisions live:

```sh
agengo spec .agengo/spec.yaml --decision "Receipts are not printed"
# [SPEC] … · ready to approve
# Changed this round:
#   + out_of_scope: Printed receipts
# Command — agengo plan --spec .agengo/spec.yaml --approve-spec 3f9a2c71   (approve this version and draft the plan)

agengo plan --spec .agengo/spec.yaml --approve-spec 3f9a2c71 --format yaml > .agengo/plans/p1-sales.yaml
```

`--decision` runs one more spec round with the decision as an answer (kept under `clarifications` with a fresh `Q-n` ID), clears the approval, and lists what the round changed: each story, requirement, success criterion or assumption added (`+`), removed (`-`) or changed (`~`), and each change to the problem, actors, scope, constraints or feasibility notes. Review those lines; the agent may change more than the decision itself.

The approval code is the start of the revised spec's digest. `plan --spec S --approve-spec CODE` approves the spec and drafts the plan in one step, but only if the spec is still exactly the version that code was printed for; an edit or another round in between makes agengo refuse and ask you to review it again. `agengo spec S --approve` followed by `plan --spec S` still works. With `--json`, `agengo spec` reports `changes` and `approval_code`.

When a draft from a spec has questions, agengo keeps it in `.git/agent-flow/drafts/`. The next `plan --spec` for the same spec and stories sends the planner that draft as `previous_draft`, with the decisions recorded since, and asks it to revise the draft instead of starting over: tasks the decisions do not affect keep their IDs, scopes and checks. A complete plan removes the kept draft; one older than a week, or one that cannot be read, is ignored.

An answer that changes nothing you get can instead go to the planner directly with `--context "..."`.

A run keeps a copy of the spec, so later edits to the file do not change what its agents read. Builders and Reviewers receive `context.spec`: the requirements their task's criteria refer to (every requirement of the run's stories for the whole-branch review), all success criteria and what is out of scope. `status` shows the spec, its digest and the stories.

## Answering requests

Every request has a `Y-xx` code. `status`, `inbox` and notices print a `Command — ...` line you can copy.

| Kind | When | How to answer |
|---|---|---|
| `approval` | `run --await-approval` | `respond ID Y-xx --choice approve` (or `reject`) |
| `decision` | Review or integration limit reached; the Builder needs a choice; **an agent incident** (crash, timeout, reply that breaks the contract); final checks failed | `--choice A --note "guidance"` to retry under the current plan, or `--choice B --note "reason" --plan new-plan.yaml` to approve a new plan |
| `action` | A missing external prerequisite, for example an uninstalled check command or Claude Code not logged in | Do it, then `respond ID Y-xx --note "installed ..."` |
| `information` | The agent needs more information | `respond ID Y-xx --note "answer"` |

After answering, run `agengo resume ID`.

## Agent integration

Coding agents only use tools they know about. `agengo init` installs the agengo skill ([specs/skill/SKILL.md](../specs/skill/SKILL.md)) in two places:

| Path | Read by |
|---|---|
| `.claude/skills/agengo/SKILL.md` | Claude Code |
| `.agents/skills/agengo/SKILL.md` | Codex and other agents that load skills from `.agents/skills` |

It also adds a section between `<!-- agengo:begin -->` and `<!-- agengo:end -->` to `AGENTS.md` (created if missing) for agents that read only that file; `--no-agents-md` skips it. Re-running `init` after upgrading agengo refreshes these files; a skill there that agengo did not write is saved as `SKILL.md.bak` first. Claude Code reads `CLAUDE.md`, not `AGENTS.md`, so it learns about agengo from the skill; add `@AGENTS.md` to `CLAUDE.md` to share the section too. The skill carries the agengo version that wrote it, and `agengo doctor` warns when it is out of date. When `init` creates `.agengo/principles.md` it fills Stack and Commands from what it finds (`Cargo.toml`, `package.json`, `pyproject.toml`, `requirements.txt`, `go.mod`), marked as detected so you check it; it ends by printing the `git add` command for what it wrote. Run `agengo doctor` to check git, the repository and Claude Code before the first run. Commit them so everyone working in the repository gets them.

The skill tells the agent to use agengo for multi-task work or when the user mentions agengo or a plan, to settle a rough idea with `agengo spec` first (asking each question through the agent's multiple-choice prompt, `AskUserQuestion` in Claude Code, and leaving the answers and the approval to the user), to get the user's approval of the plan before running it, to put each `Y-xx` request to the user, and to report an agengo failure rather than building the tasks itself.

### Project principles

`agengo init` also creates `.agengo/principles.md`, a short template with four sections: **Stack**, **Commands**, **Conventions** and **Never**. Fill in what applies, in any language. agengo sends the file, without its guidance comments, to the agents that write specs (`agengo spec`) and plans (`agengo plan`), so they use your test commands and conventions instead of guessing them, and do not ask about what the file settles. While every section is empty, agengo ignores the file; it rejects one longer than 32 KiB. Re-running `init` never overwrites it. `init` also creates the empty folder `.agengo/plans/`, where each run's plan is kept as `<run-id>.yaml`. The skill offers to fill it from the repository the first time, and writes it only after you agree.

## Authentication

Claude Code and Codex use an API key from the environment ahead of the subscription you logged in with. Shells inside other agents, IDEs and CI often carry such keys, so agengo picks the login explicitly:

- `--auth subscription` (default): agengo removes `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`, `OPENAI_API_KEY`, `CODEX_API_KEY`, `GEMINI_API_KEY` and `GOOGLE_API_KEY` from the environment of every agent it starts, custom adapters included. `CLAUDE_CODE_OAUTH_TOKEN` (a subscription token from `claude setup-token`) is kept. Log in once on the machine: `claude`, then `/login`; or `codex login`.
- `--auth api`: the environment is passed through unchanged.

The mode is stored with the run, so `resume` uses the same one. Runs started before this option existed pass keys through. When an attempt fails because the login or key is missing or refused, the task waits for an `action` request explaining what to do; after logging in, run `agengo resume ID`.

## Running in a container

For untrusted code or agents, or on Windows where Claude Code has no sandbox of its own, run agengo inside a container or VM. The container is then the boundary: it holds the repository, the agents' logins and nothing else from your machine, and a firewall limits where it can send data. That covers every agent, including Codex and `agy`, and the plan commands, which `--sandbox` does not confine.

[docs/devcontainer](devcontainer/README.md) holds a sample: a `Dockerfile`, a `devcontainer.json` and a firewall script that allows only GitHub and a short list of hosts. Copy it to `.devcontainer/` and add your toolchain. Inside it, `--sandbox auto` is still worth using for the short environment it passes to agents and plan commands; Claude Code's own sandbox does not start in an unprivileged container, so `auto` says so once. A container does not make a hostile repository safe: anything inside it, including the agent logins in its volumes, is still reachable by the agent.

## Security limits

- Plan commands (`setup`, `verify`, …) run with your permissions. Only run plans you have read; `--await-approval` enforces an approval step and lists every command that will run, with a `!` on the ones that look risky.
- For Claude Code, the Builder and Reviewer run with deny rules for network tools (`curl`, `wget`, `ssh`), `sudo`, `git push`/`config`/`remote`/`worktree`, and reads of `~/.ssh`, `~/.aws` and `.env` files. These are prefix rules and can be bypassed (for example `bash -c`, or a script the agent writes), so they reduce accidents but do not replace a sandbox.
- The Builder and Reviewer can use Bash and, with `--sandbox off`, on native Windows and for `agy`, are **not sandboxed**. Worktrees separate the working directory but share `.git` with the repository, so an agent could in principle read or change refs and the state file. The checks after every attempt (HEAD, index, `owns` scope, SHA, the `af/<run>` ref) catch most deviations but do not replace a sandbox. For untrusted code or agents, run agengo inside a container or VM ([sample](devcontainer/README.md)).
- agengo's own Git commands run with hooks and `core.fsmonitor` disabled, so a hook planted by an agent never runs inside agengo. While a run executes, agengo also watches the repository's `config`, `config.worktree`, `hooks/` and `info/attributes`: if they change during an agent attempt or a check, the result is rejected and the task waits for an `action` request. Inspect the files, remove anything you did not add, then `respond` and `resume`; the files as they are then become the new baseline. Setup commands that install hooks on their own (for example husky or pre-commit) trigger this once.
- If one of your branches or tags (anything outside `af/` and `af-work/`) moves while agents are running, agengo prints a warning with the `git reflog` command to check. It does not stop the run, because you may be committing in the same repository at the same time.
- `--sandbox auto` (or `strict`) switches on Claude Code's OS sandbox for the Builder and Reviewer where it can run (bubblewrap and socat on Linux, Seatbelt on macOS, nothing on native Windows) and passes agents only a short list of environment variables instead of your whole environment. It is the default; `--sandbox off` turns it off. It also gives plan commands the same short environment, without API keys, and on Linux with `bubblewrap` runs them with a read-only file system apart from the worktree and package caches, hidden credential folders, and no network for the checks. It does not cover the Read/Edit tools or, on macOS and Windows, plan commands (`strict` then refuses to run them). See [Sandbox](reference.md#sandbox).
- Child processes inherit your full environment, including tokens, unless you use `--sandbox auto` or `strict`.
- agengo never pushes and never changes your current branch.

## Conventions

### Repository layout

```
<repo>/
├── .agengo/                       # commit this folder: it records what was decided and planned
│   ├── principles.md              # your stack, commands, conventions, and what agents must never do
│   ├── spec.yaml                  # the approved spec (default output of `agengo spec --idea`)
│   └── plans/
│       ├── .gitkeep               # keeps the folder in a fresh clone
│       ├── p1-admin.yaml          # one plan per run, named after its run ID
│       └── p2-voucher.yaml
├── .claude/skills/agengo/SKILL.md # installed by `agengo init` (Claude Code)
├── .agents/skills/agengo/SKILL.md # installed by `agengo init` (Codex and others)
├── AGENTS.md                      # gets a short agengo section
└── … your code
```

Outside the working tree:

- `.git/agent-flow/state.sqlite3`: run state, including a copy of every approved plan revision and spec. Not committed.
- `~/.cache/agengo/worktrees` (`%LOCALAPPDATA%\agengo\worktrees` on Windows, or `AGENGO_WORKTREES`): temporary worktrees, removed after delivery or by `agengo clean`.

A plan file is only the input to a run. Once a run starts, the state database keeps its own copy, so editing or overwriting the file never changes a run in progress; use `agengo amend` for that.

One spec per repository is the default. For a second, independent product line, pass `-o .agengo/specs/<name>.yaml`.

### Naming

| Thing | Convention | Example |
|---|---|---|
| Run ID | `<phase>-<scope>`, lowercase, short | `p1-admin`, `p2-voucher`, `fix-login` |
| Plan file | `.agengo/plans/<run-id>.yaml` | `.agengo/plans/p1-admin.yaml` |
| Branch | `af/<run-id>`, created by agengo | `af/p1-admin` |
| Task ID | short kebab-case noun or verb phrase, unique in the plan | `admin-login`, `voucher-api` |

Without `--id`, `agengo run` names the run after a plan file kept in `.agengo/plans/`, so the plan, the branch and `status`/`inbox`/`metrics` all use the same name. A plan elsewhere (such as a reused `plan.yaml`), or a file name that is not a valid run ID, gets a generated one. If a run with that name exists, agengo stops and suggests `resume` or `--id`.

IDs that agengo assigns are never renamed or reused: `US-n` (story), `FR-n` (requirement), `SC-n` (success criterion), `Q-n` (question), `AC-n` (acceptance criterion), `F-nn` (review finding), `Y-xx` (request for a person).

### Shaping tasks

- **One task, one reviewable change.** If a reviewer could not judge it in one sitting, split it.
- **Disjoint `owns` means parallel work.** Tasks that share a file run one after another, however many `--jobs` you allow. Code split by feature (`routers/admin.py`, `schemas/admin.py`, `tests/test_admin.py`) parallelizes; one large `main.py` that every task edits does not.
- **Shared registration goes last.** When features must be wired into a shared file (a router index, `main.py`), give that wiring its own small task that `depends` on the feature tasks.
- **Checks are real commands.** `verify` uses the project's own test commands, listed in `.agengo/principles.md`, and runs in minutes.

### Where a decision goes

| The question is about… | Record it with | Why |
|---|---|---|
| What the user gets (scope, behavior, priorities) | `agengo spec .agengo/spec.yaml --decision "…"`, review the changes it lists, then `agengo plan --spec .agengo/spec.yaml --approve-spec <code>` | The spec is the single record of product decisions (D6) |
| How to build or check it, changing nothing the user gets | `agengo plan … --context "…"` | Not the user's question; say what was decided |
| A task blocked during a run | `agengo respond`, `agengo resolve` or `agengo amend` | Recorded against the run (D7) |