loki-mode

Loki 10 engine guide

Default: Loki 10 engine for loki start, loki "<task>", loki owner/repo#N and loki quick "<task>". loki legacy was removed in 11.0.0; the previous loop runs only on an explicit --engine legacy or LOKI_ENGINE=legacy (see Routing).

Loki 10 is the rewritten engine. Since the D48 flip it runs loki "<task>", loki owner/repo#N (issue mode) and loki quick "<task>", each printing one start line beginning Loki 10 engine, then the summary below. loki start <issue ref | issue URL | "multi-word task"> takes the same v10 path as loki <ref>. loki keys and loki verify --pubkey always run on Loki 10. Bare loki verify follows the newest run: when the newest entry in .loki/runs/ is a v10 run newer than the newest legacy proof it runs the v10 verify, otherwise the legacy verify. If bun is missing or LOKI_PROVIDER is unsupported, the default mode falls back to the bash path and prints one stderr line saying why. In 11.0.0 (LEGACY-ZERO W1-01) loki legacy was removed (it exits 2 with a removal message). From 11.4.0 --engine legacy|engine10 and LOKI_ENGINE select the engine explicitly (see Routing below).

Routing

Argument order and input form never change the engine. Flags are normalized before the routing decision, so these all run on Loki 10:

loki start prd.md              loki start --no-pr prd.md
loki start owner/repo#123      loki start --provider opencode owner/repo#123
loki start "fix the login bug" loki start --no-pr "fix the login bug"
loki start fixit               loki quick -v "fix the login bug"

A PRD file, an issue ref or URL, a multi-word task and a one-word brief take the same path. -v means --verbose, --budget and --budget-limit mean --max-cost, and --yes, -y, --no-plan, --no-mirofish and --no-dashboard are accepted and ignored. A PRD file path that does not exist exits 2 with “PRD file not found”.

Inside a git repository, loki start and loki quick with no task resume an interrupted run when there is one; otherwise they print the loki "<goal>" usage and exit 64. A bare loki start takes LOKI_PRD_FILE as its PRD, and outside a repository it shows the offline sample receipt. loki demo and loki quickstart build with loki start <prd>, so they run Loki 10 too; in an empty folder they create the repository first.

A flag Loki 10 does not support (for example --simple, --parallel, --github, --sandbox, --max-iterations) is refused with exit 2 and a line naming its replacement. A provider other than claude or opencode, or a machine with no working bun, also exits 2 with the fix. The removed providers (codex, cline, aider, gemini) exit 2 with one line, from --provider or LOKI_PROVIDER, for every command:

loki: provider 'codex' is no longer supported. Supported providers: claude (Claude Code CLI, or an Anthropic API key through the Agent SDK) and opencode (any model, including OpenRouter via OPENROUTER_API_KEY). Switch with --provider claude or --provider opencode, or unset LOKI_PROVIDER.

The previous loop (autonomy/run.sh) runs only when you pass --engine legacy or set LOKI_ENGINE=legacy (the flag wins over the variable), or when the PRD is larger than 100000 bytes (one stderr line says why).

loki <word> with a single bare word stays the command namespace (loki doctor), so use loki start <word> for a one-word brief. A first argument starting with - followed by a multi-word task or an issue ref (loki --no-pr "fix it now") runs on Loki 10 like the positional form.

See the route without running

loki route start prd.md
loki route quick "fix the login redirect loop" --json
loki start --simple prd.md --explain-route

loki route [start|quick] <same args> and --explain-route on start or quick print the engine, provider, model, input type and the reason, then exit 0 without running anything. --json prints one JSON object with the keys engine, provider, model, input_type, input, reason.

Some pieces named in this guide are still being built. Each one below says so plainly instead of describing a finished feature.

Quickstart

loki start is the primary path. Give it a PRD file, an issue ref, a task in quotes or a one-word brief. Flags may come before or after it; the engine is the same (see Routing).

loki start prd.md
loki start "fix the login redirect loop" --no-pr

