Skip to content
Skills Library
AI & agents · Tool integration

actual

/actual

Feature-complete companion for the actual CLI, an ADR-powered CLAUDE.md/AGENTS.md generator. Runs and troubleshoots actual adr-bot, status, auth, config, runners, and models, plus the Actual AI platform surface: login, logout, whoami, and advisor (org-scoped architecture Q&A). Covers all 5 runners (claude-cli, anthropic-api, openai-api, codex-cli, cursor-cli), all model patterns, all 3 output formats (claude-md, agents-md, cursor-rules), and all error types. Use when working with the actual CLI, running actual adr-bot, signing in to Actual AI, asking the advisor, configuring runners or models,

Licence
Apache-2.0
Last repository change
26.10.2026

Assessment and security

95/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content30 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
8
Scripts
1
HTML comments
2
URLs in SKILL.md
7
Deprecation

No signals detected. Repository changed on 26.10.2026, without references to retired models or APIs.

Licence

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

What to check before installing
  • 1 scripts in this package. Review them before installing, as Claude may execute them.
  • SKILL.md zawiera komentarze HTML (2). Nie widać ich w podglądzie Markdown, a model je czyta.

Scripts: scripts/diagnose.sh

What it does and when to use it

Feature-complete companion for the actual CLI, an ADR-powered CLAUDE.md/AGENTS.md generator. Runs and troubleshoots actual adr-bot, status, auth, config, runners, and models, plus the Actual AI platform surface: login, logout, whoami, and advisor (org-scoped architecture Q&A). Covers all 5 runners (claude-cli, anthropic-api, openai-api, codex-cli, cursor-cli), all model patterns, all 3 output formats (claude-md, agents-md, cursor-rules), and all error types. Use when working with the actual CLI, running actual adr-bot, signing in to Actual AI, asking the advisor, configuring runners or models,

Original author description

Feature-complete companion for the actual CLI, an ADR-powered CLAUDE.md/AGENTS.md generator. Runs and troubleshoots actual adr-bot, status, auth, config, runners, and models, plus the Actual AI platform surface: login, logout, whoami, and advisor (org-scoped architecture Q&A). Covers all 5 runners (claude-cli, anthropic-api, openai-api, codex-cli, cursor-cli), all model patterns, all 3 output formats (claude-md, agents-md, cursor-rules), and all error types. Use when working with the actual CLI, running actual adr-bot, signing in to Actual AI, asking the advisor, configuring runners or models,

How it works

  1. CLI Not Installed
  2. Commands
  3. Platform Identity & Advisor
  4. Plan- and Implementation-Stage Governance (Claude Code hooks)
  5. Runner Decision Tree
  6. Non-Interactive Environments
  7. Sync Quick Reference
  8. Operational Workflow: Running Sync
  9. Operational Workflow: Diagnostics
  10. Troubleshooting Quick Reference
Original SKILL.md headings · 838 lines, 8,407 words
SKILL.md preview
---
name: actual
description: >-
  Feature-complete companion for the actual CLI, an ADR-powered
  CLAUDE.md/AGENTS.md generator. Runs and troubleshoots actual adr-bot,
  status, auth, config, runners, and models, plus the Actual AI platform
  surface: login, logout, whoami, and advisor (org-scoped architecture
  Q&A). Covers all 5 runners (claude-cli, anthropic-api, openai-api,
  codex-cli, cursor-cli), all model patterns, all 3 output formats
  (claude-md, agents-md, cursor-rules), and all error types. Use when
  working with the actual CLI, running actual adr-bot, signing in to
  Actual AI, asking the advisor, configuring runners or models,
  troubleshooting errors, or managing output files.
---

# actual CLI Companion

Inline knowledge and operational workflows for the actual CLI. Read this file first; load reference files only when you need deeper detail for a specific topic.

## CLI Not Installed

If the `actual` binary is not in PATH, **stop before doing anything else** — all commands, pre-flight checks, and diagnostics require the CLI. Offer to install it rather than just printing the steps: ask using an interactive question tool (e.g. `AskUserQuestion`) so your turn actually pauses for an answer, and don't continue — not even to keep exploring or planning — until the user responds. Mentioning it and continuing anyway isn't the same as asking. If they agree, run the command yourself with the Bash tool; if they decline, leave it at that and resume — installation stays optional, but only once they've actually answered.

Detect with:
```bash
command -v actual
```

Install options (try in this order):

| Method | Command |
|--------|---------|
| npm/npx (quickest) | `npm install -g @actualai/actual` |
| Homebrew (macOS/Linux) | `brew install actual-software/actual/actual` |
| GitHub Release (manual) | Download from `actual-software/actual-releases` on GitHub |

For one-off use without installing globally:
```bash
npx @actualai/actual adr-bot [flags]
```

After installing (or after the user declines and installs it themselves), verify: `actual --version`

Before using a documented subcommand or flag, verify it exists in the installed
CLI with `actual --help` or `actual <subcommand> --help`. If it is missing,
help the user update the CLI; do not run development-only flags against an older
release.


## Commands

| Command | Purpose | Key Flags |
|---------|---------|-----------|
| `actual adr-bot` | Analyze repo, fetch ADRs, tailor, write output | `--dry-run [--full]`, `--force`, `--no-tailor`, `--project PATH`, `--model`, `--runner`, `--verbose`, `--reset-rejections`, `--max-budget-usd`, `--no-tui`, `--output-format`, `--show-errors` |
| `actual status` | Check output file state | `--verbose` |
| `actual auth` | Check the runner (coding-agent) auth status | (none) |
| `actual config show` | Display current config | (none) |
| `actual config set <key> <value>` | Set a config value | (none) |
| `actual config path` | Print config file path | (none) |
| `actual runners` | List available runners | (none) |
| `actual models` | List known models by runner | (none) |
| `actual login` | Sign in to Actual AI (browser OAuth) | `--org <id>`, `--api-url <url>`, `--no-browser` |
| `actual logout` | Sign out of Actual AI and clear local credentials | (none) |
| `actual whoami` | Show the signed-in Actual AI identity (no network) | (none) |
| `actual advisor "<query>"` | Ask the Advisor an architecture question | Released v0.2.0: `--org <uuid>`, `--repo <uuid>`, `--api-url <url>`; newer builds may add named/automatic scope |
| `actual cache clear` | Clear local analysis and tailoring caches | (none) |
| `actual plan-check` | Check an implementation plan against the rules in `.actual/rules/` | `--claude-hook`, `--rules-dir <dir>`, `--max-rounds` (newer builds only; verify with `actual plan-check --help`). Resolve plan text in the order below; never emit `permissionDecision: "allow"` |
| `actual impl-check` | Check a working-tree diff against the rules in `.actual/rules/` — plan-check's implementation-stage counterpart (AK-755) | `--claude-hook`, `--diff-file <path>`, `--rules-dir <dir>`, `--max-rounds` (newer builds only; verify with `actual impl-check --help`). `--claude-hook` always resolves the working-tree diff (tracked changes plus untracked, non-ignored files) against the commit the turn started from when a `UserPromptSubmit` call recorded one, otherwise against `HEAD`. Direct mode also accepts `--diff-file` or piped stdin, and diffs the working tree against `HEAD` when neither is given. Never emit `permissionDecision: "allow"` |
| `actual check-override` | A human explicitly clears a rule that `plan-check` or `impl-check` denied for a session (refuses to run non-interactively; never invoked by the agent). `plan-check-override` still works as a backward-compatible alias | `--session <id>`, `--rule <doc-slug>::<rule-id>` (repeatable), `--reason "<text>"` — all required; `--repo`/`--rules-dir` optional, defaulting to the current directory |

