> ## Documentation Index
> Fetch the complete documentation index at: https://docs.actual.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Unattended agents and CI

> Run the checks where nobody is watching, in an agent that approves its own passing plans and in a CI job that reads the check's status.

The checks work the same way with nobody watching. What changes is who answers the dialogs, and how a job tells a clean result from one that couldn't be checked.

## An agent nobody is watching

Claude Code holds a plan that passes the check at its approval dialog until someone answers, so an unattended agent would wait there for good. Turn on **Governance: approve plans for an unattended agent** under `/plugin`, or set `ACTUAL_UNATTENDED=on`, and the plugin answers that dialog for the agent:

* The plan check still runs first. A conflicting plan is denied and revised as before.
* A plan that passes, or that couldn't be checked, is approved, and the session goes back to the permission mode it had before planning.
* The denial dialog is off too, so the agent revises on its own.
* While it's on, it approves plans in every repository, with rules or without.

It's off by default. Leave it off wherever a person reviews plans, because it approves on their behalf. `ACTUAL_UNATTENDED=on` or `=off` wins over the `/plugin` row, and `ACTUAL_PLAN_GATE=off` turns it off along with the rest of governance.

In Codex, a run nobody is watching, such as `codex exec`, takes `ACTUAL_UNATTENDED=on` or `ACTUAL_OVERRIDE_DIALOG=off`. A conflict then sends the agent straight back to revise, instead of ending the turn to ask you. See [Codex](https://docs.actual.ai/guides/codex.md).

## Checks in CI

`actual plan-check` and `actual impl-check` need no Actual AI account, only a runner to judge the rules. In CI, an API runner is the usual choice:

| Runner | What it needs |
| - | - |
| `anthropic-api` | `ANTHROPIC_API_KEY` |
| `openai-api` | `OPENAI_API_KEY` |
| `claude-cli` | Claude Code installed and signed in. The default runner |
| `codex-cli` | The `codex` binary on your `PATH` |
| `cursor-cli` | `cursor-agent` on your `PATH` |

Pass `--runner` on each call, or set it once with `actual config set runner anthropic-api`.

Each check reports one of four outcomes in the `status` field of its `--json` output:

| `status` | Meaning | Exit code |
| - | - | - |
| `conforming` | Checked, and nothing conflicts | 0 |
| `conflicting` | At least one rule conflicts | 1 |
| `requires_decision` | The change deliberately supersedes a rule and needs a person to decide | 0 |
| `not_checked` | No runner was available, no rule applied, or the judge call failed | 0 |

Only a conflict exits non-zero, so a job that gates on the exit code alone can't tell "checked and clean" from "couldn't check". Read `status` instead. With `--json`, the report is printed before a conflict exits 1.

This GitHub Actions job checks a pull request's changes with the Anthropic API runner:

```yaml theme={null}
name: Architecture rules
on: pull_request

jobs:
  impl-check:
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Install the Actual CLI
        run: npm install -g @actualai/actual
      - name: Check the change against the rules
        env:
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
        run: |
          git diff "origin/${{ github.base_ref }}...HEAD" \
            | actual impl-check --runner anthropic-api --json > impl-check.json || true
          status=$(jq -r '.status' impl-check.json 2>/dev/null || echo "no report")
          echo "impl-check status: $status"
          case "$status" in
            conforming) ;;
            conflicting) echo "::error::The change conflicts with an architecture rule."; exit 1 ;;
            *) echo "::warning::impl-check reported $status." ;;
          esac
```

`impl-check` checks a diff piped to it or named with `--diff-file`; with nothing piped, it checks the working tree against `HEAD`, untracked files included. To check a plan, run `actual plan-check --plan-file plan.md --json` and read `status` the same way. On Linux, the CLI's prebuilt binary needs glibc 2.39 or newer, which `ubuntu-24.04` has; see [Install the CLI](https://docs.actual.ai/install-cli.md).

## Signed-in commands without a browser

The commands that act on Actual AI, `actual advisor` and the signed-in `actual adr` commands, use the sign-in that `actual login` stores. A person completes that sign-in in a browser; an agent can't.

* `actual login --no-browser` prints the sign-in URL instead of opening a browser, which helps over SSH.
* The CLI renews the stored sign-in as it uses it.
* `actual whoami --check` asks the server whether the sign-in still works, renewing it first when it's about to expire. It exits 2 when someone needs to run `actual login` again, and 3 when the server can't be reached, so an unattended run can check first and stop with a clear message. It needs Actual CLI 0.15.0 or later.

## Tokens for headless callers

Two commands mint an Actual AI access token for a caller that has no browser: `actual mint-token` from a service-account key, and `actual auth create-token` from your own sign-in.

> [!NOTE]
>
> In Actual CLI v0.16.0, the CLI's own signed-in commands read the sign-in that `actual login` stores, whichever token you mint. `actual auth create-token` suggests passing its token as `ACTUAL_TOKEN`, but no v0.16.0 command reads that variable.

### Service-account tokens

`actual mint-token` needs no sign-in. It signs a short-lived assertion with a service-account private key whose public half is registered with Actual AI, and trades it for an access token through the [RFC 7523](https://datatracker.ietf.org/doc/html/rfc7523) jwt-bearer grant:

```bash theme={null}
export ACTUAL_SERVICE_ACCOUNT_KEY="$(cat service-account.pk8.pem)"
TOKEN=$(actual mint-token \
  --service-account-id <service-account-uuid> \
  --kid <key-id> \
  --scope adr:query --scope adr:review)
```

| Input | Flag | Variable |
| - | - | - |
| Service-account id, a UUID. Required | `--service-account-id` | `ACTUAL_SERVICE_ACCOUNT_ID` |
| The registered key's id. Required | `--kid` | `ACTUAL_SERVICE_ACCOUNT_KID` |
| The private key's PEM contents | none | `ACTUAL_SERVICE_ACCOUNT_KEY` |
| A path to the private key's PEM file | `--key` | `ACTUAL_SERVICE_ACCOUNT_KEY_FILE` |

A key file wins when both key variables are set, and no flag takes the key itself, which keeps it out of the process list and your shell history. An EC (P-256) key must be PKCS#8, the PEM that opens `BEGIN PRIVATE KEY`; convert one that opens `BEGIN EC PRIVATE KEY` with `openssl pkcs8 -topk8 -nocrypt -in sec1.pem -out service-account.pk8.pem`. RSA keys load in either encoding. `--scope` asks for part of the service account's grant, and the server mints its full grant when you leave it out.

The token is the only thing `mint-token` writes to standard output, so `TOKEN=$(...)` captures exactly the token; `--json` prints the full response, with its lifetime and granted scope, as one line instead. The signed assertion lives 60 seconds by default (`--assertion-ttl-seconds`, up to 300). In CI, mint once per job and mask the token before anything can log it:

```yaml theme={null}
- name: Mint a service-account token
  env:
    ACTUAL_SERVICE_ACCOUNT_KEY: ${{ secrets.ACTUAL_SERVICE_ACCOUNT_KEY }}
    ACTUAL_SERVICE_ACCOUNT_ID: ${{ secrets.ACTUAL_SERVICE_ACCOUNT_ID }}
    ACTUAL_SERVICE_ACCOUNT_KID: ${{ vars.ACTUAL_SERVICE_ACCOUNT_KID }}
  run: |
    TOKEN=$(actual mint-token --scope adr:query)
    echo "::add-mask::$TOKEN"
```

Treat the private key as more sensitive than any token: a leaked token is revoked once, while a leaked key keeps minting tokens until its public half is replaced.

### Personal access tokens

> [!WARNING]
>
> `actual auth create-token` is a prototype. The server endpoint it calls isn't final, so its path and payload may change.

`actual auth create-token` mints a scoped personal access token from the sign-in `actual login` stored, so it needs that sign-in first:

```bash theme={null}
actual auth create-token --name deploy-bot --scopes adr:query,adr:review
```

`--name` labels the token and the agent that uses it, and `--scopes` takes a comma- or space-separated list. The token is printed once, on its own line on standard output, and then kept in your OS keychain. Where no keychain is available, set `ACTUAL_TOKEN_PASSPHRASE` and it's kept in an encrypted file under the CLI's config directory instead; `ACTUAL_TOKEN_STORE` picks the store (`auto`, the default, `keyring` or `file`).

### Keep tokens away from the agent

* **One token per agent.** Mint a separate token for each agent, named after it, so every action is attributable and you can revoke one token without touching the others. Never hand an agent your own sign-in.
* **The token never enters the model's context.** Keep it out of prompts, the conversation, shell history, command-line arguments and logs. An agent reads untrusted input, and an injected instruction can only send out a secret that's in its context.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.