Legion Flow
Legion Flow is a command-line workflow engine that lets AI coding agents (Claude Code, Codex) do real work on your repository while a human keeps authority over every decision that matters. You describe a change in a sentence; the agent drafts a spec and a plan for you to review and approve; then Legion runs each task inside a hardened Docker sandbox, verifies the result in the same tree the agent edited, and only then applies it to your checkout. Every step leaves hashed evidence and an audit trail, and nothing ships until the required gates pass and a named person says so.
Status: pre-release (version 0.0.0). Every planned feature is built and covered by tests, but the tool has been exercised on Windows 11 with Docker Desktop only, has no CI yet, and is not published to npm. Install it from source (below). Expect rough edges.
spec ──approve──▶ plan ──approve──▶ execute ──(decide)──▶ review / eval ──▶ ship ──commit──▶ shipped
human human agent in sandbox human gates human
Contents
- What it does
- Requirements
- Install
- Key ideas in five minutes
- Quick start: an agent drafts, you approve
- Let Claude Code or Codex drive
- Setting up your coding agent
- Risk tiers and gates
- Sandboxes
- More capabilities
- Configuration reference (
project.json)
- Output, exit codes, and automation
- Where state lives
- Troubleshooting
- Command reference
- Developing Legion Flow
- Further reading
- Appendix: writing specs and plans by hand (no model needed)
What it does
- Human authority gates. Specs, plans, risky changes, and releases are approved by a named decision owner. Agents can never run
approve, decide, or ship --commit.
- Sandboxed execution. By default each task runs in a hardened Docker container (
--network none, read-only root, all capabilities dropped, non-root user, pinned image). When the agent needs its model provider, an egress proxy container holds the real API key and the agent only ever sees a placeholder.
- Verify before apply. The agent edits a copy of your tree. Legion restores anything outside the task's file contract, runs your checks in that exact tree, and applies only the files that passed.
- Tri-state gates. Every gate is
satisfied, unsatisfied, or unevaluable. Missing or tampered evidence is never a pass.
- Evidence and audit. Runs, proposals, checks, tool calls, and decisions are content-addressed files. A hash-chained audit log detects any edit or removal.
- Built for host agents too. Every command speaks
--json, and a read-only MCP server lets other agents read status, plans, and memory without being able to approve anything.
Legion Flow is the third sibling of legion-cli and legion-ascended. Its command is always legion-flow (there is no legion alias), and its state lives in .legion-flow/.
Requirements
| Need | Version | Why |
|---|
| Node.js | 22.13.0 or later (tested on 24) | runtime |
| pnpm | 9.15.9 (pinned; corepack enable provides it) | building from source |
| git | any recent | cloning; optional --materialize worktree |
| Docker Desktop (or Docker Engine) | a recent version (tested with 29.x on Docker Desktop for Windows) | the default vm-docker sandbox |
| Claude Code and/or Codex CLI | optional | real agents; the built-in fake adapter needs neither |
Docker is strongly recommended. Without it you can only run on the unhardened tier, which is not a sandbox and must be confirmed on an interactive terminal.
Install
From a clone of this repository:
git clone https://github.com/9thLevelSoftware/legion-flow.git
cd legion-flow
corepack enable # makes the pinned pnpm available
pnpm install
pnpm run build
npm install -g ./packages/cli # puts `legion-flow` on your PATH (a link to this checkout)
Check it works and that your machine is ready:
legion-flow doctor
doctor checks Node, PATH collisions (a bare legion belongs to a sibling tool), Docker, the agent CLIs, images, the SQLite driver, browsers, and your project's config. Every warning or failure prints a FIX: line telling you exactly what to do.
If you prefer not to install globally, run node /path/to/legion-flow/packages/cli/dist/bin.js wherever this README says legion-flow.