## Platform Identity & Advisor

These commands talk to the **Actual AI platform** (your account/org) and are **separate from `actual auth`** — `actual auth` only checks the local coding-agent/runner (claude/codex/cursor) that `adr-bot` drives. `login`/`logout`/`whoami` manage your Actual AI platform identity; `advisor` asks organization- or repository-scoped architecture questions against it. (The runner/model sections below pertain to `adr-bot`, not to these.)

**Endpoint config** — production works without an override.
- `login` reads `--api-url <url>`, then `ACTUAL_AUTH_URL`, then defaults to `https://app.actual.ai`.
- `advisor` reads `--api-url <url>`, then `ACTUAL_API_URL`, then defaults to `https://api-service.api.prod.actual.ai`.
- OAuth `client_id`/scopes default to `actual-cli` and `openid profile offline_access adr:query adr:review` (override via `ACTUAL_OAUTH_CLIENT_ID` / `ACTUAL_OAUTH_SCOPES`).

### login — interactive; hand off to the human

`actual login` runs a browser OAuth flow (auth-code + PKCE + a `127.0.0.1` loopback). **It needs a human at a browser, so an agent cannot complete it inside a non-interactive shell.** Drive it like this:

1. First check whether the user is already signed in with `actual whoami` (no network; non-zero exit / "Not signed in" when logged out). If signed in, skip login.
2. If not signed in, **ask the human to run login**, or run it for them and surface the URL:
   ```bash
   actual login --no-browser       # prints the authorize URL instead of opening a browser
   actual login --org <org-id>     # multi-org accounts: pre-select an org (single-org auto-selects)
   ```
   With `--no-browser`, give the printed URL to the user to open; the CLI waits on the loopback redirect to finish the sign-in.
3. A multi-org user who omits `--org` picks the org on the consent page; if the redirect times out, re-run with `--org <id>`.

Do **not** attempt to script the browser/consent step — treat login as a human handoff, then resume automation once `whoami` succeeds.

### whoami — safe, non-interactive

```bash
actual whoami
```

Prints the cached identity — Organization, Account, Member, Scopes — with **no network call**. Use it as the pre-flight gate before `advisor`: exit code `2` ("Not signed in to Actual AI") means run `login` first.

### logout

```bash
actual logout
```

Best-effort server-side token revoke, then always clears local credentials. Safe and non-interactive.

### advisor — non-interactive, async query

`actual advisor "<question>"` asks an architecture question. It is **agent-friendly** (no TTY required): it starts an async job, polls to completion, and prints a plain-text summary followed by the related ADRs. Progress ("advisor thinking…") goes to stderr; the answer goes to stdout.

```bash
actual advisor "How should I handle database access in a new service?"

# point at a local/staging endpoint — one export steers it; --api-url overrides
ACTUAL_API_URL=https://your-advisor-endpoint actual advisor "…"

# released v0.2.0: scope by connected-repository UUID
actual advisor "…" --repo <repo-uuid>

# newer builds only; verify these flags with `actual advisor --help`
actual advisor "…" --repo actual-software/actual-cli
actual advisor --show-scope
actual advisor --repo none
actual advisor --repo auto
```

Requires a valid signed-in session — `NotLoggedIn` (exit `2`) means run `login` first. The advisor transparently refreshes an expired token before the call. Output is human-readable text today (no `--json` flag yet).

Scope behavior is version-dependent:

- Released v0.2.0 accepts only a connected-repository UUID; omitting `--repo`
  uses organization scope.
- Newer builds may accept a name or `owner/name`, remember a per-working-tree
  scope, auto-detect from `origin`, and expose `--show-scope`, `--repo none`,
  and `--repo auto`.

Always inspect `actual advisor --help` before using the newer scope workflow.

> For the full OAuth flow, scopes, multi-org selection, the advisor poll model, and org/repo scoping, see `references/platform-advisor.md`.

## Plan- and Implementation-Stage Governance (Claude Code hooks)

This plugin ships Claude Code hooks that check an implementation plan, and separately
the diff an agent actually produces, against the ADR rules committed in the
repository. They are registered automatically on install — there is no manual setup.

