# System overview

Koi is a set of tools that keep a long engineering change in the repository instead of in a chat. This page names each part, says what it owns, and shows how the parts meet.

## The problem Koi solves

A coding agent forgets everything when its chat ends. A change that takes twenty sessions, such as a framework migration, needs somewhere to keep the plan, the decisions, and the position reached so far. Koi keeps all of that in files under `.koi/` in your repository. Any agent, in any session, can read those files and carry on. That is what lets a run go on unattended, phase after phase.

## The parts

Koi is the name of the whole system, of the `.koi/` folder convention, and of the `koi` command that installs and checks everything. The work is done by five parts.

| Part | What it is | What it owns |
| --- | --- | --- |
| koi | A Rust program, the `koi` binary, from `koi-installer.sh` | Installing the skills and `yokai` at one version (`koi setup`), updates (`koi update`), diagnostics (`koi doctor`), and the board commands Junji and Yokai's turns call (`koi board status`, `koi board move`) |
| Junji | A skill you install into your coding agent with `koi setup` | The method: the twelve verbs, the plan, the board, the notes, the verification commands in `CONTEXT.md` |
| Yokai | A Rust program, the `yokai` binary | Unattended execution: picking the next phase, running it through an agent, checking the result on disk, recovery, the cockpit |
| Tori | A Rust library inside Yokai | The connection to the agent over the Agent Client Protocol (ACP), one turn at a time |
| The agent | Claude Code, Codex, Cursor CLI or OpenCode | Reading code, editing files, running commands, committing |

You can use Junji alone. You type `/junji next` in your agent and it runs one phase while you watch. Yokai is optional. It reads the same files and runs the phases for you, with a second agent turn reviewing each change and scripts on disk deciding whether it passed.