loki "<task>" and loki owner/repo#N are shorthand for the same run. loki chat is an interactive alternative that can start and join these runs (see Chat below).

The Wall session (a separate model session that writes acceptance tests from the task alone) is off by default: in the 2026-11-05 measurement it raised the cost per merge-ready change and lowered the merge-ready count. LOKI_E10_WALL=1 turns it back on. With it off, a run reads VERIFIED only on evidence the harness produced itself: your repo’s own tests all pass, a test exercises the changed code, no existing test was weakened, and nothing regressed. A test the run wrote or edited counts as that exercise only when the harness shows it fails on the base commit and passes on the change (the receipt’s proof line names the file); otherwise the run reads PARTIAL and NOT PROVEN says “no test shown to fail on the base commit and pass on the change”.

loki quick "<task>" is the small-task entry. It runs the same engine without opening a pull request (the legacy quick never opened one), and the engine’s own sizing picks the lean path for a small task: Plan and Wall are skipped and implement runs on your run’s own model, like a raw session. LOKI_E10_CASCADE=1 opts in to the cheaper sonnet start (it prints and records the downgrade); a repeated test failure always escalates up, never down (Engine Law L1). LOKI_ROUTER=auto (also set by --haiku and --cost lean) is the router’s auto preset (Engine Law L1, as amended 2026-11-01, allows Haiku as the executor when asked for): Haiku runs implement and fix, Opus writes the plan of a hard task (judged from the task, never the repo size: sized large, or a task naming more than 4 distinct non-test files), the Opus advisor tool is attached to a fix round on Haiku or Sonnet (never to an Opus session), a Haiku implement that claims the work is already done with no diff climbs one rung, the Wall test author (with its re-author, the already-done check and the Wall referee) runs on the executor unless LOKI_E10_WALL_TIER or a model pin is set, and a code-owned failure, a stall or a spec conflict climbs the router’s ladder (Sonnet, then Opus). The start line names the downgrade and the route; the receipt’s route block records the executor and every climb. LOKI_ROUTER_EXECUTOR picks another executor; LOKI_ALLOW_HAIKU=false makes it Sonnet. Every Haiku session (router on or off) carries a 100K autoCompactWindow, which keeps requests under Haiku’s 100K price cliff. This overrides a user’s or project’s own autoCompactWindow on Haiku sessions; a CLAUDE_CODE_AUTO_COMPACT_WINDOW set in the environment wins over it. Sonnet and Opus sessions are not touched. loki quick --help prints the help; loki quick -v "<task>" runs on Loki 10 with --verbose.

loki quick "fix the login redirect loop"

If bun is not installed, or LOKI_PROVIDER names a provider the v10 engine has no invoker for (anything but claude or opencode), these entry points exit 2 with the fix; a removed provider (codex, cline, aider, gemini) prints the migration line above.

Issue refs work the same way:

loki owner/repo#123
loki https://github.com/owner/repo/issues/123
loki "fix #123"
loki "#123"
loki "<issue URL as copied, with ?query or #comment>"
loki https://github.com/o/r/pull/5       # verify-pr

A GitHub issue ref works from any folder. When the folder is not a checkout of that repository, Loki clones it under ~/.loki/checkouts and says so; your own folders are not touched.

A pasted goal that names one issue is read as that issue: a copied URL loses a trailing slash, ?query or #fragment, and “#123”, “fix #123” or “fix issue 123” becomes owner/repo#123 from the checkout’s origin (“#N” needs a GitHub origin; quote it, since an unquoted # starts a shell comment). Loki prints a goal: line when it read a ref. Extra words (“fix #123 and add a test”) keep the goal as text, and LOKI_GOAL_REF=0 turns the reading off. The run itself asks nothing: headless intake records its assumptions in the receipt, and no rating prompt follows a VERIFIED run. Models and –deep are not auto-picked yet.

bin/loki routes GitHub, GitLab (.../-/issues/N) and Jira (.../browse/KEY) issue URLs to the v10 engine, and the issue-fetch step (autonomy/issue-providers.sh) fetches title/body/labels from all three. Only the extra already-done check (an issue’s state and whether it was closed by a merged PR) is GitHub-only; a GitLab or Jira issue still runs, just without that extra signal.

