> ## 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.

# Plan and change checks

> How actual plan-check and actual impl-check choose the rules that apply, how the judge decides, and what each outcome and exit code means.

`actual plan-check` judges a plan and `actual impl-check` judges a diff, each against the rule files committed under `.actual/rules/`. Both run the same way: they select the rules that apply, ask a model to judge the plan or diff against them, and report one outcome. The plugin runs them in your coding agent, and you can run them yourself in a terminal or CI.

## The two checks

| | `actual plan-check` | `actual impl-check` |
| - | - | - |
| Judges | Plan text, from the argument, `--plan-file` or stdin | A `git diff`: by default the working tree against `HEAD`, untracked files included; or a diff on stdin or in `--diff-file` |
| In Claude Code | When the agent leaves plan mode, before you see the approval dialog | At the end of every turn, against the commit the turn started from, so work the agent committed during the turn counts |
| In Codex | When a Plan-mode turn ends | When any other turn ends |
| Round limit setting | `--max-rounds`, or `ACTUAL_PLAN_CHECK_MAX_ROUNDS` | `--max-rounds`, or `ACTUAL_IMPL_CHECK_MAX_ROUNDS` |

[actual plan-check](https://docs.actual.ai/cli/plan-check.md) and [actual impl-check](https://docs.actual.ai/cli/impl-check.md) list every flag.

## How rules are selected

A check judges only the rules that apply to the change, at most `--limit` rule files (20 by default). Selection runs in two stages over an index of your rule files.

```mermaid theme={null}
flowchart LR
    A["Rule files in .actual/rules/"] --> B["Scope index"]
    B --> C["Prefilter: up to --candidates files"]
    C --> D{"More candidates than --limit, with plan text to read?"}
    D -->|yes| E["Rank: a model keeps the files that govern"]
    D -->|no| F["Selected rules"]
    E --> F
    F --> G["Judge"]
```

### The scope index

The CLI indexes every `.md` file directly under `.actual/rules/` and caches the index in your config directory, under `~/.actualai/actual/scope-index/`, never in the repository. The cache is keyed by a SHA-256 of every rule file's bytes, so any edit, addition or removal rebuilds it. Building an index over 425 rule files takes about 130 ms, and a query against it is sub-millisecond. A decision whose status doesn't govern, such as `draft`, is left out of the index, so no check ever sees it. `actual rules index` shows the index, `--rebuild` on either check rebuilds it first, and `actual rules index --clear` removes every cached index.

### Stage 1: the prefilter

The prefilter ranks every rule file against the plan or diff with no model and no network. It scores five signals, each weighted on its own:

| Signal | Source | Weight |
| - | - | - |
| `path` | The paths a header declares, or else the operands of the file's `### Verify` block | 3.0 |
| `scope` | The rule's prose scope sentence | 2.0 |
| `path-terms` | The words inside those paths | 1.0 |
| `title` | The file's `#` heading | 1.0 |
| `slug` | The topic part of the file name | 0.5 |

A word scores by how rare it is across your rule files (inverse document frequency), so a word every file shares counts for nothing, and by how often the rule file uses it, with a cap so repetition can't buy rank. Paths match by depth: a rule for the exact directory a change touches outranks one for the whole tree. A decision's `!` excludes are a hard limit, applied before any scoring, and so is its root when its header declares paths. For a diff, the paths come from the diff's file headers.

The prefilter keeps up to `--candidates` rule files (30 by default; raised to `--limit` when smaller).

### Stage 2: the rank

When the prefilter keeps more candidates than `--limit` and there's plan prose to read, a model sorts the candidates into `governs`, `related` and `unrelated`, and the check drops `unrelated`. The model only judges the fixed list: it can't add a rule file or reorder within a verdict, and a rank that keeps nothing counts as failed. Any failure, including no runner or a 90-second deadline passing, falls back to the prefilter's answer.

In the agent, the checks skip this stage and use the prefilter alone, keeping their one model call for the judge inside Claude Code's 120-second hook timeout. In a terminal, `--no-rank` skips the stage too, which makes selection offline and exactly reproducible.

To see what a check would select without judging anything, run `actual rules select "<plan>"`, or `actual rules brief --file <path>` for one file.

## The judge

The judge is one model call, through the runner the CLI finds or the one `--runner` names. It gives each selected rule a verdict:

| Verdict | Meaning |
| - | - |
| `followed` | The change falls within the rule's domain and meets it. In the `--json` report, `span` quotes the line that shows it |
| `not_applicable` | Nothing in the change falls within the rule's domain |
| `conflicting` | The change breaks the rule |
| `requires_decision` | The change deliberately supersedes the rule and needs a person to decide |

Before CLI 0.15.0, `followed` and `not_applicable` were one verdict, `conforming`.

The check's outcome, the `status` field in `--json`, is one of four:

| Outcome | Meaning | Exit status |
| - | - | - |
| `conforming` | No rule conflicts | 0 |
| `conflicting` | At least one rule conflicts | 1 |
| `requires_decision` | A rule needs a person's decision | 0 |
| `not_checked` | No runner was available, no rule applied, or the judge call failed | 0 |

Only a conflict exits non-zero, so a CI job that gates on the exit status alone can't tell "checked and clean" from "couldn't check". Read `status` from `--json` to tell them apart. [Unattended agents and CI](https://docs.actual.ai/guides/unattended-agents-and-ci.md) has examples.

## In a session

Inside Claude Code or Codex, the plugin runs the checks in their hook modes, which add session rules:

* **A rule judged `followed` or `not_applicable` is cleared for the session**, so later rounds don't ask about it again.
* **`requires_decision` blocks like a conflict**, until you revise the change or override the rule.
* **Each rule has a round limit.** A rule that stays unresolved stops blocking after three denied rounds in a session (`--max-rounds`), counted per rule, and separately for plans and changes. A new conflict always starts its own count.
* **Overrides last the session.** An override clears a rule at both checks for the rest of the session. [Overrides](https://docs.actual.ai/guides/overrides.md) covers how to give one.
* **Failures fail open.** A missing or crashed CLI, a runner that can't be reached or an unreadable hook input lets the agent continue, with a message instead of a block.

Every round and override is recorded in `~/.actualai/actual/plan-check-overrides.log`.

## Run the checks yourself

From inside the repository:

```bash theme={null}
actual plan-check --plan-file plan.md --json
actual impl-check --json                 # the working tree against HEAD, untracked files included
git diff main...HEAD | actual impl-check  # a branch's changes, from stdin
```

The checks need a runner, the Claude Code CLI by default; `actual runners` lists the others and [Configuration keys](https://docs.actual.ai/cli/configuration-keys.md) shows how to choose one. They need no Actual AI account.


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