UNPKG

akm-cli

Version:

akm (Agent Knowledge Manager) — a portable, local-first capability library for AI agents. Discover, load, share, and improve reusable skills, scripts, workflows, and knowledge across any shell-capable coding agent, including Claude Code, OpenCode, and Cur

1,439 lines • 100 kB
# Configuration

AKM reads one user configuration file: `$XDG_CONFIG_HOME/akm/config.json`
(normally `~/.config/akm/config.json` on Linux and macOS, or
`%APPDATA%\akm\config.json` on Windows). Set `AKM_CONFIG_DIR` to override the
directory. `akm --config <file> <command>` selects a particular file, ahead of
`AKM_CONFIG_FILE`, which in turn takes precedence over the directory rules.
Relative file paths resolve from the invoking directory; an empty `AKM_CONFIG_FILE` is warned about once and ignored, and an empty `--config` fails. `credentials.json` and `models.json` always live in the config directory (`AKM_CONFIG_DIR`, else the platform default), never beside a selected file.
Without either selector all existing directory overrides and defaults are
unchanged. A missing file uses the existing defaults and can be created by setup
or configuration writes. Project `.akm/config.json` files are not merged. A config file may
optionally extend one other config via `extends` (Deprecated, removed in 0.11; see
"Sharing configuration across installs" below) — this is a single, explicit,
user-opted-in key, not automatic project-config discovery.

## Version 0.9

`configVersion` is `"0.9.0"`, the only value akm has ever shipped. It is
read, never gated on: a file without the field loads silently, and a file
declaring any other value is named once on stderr (`config.json declares
configVersion "X"; this release reads it as 0.9.0.`) and read as the
current shape anyway — nothing is rewritten on disk. The next config write
(`akm config set`, etc.) and `akm migrate apply`'s config step both persist
`"0.9.0"`, which silences the note. When a newer akm wrote the shared
config, `akm doctor`'s `binary-config-skew` advisory is what says so. Pre-0.9
config and database layouts are not runtime inputs. Historical task sources
are handled by the standalone `akm-migrate` executable, also invoked by `akm
migrate` / `akm upgrade`; ordinary runtime code reads only the current shape.

```jsonc
{
  "configVersion": "0.9.0",
  "connections": {
    "default": {
      "endpoint": "http://localhost:11434/v1",
      "models": { "fast": "qwen3-8b", "balanced": "qwen3-32b", "reasoning": "qwen3-32b" }
    }
  },
  "harnesses": { "claude": {} },
  "embedding": { "model": "nomic-embed-text" },
  "workflow": { "maxConcurrency": 8 },
  "improve": {
    "strategy": "nightly",
    "processes": {
      "memoryInference": { "model": "qwen3-8b", "llm": { "temperature": 0.1 } }
    },
    "strategies": {
      "nightly": {
        "processes": { "reflect": { "limit": 10 } }
      }
    }
  }
}
```

