# What lives in .koi/

.koi/ holds settings you reuse from one change to the next. .koi/run/ holds one change in progress and is deleted when you consolidate. This page lists every file, who writes it and when it goes away.

## Two folders, two lifetimes

Koi uses one fixed folder at the repository root. It has two parts with different lifetimes.

- `.koi/` is the project home. It keeps what does not change between efforts: Yokai's settings, the reviewed sensor scripts and the sandbox image recipe. It survives `consolidate`.
- `.koi/run/` is the working folder for one effort. It holds the plan, the board and every record of the run. `/junji consolidate` deletes all of it, with `git rm -r .koi/run/`, in the same commit that adds the final document.

Both folders are committed to Git on purpose. Every phase starts by reading them, so a run can continue in any session, with any agent, on any machine.

<figure class="diagram" aria-labelledby="dg-files-caption">
<figcaption id="dg-files-caption">What stays and what goes</figcaption>
<div class="diagram-frame" tabindex="0" role="region" aria-labelledby="dg-files-caption">
<svg viewBox="0 0 560 344" width="560" height="344" role="img" aria-labelledby="dg-files-title dg-files-desc">
<title id="dg-files-title">The project home contains the working folder</title>
<desc id="dg-files-desc">The .koi/ project home is kept between efforts. It holds yokai.yml, the sensors folder and Dockerfile.sandbox. Inside it, the run/ working folder is removed by consolidate. The working folder holds CONTEXT.md and the plan, BOARD.json with NOTES.md and the phases folder, and Yokai's ledger and session records.</desc>
<rect class="dg-box is-group" x="0" y="8" width="560" height="320" rx="4"/>
<text class="dg-note is-start" x="16" y="32">.koi/ · project home, kept</text>
<rect class="dg-box" x="16" y="88" width="200" height="48" rx="4"/>
<text class="dg-label" x="116" y="112">yokai.yml</text>
<rect class="dg-box" x="16" y="168" width="200" height="48" rx="4"/>
<text class="dg-label" x="116" y="192">sensors/*.sh</text>
<rect class="dg-box" x="16" y="248" width="200" height="48" rx="4"/>
<text class="dg-label" x="116" y="272">Dockerfile.sandbox</text>
<rect class="dg-box is-group" x="248" y="48" width="296" height="264" rx="4"/>
<text class="dg-note is-start" x="264" y="72">run/ · removed by consolidate</text>
<rect class="dg-box" x="264" y="88" width="264" height="48" rx="4"/>
<text class="dg-label" x="396" y="112">CONTEXT.md · PLAN.md</text>
<rect class="dg-box" x="264" y="168" width="264" height="48" rx="4"/>
<text class="dg-label" x="396" y="192">BOARD.json · NOTES.md · phases/</text>
<rect class="dg-box" x="264" y="248" width="264" height="48" rx="4"/>
<text class="dg-label" x="396" y="272">ledger.jsonl · sessions.jsonl</text>
</svg>
</div>
</figure>

## The full layout

```text
.koi/
  yokai.yml               Yokai settings, sandbox settings, gate review fingerprints
  sensors/*.sh            reviewed check scripts (optional for Junji)
  Dockerfile.sandbox      image recipe for sandbox mode (optional)
  sandbox-setup.sh        runs once in each new sandbox (optional)
  run/
    CONTEXT.md            binding facts, skills, verification bar, standing overrides
    PLAN.md or PLAN.html  the plan: problem, approach, decisions and why
    DESIGN.md             visual contract, if you used /junji design
    METHOD.md             per-phase protocol, copied from the Junji templates
    BOARD.json            nextAction and the ordered phase cards
    NOTES.md              carry-forward decisions
    phases/               one plan per phase, with an Outcome section once done
    researches/           notes from /junji research
    designs/              notes from /junji design
    reviews/              notes from /junji review
    yokai.yml             Yokai settings for this effort only
    ledger.jsonl          one row per phase run: cost, gate result, commits
    sessions.jsonl        one row per agent turn
    FEEDBACK.md           sensor and judge findings during Build
    RECOVERY.md, saves/   recovery index and episodes
    live-session.json     handle to the agent session in flight
    session-reuse/        session handles for token savings
```

Files marked optional appear only when you use the feature. A run made with Junji alone has no `yokai.yml`, no ledger and no sensors.

## Who writes each file

| File | Written by | When |
| --- | --- | --- |
| `CONTEXT.md` | Junji `begin` (observed facts), `plan` and `grill` (decisions) | Start of the effort, and when a decision changes |
| `PLAN.md` / `PLAN.html` | Junji `plan`, `grill`, `iterate` | Planning |
| `METHOD.md` | Junji `begin` copies it | Once |
| `BOARD.json` | Junji `refine`, `next`, `review`, `iterate`; Yokai during each act | Every phase |
| `NOTES.md`, `phases/` | Junji `next`, or the agent in Yokai's Plan and Seal turns | Every phase |
| `.koi/yokai.yml`, `sensors/` | Yokai setup, or the optional `/yokai` helper skill, after you approve | Setup |
| `.koi/run/yokai.yml` | You, Yokai setup | When one effort needs different settings |
| `ledger.jsonl`, `sessions.jsonl`, `FEEDBACK.md`, `saves/` | Yokai only | During a run |

Yokai is the only writer of `FEEDBACK.md`. The agent reads it but never edits it.

## Where the model tier lives

On a JSON board, a reviewed model tier sits on the card under the optional `yokai` key:

```json
{
  "id": "P2",
  "title": "Persist tasks in localStorage",
  "status": "todo",
  "description": "...",
  "yokai": { "model-tier": "high", "reason": "Recovery touches shared state and reload behavior." }
}
```

Junji never reads this object but preserves it on every edit. Older Markdown runs keep the same choice under `phases.P2.tier` and `phases.P2.reason` in `.koi/run/yokai.yml`. See [Model tiers](/en/docs/architecture/models).

## What consolidate keeps

After `/junji consolidate`, the repository has one new document (for example `specs/daylist.md`, in the location `CONTEXT.md` recorded) and no `.koi/run/`. The ledger, the session records, the phase assessments and the effort settings are gone from the tree. Git history still has them. Copy `ledger.jsonl` first if you want cost records outside Git.

The next effort starts with `/junji begin`. It inherits `.koi/yokai.yml`, the sensors and the sandbox recipe, needs fresh phase assessments, and starts new cost accounting.

## What can go wrong

- `phases/`, `PLAN.md` or `CONTEXT.md` appear at the repository root or directly in `.koi/`. Paths are always `.koi/run/...`. Move them and tell the agent.
- `.koi/` is in `.gitignore`. Remove the entry. A run that is not committed cannot continue in another session or on another machine.
- Both `BOARD.json` and `BACKLOG.md` exist. Keep the one the run actually uses and delete the other.
- `consolidate` ran by accident during an unattended run. Restore `.koi/run/` from Git. `METHOD.md` forbids consolidating without a human.