| Hook | Event | What it does |
|------|-------|--------------|
| `hooks/preflight.sh` | `SessionStart` (`startup`, `resume`, `clear`, `compact`, `fork`) | Bootstrap preflight, silent and without running the CLI unless the repository has rules. It reports whether the `actual` CLI is installed, and compares `actual --version` with the minimum the plugin declares (`MIN_CLI_VERSION` in `hooks/lib/bootstrap.sh`). On an older CLI it asks the agent to offer the upgrade: the command `actual version --json` names for the channel that installed it, when it is one of the two commands actual-cli uses, the actual-releases page for a CLI installed some other way, or both the npm and Homebrew commands otherwise. Below `GATES_MIN_CLI_VERSION`, where a check stops running in full, the offer interrupts the task when the session starts (`startup`), and every later SessionStart repeats the news with the offer at a pause, asking the agent not to repeat it after a no. From that floor up it follows the report that governance is active, at a pause. A CLI whose `actual --version` fails runs no check, so it interrupts with the npm and Homebrew reinstall commands instead. The install and reinstall offers interrupt at every SessionStart, and ask the agent not to repeat them after a no. Each CLI call gets `CLI_CALL_TIMEOUT` seconds, and a `--version` that takes longer prompts nothing. When the rule files carry a YAML header (ADR header v2) and the CLI is too old to read it, it reports that instead (see "ADR header v2 rule files"). Re-runs after compact so the reminder survives summarization |
| `hooks/plan-gate.sh` | `PreToolUse` on `ExitPlanMode` | The plan/implementation boundary. Hands the plan to `actual plan-check` and blocks a non-conforming plan |
| `hooks/turn-start.sh` | `UserPromptSubmit` | Marks where each turn starts: runs `actual impl-check --claude-hook`, which on a `UserPromptSubmit` envelope records `HEAD` for the session, so the `Stop` check also covers work the agent commits, or commits and pushes, during the turn. Silent on every path, since this event's stdout is added to the prompt. Without it, the check diffs against `HEAD`. The dispatch needs CLI 0.7.0 or later, and on an older CLI the call would run a full check on every prompt, so the hook first checks that `actual impl-check --help` names `UserPromptSubmit` and does nothing when it doesn't |
| `hooks/impl-gate.sh` | `Stop` | The end-of-turn checkpoint (AK-754). Hands the turn's accumulated working-tree diff (tracked changes plus untracked, non-ignored files, against the commit `turn-start.sh` recorded when the turn began, or `HEAD` when none was) to `actual impl-check` and forces the agent to continue on a non-conforming diff. Fires **unconditionally, every turn** — never gated on `plan-gate.sh` having run earlier in the session, so a turn that skips plan mode entirely is still governed |
| `hooks/rules-brief.sh` | `PostToolUse` on `Read`, `PreToolUse` on `Edit\|Write` | Read-time briefing (AK-793) and the write-time reminder (AK-794), for versions of Claude Code that cannot load a mod. Hands the envelope to `actual rules brief --claude-hook` and forwards only an allowlisted `additionalContext` reply naming the event it was called for. Advisory: never denies, never decides, silent on any failure; on `PreToolUse` it names no `permissionDecision`, so the normal permission flow is unchanged. **Where the mod loads it stands down**: the mod passes `classic.PostToolUse` (Read) on with an `actual_rules_brief_by_mod` marker, and for Edit and Write sets `ACTUAL_SKILL_MOD_SESSION` to its session id before the hook runs, which the hook inherits and stands down on when it matches its own `session_id`. The mod writes no files. Edit and Write cannot carry a marker: the tool's arguments are what the permission check judges, and auto mode refuses to judge a Write with a field it does not know. Either way the brief is delivered once, by the path that also has a budget and a record, and every other hook on those events still runs. It has no budget, no session cap and none of the four limits below: it forwards none of them |
| `hooks/register.js` | Claude mod, `$.ui.log` per read and a `/rules-brief` pane | What briefing did, for the person watching. One line per read names the ADRs and rule counts; a read that briefed nothing says why (nothing new, budget spent, CLI error), from the reason the CLI names on stderr. A read of only ungoverned files reports nothing, since most files are ungoverned. `/rules-brief` lists the session oldest first, because a suppressed row only makes sense after the delivered row it refers to. The model reads none of it, so none of it is charged against the context budget — and nothing is reported in `claude -p`, the SDK, the VS Code chat panel or a cloud session |
| `hooks/register.js` | Claude mod, `tool.call` on `Bash`, `Read`, `Edit` and `Write` | Briefing for both the Read tool and reads that bypass it. Measured across 212 local sessions, 80% of file reads went through `cat`/`head`/`sed -n`/`grep`, which fires no Read hook. Briefs only a Bash command Claude Code reports as `isReadOnly`, in the call's context beside its output. `Edit` and `Write` are briefed as a reminder for a file never read (AK-794): it lands with the tool result, after the write, and a file already briefed by its read adds nothing and reports nothing. Requires Claude Code 2.1.287+, or 2.1.285/2.1.286 with `CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1` |
| `hooks/register.js` | Claude mod, `session.start`, `turn.complete` (main loop), `classic.SessionStart` (all but `startup`) and `ui.render` on `AbovePrompt` | The band above the prompt, showing the `line` of `actual session summary --session <id> --rules-dir <dir> --json` as given, such as `Actual AI: 3 of 12 ADRs added to context · 2 areas with no ADR` or `Actual AI: no ADR covers the 3 areas you worked in`. Read for the rules directory briefing uses, in the background at session start, after each main-loop turn, and on `/clear`, compaction, resume and fork. The ADR count can include the decisions of the one brief the session budget withheld, which the CLI recorded before the mod held it back. Empty with no rule files, no decision in them, no CLI or one too old to write the line, or `ACTUAL_CLI_SUBPROCESS=1`. Drawn in the terminal and the desktop app, and the model never reads it |

`PreToolUse` on `ExitPlanMode` fires **after** the plan is written and **before** the
user's plan-approval dialog, so a blocked plan is revised by the agent rather than
shown to the human as an approvable artifact.

This ordering is **observed behavior, not a documented contract**. It was verified on
Claude Code **2.1.231**: a hook deny on `ExitPlanMode` logs `ExitPlanMode tool
permission denied`, the agent receives the reason and revises, and no approval dialog
is shown. Re-check it when moving to a materially newer Claude Code. Enforcement does
not depend on it — a deny blocks the call whenever the hook runs — but the "the human
never sees a blocked plan" property does.