A config with no connection and no harness is valid: everything that needs no
model works. [Connections](#connections), [Harnesses](#harnesses) and [Where
each process runs](#where-each-process-runs) say how models are added.

## Scheduler activation

`scheduler.enabled` is this host's list of scheduled refs, such as
`stash//tasks/nightly`, held and written as plain refs. A ref that is not
listed is disabled, and removing a bundle drops its refs. The older
`{kind, ref, sourceId}` entries are read as their `ref` and written back
plain.
A config without the list (written before 0.9.17) means "keep what is
installed": the first `akm doctor scheduler sync`, `akm setup`, `akm task enable` or `akm task
disable` fills it from the akm-written native scheduler rows.
There are no grants, source identities or fire-time checks. Authored
task/workflow files may describe schedules but cannot put themselves on the
list.

This key is deliberately local: if a config uses `extends`, any `scheduler`
section in the base is ignored with a warning. Only the top-level local config
can activate schedules. Prefer `akm task enable <ref>` and `akm task disable
<ref>` over editing the JSON by hand; both update the allow-list and sync the
affected bundle. An unscoped `akm doctor scheduler sync` reconciles enabled refs across all
enabled configured bundles.

## Connections

A connection is an OpenAI-compatible endpoint akm sends model requests to, and
the models it serves. `connections` maps a name to one. A name is lowercase
kebab-case, at most 63 characters, and cannot start with `akm-`. The
connection named `default` is the default connection; a lone connection is the
default whatever it is called. `akm setup` names the first one `default`.

```jsonc
{
  "connections": {
    "default": {
      "endpoint": "http://localhost:11434/v1",
      "models": {
        "fast": "qwen3-8b",
        "balanced": "qwen3-32b",
        "reasoning": { "model": "glm-5", "reasoning_effort": "high" }
      },
      "top_p": 0.9
    }
  }
}
```

akm reads these keys of a connection:

| Key | Meaning |
| --- | --- |
| `endpoint` | Required. The OpenAI-compatible base URL (`http://localhost:11434/v1`) or the chat-completions URL itself, starting with `http://` or `https://`. Requests go to `<base>/chat/completions` and the model list is read from `<base>/models`; a query string on the URL (a gateway's `api-version`, say) stays after the path on every request, and a `#fragment` is dropped. A username or password in the URL is warned about; put the key in `apiKey` or `credentials.json`. |
| `apiKey` | A `$VAR` or `${VAR}` reference to an environment variable. Absent, the key is the one stored in `credentials.json` for the connection and its endpoint. See [Credentials](#credentials). |
| `apiKeyFile` | Retired. `akm migrate apply` leaves an engine's key file here, as written, when it cannot read the file yet; akm ignores it (never reads it or sends it) and a later `akm migrate apply` moves the key it names into `credentials.json`. |
| `models` | Alias to model. See [Aliases](#aliases). |
| `contextLength` | The model's context window in tokens. `akm improve` sizes its prompts from it (consolidate's chunks, reflect's asset content); unset, it assumes 4096. |
| `timeoutMs` | How long one call may take, in milliseconds; `null` runs unbounded. Unset, a model call stops after 600 000 (ten minutes) and agent work runs until it finishes; akm's own runtime also tells a model that keeps repeating one tool call and result, and ends the run if it goes on, but does not stop one that keeps making different calls ([Without a harness](#without-a-harness)). The ceiling is 2 147 483 647. |
| `concurrency` | How many requests a workflow `map` step may have in flight on this connection, clamped to 1–64. Unset, 1 on a loopback endpoint (a local model server runs one inference at a time) and 4 on a remote one. akm never sends it. |

Every other key, on the connection or in a model entry, is a request field in
the endpoint's own spelling and is sent with each request as written (`top_p`,
`reasoning_effort`, `chat_template_kwargs`, ...). A connection's fields apply to
all its models and a model entry's override them; an object field on both sides
(`chat_template_kwargs`) merges key by key. `model`, `messages`, `tools`,
`stream` and `response_format` are akm's, on a direct call and in akm's own
runtime alike: the resolved model, the conversation and tool state, whether the
reply streams and the response format a caller asks for are never replaced. A
connection or model entry, or an `extraParams` of a call, a process or a
workflow step, that writes one of them is ignored for that field, with one
warning (the final fields are checked, whichever layer brought it).

A transient failure (an HTTP 5xx, a dropped connection) is retried once, within
what is left of the call's timeout. A 4xx is not.

A reply that stops at the output limit (`finish_reason: "length"`) or has no
`content` is a failed call (`parse_error`), not an answer: the error says the reply was
cut at the output limit, or had no content, and names the model and endpoint (and
`reasoning_content` when the reply held some). Reasoning is never returned as the
answer, so a provider that puts its answer in `reasoning_content` fails until its
reasoning parser is set up to fill `content`. The call's usage event records
`outcome: "error"`, `errorCode: "parse_error"` and the `finishReason`.

### Settings a call asks for

A command, agent, workflow step or task can run against any endpoint, so it asks
for these in akm's words, and akm writes them as the endpoint's fields over the
connection's own:

| Setting | Request field |
| --- | --- |
| `temperature` | `temperature` |
| `maxTokens` | `max_tokens` |
| `reasoningEffort` (an asset's `effort` is the same setting) | `reasoning_effort` |
| `enableThinking` | `chat_template_kwargs.enable_thinking` and `enable_thinking` |

They are written `akm.inference` (and top-level `temperature` and `effort`) in
an asset's frontmatter, `llm:` on a workflow step (`max_tokens`,
`enable_thinking`, `reasoning_effort`), `inference` in a task, and `llm` on an
improve process, the quality gate or an index pass. Nearest wins: the asset,
then the process, then the model entry, then the connection. A connection and
akm's own runtime take all of them. A harness takes none: set them in the
program's own configuration, and akm reports each as an `untranslated-field`
notice while the call goes on.

akm sends no `max_tokens` unless one is written, on a connection, on a model
entry or by the call: the model and its endpoint know their own limits, and a
default cap would truncate replies silently. A direct chat call (model work on a
connection) does send `temperature: 0.3` when nothing writes one; the
connection's, a model entry's or the call's own `temperature` wins. akm's own
runtime sends none and leaves it to the endpoint.

`enableThinking: false` turns thinking off and `reasoningEffort` takes a value
such as `"none"`, `"low"` or `"high"`. akm sends **both** thinking fields,
because which one an endpoint honors is a fact about it and any gateway in front
of it. llama.cpp direct honors both (`reasoning_effort` from build b10644); vLLM
honors `chat_template_kwargs`; Bifrost drops `chat_template_kwargs` and passes
`reasoning_effort` through, so also set `reasoningEffort: "none"` behind it. A
strict hosted API that rejects the two fields (OpenAI answers 400 `Unknown
parameter: 'chat_template_kwargs'`) gets one retry without both, and akm stops
sending them to that endpoint and model for the rest of the process. A response
with reasoning tokens despite `enableThinking: false` triggers a runtime
warning.

Improve's `consolidate` and `reflect` always ask for thinking off, for a
machine-readable payload, and the quality-gate and triage judges do too unless
the judge's connection turns thinking on (`enable_thinking: true` as a request
field, or `llm.enableThinking: true`).

When a call asks for JSON that matches a schema, a connection receives the
schema as `response_format` (`json_schema`, strict). If the endpoint rejects it
with a 4xx other than 429, or with a 5xx that names the response format, akm
retries once without `response_format` and stops sending it to that endpoint and
model for the rest of the process. A harness receives the schema as one
instruction at the end of its prompt (`Respond with ONLY a JSON value matching
this JSON Schema (no prose, no code fences):` followed by the schema).

## Harnesses

A harness is an agent program you already have. `harnesses` maps a name to an
entry; an entry named for a platform enables it, so `{ "claude": {} }` enables
Claude Code. A second install of the same program sets `platform`: `{
"claude-work": { "platform": "claude", "bin": "/opt/claude-work/bin/claude" }
}`. The harness named `default` is the default harness; a lone harness is the
default whatever it is called. With several and none named `default`, there is no
default harness. `akm setup` names the default one `default`.

The platforms (generated from the harness registry; do not edit):

<!-- harness-table:start (generated by scripts/gen-config-schema.ts) -->
| `platform` | Harness | Binary | Session logs | Restricted model work | Native `agent` |
| --- | --- | --- | --- | --- | --- |
| `opencode` | OpenCode | `opencode` | yes | yes | yes |
| `claude` | Claude Code | `claude` | yes | yes | yes |
| `codex` | OpenAI Codex CLI | `codex` | yes | yes | no |
| `copilot` | GitHub Copilot CLI | `copilot` | no | no | no |
| `pi` | Pi | `pi` | no | no | no |
| `gemini` | Gemini CLI | `gemini` | no | no | no |
| `aider` | Aider | `aider` | no | no | no |
| `amazonq` | Amazon Q Developer CLI | `q` | no | no | no |
| `openhands` | OpenHands | `openhands` | no | no | no |
<!-- harness-table:end -->

An entry sets any of:

| Key | Meaning |
| --- | --- |
| `platform` | One of the platforms above. Absent, the entry's name must be one. |
| `bin` | The program to run. Default: the platform's binary above, looked up on `PATH`. Set it when that is not the one you mean, for example `opencode2` when OpenCode 2 installed it beside an older `opencode` that comes first on your `PATH`. |
| `args` | Arguments placed before the ones akm adds. |
| `workspace` | The directory agent work runs in. Default: the directory akm was started in. |
| `agent` | The harness's native agent to run when a request names none (`claude` and `opencode` only). A request's own agent wins, an agent asset's persona is kept, and model work runs no native agent. |
| `timeoutMs` | How long a run may take, in milliseconds; `null` runs unbounded. Unset, agent work runs until it finishes and model work stops after 600 000. |
| `models` | Alias to model name for this harness, over the map akm ships for its platform. See [Aliases](#aliases). |
| `modelWork` | `false` keeps akm's own model calls (improve, judging, extraction) off this harness when it is the default for them: with no connection to run them on, they are off. A call that names the harness (`--harness`, `improve.harness`) still runs there. Absent or `true`, the default harness takes model calls when no connection does. `akm doctor info` and `akm doctor` list a harness set this way. |

Asset frontmatter cannot set `workspace`, `environment` or opaque `runtime`
values; those belong to this configuration or to a workflow's environment
bindings.

### How akm runs a harness

What asks for a harness decides how akm runs it.

**Agent work** (`akm run` on an agent or command ref, `akm proposal new`, agent tasks and workflow agent steps) runs your program the way you would run it yourself. It gets your environment as it is, with nothing filtered out, and your configuration, plugins, settings and logins as they are. akm sets only its own variables for the run: the directories this akm resolved (`AKM_CONFIG_DIR`, `AKM_DATA_DIR`, `AKM_CACHE_DIR`, `AKM_STATE_DIR`, and `AKM_BUNDLE_DIR` when you set one), plus the absolute `AKM_CONFIG_FILE` when a file was selected, so a program that runs `akm` uses the same installation, and, when a task runs it, `AKM_EVENT_SOURCE` (unless already set), so the akm commands the program runs count as machine use, not yours. A workflow unit's or task's own `env:` bindings are set over them. A run given a directory (`--cwd`, a harness's `workspace`) starts there, and `PWD` names it too, as your shell sets it when you `cd` there; OpenCode takes its directory from `PWD`. On the command line, after your `args` as you wrote them, akm adds the model or agent the asset or flag names, the agent asset's persona where the program takes one there, and what the program needs to run without a person at the terminal: its print or exec mode and its approve-all switch where it asks before acting. Codex runs with the sandbox your Codex configuration sets, or the one your `args` name; model work runs it with `--sandbox read-only` (below). The prompt goes on standard input where the program reads it there and on the command line where it does not; standard output is the reply. A run that exits 0 with nothing but whitespace there gave no reply, and fails with `parse_error`, as a run on akm's own runtime does. `akm agent` with no `--prompt` starts the program interactively instead. What akm scrubs from the output it captures is in [Architecture: Connections and Harnesses](../architecture/architecture.md#connections-and-harnesses) and, for a workflow, [Workflow Schema](workflow-schema.md#the-childs-environment).

**Model work** (see [Where each process runs](#where-each-process-runs)) is akm's own process, so akm sets the call up as it needs it. The program has the same environment. akm runs it in a scratch directory that it creates for the call and removes after it, stamps the akm commands it runs `improve`, and runs no native agent of yours. Where the program can be restricted, akm also limits its tools. The "Restricted model work" column of the table says on which platforms:

- Claude Code runs with `--restricted`, so none of your settings files can widen the tools; with `Read` and `Bash` only for `akm search`, `akm show` and `akm curate`; with no MCP servers; and with no transcript saved.
- Codex runs with `--sandbox read-only`.
- OpenCode 2 runs as the `akm-model-work` agent, which akm passes inline with the run, merged into your `OPENCODE_CONFIG_CONTENT` and keeping the rest of it; akm reads that variable as OpenCode does, as JSONC (comments and trailing commas), with its `{env:NAME}` references replaced as OpenCode replaces them when the content reads only that way (a reference written outside a string, such as a number), and leaves it out, with one warning, when it is not valid JSONC holding an object. akm writes it in OpenCode 2's native `agents` map, which OpenCode reads over the legacy `agent` map, so an entry of that name in your config, in either map, inline or in a file, does not change it (a same-named entry in your inline `agent` map is left out). Its tools are limited to reading and searching: every tool is denied except `read`, `glob` and `grep`, and `akm_search`, `akm_show` and `akm_curate` when you have the akm OpenCode plugin installed. A tool that a plugin of yours adds is denied too. OpenCode's built-in browser plugin is left out of the run (`-opencode.browser` after your `plugins`): model work denies the browser anyway, and from OpenCode 2.2.0 the plugin's own rules would keep the `skill` tool listed. The limit is on tools: your plugins' own setup and hooks still run in the session. The run is `--standalone`, one process that ends with it, with no background service left behind, and `--title akm`, which names the session and spares the second model request that would generate a title. The agent has a one-line system prompt of its own (`system`), which replaces OpenCode's coding-agent prompt.
- On Claude Code, Codex and OpenCode, `args` do not apply to model work, except a `--model` they name.
- OpenCode 1 (Deprecated, removed in 0.11) runs as the same `akm-model-work` agent, with the same one-line system prompt (`prompt`) and `--title akm`, defined in the `agent` map of your `OPENCODE_CONFIG_CONTENT` (OpenCode 1 reads that map, not `agents`), so it sends neither OpenCode's coding-agent prompt nor a title request. Its tools are limited as on OpenCode 2, by the agent's `permission` map: every tool is denied except `read`, `glob` and `grep`, and `akm_search`, `akm_show` and `akm_curate` when you have the akm OpenCode plugin installed. OpenCode 1 refuses a call to a denied tool as well as leaving it out of the tool list (measured on 1.18.25: a built-in tool, a plugin's tool and an MCP server's tool, all denied, were not run), and the model gets neither the `skill` tool nor OpenCode's listing of every skill it finds (your Claude Code skills included). A same-named entry in a config file of yours is merged with akm's, which is set inline over it.
- Every other platform cannot be restricted: the run is unrestricted, in the scratch directory, and akm reports that. The other platforms get the agent-work command line, `args` included.
- OpenCode model work sets `OPENCODE_DISABLE_FREE_MODELS=1`, which OpenCode 2.1.2 and later honor: a call with no usable provider fails instead of sending the prompt to OpenCode's hosted free model, and so does a call whose model (named, or your OpenCode's default) is one of its free ones. Agent work does not set it: your OpenCode's models are as you would get running it by hand.

Where model work is restricted, its tools cannot change the library, so what it changes there reaches it only as a proposal, through the review queue. Where it cannot be restricted, nothing but its scratch working directory stands between the run and your files: the program keeps its own tools and runs with the file and command authority of the user running akm, in your environment, so it can edit files and run commands, in or outside the library, and akm does not check what it did. Any harness may be enabled for model calls; a connection is the way to keep them from touching anything. `akm setup` says so when you enable such a harness for akm's model calls, and saves `modelWork: false` on the harness when you decline ([setup](cli.md#setup)).

**History.** A harness run leaves a session in the program's own history, and `akm proposal extract` and improve read that history like any other. The exceptions are the model-work sessions akm marked: Claude Code keeps no transcript of them, and OpenCode records them under the `akm-model-work` agent, which the reader skips. OpenCode 1 records the agent on the session too, from the release that added that column (May 2026), and the reader skips them the same way. Codex cannot be marked, so its model-work sessions are read like any other. akm's own runtime (below) keeps its sessions in `<akm data dir>/opencode-runtime/data/opencode/opencode.db`, read the same way.

**Failure.** A harness that exits non-zero is a failed run (`non_zero_exit`), and its error ends with the program's own reason: the last non-empty line it wrote, with terminal escapes removed and cut at 300 characters, from standard output for Claude Code (print mode) and from standard error for Codex, OpenCode 2, Gemini, Aider, Amazon Q, Copilot, OpenHands and pi (`agent CLI "codex" exited with code 1: Invalid API key`). OpenCode 1 and akm's own runtime give no such line; OpenCode 1's reason comes from its event stream (see below). A prompt too long for the command line fails saying so, with its size. An empty or blank `--prompt` is a usage error.

**Stopping.** When akm stops a run (a timeout, an abort or a signal to akm) it sends the program's process group SIGINT, as Ctrl-C would. If anything in the group still runs after 5 seconds, or as soon as the program itself has exited and left members behind, it sends SIGTERM, and 5 seconds after that SIGKILL if anything still runs. Workflow `exec` units and task commands are stopped the same way. A program that exits on its own while a captured run still has processes in its group (a server it started with `&` or `nohup`) is treated alike: akm gives the output 2 seconds to finish, stops what is left with the same SIGINT, SIGTERM, SIGKILL steps, and returns the program's own result and the output read. A process that must outlive the run starts its own session and redirects its output (`setsid server >server.log 2>&1 &`); either alone fails. Windows has no process groups, and a signal sent to a process there ends it at once. A program that records how a run ended acts on the SIGINT: OpenCode 2 marks its session interrupted and releases it, and only a run that had to be terminated or killed stays suspended in your OpenCode history, where your own OpenCode's background service may resume it when it next starts (up to ten attempts, OpenCode's own policy). Through OpenCode 2's background service (measured on 2.1.4 and 2.2.0) the interrupt ends the `opencode` command and the service's turn alike: the service abandons the turn's model request and marks the session interrupted, and keeps running itself.

**OpenCode.** The `opencode` platform runs your installed OpenCode as `opencode run`; the reply is its standard output. OpenCode 2 is the supported major. **OpenCode 1 is Deprecated and removed in 0.11:** a run on it prints one `[deprecated]` line on stderr per process (silenced by `--quiet`, for scheduled runs, and in an akm that a task, improve or audit started, which `akm doctor`'s `opencode-major` advisory covers), and `akm doctor` warns while a configured harness is OpenCode 1. Agent work is that command with the prompt on stdin, your `args` as written after `run` (akm writes `run` itself, so an `args` of `["--standalone"]` runs `opencode run --standalone`, and an authored leading `run` is not doubled), `--model` when akm names a model and `--agent` when the asset names an agent. Your OpenCode owns its configuration, logins, token refresh and sessions: akm reads, copies and embeds nothing of yours. akm runs `opencode --version` once per process, for agent work and model work alike, to tell the majors apart; a binary whose version it cannot read is run as OpenCode 1, with one warning.
- On OpenCode 1 akm adds `--format json` (an authored `--format` is replaced) and reads the event stream, because OpenCode 1 exits 0 when its turn ends on a refused tool call. The reply is the same text; with `--thinking` the `Thinking:` lines are not in it. A turn that ended unfinished (a refused tool call, a last step that is not a finished one, no finished step) fails with `parse_error`, and a provider error OpenCode reports in the stream is in the failure's `error`. The run carries a `sessionId`. OpenCode's error message and its failed-tool lines are in `error` rather than on stderr; its `! permission requested ... auto-rejecting` line stays on stderr.
- OpenCode 2 runs agent work through its own background service, which stays up after the command. Add `--standalone` to the harness's `args` for a run that is one process.
- A model name is OpenCode's `provider/model`, from the request, else the `--model` in the harness's `args`; without one, your OpenCode's default decides.

Nobody can answer an akm run. OpenCode's headless `run` cancels every question
and rejects every permission request that would ask, and the model carries on
without it; that holds for akm's own runtime and for the `opencode` harness
alike. A run whose turn then ends with no reply has failed (`parse_error`),
though OpenCode exits 0.

### Without a harness

Agent work runs on akm's own runtime when no harness is configured: a pinned
OpenCode 2 binary (2.2.0) that akm runs as a process for each run, driven by the
default connection. The npm package and the standalone binary do the same.

- **The first run fetches OpenCode.** akm downloads the binary for your platform
  from the npm registry, one package of about 114 MB (240 MB on disk), checks it
  against the registry's integrity hash, and keeps it in
  `<akm cache dir>/opencode/2.2.0/`; later runs, and later versions of akm that
  pin the same OpenCode, fetch nothing. Nothing else is downloaded: the binary
  carries the package it reaches the endpoint with. If the fetch fails the run
  fails as not started, naming the package, its URL and the cache path. With no
  network access for this step, enable the `opencode` harness with an installed
  OpenCode 2 instead: no setting points akm's runtime at a binary of your own.
  On Alpine (musl) the binary needs `libstdc++` and `libgcc`: the Alpine Node
  image has them, a bare Alpine needs `apk add libstdc++ libgcc`. akm's cache
  and data directories must not be mounted `noexec`: the binary runs from the
  first and unpacks its own native pieces into the second.
- It uses your connections. The connection a run is dispatched with (its
  endpoint, key, model and context window, as they were when the run was planned)
  is the process's only provider, so a connection edited or removed afterwards
  cannot redirect a run that was already planned. Your OpenCode's configuration is
  not read: its config, data, cache, state and temp directories are akm's, under
  `<akm data dir>/opencode-runtime/`, so none of your plugins, MCP servers or
  agents load, and no `OPENCODE_*` variable of your environment reaches it.
  OpenCode still reads `~/.agents` and its system config (`/etc/opencode`, or
  macOS managed preferences); a project's `AGENTS.md` and `opencode.json` and
  your Claude Code skills (`~/.claude/skills`) are not read; OpenCode's free
  models and its model-catalog fetch are off.
- It has OpenCode's default agent and tools, editing files and running commands
  included, and akm's `akm_search`, `akm_show` and `akm_curate`, which run the
  `akm` that started the run. A request's `persona` goes in the prompt, as for
  the `opencode` harness.
- The connection's request fields (`reasoning_effort`, `top_p`, a `max_tokens`
  and the rest) are sent with each model request as written. OpenCode's own
  output cap is not: a request carries the cap the connection or the call writes,
  and none otherwise, as a direct request does.
- Its sessions are in `<akm data dir>/opencode-runtime/data/opencode/opencode.db`,
  and all of its files under `<akm data dir>/opencode-runtime/`. Nothing is
  written under `~/.local/share/opencode`.
- The connection's key is in no process's environment: akm writes it for the
  run to a file under `<akm data dir>/opencode-runtime/keys/` (readable by you
  alone), names that file in the runtime's config, and removes it when the run
  ends.
- The commands the agent runs get the environment akm runs in, with the
  directories this akm resolved and the run's variables set over it, less your
  `OPENCODE_*` variables. What akm sets for the OpenCode process itself (its
  directories and its OpenCode settings) is not in it: akm's plugin puts those
  variables back to what akm runs in, or removes them, for each command.
- A run reports its session id and the tokens its turn used, read from that
  session once the process has ended; a workflow's `budget.max_tokens` counts
  them. A failed run is a non-zero exit with OpenCode's own message
  (`non_zero_exit`), as for a harness; when the session recorded why its turn
  failed, the run's error carries that too, so a workflow's unit shows it.
- A model that repeats itself is told, then stopped. When it has made the same
  tool call, with the same input, and been given the same result three turns in
  a row, akm adds a message from the user to its next request: it names the
  tool, says the result will not change, asks the model to use the result it
  has or take a different approach, and says that calling it again stops the
  run. **That one request overrides a lower temperature the connection sets**:
  a `temperature` below 0.7 (0, say) is sent as 0.7, because a model sampled
  greedily (temperature 0) gave the same call again to every wording in every
  try, so at 0 the message alone does nothing, and at 0.7 it left the repeat in
  about half of them. A connection that sets no `temperature` sends none on that
  request either (the endpoint's default applies, and OpenAI's reasoning models
  refuse any other), and one of 0.7 or more is kept. Every other request keeps
  the connection's settings. If the model makes the same call again, or, after
  other calls, makes it three turns in a row again, the run fails
  (`non_zero_exit`) with a message that names the tool. One that changes course
  is not stopped. Each session of a run (a subagent's too) is told for itself.
  OpenCode has no check of its own for this, and with `timeoutMs` unset such a
  run would never end. A call whose result changes is not a repeat, but a poll
  that gets the same answer three times in a row is. An output too long to send
  whole is compared by its text, not by the file OpenCode saves it to. The
  message is added to the request on its way to the model, so OpenCode's stored
  session does not show it; the stop is recorded as any failure is. Only akm's
  own runtime does this; a harness is your program, with whatever limits it has.
- A run that keeps making different calls is not stopped by that. Its timeout
  bounds it: the connection's `timeoutMs`, one the run is given (`akm run --timeout`, a workflow unit's `timeout`) or,
  in a scheduled task, the task's `timeout:` (six hours when unset). With none,
  as for `akm run` by default, it runs until it
  finishes.
- Runs that start together, in one akm process or several, wait while the first
  run of this OpenCode version prepares its database alone.

## Credentials

akm reads an API key from one of two places, and nowhere else:

- **A `$VAR` reference.** `"apiKey": "$LOCAL_LLM_KEY"` (or `"${LOCAL_LLM_KEY}"`)
  names an environment variable, read when the call is made. An unset or empty
  variable is warned about once and the request goes without a key.
- **`credentials.json`.** With no `apiKey`, the key is the entry stored for the
  block in `credentials.json`, in the default config directory (never beside a file selected with `--config`), written with mode 0600:

  ```json
  { "connections": { "<name>": { "key": "…", "endpoint": "…" } },
    "services":    { "embedding": { "key": "…", "endpoint": "…" } } }
  ```

  A key is stored for one endpoint and read for that endpoint alone. Change a
  block's endpoint and the old key is not sent to the new one (it is named once,
  without its value, and the block goes without until a key is stored for the new
  endpoint). A connection's name and the `embedding` service are
  different namespaces, so a connection called `embedding` and the embedding
  service hold different keys. An `embedding` that runs on the default connection
  uses that connection's entry. A connection that only an `extends` base defines
  gets its endpoint from that base, so it never uses a stored key: stored keys
  are for the connections your own `config.json` names (name it there, even with
  only its `models`, and a key stored for the endpoint it ends up with is used).
  A key in the older flat `{ "<name>": "<key>" }` form names no endpoint and is
  not used; `akm migrate apply` files it under the endpoint your own config gives
  that block, after copying `credentials.json` to `<cache dir>/config-backups/`.
  A block that already has a stored key is never overwritten by it: the same key
  for the same endpoint just drops the older entry, and any other leaves both in
  the file, with a note. A flat key called `connections` or `services` (a
  connection of that name) is told from the namespace of that name by its shape and
  filed first; until it is, a write that would replace it stops with an error
  instead.

`akm setup` asks for a key at a masked prompt and stores it in
`credentials.json` for the endpoint it was typed for; `--api-key-env NAME` sets
`apiKey: "$NAME"` instead. Setup an endpoint change that comes with no key does
not carry the old key to the new endpoint (a `$VAR` is dropped from the entry, a
stored key stays for the old endpoint), and says so. A key
is never written to `config.json` or passed on a command line. A literal
`apiKey` in the file, or a `${secrets/...}` reference, is warned about once and
ignored (never sent), and `akm config set` refuses to write one. `akm migrate
apply` moves such a key into `credentials.json`. The key is sent as
`Authorization: Bearer <key>` and redacted from everything akm prints and logs.

The bundle's `secrets/` store, `akm secret` and `akm env` are for the secrets
your own agents and tasks need, and have nothing to do with these keys.

## Aliases

A model alias names "a model of this kind", so the same bundle means the same
thing on every machine. `fast`, `balanced` and `reasoning` are the standard
ones; add any other you like. A connection's `models` and a harness's `models`
say which of their models answers each:

```jsonc
{
  "connections": {
    "default": {
      "endpoint": "http://localhost:11434/v1",
      "models": { "fast": "qwen3-8b", "balanced": "qwen3-32b", "reasoning": "qwen3-32b" }
    }
  },
  "harnesses": { "claude": { "models": { "fast": "claude-haiku-4-5-20251001" } } }
}
```

A model is asked for by `model:` in an asset's frontmatter, `--model` on a
command, or `model` on an improve process, and it is an alias or an exact model
name:
- An alias is looked up in the selected connection's `models` (or harness's).
- A name that is not an alias is used as written.
- An alias the connection does not map answers with its first model. A
  connection with no `models` at all cannot answer an alias; the error names
  `akm models set`.
- A harness passes no model for an alias it has none for, and the program uses
  its own default; when the harness maps other aliases, akm says so once. Claude
  Code ships a map (`fast` Haiku 4.5, `balanced` Sonnet 4.6, `reasoning` Opus
  4.7), which a `models` entry overrides. No other harness ships one. A
  harness is passed the model name only: an alias written as an object
  (`{ "model": "...", "effort": "high" }`) gives its `model`, and akm says once
  that its other fields are ignored.

A kind of work that names no model asks for a default alias: improve's
processes, the index passes, extraction and the Deprecated `akm remember --enrich` ask for
`fast`; the quality and triage judges and a workflow gate ask for `balanced`;
agent work asks for `balanced`.

`akm models` lists a connection's aliases, then the models its endpoint lists,
and `akm models set <alias> <model>` changes one; see the [CLI
reference](cli.md#models). A harness's `models` is edited with `akm config set`.

## Where each process runs

akm's work is of two kinds, and each has a default place to run.

- **Model work** asks a model for an answer with nobody watching: the improve
  processes (reflect, distill, consolidate, memory inference, extract, and
  validation's repair), the quality and triage judges, the judge of a workflow
  `### gate`, the index passes, and the Deprecated `akm remember --enrich`. It runs on the
  default connection, as a direct request to the endpoint. With no connection it
  runs on the default harness, unless that harness has `modelWork: false`. On a
  harness it is akm's own process, not your use of the program ([How akm runs a
  harness](#how-akm-runs-a-harness)).
- **Agent work** runs an agent: `akm run` on an agent or command ref, `akm proposal
  new`, agent tasks and workflow agent steps. It runs on the default harness.
  With no harness it runs on akm's own runtime, over the default connection.

With neither a connection nor a harness, model features and agent work are off:
each command that needs one says so and points at `akm setup`, and everything
that needs no model keeps working.

Anywhere a connection or harness can be named (config, a flag, an asset's
`connection:` or `harness:`) and none is, the default is used. A name that is
not configured is an error (exit 78), never a reason to use the default: the
message names the selector, says it is not configured, lists the configured
connections (or harnesses) and the nearest name when one is close, and the same
holds for the retired `engine:` and `--engine`. Defaults apply only when nothing
was named, so a call for a private connection is never sent to a remote service,
nor a call that must not touch files to a harness that can, by a typo, a removed
entry, or an entry akm ignored when it loaded the config (`akm doctor` lists
what is configured).

A harness is named by its name or by its platform, so a shared asset that says
`harness: claude` runs wherever Claude Code is set up, whatever the entry is
called. The name comes first. Failing that, the one harness that runs the
platform (its `platform`, else its key) is chosen; when several do, the one
named `default` is, and with none named `default` the call fails like any
unconfigured name, naming them. akm never picks the first.

These settings, all optional, choose another place for one piece of work:

| Key | Chooses where |
| --- | --- |
| `improve.enabled` | `false`: background learning is off on this host, and `akm improve` and `akm proposal extract` do nothing. Written by `akm setup --learning off`; absent means on |
| `improve.connection`, `improve.harness` | All of `akm improve`'s model work |
| `improve.processes.<process>` | One improve process: `reflect`, `distill`, `consolidate`, `memoryInference`, `extract`, `validation`, or `triage` (its judgment) |
| `improve.qualityGate` | The judge of the reflect and distill quality gates |
| `index.connection`, `index.<pass>` | The index passes (`index.memory`) |

Each takes `connection` or `harness`, `model` (an alias or a name), `llm` (the
[settings a call asks for](#settings-a-call-asks-for)) and `timeoutMs`. A pass
under `index` takes `connection`, not `harness` (one that names nothing runs
where model work does: the default connection, else the default harness), and
`enabled: false` turns it off:

```jsonc
{
  "improve": {
    "connection": "default",
    "processes": {
      "reflect": { "connection": "cloud", "model": "reasoning" },
      "memoryInference": { "model": "qwen3-8b", "llm": { "temperature": 0.1 } }
    },
    "qualityGate": { "connection": "judge", "llm": { "enableThinking": true } }
  },
  "index": { "connection": "default", "memory": { "enabled": false } }
}
```

The nearest setting wins, farthest to nearest: the shipped alias of the kind of
work, `improve.connection` and `improve.harness`, the process's entry in
`improve.processes`, and `--connection`, `--harness` and `--model` on the run,
which reach every call in it, the judges included. The quality-gate judge is the
exception: a process's own entry is the writer's, so `improve.qualityGate`
replaces it, and a `reasoning` model chosen for reflect is not the one that
judges it. An index pass reads `index.*`, then `index.<pass>`. A strategy adds no
layer: it says which processes run, never where.

`akm doctor` and `akm doctor info` print this as a table, resolved by the same code the
calls use: for each kind of work, the connection or harness and the model.

## Workflows

Workflows are Deprecated and removed in 0.11 (see [STABILITY.md](../../STABILITY.md)); their settings are read through 0.10.

`workflow.maxConcurrency` is the ceiling on units a workflow run executes at
once. An explicit value is clamped to `1..64`. When absent, akm derives it once
from the CPU count (`min(16, max(1, cores - 2))`) and freezes it into the run
plan, so resuming on a different host or after a config edit does not change the
policy.

`workflow.defaultMapConcurrency` is the width a `map` step freezes when it
declares no `concurrency:` of its own. Unset means 4. An explicit value is
clamped to `1..64`; set it to `1` for serial fan-out. It is only a default: an
authored `map.concurrency` always wins, and a step never runs wider than
`workflow.maxConcurrency`, the selected connection's `concurrency`, or the host
CPU cap.

The judge of a `### gate` rubric is model work, so a workflow with completion
criteria needs a connection or a harness before a new run can be frozen. The
choice is frozen into each run, so later config edits do not change an
in-flight run's verifier. A missing, failed or malformed verdict rejects the
gate; criteria are never silently bypassed.

## Strategies

Improve presets live under `improve.strategies`; invoke one with
`akm improve --strategy <name>`. The selection order is `--strategy`,
`improve.strategy`, then built-in `default`. A strategy says which processes run
and how each is tuned (`enabled`, limits, gates), never where: where each process
runs is [Where each process runs](#where-each-process-runs), whichever strategy
is selected.

```jsonc
{
  "improve": {
    "strategy": "nightly",
    "strategies": {
      "nightly": {
        "processes": {
          "reflect": { "limit": 10 },
          "memoryInference": { "enabled": false }
        }
      }
    }
  }
}
```

The built-in strategies are `default` and `consolidate`. `consolidate` is a
patch that is deep-merged onto `default`, and a user-defined strategy of the
same name is merged on top of that; so every strategy, built-in or user-defined,
inherits omitted fields from `default`. A name that is neither built-in nor
defined under `improve.strategies` is refused: `improve.strategy` when the config
loads, `--strategy` when the command runs. A block named `quick`, `thorough`,
`catchup`, `reflect-distill` or `proactive-maintenance` is an ordinary
user-defined strategy that inherits `default`, and `--strategy` naming one with
no such block fails with an error that names `default`. For a judged triage
drain, set `processes.triage` (`enabled`, `applyMode: "promote"`,
`judgment: true`) in your own strategy.

`processes.triage.judgment` controls the optional judgment tier: `true` enables
it, `false` disables it, and an object holds `enabled` (default `true`). The
judgment is a model call; it runs where `improve.processes.triage` says
(`connection` or `harness`, `model`, `llm`, `timeoutMs`), over `improve.connection`
and `improve.harness`, and over the defaults. Enabling it with no connection or
harness configured fails before the run starts, naming `akm setup`.

The `default` strategy runs triage in `promote` mode with judgment off and
`maxAcceptsPerRun: 200` (#1143), so the proposal backlog drains through the
deterministic gates without `experimental.improveAutonomy`. Turning judgment on
in a promote strategy is what that opt-in gates.

Judgment is off in every built-in strategy, and the judgment tier may accept
only a consolidate promotion. Retirements and reflect revisions it
would accept are left for a person. This is measured, not cautious by habit
(#1132, #1094): with `experimental.improveAutonomy` and judgment over every
proposal kind, the nightly eval solved 0.49 (gpt-5.6-terra) and 0.53
(qwen3.8-27b) of its items while harming 14 and 11, and changed 18 and 21 notes
outside the planted set; the judge accepted unsafe retirements and applied exact
fixes unreviewed. Judging promotions alone was reasonable: on qwen3.8-27b it
had precision 0.87 and recall 0.78 and accepted 4.8% of bad promotions; on
gpt-5.6-terra it was very cautious (precision 1.0, recall 0.17).

```jsonc
{
  "improve": {
    "processes": { "triage": { "harness": "claude" } },
    "strategies": {
      "nightly": {
        "processes": { "triage": { "enabled": true, "judgment": true } }
      }
    }
  }
}
```

`processes.reflect.qualityGate` and `processes.distill.qualityGate` control
each process's LLM-as-judge quality gate. Each is on unless it sets
`enabled: false`, and each follows only its own switch. A reflect revision the
judge passes is staged for the triage drain to accept; a distill lesson it
passes is deferred for a person (reason `distill-review`), which the drain and
its judgment tier leave alone. With the distill gate off nothing is judged, and
the drain decides. The judge is a model call that
runs where `improve.qualityGate` says (`connection` or `harness`, `model`, `llm`,
`timeoutMs`), for both gates, over `improve.connection` and `improve.harness`
and the defaults: with no `qualityGate`, the default connection answers with its
`balanced` model. The process's own entry in `improve.processes` is the writer's
and does not reach the judge. The judge may be a connection or a harness; a
harness that cannot be restricted runs it unrestricted, with a notice ([How akm
runs a harness](#how-akm-runs-a-harness)). It runs
at temperature 0 with thinking off unless its connection turns thinking on.
Thinking is slow: on a 27B llama.cpp server, a thinking judgment took a median
of 30–67 s and up to about 3 minutes, against about 5 s without.
Behind a gateway that drops `chat_template_kwargs` (Bifrost), point a thinking
judge's connection at the server directly.

```jsonc
{
  "connections": {
    "judge": {
      "endpoint": "http://127.0.0.1:8080/v1",
      "models": { "balanced": "qwen3-27b" }
    }
  },
  "improve": {
    "qualityGate": { "connection": "judge", "llm": { "enableThinking": true } }
  }
}
```

`processes.reflect.defectFilter` sets the wording of the checks reflect runs
before the judge. With the quality gate on or off, reflect refuses a revision
that adds placeholder text, talks about its own edit, or copies frontmatter into
its body: no proposal, and no judge call. Each rule counts only what the
revision adds to its source, so wording the asset already had and kept is not
held against it. Each of the three lists is optional. A list you set replaces
that rule's default list, and `[]` turns the rule off.

| List | Rule | Default |
|---|---|---|
| `placeholders` | `placeholder_added` | `please confirm`, `please verify`, `to be confirmed`, `to be determined`, `to be verified` |
| `metaCommentary` | `meta_commentary_added` | `feedback signal`, `feedback signals`, `feedback indicate`, `feedback indicates`, `feedback suggest`, `feedback suggests`, `feedback ask`, `feedback asks`, `feedback says`, `feedback report`, `feedback reports`, `feedback request`, `feedback requests`, `this revision`, `the source asset`, `the source note`, `the source memory`, `the original asset`, `the original note`, `the original memory`, `the original version of this`, `quality gate rejected`, `proposal rejected` |
| `frontmatterKeys` | `frontmatter_copied_into_body` | `sources`, `updated`, `inferenceProcessed`, `captureMode`, `beliefState`, `xrefs`, `contradictedBy`, `outcomeData`, `orderedActions`, `generated`, `verified`, `description`, `when_to_use`, `tags`, `searchHints`, `quality`, `salience`, `salienceInputs`, `type` |

`placeholders` and `metaCommentary` entries are plain phrases, not patterns:
whole words, in any case, with any run of whitespace between words.
`frontmatterKeys` entries are exact key names: a line outside a code fence that
starts with `key:` counts. The rule also refuses a `sources`, `xrefs` or
`contradictedBy` value copied into the body; `frontmatterKeys: []` turns that
off too. Every entry must be a non-empty string, or the config does not load.

```jsonc
{
  "improve": {
    "strategies": {
      "nightly": {
        "processes": {
          "reflect": {
            "defectFilter": {
              "placeholders": ["please confirm", "to be confirmed", "[draft]"],
              "frontmatterKeys": []
            }
          }
        }
      }
    }
  }
}
```

No shipped strategy turns improve-stage session extraction on.
`proactiveMaintenance` is on in `default` and off in `consolidate`, the only
other shipped strategy. It plans stable assets that have had no feedback: at most
`maxPerRun` (default 15) per run, only assets not reflected or distilled for
`dueDays` (default 30), so each comes up at most once a month, and reflect's
`limit` (25) still bounds the run. A preset that omits either process
inherits the `default` value; set `processes.proactiveMaintenance.enabled: false` in the
selected strategy to turn the lane off. A proposal from this lane is never
accepted by `proposal drain`: it waits for a person (reason
`proactive-needs-review`, #1147). User strategy overrides
are applied last, so an explicit `enabled: true` still opts the selected
strategy in.

These improve-stage defaults do not gate explicit standalone extraction through
`akm proposal extract --sessions <harness>` or `akm proposal extract --auto`. The interactive
scheduled-task step also continues to offer the bundled `core/extract` template
as an unselected opt-in; it is not installed merely because the template is
bundled.

## Indexing

AKM-native Markdown contributes a normalized body projection to the `content`
search field, which BM25 weights like the other four. The projection is capped
at 1,000,000 characters, removes frontmatter, comments, and link destinations,
and is never produced for secret, env, session, or session-checkpoint assets.
From fenced code it keeps only the identifiers: names, CLI flags, keys, paths
and dotted references, after the prose. Quoted strings (other than keys and absolute
paths), assignment values, URLs and long token-like strings (base64 included)
are dropped, so a fence's literal values are not indexed. Two kinds of value
stay, as they do in prose: a bare short word (`-p hunter2`) and the words after
the first of an unquoted value with spaces (`key: two words`). Indented code
blocks, `<pre>` blocks and fences inside a blockquote are not read as code:
they are indexed as prose, values included. Search results return no
`content`, so this changes what search finds, not what it hands an agent.
Embedding input is the head of the entry's search text, structured metadata
first, cut at `embedding.maxInputTokens` (default 512 estimated tokens, about
2,048 characters).

## Semantic search

`semanticSearchMode` (top-level, `"off" | "auto"`, default `"off"`, or `"auto"` when `embedding` is set) gates
embedding-based search. `"auto"` lets AKM set up embeddings (which downloads
a local model from Hugging Face Hub into `$CACHE/models` unless you point
`embedding` at a remote provider) and falls
back to keyword-only FTS if the embedding runtime is unavailable; `"off"`
disables semantic search outright and search is always keyword-only FTS.
If a backend marked ready cannot serve a query, search still returns the FTS
results but reports `searchMode: "fts-fallback"` and one sanitized warning.
This is distinct from `searchMode: "keyword"`, which is the normal result when
semantic search is disabled or has not been built. A read-only sandbox that
cannot record best-effort usage telemetry does not by itself mark search as
degraded.
The local embedder runs its model (`Xenova/bge-small-en-v1.5` unless
`embedding.localModel` names another) on ONNX Runtime, through
`onnxruntime-node`'s native binding, with `@huggingface/tokenizers` for the token
ids. akm offers local embeddings on Linux x64 (glibc) and Apple-silicon
macOS; on every other platform semantic search uses an embedding endpoint or
stays keyword-only. akm does not install `onnxruntime-node`:
`akm setup --embedding local` (or the wizard's built-in embedder) downloads that
package's binding and library for this platform once from the npm registry
(about 86 MB; the registry's sha512 integrity is checked before anything is
extracted) into `<cache dir>/onnxruntime/<version>-<platform>-<arch>/`, and the
first local embedding downloads them when setup did not. The model's four files
(about 127 MB) come from the Hugging Face Hub the same way, into
`$HF_HOME/<repo>/` (default `<cache dir>/models`); `HF_HUB_OFFLINE=1` forbids
that download. `akm index --format json` reports the runtime it embedded with as
`verification.embeddingRuntime`. If the runtime cannot be downloaded or does not
load (the cache directory is mounted `noexec`), the index reports semantic search
`blocked` with the reason and search stays keyword-only. On a platform without
local embeddings, `akm setup` offers an endpoint or keyword search,
`--embedding local` warns and saves keyword search, and a config that turns
semantic search on anyway gets it reported unavailable for the platform by the
index and a warning from `akm doctor`.

**Without network access**, fill akm's cache directory (`akm doctor info` prints
`cacheDir`; `AKM_CACHE_DIR` moves it) before the first `akm index`:

- `onnxruntime/<version>-<platform>-<arch>/` (for example
  `onnxruntime/1.24.3-linux-x64/`) holding `onnxruntime_binding.node` and the
  library it links (`libonnxruntime.so.1` on Linux,
  `libonnxruntime.1.24.3.dylib` on macOS). Take both from
  `package/bin/napi-v6/<platform>/<arch>/` in the `onnxruntime-node@1.24.3`
  tarball (`npm pack onnxruntime-node@1.24.3`), or copy the folder from a
  connected machine of the same platform after
  `akm setup --yes --embedding local`.
- `models/Xenova/bge-small-en-v1.5/` holding `tokenizer.json`,
  `tokenizer_config.json`, `config.json` and `onnx/model.onnx`, or set `HF_HOME`
  to a directory that holds them and `HF_HUB_OFFLINE=1`.
- `opencode/2.2.0/opencode` (`opencode.exe` on Windows) for akm's own agent
  runtime.
The default is `"off"` so a bare or headless install (`akm bundle create`, `--yes`,
`--config`) never silently downloads the local embedding model on first
index. A config that has an `embedding` block and sets no `semanticSearchMode`
reads as `"auto"`: writing the block says semantic search is wanted.
The interactive `akm setup` wizard pre-selects semantic search **on**
regardless of this default, and warns that choosing it downloads the model
unless a remote `embedding` config is provided.

```jsonc
{ "semanticSearchMode": "off" }
```

`embedding` configures the connection used for semantic search and
`akm improve`'s memory-inference/consolidate passes when they call an
embedding model: `provider`, `endpoint`, `model`, `apiKey` (a `$VAR` reference,
or the `embedding` service's entry in `credentials.json`; see
[Credentials](#credentials)), `dimension`, `localModel`,
`maxInputTokens`, `maxTokens`, `batchSize`, `contextLength`, `timeoutMs`,
`queryTimeoutMs`, `queryTemplate`, `documentTemplate`, `concurrency`, and
`ollamaOptions.num_ctx`. An `embedding` with a `model` and no `endpoint` names a
model the default connection serves, at its endpoint and with its key; with no
default connection there is nothing to serve it, and the built-in local embedder
runs, with a warning.

Choosing another embedder with `akm setup` (or in AKM Desktop) replaces `endpoint`, `model`, `apiKey` and `provider`;
keeps `dimension`, `queryTemplate` and `documentTemplate` only while the model is the same; and keeps every other key.
The built-in embedder leaves no block when nothing remains.

Retrieval models expect a prompt around queries and documents. akm picks it by
model name (`src/llm/embedders/profile.ts`): Qwen3-Embedding gets
`Instruct: Given a question or task, retrieve the knowledge asset that helps with it\nQuery:{text}`
on queries; nomic-embed `search_query: ` / `search_document: `; the BGE
English, mxbai and arctic models `Represent this sentence for searching
relevant passages: ` on queries; E5 `query: ` / `passage: `; any other model
none. `embedding.queryTemplate` and `embedding.documentTemplate` override the
preset (`{text}` marks where the text goes, a template without it is a prefix,
and `""` means none). The document template is part of the embedding
fingerprint, so changing it re-embeds the index; the query template applies
at search time only. `embedding.queryTimeoutMs` (default `3000`) bounds how
long a search waits for its query embedding before falling back to keyword
ranking with a warning.

The knobs that bound request/document size and rate, all optional (defaults
apply when unset), for a remote endpoint (`src/llm/embedders/remote.ts`):

| Key | Default | Bounds |
| --- | --- | --- |
| `embedding.maxInputTokens` | `512` | Per-DOCUMENT cap, applied before batching. A document's embedded text is truncated to its head (unicode-safe) at this many estimated tokens instead of ever being skipped for size alone — a document is skipped only when its truncated head is empty. |
| `embedding.maxTokens` | `6000` (`DEFAULT_TOKEN_BUDGET`) | Per-REQUEST token budget: how many (already-capped) documents' estimated tokens fit in one HTTP request. With the 512-token default document cap, a request carries about 11 documents by default. The 4-chars-per-token estimator undercounts dense technical text, so a larger budget can overshoot an 8192-token endpoint's real context window. |
| `embedding.batchSize` | `100` | Per-REQUEST document-COUNT safety cap, independent of the token budget — guards against many tiny documents packing an oversized request. |
| `embedding.contextLength` | unset | Ollama's `num_ctx` ONLY, forwarded verbatim as `options.num_ctx` on the native `/api/embed` request. Does **not** feed the request token budget above. |
| `embedding.timeoutMs` | `120000` (120s) | Per-request wall timeout — see below. |
| `embedding.concurrency` | `1` loopback / `2` remote | In-flight request window — see below. |

`embedding.timeoutMs` (positive integer, default `120000` — 120s) is the
budget for a request at the FULL token budget (`embedding.maxTokens`); a
local model server on a large, token-budget-bounded batch legitimately takes
longer than the prior fixed 30s cut off. A smaller request gets a
proportionally smaller timeout —
`clamp(timeoutMs × requestTokens / tokenBudget, 30000, timeoutMs)` — so a
dead endpoint is still detected in seconds on the common case of small
documents. Set `embedding.timeoutMs` lower to fail fast against a
known-fast endpoint, or higher for a slow local server on large batches.

`embedding.maxTokens` (or its default) is also a run-scoped adaptive
starting point, not a hard ceiling: on the FIRST rejection of an
`akm index` run for exceeding the endpoint's context window, akm shrinks
the request budget to three quarters of its current value — floored at
twice `embedding.maxInputTokens` — for every request not yet sent, and
prints one line naming the new value. This never changes the rejected
request's own split-and-retry (below), never shrinks a second time in the
same run, and never grows the budget back up. Users who set
`embedding.maxTokens` explicitly get the same same-run recovery if their value
turns out to be too high for the endpoint.

A request TIMEOUT (not a rejection for exceeding the context window) never
drops its batch immediately: field confirmation showed that once akm
abandons a timed-out request, the endpoint (e.g. llama-server) keeps
computing it anyway, so dropping it right away just grows the provider's
queue while every following batch dies the same way. Instead akm backs off
(5s, doubling, capped at 60s) and retries the same request once; a second
timeout splits it in half and retries each half the same way, down to
individual documents, and a single document that still times out is finally
skipped (logged at the default `warn` level). After 3 consecutive failures
at single-document size (timeout or network error), or 3 consecutive
network errors at any size, the embedding phase stops dispatching further
requests and reports failure — batches already committed are kept; rerun
`akm index` once the endpoint is healthy.

`akm index` keeps a small number of `/v1/embeddings` requests in flight at
once (a remote endpoint only; the local transformer path is unaffected):
`1` for a loopback endpoint (`localhost`, `127.0.0.0/8`, etc. — a local
model server serves one inference at a time, and parallel requests thrash
it) and `2` for a remote one, unless `embedding.concurrency` (positive
integer, 1-16) overrides it. This default holds for the overwhelming
majority of setups; set the override only for an endpoint that genuinely
serves parallel requests — a local server started with a multi-slot flag
(llama.cpp's `--parallel N`, vLLM) — not to "speed up" an ordinary
single-slot model server, which the default already protects from
reload-thrash. Request SIZE remains the first throughput lever regardless:
`embedding.batchSize` (a document-count cap, default 100) together with
`embedding.maxTokens` (an estimated token budget per request, default 6000
— NOT `embedding.contextLength`, see the table above) control how many
documents land in one request — with the default 512-token
`embedding.maxInputTokens` document cap, that is about 11 documents,
taking about the same wall time as a single one against a healthy endpoint.

## Search tuning

`search` sets which types search leaves out by default:

| Key | Purpose |
| --- | --- |
| `search.defaultExcludeTypes` | Asset types excluded from results by default |

An older config that still has `search.curateRerank` (the removed curate reranker) loads, warns once that
the key is ignored, and enables nothing; `akm migrate apply` drops it.

## Feedback

`feedback` configures `akm feedback`:

| Key | Purpose |
| --- | --- |
| `feedback.requireReason` | Whether `akm feedback --negative` without `--reason` is a hard error. **Defaults to `true`** when unset — set `false` to downgrade the check to a warning instead |

## Usage

`usage` configures the local-only CLI usage counts and the daily usage report (see
[Data and Telemetry](data-and-telemetry.md#cli-usage-counts)):

| Key | Purpose |
| --- | --- |
| `usage.capture` | Whether akm records counts of its own commands in `metrics.db`. **Defaults to `true`**; `false` turns the recording off. Read from the config file itself (the one `--config` or `AKM_CONFIG_FILE` selects) before the rest of the config loads, so a missing or broken file leaves it on. `--read-only` records nothing either way. |
| `usage.report` | Whether akm sends its [daily usage report](data-and-telemetry.md#daily-usage-report) (the CLI's and AKM Desktop's). **Defaults to `true`**; `false` sends nothing. Read from the effective config, so `false` in a config you `extends` turns it off unless a nearer layer sets it to `true`. A config that cannot be loaded sends nothing. The CLI also sends nothing under `--read-only` or when `usage.capture` is `false`. |

## Bundles and write target

`bundles` (replacing the retired `stashDir`/`sources[]`/`installed[]` trio)
and `defaultBundle` are the 0.9 source configuration shape — see
[Concepts](../guides/concepts.md) and the [CLI reference](cli.md) for the
full bundle model (`path`, `git`, `website`, `npm`, `location`, `writable`,
`registryId`, `adapter`, `root`, `lint`). A bundle carries exactly one of `path`,
`git`, `website`, `npm` and `location`.

```json
"bundles": {
  "main":    { "path": "~/akm", "adapter": "akm", "writable": true },
  "skills":  { "git": "https://example.com/skills.git", "root": "skills", "adapter": "agent-skills" },
  "keyring": { "adapter": "secret-tool", "location": "akm" },
  "vault":   { "adapter": "azure-key-vault", "location": "team-vault" }
}
```

| Key | Purpose |
| --- | --- |
| `adapter` | The id of the [adapter](../architecture/adapters.md) that reads the bundle (`akm`, `okf`, `secret-tool`, ...). Without it, akm detects one from the bundle's content. An unknown id is a config error that names the valid ones. |
| `root` | The content root inside the bundle. Only with `path` or `git`. |
| `writable` | The one writability key. Default: `true` for a local `path` and for `location`, `false` for the rest. |
| `location` | Where the adapter finds a bundle that is not a directory: a keyring's or a Key Vault's name. It needs `adapter`. |
| `credential` | A reference to a secret (`$VAR`, `${VAR}` or `${secrets/<name>}`), never a literal. On a `git` bundle, the HTTPS bearer credential. On a `secret-tool` bundle, the password akm unlocks the locked GNOME keyring with (see [Environment & Secrets](env-and-secrets.md#secrets-kept-by-a-secret-manager)). No other bundle takes one. |

`location` names a keyring (`secret-tool`) or an Azure Key Vault
(`azure-key-vault`); see
[Environment & Secrets](env-and-secrets.md#secrets-kept-by-a-secret-manager) for
how each is found, unlocked and used. An adapter that reads a store needs a
`location` and a directory adapter cannot have one; a bundle that breaks this is
a config error, which `akm config set` refuses and `akm doctor` reports.
`akm bundle add <location> --adapter <id>` writes the `location`.
`akm bundle list` shows each bundle's `adapter` and whether it was `detected`,
and `status.exists` comes from the adapter: whether the directory, keyring or
vault is there.

`defaultBundle` must name a key in `bundles` when set. A bundle's `adapter` key
pins it to a specific format adapter instead of relying on auto-detection.
`root` (a `path` or `git` bundle) is the content root inside the bundle. The
retired `components` map is read as these keys, with a warning, and
`akm migrate apply` rewrites the file; `akm config set
bundles.<name>.components.*` is refused, naming `bundles.<name>.adapter`, `root`
and `writable`. See [Bundle Types](bundle-types.md) for the full adapter list
and what each one reads and writes. An entry without `adapter` gets the
adapter detected from its content once, when akm resolves its bundles, and
`akm bundle add` of a local directory records the adapter it detects.

A bundle entry also carries the lint policy for its own files:

| Key | Purpose |
| --- | --- |
| `lint.skip` | `{ "<rule>": ["<glob>", ...] }`: lint skips the rule for files whose bundle-relative path matches a glob (`**` is the whole bundle), for example `"stale-path": ["skills/sec/**"]` or `"tracked-secrets": ["**"]`. Any rule `akm lint` reports can be skipped. See [`akm lint`](cli.md#lint). A rule name lint does not know is warned about once and ignored. |

Each physical content root has one bundle id. Duplicate paths and symbolic-link
aliases are rejected because source ownership, scheduler authority, and default
selection must not depend on which spelling a caller used. If an older config
contains aliases, choose the id whose durable refs should survive and remove
the other entry before running ordinary commands.

### defaultWriteTarget

`defaultWriteTarget` names the bundle that write commands (`akm remember`,
`akm import`, `akm env create`, `akm secret set`, `akm improve`, etc.) fall
back to when no explicit destination flag is given and the command isn't
already scoped to a specific source. It must name a configured bundle; setting it with no
`bundles` configured, or naming an unconfigured bundle, is rejected at
`config set` (or config load) time. The full write-target resolution order
is the command's destination flag (`--bundle`) -> `defaultWriteTarget` ->
working bundle (`defaultBundle`) -> `ConfigError`.

### Memory scope

`akm remember`'s scope flags (`--user`, `--agent`, `--run`, `--channel`)
write four canonical top-level frontmatter keys on the memory file:
`scope_user`, `scope_agent`, `scope_run`, `scope_channel` (one key per
non-empty scope value; string values). This is not a config-file setting —
it is documented here because it is the contract
that `akm search --filter` and `akm curate --filter` read back, to select inside a set the caller may already read (tenants are separated by deployment or bundles, not scope):
`--filter user=<id>` / `--filter agent=<id>` / `--filter run=<id>` /
`--filter channel=<name>` (repeatable; a repeated key matches any of its values, different keys must all match) narrow results to assets
whose frontmatter scope matches; search applies them before ranking. A memory
with only scope flags and no tags is valid; all memory metadata flags are
independent of tags. `--scope` was removed in 0.9.0 with no alias; use
`--filter`.

`archiveRetentionDays` (default `90` when unset) controls how long a pending
proposal is kept before `akm improve`'s maintenance pass archives it (status
`rejected`, reason `"expired: no action within retention window"`; counted
from the last `akm proposal reopen`, if there was one) — `akm proposal` itself
has no archive/expire verb, though `akm proposal reopen` puts an expired
proposal back. Setting it to `0` or less disables expiry entirely.

## Projects

`projects` names the places you work. Each entry lists its directories and, optionally,
what akm reads and writes there:

```jsonc
"projects": {
  "akm": { "paths": ["~/code/akm", "~/code/akm-wt-feature"] },
  "acme": {
    "paths": ["~/clients/acme"],
    "from": ["acme", "personal"],
    "filters": { "channel": ["acme", ""] },
    "prefer": { "team": "consulting" },
    "rules": ["rules/acme/development", "team//rules/review"],
    "write": { "bundle": "personal", "channel": "acme", "metadata": { "client": "acme" } }
  }
}
```

- `paths`: absolute or `~`-prefixed; the project whose path most specifically contains the
  working directory (symlinks resolved, whole segments) applies. A project without `paths` is
  chosen with `--project` only.
- `from`, `filters`, `prefer`: the defaults for `akm search` and `akm curate`, in the shape of
  `--from`, `--filter` and `--prefer` (a value or a list; an empty string matches assets
  without the key).
- `rules`: the rules `akm rules` loads for the project, exactly and in order, from any enabled bundle. An unqualified ref resolves as `akm show` does. The list replaces matching by `project:`; a listed ref that does not load warns and is skipped.
- `include`: retrieval exclusions to relax, e.g. `{ "quality": "proposed", "type": ["session"] }`. Only `quality=proposed` and named types are supported. Each explicit call's include value replaces this whole object; `{}` deliberately supplies no inclusions. Queries, filters, explicit type and source boundaries still apply.
- `write`: `bundle` (a default for `remember` and `proposal new`, between `--bundle` and
  `defaultWriteTarget`; an explicit `--bundle` or a `--supersedes` ref decides first), `user`,
  `agent`, `channel` (each fills a flag you left out) and `metadata` (frontmatter keys a write
  lacks; the body's own keys win, and akm's own keys win over both; keys akm sets itself, such
  as `description` or `tags`, are ignored with a warning). `proposal extract` uses `user`,
  `agent`, `channel` and `metadata`, never `bundle`.
- A project with no `prefer` prefers `project=<name>`; with no `write.metadata.project`, its
  writes carry `project: <name>`.
- A malformed project or key warns once and is ignored, as is a path that is `~user/...` or
  relative. When two projects list the same path, the first in the file is used, with a warning.
  `extends` layers combine projects by name: a project in the local file replaces the inherited
  one of that name whole, never field by field. Improve's session extract names a memory folder and a session asset's
  `project:` after the project containing the session's working directory, when there is one.

See [Projects in the CLI reference](cli.md#projects) for how a call chooses one.

## Registries

`registries` (top-level array, distinct from `bundles`) lists remote package
registries `akm registry`/`akm bundle add` can search and install from.
Each entry is `{ url, name?, enabled?, provider?, options? }`; `provider`
defaults to `"static-index"`. With no `registries` key, the defaults are the
official registry and a skills.sh entry that ships with `enabled: false`. See
[Registries](registry.md) for the field reference, the provider list and how to
enable skills.sh.

Registry `url` values cannot carry a username or password: such an entry is
dropped with a warning. The built-in providers send no credentials and
`options` does not add any; use a credential-free HTTPS endpoint.

## Output defaults

`output.format` (one of `json`\|`yaml`\|`text`\|`jsonl`\|`md`,
default `json`) and `output.detail` (`brief`\|`normal`\|`full`, default
`brief`) set the CLI's default `--format`/`--detail` when the flags are
omitted. Per-command flags always override these. A config that still says `output.format: html` (retired with
akm's HTML output) loads: one warning names it and the default format applies.

## Setup-derived recommendations

`setup` is reserved for configuration derived by `akm setup`. It currently
holds no keys — the `setup.taskSchedules` sub-key was removed in 0.9.0 after
nothing in the setup flow or the tasks subsystem was found to read or write
it. Scheduling lives in the tasks subsystem (`akm task`).

## Experimental opt-ins

`experimental` holds explicit opt-ins for behavior outside the
stability contract (see [STABILITY.md](../../STABILITY.md) for full
classification). Every key defaults to **off**; an absent `experimental`
section, an absent key, and an explicit `false` all read identically as off.

```jsonc
{
  "experimental": {
    "improveAutonomy": false,
    "exec": false,
    "memoryEnrichment": false
  }
}
```

- **`experimental.exec`** — turns on [`akm exec`](cli.md#exec), which runs any
  command with env assets and secrets injected. Off by default: `akm exec`
  refuses and runs nothing. `akm run --env` and `--secret` are not gated, nor are
  the `exec:` and `prompt:` steps of a [version 5 task](tasks.md#task-source-v5-experimental).
- **`experimental.memoryEnrichment`** — the replacement for the Deprecated
  `akm remember --enrich` and `--auto`. When on, `akm improve`'s reflect process
  asks for 1-5 `tags` for a memory that has none, in the same reply as its
  `description`, `when_to_use` and `title`, and proposes them on their own; a tag
  list the memory already has is never replaced. The tags proposal is judged by
  the tags judge (`memory.tags`), not reflect's revision judge, and goes through
  the proposal queue like any other. In proactive maintenance, memories with no
  tags are planned first. Reflect makes the same one model call per memory as
  before; with the quality gate on, the tags add one judge call. Off by default, with the prompt
  and the reply schema unchanged. It does not need `experimental.improveAutonomy`.
- **`experimental.improveAutonomy`** — gates only the autonomous
  `memoryInference`, `triagePromote` (a promote with triage judgment on; a
  deterministic-only promote runs without it), and `memoryCleanup` lanes. `akm improve`
  itself always runs; this only gates mutations without a human in the loop.
  Consolidation is not gated: it remains advisory and emits reviewable
  proposals. With `triage` `applyMode: "promote"` on, `akm improve`'s triage pass
  accepts the proposals the quality judge passed, and the consolidate pair
  pass's retire proposals that it staged with no continuity risk. These are
  outside the gate: session assets written under `sessions/`, the purge of
  archived memories past their grace period at the start of every improve run,
  the commits `akm proposal accept` makes, and the end-of-run `sync.push`
  (which has its own `--no-push` and `sync.push` controls).

### Experimental web settings

`experimental.web` holds the settings the AKM Desktop server (`akm-web`) reads when you run it by hand on a headless machine; Desktop itself ignores them. Every key is optional. `secret` is a reference, never the secret itself. `akm-web` does not start without a secret. Behavior is described in the [Desktop README](https://github.com/itlackey/akm/blob/main/desktop/README.md#run-it-on-a-server).

| Key | Meaning | Default |
| --- | --- | --- |
| `host` | Address to listen on. | `127.0.0.1` |
| `port` | Port to listen on, 0 to 65535. | a free port |
| `origin` | The address the browser uses: `http(s)://host[:port]`, no path, query or fragment. | the bound address |
| `secret` | Reference to the secret (at least 32 characters): `$NAME`, `${NAME}` or `${secrets/<name>}`. `akm config get` shows the reference, never the value. `AKM_WEB_SECRET`, when set, overrides it for that run. | none |
| `allowedHosts` | Extra `Host` values to accept: a host name or address with an optional port (`akm-internal`, `akm-internal:8080`, `[::1]:3000`), no scheme, no path. Without a port, any port; with one, only that port. | none: only the origin's host |
| `frameParents` | Exact `http(s)` origins allowed to show the UI in a frame; a wildcard is refused. | none: framing is denied |

### Experimental learning aliases

`experimental.learning.strategies` and `experimental.learning.qualityGate` mirror
`improve.strategies` and `improve.qualityGate` key for key. They are the
experimental home of the research learning controls and first ship in
0.10.261120. The config reader folds them into `improve.*` in memory when it loads
the file, so the strategy engine sees the one shape it always read. The old
`improve.*` keys keep working, with the same effective settings, through 0.10.

```jsonc
{
  "experimental": {
    "learning": {
      "strategies": {
        "nightly": { "processes": { "reflect": { "limit": 10 } } }
      }
    }
  }
}
```

- Objects merge key by key. Any other value under `experimental.learning`
  replaces the same key under `improve`, so `false`, `0` and `[]` carry through.
- When both paths set a key to different values, the `experimental.learning`
  value wins and one warning per key names both paths. Equal values warn nothing.
- `experimental` is host-local: a base config pulled in with `extends` cannot
  carry `experimental.learning` (see [Sharing configuration across
  installs](#sharing-configuration-across-installs)).
- The key adds no behavior by itself. An absent `experimental.learning` leaves
  every default as it was, and it does not gate `experimental.improveAutonomy`.

Classification of each learning control:

| Control | Decision |
| --- | --- |
| `improve --require-feedback-signal` | Deprecated, no new key. Use a strategy with `processes.proactiveMaintenance.enabled: false`, selected with `--strategy`. |
| `remember --auto`, `--enrich` | Deprecated. Replaced by `experimental.memoryEnrichment`. Removed in 0.11. |
| Bulk proposal controls (`accept`/`reject` `--generator`, `--older-than`, `--max-diff-lines`; `proposal drain` `--max-accepts`, `--older-than`, `--judgment`; `triage.maxAcceptsPerRun`) | Unchanged. Both the filtered accept/reject and drain stay. |
| `distill.requirePlannedRefs`, `consolidate.maxChunkSize`, `proactiveMaintenance.dueDays` | Research: kept under `experimental`. |
| `improve.qualityGate` | Research: under `experimental`. Per-process runner overrides and `--connection`, `--harness`, `--model` stay supported. |
| `--limit` and `reflect.limit` | Supported. Strategy-level `limit` and `consolidate.limit` are removed in 0.11. |
| Strategy `sync` | Stays in the strategy for 0.10. In 0.11 a per-bundle sync-mode setting replaces it. |
| `distill.cls.enabled`, `distill.cls.adjacentCount` | Research: kept under `experimental`. |
| `extract.triage` (`enabled`, `minScore`) | Research: the whole object moves under `experimental`. |
| `improve.stateGc.collect` | Removed in 0.11. |
| `extract.maxSessionsPerRun` / `extract.minNewSessions` | `maxSessionsPerRun` is supported; `minNewSessions` is removed in 0.11. |
| `improve --require-engines` | Removed in 0.11. |
| Ordinary scope flags and keys with no evaluation or plugin caller | Supported. |

## Plugins

`plugins` holds the settings of the akm plugins for Claude Code, Codex and
OpenCode. The plugins read this file themselves, find it the way akm does
(`AKM_CONFIG_DIR`, else `XDG_CONFIG_HOME/akm`, else `~/.config/akm`) and own the
keys and their validation: akm keeps the section, never reads it, and never warns
about what is inside it. A wrong plugin value is ignored by the plugin, with a
warning in its own log. Every key is optional.

```jsonc
{
  "plugins": {
    "autoFeedback": true,
    "indexOnSessionEnd": true,
    "curateLimit": 5,
    "curateTimeoutSeconds": 8,
    "pendingProposalTimeoutSeconds": 2,
    "redact": { "pii": false, "highEntropy": false }
  }
}
```

- `autoFeedback` (default `true`): record `akm feedback` from a session's signals. Never on under Codex.
- `indexOnSessionEnd` (default `true`): run `akm index` when a session ends.
- `curateLimit` (integer 1 to 25, default 5): results injected per prompt.
- `curateTimeoutSeconds` (default 8) and `pendingProposalTimeoutSeconds` (default 2): how long the plugin waits for those calls.
- `redact.pii` and `redact.highEntropy` (default `false`): redact phone, SSN and card numbers, or long high-entropy tokens, from what the plugin writes to its logs and memory events. Set `true` on any host that handles personal data.

Whether a plugin learns from sessions is not a plugin key: it is `improve.enabled`
(`akm setup --learning on|off`).

`akm config set plugins.curateLimit 8` writes a key. A nested key such as
`plugins.redact.pii` is stored too, with a one-line note that akm does not define it.

## Managing Config

```sh
akm config list
akm config get connections.default
akm config set connections.fast '{"endpoint":"http://localhost:11434/v1","models":{"fast":"qwen3-8b"}}'
akm config set connections.fast.apiKey '$LOCAL_LLM_API_KEY'
akm config unset connections.old
```

Object values passed to `config set` deep-merge with their current value.
Arrays replace, `null` is only valid for nullable fields, and `config unset` is
the only deletion operation. It removes the named key and nothing else: a
parent object left empty stays, because `harnesses.opencode: {}` is how a
harness is enabled. `configVersion` cannot be set or unset with the generic
walker.

`config get <key> --show-source` wraps the (redacted) value as
`{ value, source }`, where `source` is `"local"` when the local file's own
JSON sets the key, `"extends:<ref>"` for the nearest `extends` chain member
that sets it, or `"default"` when neither does. It is opt-in — plain
`config get` keeps its Stable, script-safe bare-value shape.

### Sharing configuration across installs

> **Deprecated (0.10.261120), removed in 0.11:** `extends` still works, and
> akm prints one stderr line per process when a config sets it (`--quiet`
> silences it). Copy the shared settings into each host's own config file;
> `akm config get <key> --show-source` shows which keys come from the base
> (`source` is `extends:<ref>`).

Five hosts running the same fleet often carry an identical `connections` map and
`improve.strategies` block, differing only in credential delivery, bundle paths,
and cron offsets. Hand-syncing that block across hosts drifts silently. `extends` fixes this: put the shared block in
one file, and have each host's local config extend it.

```jsonc
// bundles/fleet/config/shared.json — versioned with the bundle, shared by every host
{
  "configVersion": "0.9.0",
  "connections": {
    "fast": { "endpoint": "https://api.example.test/v1", "models": { "fast": "qwen3", "balanced": "qwen3" } }
  },
  "improve": { "connection": "fast", "strategies": { "nightly": { "processes": { "reflect": { "limit": 10 } } } } }
}
```

```jsonc
// ~/.config/akm/config.json — this host's local file, under 20 lines
{
  "configVersion": "0.9.0",
  "extends": "fleet//config/shared.json",
  "bundles": {
    "fleet": { "git": "https://github.com/example/fleet-bundle.git" },
    "stash": { "path": "~/akm-stash", "writable": true }
  },
  "defaultBundle": "stash",
  "connections": { "fast": { "apiKey": "$FAST_API_KEY" } }
}
```

`extends` accepts either form:

- A filesystem path — relative paths resolve against the directory of the
  config file that declares them; a leading `~` expands.
- A `bundle//<path>` ref — a plain file path *relative to that bundle's
  content root* (e.g. `config/shared.json`), resolved through the bundle's
  configured `path`, not the search index — so it never needs `akm index` to
  have run. This is not an asset ref: the path after `//` needs no asset type
  (`scripts/`, `knowledge/`, …) and the shared file is never indexed; it can
  live anywhere under the bundle. An empty, absolute, or content-root-escaping
  path is rejected. Only a filesystem bundle (`bundles.<id>.path`) can host an
  `extends` source; sync a `git`/`website` bundle with `akm bundle
  add`/`akm sync` first so the file is materialized locally, then point
  `extends` at it.

Shared layers carry portable policy, not host authority. `bundles`, source and
write defaults, registries, embedding connections, scheduler activation,
`experimental`, and setup state are ignored when inherited.
Connection and harness definitions may be shared, but credentials and
executable authority (`apiKey`, `bin`, `args`, and `workspace`) are ignored
when inherited and must be supplied by the local file; a key in the host's
`credentials.json` needs no entry at all. Improve publication (`strategies.*.sync`) is local as well. Bundle-relative chains stay physically inside
the bundle root for every hop; lexical `..` paths and symlink escapes are both
rejected before a referenced file is read.

There is no `extends: <url>` form: config load is synchronous and runs on
every invocation, and akm deliberately does not fetch network resources at
load time (the same reason `registries` is never fetched until a
registry-touching command runs). A URL-backed shared config should be synced
as a `git`/`website` bundle and referenced as `extends: bundle//<path>`
once materialized, reusing the sync machinery akm already has instead of a
second one inside config load.

The base config runs through the exact same load pipeline as the local
file — its own version shim, its own legacy-shape shim — so it can carry an
older `configVersion` independently, and it may itself set `extends`
(chained). Cycle detection (`ConfigError`, "extends cycle detected") stops A
extends B extends A instead of recursing forever. Merge order is
`DEFAULT_CONFIG` (outermost) → the resolved `extends` chain → the local
file's own keys (local always wins) — the same `deepMergeConfig` "override
wins" semantics `config set` already uses. A referenced file/bundle that does
not already exist locally is a load-time `ConfigError` naming the ref — akm
never fetches or syncs one on your behalf.

`akm config diff <path|bundle//path>` compares this host's EFFECTIVE
config (its own `extends` already applied) against another config file or
bundle-relative file (loaded through the same loader, so ITS `extends` is
honoured too), printing sorted `{ path, local, other }` rows for every leaf
that differs. Both sides are redacted the same way `config get`/`list` are
before comparison, so a differing secret never round-trips into the diff
output. Cross-host comparison (`ssh host2 akm config diff ...` in a loop) is
left to the operator; akm has no concept of a networked fleet to compare
against directly.

```sh
akm config diff ~/other-host/config.json
akm config diff fleet//config/shared.json
```

## Environment

| Variable | Purpose |
| --- | --- |
| `AKM_CONFIG_FILE` | Select a config file; `--config` wins. Children inherit its absolute path, including native rows written by `task sync`. Credentials and `models.json` stay in the default config directory. An empty value is warned about once and ignored. Does not change data, state, cache, or bundle locations. |
| `AKM_CONFIG_DIR` | Override the user config directory (or set `XDG_CONFIG_HOME`); used when no file selector is set |
| `AKM_BUNDLE_DIR` | Deprecated, stays retired in 0.11: register the bundle and select `defaultBundle`. Overrides the bundle directory |
| `AKM_DATA_DIR` | Override the data directory — `index.db`, durable `state.db`, and `akm.lock` (or set `XDG_DATA_HOME`) |
| `AKM_CACHE_DIR` | Override the cache directory — regenerable caches (or set `XDG_CACHE_HOME`) |
| `AKM_STATE_DIR` | Override the state directory — the scheduler lock and, per bundle, `akm improve`'s whole-run lock (or set `XDG_STATE_HOME`) |
| `AKM_SQLITE_JOURNAL_MODE` | Deprecated, no replacement; removed in 0.11. SQLite journal mode: `WAL` (default), `DELETE`, or `TRUNCATE` |
| `AKM_NPM_REGISTRY` | Base URL of an npm mirror; replaces `registry.npmjs.org` for npm bundle resolution |
| `AKM_REGISTRY_URL` | Deprecated; migrate the selection to config. Comma-separated registry URLs that replace the configured `registries` in every registry search akm performs; `akm registry list`, `akm doctor info` and the `egress-endpoints` health advisory still show the configured list (prefix an entry with `<provider>::` to choose a provider) |
| `AKM_VERBOSE` | Deprecated: use `--verbose`. A truthy value enables the same diagnostics |
| `AKM_DEBUG` | Deprecated: use `--verbose`. `1` prints a stack trace on unexpected internal errors |
| `AKM_UPGRADE_SKIP_CHECKSUM` | Deprecated, removed in 0.11: use `akm upgrade --skip-checksum` |
| `AKM_EVENT_SOURCE` | `user`, `agent`, `task`, `improve` or `audit` marks the provenance of the commands a process runs (usage events and CLI usage counts); akm sets it for the programs it runs for a task. Anything else means `unknown` |
| `AKM_TASK_REF` | Set by akm for the programs it runs for a task: the ref of that task. akm records it on its local per-invocation CLI usage record only ([CLI usage counts](data-and-telemetry.md#cli-usage-counts)); it is never sent |
| `AKM_TASK_STATE` | Experimental. Path of the JSON state file of a version 5 task run; akm sets it for a step it runs as a process and does not read it |

`AKM_SQLITE_JOURNAL_MODE` is Deprecated, has no replacement and is removed in
0.11. AKM uses WAL and, on its own, falls back to `DELETE` when the data
directory is on a detected network filesystem (NFS, SMB/CIFS, 9p such as WSL2's `/mnt/c`, CephFS, FUSE such as
sshfs or virtiofs). Detection works on Linux only, so a data directory on a network
filesystem on macOS or Windows is unsupported. In containers that are thrown
away, keep SQLite on local disk and use snapshots. An explicit `WAL` is treated
like the default, so the network fallback still applies.

## Retired Configuration

A key akm no longer reads is named once, ignored, and dropped by `akm migrate
apply`. That covers `profiles`, `llm`, `agent`, `features`, `stashes`,
`defaults.llm`, `defaults.agent`, `defaults.improve`, the settings that sat
under `index.<pass>` (`endpoint`, `provider`, `apiKey`, `baseUrl`,
`temperature`, `maxTokens`, `capabilities`), `index.graph.*`, every strategy's
`processes.graphExtraction.*`, a strategy's `processes.feedbackDistillation`
(use `processes.distill.enabled`), `processes.consolidate.incrementalSince`
and `neighborsPerChanged`, and `embedding.chunkSize`. The strategy name
`graph-refresh` is always refused, even when `improve.strategies["graph-refresh"]`
holds an override; `akm migrate apply` drops the override.

### The `engines` form

A config that holds `engines` or `defaults` loads: akm reads it in memory as
`connections` and `harnesses`, with one warning that names `akm migrate apply`.
`akm migrate apply` makes the same conversion permanent, under a backup, and
prints a note for everything it cannot carry. Credentials, `models.json` and
asset keys move as the table says.

| In the file | What `akm migrate apply` does |
| --- | --- |
| `engines.<name>` with `kind: "llm"` | `connections.<name>`. `endpoint`, `contextLength`, `timeoutMs`, `concurrency` and an `apiKey` that is a `$VAR` are kept. `model` becomes `models`, with `fast`, `balanced` and `reasoning` all naming it. `temperature`, `maxTokens`, `enableThinking`, `reasoningEffort` and `extraParams` become request fields (`temperature`, `max_tokens`, `enable_thinking` with `chat_template_kwargs.enable_thinking`, `reasoning_effort`, and the extras as written). `kind`, `provider` and `supportsJsonSchema` are dropped, with a note. |
| `engines.<name>` with `kind: "agent"` and `platform: "opencode-sdk"`, no `llmEngine` | `harnesses.<name>` with `platform: "opencode"`. The engine ran your own OpenCode, with its providers, models and logins, and the `opencode` harness runs it now. `bin`, `workspace`, `agent` and `timeoutMs` are kept, and `model` (an OpenCode `provider/model`) becomes `models`, naming it for all three aliases. `args` is dropped, with a note: 0.9 did not pass it to OpenCode. |
| `engines.<name>` with `kind: "agent"` and `platform: "opencode-sdk"`, with an `llmEngine` | Removed: OpenCode ran over that connection, which is what akm's own runtime is, so it has no entry. When `defaults.llmEngine` or `defaults.engine` names the engine, and `defaults.llmEngine` names no connection, the `llmEngine` connection becomes `default`. The engine's `model`, `timeoutMs`, `workspace`, `bin` and `agent` are dropped, with a note naming those it set. |
| `engines.<name>` with `kind: "agent"`, any other platform | `harnesses.<name>`, keeping `platform`, `bin`, `args`, `workspace`, `agent` and `timeoutMs`. `model` becomes `models`, naming it for all three aliases. |
| `defaults.llmEngine`, else `defaults.engine` when it names an LLM engine | That connection is renamed `default`, and every reference to the old name follows. An entry already called `default` moves aside to `legacy-default`, or the first `legacy-default-<n>` nothing else has: the renaming is one name to one name, so no two entries share a name and none is lost. A `defaults.llmEngine` that named an agent engine ran akm's model work there; model work runs on the default connection, else the default harness, so a note says when that is another place and names `improve.harness`. With no `defaults.llmEngine` and no connection, 0.9 ran no model work unless a setting named an engine and the default harness takes it now; a note says so and how to turn it off (`modelWork: false`). |
| `defaults.engine` naming an agent engine, when there are several | That harness is renamed `default`. With no `defaults.engine`, an engine called `opencode-sdk` is the default agent engine, as the 0.9 fallback made it. |
| No `defaults.engine` | 0.9 ran agent work on your own OpenCode, when it was installed. A note says where agent work runs now: on the harness if one is configured, else on akm's own runtime, and then how to enable the harness (`akm setup --harness opencode`). |
| `defaults.improveStrategy` | `improve.strategy`. |
| `models.json` | Folded into the `models` of the connections and harnesses it names; what it cannot place is listed in the notes. The `opencode-sdk` column names the harnesses that were `opencode-sdk` engines, and the `opencode` column those that were `platform: "opencode"`. A harness whose engine had a `model` of its own keeps it for every alias, over any column: it is what ran when a request named none. The file moves to `config-backups/` in the cache directory. |
| `apiKeyFile`, a literal `apiKey`, a `${secrets/...}` `apiKey` | The key moves to `credentials.json` for the connection and its endpoint; a note names where it was, never its value. A key that cannot be read stays on the connection as it was (`apiKey`, or `apiKeyFile` for a key file), with a note that it is still to do; a later run moves it once it can be read. |
| `AKM_ENGINE_<NAME>_API_KEY` or `AKM_LLM_API_KEY` set in the environment | `apiKey: "$AKM_ENGINE_<NAME>_API_KEY"` (or `$AKM_LLM_API_KEY`) on that connection. Set in no variable, an engine that names no key gets none, and a note names the variables 0.9 read. |
| `improve.strategies.<name>.engine`, `model`, `llm`, `timeoutMs` | Dropped, with a note: a strategy says which processes run, not where. |
| `engine`, `model`, `llm`, `timeoutMs` on a strategy's process, its `qualityGate` or its `triage.judgment` | Moved to `improve.processes.<process>` or `improve.qualityGate`, with `engine` becoming `connection` or `harness` by what it named. When that place already says, the first one is kept, with a note. |
| `index.defaults.*`, `index.<pass>.engine` | `index.*`, and `connection`. An index pass cannot name a harness, so an engine that named one is dropped, with a note; a pass that names nothing runs where model work does: on the default connection, else the default harness. |
| `workflow.judgeEngine` | Dropped, with a note: a gate's judge runs on the default connection, else the default harness. The note says whether the engine it named is that default, or the judge has moved. With none set, 0.9 ran the judge on `defaults.engine`; a note says when that is not where it runs now. |
| `engine:` in an asset's frontmatter, a workflow step or a task source | `connection:` or `harness:`, by what the configured target is; a name it cannot place becomes `harness:`, with a note. A bundle akm may not change, and an asset that is a symbolic link, are skipped. |

An `engine:` key on an asset that has not been migrated is read the same way,
with a one-time notice, and so is `--engine NAME` (hidden from `--help`): both
name a connection by that name, else a harness. While the config file is still
in the `engines` form they name the connection or harness that engine became, so
`engine: lab` still means the engine called `lab` after the conversion has
renamed it `default`. Once `akm migrate apply` has rewritten the file, the names
the engines had are kept in akm's data directory
(`migrate/engine-targets.json`), and the key and the flag go on meaning the same
engine until the migrator has rewritten every `engine:` key it can reach; an
asset in a read-only bundle, or a block it could not splice, is rewritten under
the same names by a later run, and an asset that is a symbolic link is read but
never rewritten, so it is listed as skipped and keeps the names until you change
the file it leads to. Then the names are forgotten, an old name that is
neither a connection nor a harness fails like any unconfigured name (exit 78),
and the run that forgets them prints one note listing each renamed engine and
the flag that replaces it. A script or scheduled command that passes `--engine`
is not one the migrator can reach: change it to `--connection` or `--harness`. A
remembered name whose connection is no longer configured fails like any
selection of an unconfigured name.