The task the agent works from is the issue’s title and description plus an “Issue tracker context” section: the labels, and the comments of people the repo trusts. On GitHub that is comments by an OWNER, MEMBER or COLLABORATOR (the same rule /loki and comment steering use), never a bot, Loki’s own comments or a hidden comment. Other comments are counted in issue.json (comments_excluded) and never quoted. Comments are capped at 16 KB, newest kept. The whole task stays quoted as untrusted data in every brief. Jira and Linear trust is set in docs/trackers.md.

Flags, from the engine’s own --help:

--no-pr, --deep and --provider are parsed by the supervisor (loki-ts/src/engine10/supervisor.ts) and take effect on a real run.

loki status, loki verify and loki dashboard are all built on main and route through cli.ts’s table like any other subcommand.

The free-text and issue-ref run itself (the supervisor that plans, builds and verifies) is wired into the CLI on main: loki "<task>" and `loki

` run the full worker flow (intake, plan, wall, implement, verify, seal) and then, in the supervisor, the pr stage, ending in the 5-line summary below. Slack is not part of the v10 engine surface (no command, no notification hook) and is in progress, tracked with the other wave 3 items. ## Small changes: loki edit `loki edit` is the lightest path: one Claude pass on the current repo with no PRD, plan, council, PR, receipt or branch switch. It prints the diff stat, the diff, and one line with cost and elapsed time. ``` loki edit "rename fooBar to foo_bar" loki edit src/foo.ts "rename X to Y" loki edit --verify --commit src/a.ts "add null checks" loki edit --dry-run "describe the change" ``` - `--verify` runs the fast verifier on the result. - `--receipt` writes an unsigned receipt to `.loki/edit-receipts/`. - `--commit` commits only the files the pass touched, by name; skipped when verify failed. - `--dry-run` plans only (plan permission mode); nothing changes. - `LOKI_EDIT_MODEL` overrides the model. Claude provider only for now. Use `loki edit` for a single pass, `loki quick ""` for a small task with a verify loop, and `loki start` for anything that needs a plan, verification and a sealed receipt. Exit codes: 0 done, 1 provider or verify failure, 2 usage or setup error ([exit-codes.md](/loki-mode/docs/exit-codes.html)). ## Custom agents Define child agents as markdown with YAML frontmatter in `.loki/agents/.md` (project) or `~/.config/loki/agents/.md` (user). A project agent wins over a user agent of the same name. The body is the system prompt. Frontmatter keys: `name` (must equal the file name without `.md`), `description` (required), `model`, `provider` (`claude` by default, or `opencode`), `tools` (allow list), `deny` (deny list) and `permission` (`plan` default, `edit` or `full`). ``` loki agents list loki agents new reviewer # reviewer, planner and tester copy shipped examples loki agents show reviewer loki agents export --claude # writes .claude/agents/ (add --user for ~/.claude/agents) ``` `permission: plan` exports as Claude Code `disallowedTools` Edit, Write, NotebookEdit and Bash. Council reviewers pick up a matching agent: one named `reviewer`, `tester` or `security` replaces the council-v2 reviewer prompt and model for the matching roles (`code_quality_reviewer` and `requirements_verifier` use `reviewer`; `test_auditor` uses `tester`; `devils_advocate` uses `security`, then `reviewer`). With no agents configured nothing changes. `loki agent` (singular) is the unchanged built-in agent-type command. ## Chat (interactive alternative) `loki start` stays the primary path. `loki chat` is an interactive session for exploring and small steps, and it hands off to and from `loki start`. - Start with `loki chat` (needs a TTY; for one-shot tasks use `loki quick`). Bare `loki` does not open chat. - The session starts in Plan mode (read-only); `/plan` and `/build` switch modes and the prompt shows `loki[plan]>` or `loki[build]>`. Plan mode is enforced for Claude (`--permission-mode plan`); other providers get a prompt-level read-only instruction. - Slash commands: `/plan`, `/build`, `/run <prd|brief>`, `/quick `, `/edit `, `/verify`, `/receipt`, `/cost`, `/diff`, `/undo`, `/model `, `/provider `, `/help`, `/exit`. - `/run` starts a normal `loki start` run with the chat's model and provider. - `loki chat --attach` joins a running or the last `loki start` session, with `/status`, `/steer`, `/diff`, `/verify`, `/receipt` and `/stop`. - `loki chat --tui` launches the full Claude Code TUI with the Loki system prompt appended. ## Setup, doctor and config ``` loki setup # wizard: tools, Claude login, provider, model route, spend cap loki setup --yes # non-interactive defaults loki setup --check # report only loki doctor --fix # create state dirs and a default config; prints exact commands for the rest loki config list # also: get , set , path ``` `loki setup` flags: `--provider claude|opencode`, `--model`, `--budget USD` and `--global`. `loki doctor --fix` never installs system packages and never runs sudo. Prerequisites are in [INSTALLATION.md](/loki-mode/docs/INSTALLATION.html). ## Exit codes One contract, enforced from 11.4.0: [exit-codes.md](/loki-mode/docs/exit-codes.html) lists the per-command codes, including `loki verify`. CI gates should use `loki verify || fail`, not `[ $rc -eq 1 ]`, and treat any code of 2 or higher as worse than CONCERNS. This is a breaking change for scripts that tested rc==1 on an empty diff or a non-git directory. ## The summary Every run on both engines also ends with one unified block: `Result:` (verified, done-unverified, failed or stopped), `Files:` (N changed, +ins -del), `Cost:` (`$X.XX`, marked `(estimated)` when not provider-reported, `not measured` when unknown), `Elapsed:`, `Receipt:` (path, when one exists) and one `next:` line naming the suggested command (`loki diff`, `loki verify`, `loki undo`, `loki status`, `loki doctor`, or `loki chat --attach`). Pass `--quiet` to print only this block and `--json` to add a `summary` object to the JSON output. `NO_COLOR=1` disables color, which is also off when stdout is not a TTY. On the previous loop, `LOKI_SUMMARY_JSON=1` prints the summary as one JSON line, and its cost is always an estimate from the context tracker. A finished engine10 run prints the start line, then one label per line (Outcome, PR, Receipt, NOT PROVEN, Cost, Time; a Reason line is added for any outcome other than VERIFIED or ALREADY_SATISFIED). The quiet default stays within 8 lines. The block below is the older 5-line form; the labels are the same: ``` PR: https://github.com/owner/repo/pull/1 Verdict: VERIFIED NOT PROVEN: full suite, app boot, security scan Cost: $0.42 (claude, 212k tokens) Time: 4m12s (intake 11s, plan 20s, implement 3m10s, verify 31s) ``` - **PR**: the opened pull request URL, or `none` when the run used `--no-pr` or never got that far. A draft PR adds the draft reason in parentheses. The PR body is reviewable in 60 seconds (note: the INTEL-3 `renderPrBody` renderer, a 60-line reviewer-first layout, exists but is not yet wired into the live PR stage, which still uses `renderReviewerBody`). It leads with what the issue asked, then what changed and why, how it was tested, NOT PROVEN, and the receipt digest with the `loki verify` command. A field the run did not record reads "not recorded", never a number: ``` ## What the issue asked - handles empty input - rejects bad tokens ## What changed and why - Why: Fix the parser - src/parser.ts - tests/parser.test.ts ## How it was tested - Verdict: VERIFIED - Checks: 2 passed, 0 failed, 0 not run, 0 flaky (4 individual tests counted) - Command: `bun test tests/parser.test.ts` -> pass - Target tests (written before the fix): parser.test.ts - Before the fix: 2 failing, 0 passing on base; after: pass ## NOT PROVEN - none ## Receipt - Digest: sha256:ab12... (signed) - Verify: `loki verify run-1` ``` - **Verdict**: one of VERIFIED, PARTIAL, ALREADY_SATISFIED, SPEC_CONFLICT or FAILED. - **NOT PROVEN**: everything the run did not check, comma-joined. Never empty by omission: a check that was skipped or deferred is always listed here, not silently dropped. A flaky test found during verify appears as a separate `; flaky ...` clause on the same line. - **Cost**: the provider-reported dollar figure and token count. When the provider does not report cost, this line reads `not measured` instead of `$0.00`; a missing cost is never rendered as free. The one exception is the CLI invoker (LOKI_E10_INVOKER=cli, which the first-run gate's stub uses): it has no dollar figure to report, so the run records 0 with the source marker `cli-invoker-unmetered` in the cost event, the receipt (`cost.source`) and the efficiency record, shows `$0.00 (...; CLI invoker records no cost)`, and adds `cost unmetered (CLI invoker; recorded as 0)` to NOT PROVEN. The cost fields are never null on such a run. - **Time**: total wall time, then each stage's own duration in parentheses. This formatter (`loki-ts/src/engine10/output.ts`, `formatSummary`) is called by the supervisor at the end of every run, so a real `loki ""` or `loki ` run prints this block on completion. The block above is that function's real output, not a mockup. ## Triggers without a cloud Both run on your own GitHub Actions minutes; there is no hosted service. - Label an issue, get a pull request. Save this as `.github/workflows/loki.yml` in your repository: ```yaml name: Loki on: issues: types: [labeled] jobs: loki: permissions: contents: write pull-requests: write issues: write uses: asklokesh/loki-mode/.github/workflows/loki-issue-to-pr.yml@v11.199.0 with: version: '11.199.0' secrets: ANTHROPIC_API_KEY: $ ``` Then, once per repository: add the `ANTHROPIC_API_KEY` secret (Settings > Secrets and variables > Actions), turn on "Allow GitHub Actions to create and approve pull requests" (Settings > Actions > General > Workflow permissions; it is off by default on a new repository), and create a label named `loki`. Put that label on an issue. Loki runs `loki owner/repo#N --no-pr` and you get: - one pull request for the issue, on a branch `loki/issue---`, whose body is the evidence receipt. The title carries the result when it is not VERIFIED, and only a VERIFIED result says "Resolves #N". A large issue that Loki splits into slices gets no pull request from this workflow: the comment lists the slices and their results and says that no single pull request was opened. - one comment on the issue: the result label (VERIFIED, PARTIAL, ...), how many checks passed outside the model and how many items are not proven, the cost, the receipt digest and the link to the pull request and the run log. - if the secret or the setting is missing, the same comment says which one and where to set it. The job must grant the three permissions above: a called workflow cannot raise them. Put the label on again (remove it, add it back) to run again: the new run opens a new pull request on a new branch, and its body and the comment link the earlier open Loki pull request for you to close. Loki never closes, edits or deletes a pull request or branch. The comment is edited in place. The agent job holds a read-only token; a separate job that runs no agent applies its patch and opens the pull request. A change that touches `.github/workflows/` cannot be pushed with the workflow token; the comment says so. GitHub documents that events made with the workflow token do not start other workflows, so a pull request this workflow opens does not start your `pull_request` CI by itself. Keep the tag (`@v`) and `with: version:` (the loki-mode npm version, an exact release) the same; `with: label:` changes the label. The workflow is checked offline (its own scripts against a local mirror with a stub model and a stub `gh`); it has not yet been run on GitHub. [docs/examples/loki-issue-to-pr.yml.example](/loki-mode/docs/examples/loki-issue-to-pr.yml.example) adds the `/loki` comment trigger, a manual trigger and the `/loki fix`, `/loki explain` and `/loki reseal` pull request commands. - Nightly: add a workflow in `.github/workflows/`. Its `schedule:` trigger runs `loki start owner/repo --label loki`, one run and one pull request per labelled open issue: ```yaml on: schedule: - cron: '17 3 * * *' # nightly, 03:17 UTC # ... - run: loki start "${GITHUB_REPOSITORY}" --label loki ``` `loki start owner/repo --label