`Stop` fires when Claude finishes responding to a turn. Per Claude Code's own hooks
reference (https://code.claude.com/docs/en/hooks), a `Stop` hook forces continuation
through a top-level `{"decision":"block","reason":"..."}` (or exit 2 with the reason
on stderr) — a different JSON shape from `PreToolUse`'s
`hookSpecificOutput.permissionDecision`, and not one this plugin assumed by analogy:
it was verified against the documented Stop contract specifically, because the two
hook events are not guaranteed to behave identically. See "Stop hook: `impl-gate.sh`'s
JSON contract" below for why that distinction matters here in particular.

### This is an advisory gate, not an enforcement boundary

Worth stating plainly: this raises the cost of an unreviewed change and catches
oversights before they ship, but it is not a security control, and several
deliberate design choices mean it fails open rather than blocking under real-world
conditions:

- **Any infrastructure problem fails open** — no `actual` CLI installed, no runner
  available, the judge call itself failing, no plan text or diff resolvable, no rules
  directory readable. All of these degrade to a non-blocking notice, never a deny.
  A hook that could get stuck or wrongly block on its own dependencies being
  unavailable would make the tool itself unreliable for reasons that have nothing to
  do with the plan or the diff.
- **A rules corpus over ~60 individual rules selected for one plan or diff is only
  partially judged** — one large document is enough on its own, and several
  ordinary ones add up just as easily. A broad or vague plan, or a large diff, is
  *more* likely to hit this, not less, since the deterministic selector has no
  relevance threshold below which it stops adding documents. This is disclosed, not
  silent: a deterministically-prioritized prefix of the rules is judged and
  acted on normally, and every surface (the panel, `--json`'s `partial`
  field, the hook's deny message, and its otherwise-silent notice) says
  plainly "N of M rules checked" rather than either reporting the prefix as
  complete coverage or refusing to check anything at all.
- **The revision loop's own escape valves are additional, deliberate fail-open
  paths, not enforcement**: the round limit stops blocking a persistently
  unresolved rule specifically so the hook does not get uninstalled, and a human
  can run `actual check-override` to wave a specific rule through outright.
  An override recorded against a session clears that rule for both `plan-check` and
  `impl-check` checks of that session — one override, not two independent
  mechanisms. Both round-limit passes and overrides are recorded
  (`~/.actualai/actual/plan-check-overrides.log`), which makes them *inspectable*,
  not enforced.

None of this is a defect — a hook that could hang or wrongly block a tool call
under infrastructure failure would be worse than one that fails open — but treat
every deny this plugin produces as a strong nudge with a paper trail, not a
guarantee nothing gets past it.

### When the hooks do nothing

All three hooks are silent no-ops — no output, exit 0 — unless the repository has at
least one `*.md` file in `.actual/rules/`. Installing the plugin therefore has no
effect on repositories that are not governed by Actual.

The gates also never hard-fail. If the CLI is missing, too old, or crashes, the hook
reports the problem and **makes no blocking decision**, leaving the turn to proceed
normally. Only an explicit **deny** from `plan-check`/`impl-check` (JSON decision or
exit 2) can block, and only when the wrapper can read it: a verdict that carries a
`\uXXXX` escape anywhere, or a duplicate `permissionDecision` key, is refused with a
notice saying the material was not checked, because the wrapper matches bytes and
never parses JSON. A conforming plan must print no `permissionDecision` --
either empty stdout, or a bare `systemMessage` notice (a partial-coverage or
round-limit disclosure, for example) with no decision attached, are both the
contract. Never emit `permissionDecision: "allow"`: it is a
**grant**, and a gate has no business approving a plan on the user's behalf. On
Claude Code 2.1.231 an `allow` does not actually bypass the plan-approval dialog —
Claude Code logs `Hook returned 'allow' for ExitPlanMode, but ask rule/safety check
requires full permission pipeline` and prompts the user anyway — but that safety
check is undocumented, so the wrapper drops an `allow` verdict rather than rely on it.

### ADR header v2 rule files

A file in `.actual/rules/` may open with a YAML header (`---` on its first line)
carrying `adr_id`, `root`, `paths` and the like. The plugin never parses it. It counts
`*.md` files exactly as before, and the CLI reads the header to decide which decisions
govern a file. Files without a header are still the original format, and a repository
can hold both.

The CLI must be 0.9.0 or later to read the header. `rules brief --help` names the
capability marker `adr-header-v2` on a CLI that does, and the hooks probe for that
literal rather than comparing versions. A repository with a headed rule file and a CLI
without the marker is the one state that changes anything:

- `preflight.sh` emits an upgrade message (an instruction to the agent, escalated like
  the `plan-check` and `impl-check` ones) instead of the success message.
- `plan-gate.sh` and `impl-gate.sh` fail open with a one-line notice naming the
  upgrade, and run no check.
- `rules-brief.sh`, `turn-start.sh` and the mod's briefing stand down silently (the mod
  logs one `OLD CLI` row a session), because a brief built from the wrong scope would
  mislead and a notice on every read would be noise.

v1 repositories, and every CLI that names the marker, behave exactly as before. The
override syntax `<doc-slug>::<rule-id>` is unchanged.

### Which repository root is governed

`<repo>` is the checkout the session is actually working in. Two signals decide it,
because neither is sufficient alone. `CLAUDE_PROJECT_DIR` is Claude Code's project
root, but it does **not** follow the session into a git worktree — it keeps naming
the original checkout. The git toplevel of the working directory names the active
checkout, but when Claude Code was launched inside a subdirectory of a larger
repository it names the outer repo rather than the subproject.

When one contains the other, the **deeper** path wins, because it is the more
specific context:

| Situation | `CLAUDE_PROJECT_DIR` | git toplevel of cwd | Governed |
|---|---|---|---|
| Worktree | `/repo` | `/repo/.claude/worktrees/x` | the worktree |
| Monorepo subproject | `/repo/packages/api` | `/repo` | the subproject |
| Ordinary session | `/repo` | `/repo` | either, they agree |

Otherwise the two are unrelated — a worktree created outside the project root, say —
and the active checkout under the working directory wins.

Measured on Claude Code **2.1.231**: entering a worktree leaves `CLAUDE_PROJECT_DIR`
on the original checkout and moves the working directory to
`<project>/.claude/worktrees/<name>`, i.e. **nested inside** that project root. A
plain "is cwd inside `CLAUDE_PROJECT_DIR`" test therefore keeps the original root and
governs the wrong branch, which is why the rule is depth rather than containment.

### Stop hook: `impl-gate.sh`'s JSON contract

`impl-gate.sh` cannot forward `actual impl-check --claude-hook`'s stdout the way
`plan-gate.sh` forwards `plan-check`'s: `impl-check --claude-hook` reuses
`plan-check`'s own JSON renderer in the CLI, so its output is always
`PreToolUse`-shaped (`hookSpecificOutput.hookEventName: "PreToolUse"`,
`permissionDecision`), regardless of which Claude Code event is actually asking.
`Stop`'s own decision control is a **top-level** `decision`/`reason` pair —
`{"decision":"block","reason":"..."}` — with no `hookSpecificOutput` involved at
all. Forwarded verbatim, the CLI's verdict would carry no `decision` field Claude
Code recognizes for `Stop`, and the turn would end silently ungoverned — exactly
the failure this hook exists to prevent.

So `impl-gate.sh` classifies the CLI's verdict — the same byte-matching allowlist
`plan-gate.sh` applies (`is_deny_decision`, `has_system_message`,
`has_permission_decision`, and the `\uXXXX`-escape / duplicate-key guards; see
`hooks/lib/bootstrap.sh`) — and **re-renders** it in `Stop`'s own shape instead of
forwarding it:

- A recognized **deny** becomes `{"decision":"block","reason":"<extracted
  permissionDecisionReason>"}`. The reason text is pulled out of the CLI's JSON with
  a quote-aware byte scan (`extract_json_string_field`), never a JSON parse — same
  dependency-hygiene constraint as everything else in `bootstrap.sh` — and is only
  trusted once the escape/duplicate-key guards have already passed, since those are
  exactly what make quote-termination unambiguous. Whitespace between the field
  name, the colon, and the opening quote is skipped, so a pretty-printed verdict
  still yields its reason. A recognized deny whose reason cannot be read still
  blocks, with a fixed reason; it does not degrade to a notice.
- A recognized bare **notice** (partial coverage, round-limit pass — no permission
  decision at all) becomes a plain top-level `{"systemMessage":"..."}`. This is
  deliberately *not* `hookSpecificOutput.additionalContext`: per Claude Code's docs,
  `additionalContext` on `Stop` "keeps the conversation going through the same loop
  protections as `decision: block`" — i.e. it also forces continuation — so it is
  unsafe for a fail-open notice that must let the turn end normally.
  `systemMessage` is `Stop`'s only channel that does not force continuation.
- Anything unsafe to interpret (an escape or duplicate key) or anything not on the
  allowlist (e.g. a wrongly-emitted `allow`) produces no decision at all, same as
  `plan-gate.sh`.
- The exit-2 fallback path is the one place this **is** a straight passthrough:
  `Stop`'s exit-2 contract ("blocks, stderr is the reason Claude sees") is identical
  to `PreToolUse`'s, so `impl-gate.sh` just propagates the CLI's stderr and exit
  code unchanged.

This was verified against Claude Code's documented `Stop` hook contract
(https://code.claude.com/docs/en/hooks) specifically — not assumed from the
`PreToolUse`/`ExitPlanMode` precedent above. The two hook events are not
guaranteed to behave identically, and here, concretely, they don't: the CLI's
renderer has no notion of which event asked, so the shell wrapper is the only
place that distinction is applied.

### Environment variables

| Variable | Effect |
|----------|--------|
| `ACTUAL_PLAN_GATE=off` | Disable all of this plugin's governance hooks (`plan-gate.sh`, `impl-gate.sh`, `turn-start.sh`, and `preflight.sh`, including its minimum-version check) |
| `ACTUAL_RULES_DIR` | Govern against a different rules directory (e.g. a subproject in a monorepo). Each hook forwards the resolved path to the CLI as `--rules-dir`; `plan-check`/`impl-check` must honor that flag rather than rediscovering rules from cwd |
| `ACTUAL_PLAN_CHECK_MAX_ROUNDS` | Override `plan-check --claude-hook`'s round limit (default 3). Independent of the variable below — the two commands' revision loops are budgeted separately, even though they share session state |
| `ACTUAL_TURN_START_LOG` | Path of a file `turn-start.sh` appends the CLI's output and exit status to, for diagnosing a turn-start record that is never written, or a `skipped` line when the CLI has no `UserPromptSubmit` dispatch. Unset by default, which keeps the hook fully silent; set, the hook is still silent on stdout and stderr |
| `ACTUAL_IMPL_CHECK_MAX_ROUNDS` | Override `impl-check --claude-hook`'s round limit (default 3) |
| `ACTUAL_RULES_BRIEF=off` | Disable briefing alone — both the `Read` hook and the mod — while `plan-gate.sh` and `impl-gate.sh` keep running. Briefing is the only path that fires on every read, so it is the only one whose cost is worth dropping on its own |
| `ACTUAL_CLI_SUBPROCESS=1` | Set by actual-cli on the nested `claude -p` it runs as its conformance judge. Every hook and the mod exit silently when it is set: without it the judge's own `Stop` hook reruns `impl-check` and recurses, and briefing would inject rules into the judge's prompt that it was never asked to weigh |
| `ACTUAL_HOOK_DEBUG=1` | Report what briefing did, on stderr for the hook and in the transcript plus the model's context for the mod, which also adds a note when it does not brief: the resolved rules directory, the CLI's exit status and stderr, the reason a reply was dropped, and the characters injected so far against the session cap. Diagnostic only — it never changes a forwarding decision |
| `ACTUAL_RULES_BRIEF_MAX_SESSION_CHARS` | Characters of rule context briefing may inject in one session before it stops and says so (default 48000). Measured basis: 40 governed files against a 425-rule repository injected 18,751 characters with dedup active, so the default is ~2.5x an ordinary session. `0` disables briefing where the mod loads; `rules-brief.sh` enforces no cap |
| `ACTUAL_RULES_BRIEF_LIMIT`, `_RULES_PER_DECISION`, `_MAX_CHARS`, `_MIN_SCORE` | Forwarded by the mod to `actual rules brief` as `--limit`, `--rules-per-decision`, `--max-chars`, `--min-score`, and only when set (`rules-brief.sh` forwards none of them), so the CLI keeps owning its own defaults. `_MIN_SCORE` especially: unset it defers to the repository's `rules_min_score`, and a score measures how narrowly a rule's `verify` glob is written rather than how relevant the rule is, so no cross-repository default is correct |

The briefing limits (`ACTUAL_RULES_BRIEF_MAX_SESSION_CHARS`, `_LIMIT`,
`_RULES_PER_DECISION`, `_MAX_CHARS`, `_MIN_SCORE`) and `debug` also appear as
labelled `userConfig` rows under `/plugin`; the other variables have none, and
all of them are read by the mod only. An environment variable wins over its
row: the row is the durable preference, the variable is the override for one
session. The exception is `debug`, which is ORed with `ACTUAL_HOOK_DEBUG`
rather than overridden by it.

### `--claude-hook` plan resolution

The wrapper does not parse the hook envelope. `actual plan-check --claude-hook`
must resolve plan text itself, in this order, and stop at the first hit:

1. **`tool_input.plan`** — non-empty string. Current Claude Code injects the plan
   into the envelope before hooks run, even when the model's literal input was
   empty. Older builds also put the plan here.
2. **`tool_input.planFilePath`** — set and readable. Same injection; no transcript
   I/O.
3. **Transcript fallback** — only if both of those are missing: `prompt_id` +
   `transcript_path` → the `plan_mode` attachment → `planFilePath`. Do not scrape
   the transcript when (1) or (2) already produced the plan.
4. If none of those work: fail open (notice, no `permissionDecision`).

The hook always invokes `actual plan-check --claude-hook --rules-dir <dir>`,
where `<dir>` is `ACTUAL_RULES_DIR` if set, otherwise `<repo>/.actual/rules`.
`plan-check` must score that directory and must not ignore the flag in favor of
cwd. `--help` should list `--rules-dir`.

Stdout must be exactly one JSON object, or empty. Logs go to stderr. A line
before the JSON makes the wrapper drop a deny; `{...}` that is not valid hook
JSON is forwarded and Claude Code reports a hook error.

Fixtures under `hooks/tests/fixtures/` encode the three envelopes:

| Fixture | Shape |
|---------|--------|
| `pretooluse-plan-injected.json` | Current: `tool_input.plan` and `tool_input.planFilePath` |
| `pretooluse-plan-inline.json` | Legacy: plan in `tool_input.plan` only |
| `pretooluse-plan-file.json` | Legacy: empty `tool_input`; plan only via transcript |

### Briefing: two paths, one dedup store

Briefing is delivered by `hooks/rules-brief.sh` on `Read` and `Edit|Write` where
no mod loads, and by the mod on `Bash`, `Read`, `Edit` and `Write` where one
does, with the hook standing down for the events the mod owns. Both call `actual rules brief --claude-hook` rather than the simpler
`--file` direct mode, because only `--claude-hook` consults brief memory —
direct mode is stateless and returns the full brief every time. That is what
keeps a file read with the Read tool and then `cat` from being briefed twice.

The CLI names why it stayed quiet on **stderr**, as `no-brief=<token>`, with
tokens `ungoverned`, `already-briefed`, `outside-root`, `no-rules` and
`nothing-to-show`. That is the second interface between the two repositories,
and it exists because hook-mode stdout cannot explain itself: stdout carries
the brief the model reads, so any explanation printed there would be read as
governance. stderr reaches neither the model nor the user — the shell hook
keeps it for `--debug`, and the mod parses it.

Without it the two silences are indistinguishable, and the mod spent several
versions asserting whichever one it had guessed: `package.json,
pnpm-lock.yaml governed, already briefed this session`, for a lockfile nothing
governs. A mod reading a CLI too old to send a token falls back to naming both
possibilities rather than picking one.

Brief memory is keyed on **`(session_id, agent_id, rules_dir)`**, which makes
that key an interface between the two paths rather than an implementation
detail. Any component the two compute differently splits the key, and the
symptom is always the same: one read briefs twice, silently, and in a monorepo
the second brief is against the wrong rule set.

Two instances of that have already been fixed, both invisible at runtime:

- The mod did not forward `--rules-dir` at all. On a fixture whose root and
  subproject rule sets both match one file, the hook briefed the subproject's
  rule and the mod, same session, briefed the root's.
- The mod derived the rules directory from `$.session.root()`. No single mods
  API call matches `resolve_repo_root`: `$.session.root()` tracks the session's
  working directory, so it is right inside a worktree and wrong one directory
  below the repo root; `$.session.repo().root` is the main checkout, so it is
  wrong in exactly the opposite cases. A mod also cannot read
  `CLAUDE_PROJECT_DIR`, which Claude Code sets for hook processes only. The mod
  now runs `git rev-parse --show-toplevel` and applies the same deeper-of-the-two
  rule as `bootstrap.sh`, with the first `$.session.root()` it resolves, the
  directory the session was launched in, standing in for the variable. Claude
  Code keeps `CLAUDE_PROJECT_DIR` there through `/cd`, a worktree move and
  `/clear`, so a moved root decides only the cache key and where git runs. The
  answer is cached per session and `$.session.root()`, so a `/cd` or a worktree
  move resolves it again and a shell `cd` does not.

- The mod did not forward `agent_id`, the third component of the key. The Read
  hook's envelope carries it inside a subagent and the mod's event carries the
  same value as `e.agentId`, so the mod filed a subagent's reads under the
  parent's slot. This one causes *missed* briefs rather than duplicates: the
  subagent is denied a brief the parent already saw — which is precisely what
  keying on `agent_id` exists to prevent — and the parent's record is polluted
  with reads it never made.

A fourth divergence is not about the key but about the same question — which
directory a relative path belongs to. The Bash tool runs every command in one
persistent shell, so a `cd` in any call changes where every later call runs, and
on Claude Code 2.1.296 `$.session.cwd()` follows it. Session 9dc24b52 did `cd <repo>/apps/actual && ls lib/oauth/` and then
read `lib/oauth/verify-token.ts` twice; resolved against the session cwd those
became `<repo>/lib/oauth/...`, which does not exist, so the existence filter
dropped them and two briefs were lost. The mod keeps no copy of the shell's
directory: it reads `$.session.cwd()` before the call and joins a stated `cd`
onto that, since by the time the call returns the cwd already includes the `cd`.
Where no `cd` states a base it tries the live cwd, the session cwd and the repo
root in that order, letting the filesystem decide.
A `cd` the command *does* state is authoritative and gets no fallback, or
`cd /elsewhere && cat a.ts` would brief a same-named file inside the repository.

So when changing either path, change both. Check all four repository layouts —
a worktree with and without `CLAUDE_PROJECT_DIR`, a monorepo subproject named
by `CLAUDE_PROJECT_DIR`, and a session launched in a subdirectory — and the
`/cd` moves `hooks/register.test.ts` lists, since a `/cd` leaves
`CLAUDE_PROJECT_DIR` where the session started. Check both inside and outside a
subagent.

### `--claude-hook` diff resolution

Unlike plan text, there is no envelope field carrying the material to check — no
tool call injects a diff the way `ExitPlanMode` injects a plan. `actual impl-check
--claude-hook` always resolves the diff from the working tree in the resolved
repository root: tracked changes plus untracked files that are not gitignored,
against the commit the turn started from. `hooks/turn-start.sh` records that commit
on `UserPromptSubmit`, so work the agent committed, or committed and pushed, during
the turn is still checked at `Stop`. When no commit was recorded, or it is no longer
an ancestor of `HEAD` (an amend, rebase or branch switch during the turn), the diff
is against `HEAD`. A file the agent has written but not `git add`ed is part of that diff.
Gitignored files stay out. The hook envelope
(`hooks/tests/fixtures/stop-turn.json` is the recorded shape) is forwarded unparsed
purely to key the revision-loop session off `session_id`, the same way
`plan-check`'s envelope is. An empty diff (nothing changed since that commit and there
are no untracked, non-ignored files) is not an error — it is the ordinary "nothing
changed this turn" case — and degrades to a non-blocking notice, never a deny.

The hook always invokes `actual impl-check --claude-hook --rules-dir <dir>`, same
`<dir>` resolution as `plan-check`'s.

### Requirements

The hooks need the `actual` CLI at the version `MIN_CLI_VERSION` names in
`hooks/lib/bootstrap.sh`, or newer. In a repository with rules, `preflight.sh`
compares `actual --version` with it at `SessionStart` and on an older CLI asks the
agent to offer the upgrade. The command comes from `actual version --json`, which
names the one for the channel that installed the CLI without making a network
request. The agent runs it on a yes, so it is passed on only when it is one of the
two actual-cli uses, compared whole: `brew upgrade actual-software/actual/actual`, or
`npm install -g @actualai/actual` with or without `@latest`. Any other answer, and a
CLI older than that subcommand, gets both the npm and Homebrew commands, with a way
to tell which one installed it, since running the other would leave a second copy on
`PATH`. A CLI installed some other way gets the actual-releases page.

The offer interrupts the task only on a CLI older than `GATES_MIN_CLI_VERSION`, the
oldest release every check runs in full on, and only when a session starts. On a CLI
older than 0.7.0, the `Stop` check misses work committed during a turn, because
`turn-start.sh` needs that release's `UserPromptSubmit` dispatch. SessionStart fires
again on resume, clear, compact and fork, and each of those repeats the news with the
offer at a pause, asking the agent not to repeat it once the user has declined. A CLI
between that floor and `MIN_CLI_VERSION` runs every check, so the agent is told
governance is active and offers the upgrade at a pause.

A CLI that is on `PATH` but fails `actual --version` runs no check at all, which is
how npm's launcher behaves when its platform package is missing. Where rules are
committed, `preflight.sh` interrupts with the reinstall commands for both channels,
`npm install -g @actualai/actual` and `brew reinstall actual-software/actual/actual`,
and a way to tell which one installed it. Like the install offer for a CLI missing
from `PATH`, it interrupts at every SessionStart and asks the agent not to repeat it
once the user has declined. A `--version` that succeeds but names no
version prompts nothing, and neither does one still running after `CLI_CALL_TIMEOUT`
seconds, since a slow machine is not a broken install. `version --json` has the same
bound, and the two commands stand in for an answer that does not arrive.

A CLI too old for `plan-check` or `impl-check` is also caught where those run: the
relevant gate emits an upgrade message instead of a flag error. In `impl-gate.sh`
that is a one-line warning, because Stop's `systemMessage` is shown to the user and
does not reach Claude; the instruction to the agent is the SessionStart text above.

| Feature | Minimum `actual` | Probe |
|---------|------------------|-------|
| `plan-check` (plan gate) | earlier releases; any current CLI has it | `actual plan-check --help` |
| `impl-check` (Stop gate) | earlier releases; any current CLI has it | `actual impl-check --help` |
| Turn-start marker | 0.7.0 | `actual impl-check --help` names `UserPromptSubmit` |
| `rules brief` (briefing) | earlier releases; any current CLI has it | `actual rules brief --help` |
| Rule files with a YAML header (ADR header v2) | 0.9.0 | `actual rules brief --help` names `adr-header-v2` |

A repository with headed rule files and a CLI below 0.9.0 gets an upgrade instruction at `SessionStart`,
and each gate prints this instead of running a check:

> Actual governance stood down: .actual/rules/ uses the ADR header v2 format, which the installed `actual` CLI is too old to read (needs 0.9.0+), so this plan was not checked against them. Upgrade with `npm install -g @actualai/actual@latest` or `brew upgrade actual-software/actual/actual`.

(`impl-gate.sh` says "this turn's diff was not checked against them".)

### The revision loop, overrides, and round limits

A denied plan is not a dead end: the agent revises and calls `ExitPlanMode`
again, which fires the hook again. Likewise, a denied diff is not a dead end at
`Stop`: the agent is forced to continue, fixes it, and the next `Stop` re-evaluates
the new accumulated diff. Both commands track this per `(session_id, rules_dir)` —
not `session_id` alone, since one Claude Code conversation can govern more than one
repository or monorepo subproject (`ACTUAL_RULES_DIR`), and those commonly share
synced rule slugs from the same ADR bank. `plan-check` and `impl-check` sessions for
the same `(session_id, rules_dir)` share this same state — a rule an override clears
is cleared for both, and a session `impl-check` sees for the first time (no prior
`plan-check` call ever touched it) simply starts fresh, the same as any other new
session. State lives under the user's config directory, never inside the governed
repo.

- **A `requires_decision` verdict blocks exactly like a real conflict.** A
  plan the judge classifies as *deliberately* superseding a rule is not
  automatically believed — that classification is model output, not a
  recorded human decision — so it is denied the same way an outright
  violation is, not just noted and allowed to proceed.
- **Cleared rules stay cleared — for the plan text that earned it.** Once a
  rule is judged conforming against a specific plan, it is never sent to the
  judge again *for that same plan text* in this session — a later round
  cannot re-flag it, even if the judge would otherwise be non-deterministic
  about it. Edit the plan at all and the rule is judged fresh; a clearance is
  never a standing pass regardless of what the plan says later.
- **An explicit, recorded override.** A human — never the agent — runs
  `actual check-override --session <id> --rule <doc-slug>::<rule-id>
  --reason "<why>"` directly, from an interactive terminal (it refuses to run
  non-interactively, since the whole point is that this is a human action).
  `plan-check-override` still works as a backward-compatible alias. The deny
  message names the session id but deliberately does not hand back a
  ready-to-paste invocation — run `actual check-override --help` for the
  exact flags, and pass `--repo`/`--rules-dir` if you are not standing in the
  same repo the denial came from. An overridden rule is excluded from judging
  from then on regardless of plan or diff text — by both commands, since they
  share session state — and every subsequent round says so in a non-blocking
  notice — an override is visible, never a silent bypass.
- **A round limit, tracked per rule.** After `--max-rounds` (default 3, or
  `ACTUAL_PLAN_CHECK_MAX_ROUNDS` / `ACTUAL_IMPL_CHECK_MAX_ROUNDS` respectively —
  each command's revision loop is budgeted independently) denials of the *same
  rule*, the gate stops blocking on that rule specifically, rather than denying
  indefinitely. A rule that has exhausted its own count never exempts a different,
  still-fresh conflict in the same round — the whole call stays denied until
  every currently-blocking rule has individually hit its limit. This pass is
  not silent either: the hook emits a loud notice, and both an override and a
  round-limit pass are appended to `~/.actualai/actual/plan-check-overrides.log`
  (kept under its original filename for history continuity; JSONL, one line per
  event) for a durable, inspectable trace.

For `impl-gate.sh` specifically, a round-limit pass or override clearance is a bare
notice — see "Stop hook: `impl-gate.sh`'s JSON contract" above: it renders as a
plain `systemMessage`, never `hookSpecificOutput.additionalContext`, since the
latter would force continuation for a condition this is deliberately choosing not
to block on.

### Testing the hooks

```bash
bash hooks/tests/run.sh
```

Runs the full decision matrix (no-op, missing binary, old CLI, pass, deny, crash)
against recorded hook payloads and a fake CLI, for both `plan-gate.sh` and
`impl-gate.sh`. No network and no real `actual` install required.

## Runner Decision Tree

Use this to determine which runner a user needs:

```
Has claude binary installed?
  YES -> claude-cli (default runner, no API key needed)
  NO  -> Do they want Anthropic models?
           YES -> anthropic-api (needs ANTHROPIC_API_KEY)
           NO  -> Do they want OpenAI models?
                    YES -> codex-cli or openai-api (needs OPENAI_API_KEY)
                    NO  -> cursor-cli (needs agent binary, optional CURSOR_API_KEY)
```

### Runner Summary

| Runner | Binary | Auth | Default Model |
|--------|--------|------|---------------|
| claude-cli | `claude` | `claude auth login` | claude-sonnet-4-6 |
| anthropic-api | (none) | `ANTHROPIC_API_KEY` | claude-sonnet-4-6 |
| openai-api | (none) | `OPENAI_API_KEY` | gpt-5.2 |
| codex-cli | `codex` | `OPENAI_API_KEY` or `codex login` (ChatGPT OAuth) | gpt-5.2 |
| cursor-cli | `agent` | Optional `CURSOR_API_KEY` | (cursor default) |

### Model-to-Runner Inference

The CLI auto-selects a runner from the model name:

| Model Pattern | Inferred Runner |
|---------------|-----------------|
| `sonnet`, `opus`, `haiku` (short aliases) | claude-cli |
| `claude-*` (full names) | anthropic-api |
| `gpt-*`, `o1*`, `o3*`, `o4*`, `chatgpt-*` | codex-cli |
| `codex-*`, `gpt-*-codex*` | codex-cli |
| Unrecognized | Error with suggestions |

> For deep runner details (install steps, compatibility, special behaviors), see `references/runner-guide.md`.

## Non-Interactive Environments

This skill runs inside coding agents (Claude Code, Codex, Cursor) where the Bash tool does **not** provide a TTY. The CLI's TUI prompts and confirmation dialogs will fail with `TerminalIOError` unless disabled.

**Always pass `--force --no-tui`** on every `actual adr-bot` invocation:
- `--no-tui` disables TUI rendering that requires a terminal
- `--force` skips interactive confirmation prompts that cannot receive input

Use the agent's built-in question/confirmation tools (e.g., `AskUserQuestion`) for user confirmation instead of relying on CLI prompts.

## Sync Quick Reference

The most common sync patterns:

```bash
# Preview what sync would do (safe, no file changes)
actual adr-bot --dry-run --force --no-tui

# Preview with full content
actual adr-bot --dry-run --full --force --no-tui

# Run sync
actual adr-bot --force --no-tui

# Sync specific subdirectories only (monorepo)
actual adr-bot --force --no-tui --project services/api --project services/web

# Use a specific runner/model
actual adr-bot --force --no-tui --runner anthropic-api --model claude-sonnet-4-6

# Skip AI tailoring (use raw ADRs)
actual adr-bot --force --no-tui --no-tailor

# Re-offer previously rejected ADRs
actual adr-bot --force --no-tui --reset-rejections

# Set spending cap
actual adr-bot --force --no-tui --max-budget-usd 5.00
```

> For the complete 13-step sync internals, see `references/sync-workflow.md`.

## Operational Workflow: Running Sync

Follow this pattern whenever running sync. Do NOT skip pre-flight.

### 0. Verify CLI installed (LOW freedom -- exact check)

```bash
command -v actual       # Must succeed before anything else
```

If missing, follow the install steps in [CLI Not Installed](#cli-not-installed) above. Do NOT proceed until `actual --version` succeeds.

### 1. Pre-flight (LOW freedom -- exact commands)

```bash
actual runners          # Verify runner is available
actual auth             # Verify authentication (for claude-cli)
actual config show      # Review current configuration
```

If any check shows a problem, diagnose and fix before proceeding.

### 2. Dry-run (LOW freedom -- exact command)

```bash
actual adr-bot --dry-run --force --no-tui [--full] [user's flags]
```

Show the user what would change. Let them review.

### 3. Confirm (HIGH freedom)

Ask user if they want to proceed using the agent's built-in tools (e.g., `AskUserQuestion`). Do NOT rely on CLI prompts — they will fail in non-interactive shells. If no, stop.

### 4. Execute (LOW freedom -- exact command)

```bash
actual adr-bot --force --no-tui [user's flags]
```

### 5. On failure: Diagnose

Match the error against the troubleshooting table below. For full error details, load `references/error-catalog.md`.

### 6. Fix and retry

Apply the fix, then return to step 1 to verify.

## Operational Workflow: Diagnostics

For comprehensive environment checks, run the bundled diagnostic script:

Run the bundled `scripts/diagnose.sh` by its absolute path under the active
`actual` skill directory. Do not assume a Claude-specific install location.
For example, when the current directory is the skill directory:

```bash
bash scripts/diagnose.sh
```

This checks all binaries, auth status, environment variables, config, and output files in one pass. It is read-only and never modifies anything.

Use inline commands instead when checking a single thing (e.g., just `actual auth`).

## Troubleshooting Quick Reference

| Error | Exit Code | Likely Cause | Quick Fix |
|-------|-----------|-------------|-----------|
| ClaudeNotFound | 2 | `claude` binary not in PATH | Install Claude Code CLI |
| ClaudeNotAuthenticated | 2 | Not logged in | Run `claude auth login` |
| CodexNotFound | 2 | `codex` binary not in PATH | Install Codex CLI |
| CodexNotAuthenticated | 2 | No auth for codex | Set `OPENAI_API_KEY` or run `codex login` |
| CursorNotFound | 2 | `agent` binary not in PATH | Install Cursor CLI |
| ApiKeyMissing | 2 | Required env var not set | Set `ANTHROPIC_API_KEY` or `OPENAI_API_KEY` |
| NotLoggedIn | 2 | Not signed in to the Actual AI platform | Run `actual login` |
| CodexCliModelRequiresApiKey | 2 | ChatGPT OAuth with explicit model | Set `OPENAI_API_KEY` (OAuth only supports default model) |
| CreditBalanceTooLow | 3 | Insufficient API credits | Add credits to account |
| ApiError | 3 | API request failed | Check API URL, network, credentials |
| ApiResponseError | 3 | Unexpected API response | Check API status, retry |
| RunnerFailed | 1 | Runner process errored | Check runner output, logs |
| RunnerOutputParse | 1 | Could not parse runner output | Check model compatibility |
| RunnerTimeout | 1 | Runner exceeded time limit | Increase `invocation_timeout_secs` |
| ConfigError | 1 | Invalid config file | Check YAML syntax, run `actual config show` |
| AnalysisEmpty | 1 | No analysis results | Check project path, repo content |
| TailoringValidationError | 1 | Tailored output invalid | Retry, or use `--no-tailor` |
| TerminalIOError | 1 | CLI needs a TTY (non-interactive shell) | Add `--force --no-tui` flags |
| IoError | 5 | File I/O failure | Check permissions, disk space |
| UserCancelled | 4 | User cancelled operation | (intentional) |

> For full error details with hints and diagnosis steps, see `references/error-catalog.md`.

## Exit Code Categories

| Code | Category | Errors |
|------|----------|--------|
| 1 | General / runtime | RunnerFailed, RunnerOutputParse, ConfigError, RunnerTimeout, AnalysisEmpty, TailoringValidationError, InternalError, TerminalIOError |
| 2 | Auth / setup | ClaudeNotFound, ClaudeNotAuthenticated, CodexNotFound, CodexNotAuthenticated, CursorNotFound, ApiKeyMissing, CodexCliModelRequiresApiKey, NotLoggedIn |
| 3 | Billing / API | CreditBalanceTooLow, ApiError, ApiResponseError |
| 4 | User cancelled | UserCancelled |
| 5 | I/O | IoError |

## Config Quick Reference

Config file: `~/.actualai/actual/config.yaml` (override with `ACTUAL_CONFIG` or `ACTUAL_CONFIG_DIR` env vars).

Most-used config keys:

| Key | Default | Purpose |
|-----|---------|---------|
| `runner` | claude-cli | Which runner to use |
| `model` | claude-sonnet-4-6 | Model for Anthropic runners |
| `output_format` | claude-md | Output format: claude-md, agents-md, cursor-rules |
| `batch_size` | 15 | ADRs per batch (min 1) |
| `concurrency` | 10 | Parallel requests (min 1) |
| `invocation_timeout_secs` | 600 | Runner timeout in seconds (min 1) |
| `max_budget_usd` | (none) | Spending cap (positive, finite) |

> For all 18 config keys with validation rules, see `references/config-reference.md`.

## Output Formats

| Format | File | Header |
|--------|------|--------|
| claude-md (default) | `CLAUDE.md` | `# Project Guidelines` |
| agents-md | `AGENTS.md` | `# Project Guidelines` |
| cursor-rules | `.cursor/rules/actual-policies.mdc` | YAML frontmatter (`alwaysApply: true`) |

Managed sections use markers: `<!-- managed:actual-start -->` / `<!-- managed:actual-end -->`.

Merge behavior:
- **New root file**: header + managed section
- **New subdir file**: managed section only (no header)
- **Existing with markers**: replace between markers, preserve surrounding content
- **Existing without markers**: append managed section

> For full format details and merge internals, see `references/output-formats.md`.

## Reference Files

Load these only when you need deeper detail on a specific topic:

| File | When to Load |
|------|-------------|
| `references/sync-workflow.md` | Debugging sync failures, understanding sync internals |
| `references/runner-guide.md` | Setting up a runner, model compatibility, runner-specific behavior |
| `references/error-catalog.md` | Troubleshooting a specific error with full diagnosis steps |
| `references/config-reference.md` | Looking up config keys, validation rules, dotpath syntax |
| `references/output-formats.md` | Output format questions, managed section behavior, merge logic |
| `references/platform-advisor.md` | Login/OAuth flow, scopes, multi-org selection, advisor poll model, org/repo scoping |

## Additional Resources

For anything not covered by this skill or its reference files, fetch the full CLI documentation:

- **Full docs (Markdown)**: https://cli.actual.ai/docs.md — complete command reference, all flags, runners, output formats, config keys, and troubleshooting
- **LLM summary**: https://cli.actual.ai/llms.txt — concise machine-readable overview
Files in this package (8)
  • SKILL.md 55 KB
  • references/config-reference.md 7 KB
  • references/error-catalog.md 15 KB
  • references/output-formats.md 4 KB
  • references/platform-advisor.md 10 KB
  • references/runner-guide.md 9 KB
  • references/sync-workflow.md 9 KB
  • scripts/diagnose.sh 5 KB

Versions

The database has no other skills named actual.

Database snapshot: 13.11.2026 · package version 344fe38d8b50 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 95ai-coding-agents
    Comprehensive guide for using Codex CLI (OpenAI) and Claude Code CLI (Anthropic) - AI-powered coding agents. Use when orchestrating CLI commands, automating tasks, configuring agents, or troubleshooting issues.
  • 90codex-cli-specialist
    OpenAI Codex CLI and cross-platform skill authoring. Use when setting up Codex CLI, converting or syncing skills between Claude Code and Codex, configuring agents/openai.yaml, or validating cross-platform skill compatibility.
  • 100agents-md-starter
    Creates or upgrades a repository's AGENTS.md (read by Codex, Cursor, and other agents) and a CLAUDE.md that imports it, so Claude Code, Codex, Cursor and Gemini CLI share one set of project rules. Scans the repo to detect languages, package manager, real build/test/lint…
  • 100install-user-instructions
    Install, update, or audit general user-level AI coding instructions across Claude Code, OpenAI Codex, GitHub Copilot CLI, and Cursor. Use when the user asks to set up global instructions, personal AGENTS.md or CLAUDE.md defaults, configure instructions for multiple agent…
  • 90gemini-agent-sdk
    Build Gemini-backed agent workflows and adapters. Use for Google Gemini API/ADK-style runners, Gemini CLI workflow parity, tool calling, structured outputs, or adding a Gemini variant beside Cursor/OpenCode/Claude runners.
  • 100import
    Adopt a project's existing AI config (CLAUDE.md, AGENTS.md, .cursor/rules, and friends) into agnostic-ai specs, then fan it out to every other tool. Use when the project already has config for one AI CLI and should feed the rest.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.