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

# Decisions and rule files

> What a decision holds, the two files it lives in, and which statuses the checks enforce.

A decision records an architecture choice your team has made, as a set of policies. Each decision in a repository has two files: the decision document under `docs/adr/`, which people read, and a rule file under `.actual/rules/`, which the checks read. Both are laid out the way Actual AI's repository sync writes them, so a later sync updates the same files instead of adding a second copy.

## A decision's parts

| Part | What it holds |
| - | - |
| Title | The decision, on one line, such as "Use Postgres for storage" |
| Context | Why the decision is needed, as a list of points |
| Policies | The rules, each written `LEVEL: statement`. The levels are `MUST`, `MUST NOT`, `SHOULD`, `SHOULD NOT` and `MAY` |
| Scope | The paths the decision governs, as globs relative to the repository root. A glob that starts with `!` excludes. No scope means the whole repository |
| Deciders | Who made the decision |
| Status | Whether the decision governs. See [Accepted or draft](#accepted-or-draft) |

A decision document can also carry Rationale, Consequences and References sections, for people to read.

## The two files

| File | Holds | Read by |
| - | - | - |
| `docs/adr/<id>-<title>.md` | A YAML header, then the decision document: the title, `Status:`, `Date:` and `Deciders:` lines, Context, and Decision with the numbered policies | People, and `actual adr check` |
| `.actual/rules/cross-cutting-<topic>-<hash>.md` | The same header, then the decision's title, a scope line and a `### Rules` list with one rule per policy | `actual plan-check`, `actual impl-check`, `actual rules` and the plugin's rule briefs |

Both file names come from the decision's id and title. The header carries the id, the status and the paths the decision applies to.

## A rule file

A rule file opens with a YAML header between `---` lines, then lists the decision's rules, each with an id. This one, shortened from the CLI's test fixtures, governs one directory of one package:

```markdown theme={null}
---
version: 2
name: cross-cutting-api-handlers-validate-input-2f9d
description: "Adopt Validated Request Handlers in the Api Package: Api Handlers Validate Input"
metadata:
  actual:
    adr_id: aac8f7b2-bd70-5b7c-9a0d-64dcd5c7acdd
    status: accepted
    candidate_group_id: 34467253-1dfe-5f7a-9f93-241807d9852a
  scope:
    root: packages/api
    paths:
      - "src/handlers/**"
    languages:
      - typescript
---

# Adopt Validated Request Handlers in the Api Package: Api Handlers Validate Input

Scope: applies to `packages/api/src/handlers/**`.

### Rules

- **R-APIH-001** MUST: Api handlers validate every request body against a schema before using it.
- **R-APIH-002** SHOULD: Api handlers return a typed error body for a rejected request.
```

| Header field | Meaning |
| - | - |
| `metadata.actual.adr_id` | The decision's id |
| `metadata.actual.status` | Whether the decision governs |
| `metadata.actual.candidate_group_id` | Groups the files of one decision, when Actual AI split it across several |
| `metadata.scope.root` | The directory the `paths` are written against; `.` is the whole repository |
| `metadata.scope.paths` | The globs the decision governs, relative to `root`; a `!` prefix excludes |

When the header declares paths, a file outside the decision's root is never governed by it, and a file that matches an exclude never gets that decision. A rule's id, joined to its file's name, is what you name when you override it: `cross-cutting-api-handlers-validate-input-2f9d::R-APIH-001`.

Reading the header needs Actual CLI 0.9.0 or later. A rule file with no header is still read in the original format, and both kinds can share `.actual/rules/`. A header the CLI can't parse is a warning, not an error: `actual rules ls` reports it and the rest of the file is still read. Only `.md` files directly under `.actual/rules/` count; the CLI skips subdirectories.

## Accepted or draft

An accepted decision governs at once: the checks read its rules. A draft governs nothing until it's accepted.

The checks leave out a decision whose status is `draft`, `deleted`, `archived-draft`, `deferred`, `rejected`, `suggested`, `superseded` or `deprecated`. Any other status, and a missing one, counts as active.

`actual adr new` writes an accepted decision when you run it at a terminal and a draft when no person is at one, as in a coding agent's shell, a script or CI, so an agent never publishes a governing decision on its own. `--status accepted` or `--status draft` sets it explicitly. To accept a draft that `adr new` wrote, change `status: draft` to `status: accepted` in the header of both files, and the decision document's `Status: proposed` line to `Status: accepted`.

## Where decisions come from

**From your terminal, signed out.** `actual adr new` (CLI 0.14.0 or later) writes both files:

```bash theme={null}
actual adr new "Use Postgres for storage" \
  --context "Each service picked its own database, and three engines are now in production." \
  --policy "MUST: Services store relational data in Postgres." \
  --policy "MUST NOT: Services open SQLite files outside tests." \
  --scope 'services/**'
```

It runs the same check Actual AI runs before saving a decision and writes nothing when the decision would be refused. `actual adr check` runs that check on the decision files under `docs/adr/` and lists likely duplicates. The files are yours to review and commit.

**In Actual AI, signed in.** Manage your organization's decisions at [app.actual.ai](https://app.actual.ai), or from the terminal with `actual adr create`, `update`, `publish` and the other `actual adr` commands. Actual AI opens a sync pull request in your repository that writes both files for each accepted decision, and merging it brings them in. A later change to a decision reaches the rule files through the same sync pull request. `actual adr create --file` sends a decision that `adr new` wrote to Actual AI and renames its two files to the names the sync uses.

[Write and draft decisions](https://docs.actual.ai/guides/write-and-draft-decisions.md) walks through both ways, and [`actual adr`](https://docs.actual.ai/cli/adr) lists every command and flag. To see what the checks will read, run `actual rules ls`, which lists the rule files with their counts by level and any warnings.


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