All of it lives in one repository, [getkoi/koi](https://github.com/getkoi/koi): the skills in `skills/`, Yokai and Tori in `crates/`, this site in `site/` and the decision records in `docs/adr/`. A release has one version and one tag, so koi 1.0.0, Yokai 1.0.0 and the 1.0.0 skills come from the same commit. `koi` and `yokai` ship as binaries, next to a `koi-skills.tar.gz` archive that `koi setup` copies the skills from; `koi board` and Yokai share one board implementation.

<figure class="diagram" aria-labelledby="dg-system-caption">
<figcaption id="dg-system-caption">Two ways to drive the same files</figcaption>
<div class="diagram-frame" tabindex="0" role="region" aria-labelledby="dg-system-caption">
<svg viewBox="0 0 560 376" width="560" height="376" role="img" aria-labelledby="dg-system-title dg-system-desc">
<title id="dg-system-title">How Junji, Yokai, Tori and the coding agent connect</title>
<desc id="dg-system-desc">You type Junji verbs into your coding agent, which loads the Junji skill. Yokai can drive the same agent instead: Yokai sends turns through Tori, and Tori talks to the agent over ACP. In both cases the agent edits code and commits to the repository, moves board cards in BOARD.json through the koi CLI, and Yokai reads and verifies the repository after each phase.</desc>
<defs><marker id="dg-system-head" viewBox="0 0 8 8" refX="7" refY="4" markerWidth="8" markerHeight="8" markerUnits="userSpaceOnUse" orient="auto-start-reverse"><path class="dg-head" d="M0 0 8 4 0 8z"/></marker></defs>
<rect class="dg-box" x="0" y="24" width="160" height="48" rx="4"/>
<text class="dg-label" x="80" y="48">You</text>
<path class="dg-line" d="M80 76V116" marker-end="url(#dg-system-head)"/>
<text class="dg-note is-start" x="96" y="96">/junji verbs</text>
<rect class="dg-box" x="0" y="120" width="160" height="48" rx="4"/>
<text class="dg-label" x="80" y="144">Junji skill</text>
<path class="dg-line" d="M164 144H196" marker-end="url(#dg-system-head)"/>
<rect class="dg-box" x="200" y="120" width="160" height="48" rx="4"/>
<text class="dg-label" x="280" y="144">Coding agent</text>
<path class="dg-line" d="M364 144H396" marker-start="url(#dg-system-head)" marker-end="url(#dg-system-head)"/>
<rect class="dg-box" x="400" y="120" width="160" height="48" rx="4"/>
<text class="dg-label" x="480" y="144">Tori · ACP</text>
<path class="dg-line" d="M480 212V172" marker-start="url(#dg-system-head)" marker-end="url(#dg-system-head)"/>
<text class="dg-note is-end" x="464" y="192">turns, events</text>
<rect class="dg-box" x="400" y="216" width="160" height="48" rx="4"/>
<text class="dg-label" x="480" y="240">Yokai supervisor</text>
<path class="dg-line" d="M280 172V308" marker-end="url(#dg-system-head)"/>
<text class="dg-note is-end" x="264" y="240">edits, commits</text>
<path class="dg-line" d="M480 308V268" marker-end="url(#dg-system-head)"/>
<text class="dg-note is-end" x="464" y="288">reads, verifies</text>
<path class="dg-line" d="M216 172V192H72V212" marker-end="url(#dg-system-head)"/>
<rect class="dg-box" x="0" y="216" width="144" height="48" rx="4"/>
<text class="dg-label" x="72" y="240">koi CLI</text>
<path class="dg-line" d="M72 268V308" marker-end="url(#dg-system-head)"/>
<text class="dg-note is-start" x="88" y="288">BOARD.json</text>
<rect class="dg-box is-solid" x="0" y="312" width="560" height="48" rx="4"/>
<text class="dg-label is-reverse" x="280" y="336">Repository: code, .koi/, Git history</text>
</svg>
</div>
</figure>

The repository is the only thing the parts share. Junji never calls Yokai and Yokai never calls Junji. Both move board cards through the same code, `koi board` for agents and Yokai's built-in copy of it. Yokai does not even need the Junji skill installed: it reads `.koi/run/BOARD.json`, the phase plans and `CONTEXT.md` as plain files. That is why you can plan in one agent on your laptop and run phases with Yokai on another machine.

## Who writes what

Each file has one owner. This keeps two tools from fighting over the same field.

- Junji writes the method documents: `PLAN.md` or `PLAN.html`, `CONTEXT.md`, `METHOD.md`, `BOARD.json`, `NOTES.md` and `phases/`.
- Yokai writes its own settings (`.koi/yokai.yml`), the reviewed sensor scripts in `.koi/sensors/`, and its run records (`ledger.jsonl`, `sessions.jsonl`, `FEEDBACK.md`, `saves/`).
- Yokai also updates the board while it runs a phase. It changes a card's `status` and, after a human approves it, the card's `yokai` object with the model tier. Junji keeps that object intact when it edits the card.
- The agent writes product code and commits it.

[What lives in .koi/](/en/docs/architecture/files) lists every file.

## A project from start to finish

1. `/junji begin` creates `.koi/run/` and records what the repository already has: languages, test commands, skills.
2. `/junji plan` agrees on the change with you and writes the verification commands every phase must pass.
3. `/junji refine` splits the plan into phases, stored as cards in `BOARD.json`.
4. Each phase runs through `/junji next` in your agent, or through `yokai`. Either way the phase ends with passing checks and a commit.
5. `/junji consolidate` turns the run into one document in your repository's spec folder and deletes `.koi/run/`. Settings and sensors in `.koi/` stay for the next change.

[Work across sessions](/en/docs/architecture/sessions) follows this path in detail.

## Read next

- [Work across sessions](/en/docs/architecture/sessions): what each new session reads, and how a card moves through its states.
- [How Yokai runs a phase](/en/docs/architecture/phases): Plan, Build and Seal, and the check that closes a phase.
- [Verification on disk](/en/docs/architecture/verification): why Yokai ignores what the agent says about its own work.
