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

# Write and draft decisions

> Write a decision and its rule file into your repository, or save it to Actual AI and publish it when it's ready.

A decision governs your agent once its rule file sits under `.actual/rules/`. The Actual CLI gives you two ways to get it there. `actual adr new` writes the decision and its rule file into your repository with no sign-in. Signed in, `actual adr create` saves the decision to Actual AI, where you can keep it as a draft, publish it, and let Actual AI's sync pull request write the same files. The `actual adr` commands need Actual CLI 0.14.0 or later.

## Write a decision into the repository

Run `actual adr new` from the repository root with a title and one `--policy` per rule:

```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." \
  --deciders "Platform team" \
  --scope 'services/**'
```

It writes two files, laid out the way Actual AI's repository sync writes them:

| File | What it holds |
| - | - |
| `docs/adr/<id>-<title>.md` | The decision document: a YAML header, the title, `Date:` and `Deciders:` lines, Context, and Decision with the policies |
| `.actual/rules/cross-cutting-<topic>-<hash>.md` | The same header, then a `### Rules` list with one rule per policy. `plan-check`, `impl-check` and `actual rules` read this file |

Commit both. [Decisions and rule files](https://docs.actual.ai/concepts/decisions-and-rule-files.md) covers what each file holds and how the header scopes a decision.

| Flag | What it sets |
| - | - |
| `--context <POINT>` | Why the decision is needed, one point per flag. Optional |
| `--policy "<LEVEL>: <statement>"` | One policy per flag. The level is `MUST`, `MUST NOT`, `SHOULD`, `SHOULD NOT` or `MAY` |
| `--deciders <NAMES>` | The decision's Deciders line |
| `--scope <GLOB>` | A path the decision applies to, relative to the repository root, one per flag. A leading `!` excludes a path. Leave it out for the whole repository |
| `--status accepted` or `--status draft` | Whether the decision governs at once. See [Accepted or draft](#accepted-or-draft) |
| `--root <PATH>` | The repository root to write into. Defaults to the current directory |
| `--json` | Prints the files written as JSON |

Before it writes anything, `adr new` runs the same check Actual AI runs before it saves a decision. When the decision would be refused, it writes nothing and lists each reason. A `--policy` with no level is refused before that check runs. The new decision gets a random local id until you push it with `actual adr create --file`, and an existing file is never replaced.

## Accepted or draft

An accepted decision governs at once: `plan-check` and `impl-check` read its rules. A draft is read by no check.

`adr new` writes an accepted decision when you run it at a terminal, and a draft when standard input isn't a terminal, as in a coding agent's shell, a script or CI. An agent that writes a decision therefore leaves a draft for a person to accept. `--status accepted` or `--status draft` sets either one yourself.

To accept a draft that `adr new` wrote, change `status: draft` to `status: accepted` in the header of both files, and the decision file's `Status: proposed` line to `Status: accepted`.

## Policies that check well

Each `--policy` becomes one rule, and the checks judge a plan or a diff against each rule on its own. A rule checks well when it states one thing a plan or a change can show:

* Write one statement per policy. "Services store relational data in Postgres" checks cleanly; a policy that bundles a database choice, a naming rule and a review process doesn't.
* Choose the level the rule means: `MUST` and `MUST NOT` for what every change has to do or avoid, `SHOULD` and `SHOULD NOT` for a default with room for exceptions, `MAY` for what's allowed. Each rule is judged together with its level.
* Give a `--scope` when the decision covers part of the repository. The checks select rules by the paths they govern, so a narrow glob such as `services/**` keeps the decision out of unrelated changes, and `!services/legacy/**` carves out an exception.
* Put the reasoning in `--context`. The context explains the decision to people; the policies are what the checks enforce.

## Check decision files

`actual adr check` runs Actual AI's save check on decision files and lists likely duplicates. It needs no sign-in.

```bash theme={null}
actual adr check                       # every file under docs/adr/ that carries a decision header
actual adr check docs/adr/<file>.md    # only these files
actual adr check --no-cloud            # compare only with the files in this repository
```

Signed in, it also compares the files with your decisions in Actual AI: the connected repository's decisions, or the whole organization's when your checkout names no connected repository. It exits 1 when a file fails the check. A likely duplicate is reported without failing the run. Two decisions look the same when their titles share at least half their content words, or when a policy of one does with a policy of the other.

## Save a decision to Actual AI

Sign in with `actual login` (see [Sign in](https://docs.actual.ai/sign-in.md)), then save a decision from a file that `adr new` wrote, or from flags:

```bash theme={null}
actual adr create --file docs/adr/<file>.md
actual adr create --title "Use Postgres for storage" --policy "MUST: Services store relational data in Postgres."
```

`create` works on the connected repository your checkout's `origin` remote names; `--repo` picks another by its name, `owner/name` or id. It runs these steps in order and stops at the first that fails:

**1. Read the decision**

It reads the decision from the file or the flags. A file that doesn't parse, flags with no `--policy`, or a `--policy` with no level is refused before anything is sent.

**2. Look for duplicates**

It reads the repository's decisions in Actual AI and refuses when the decision is already one of them or looks the same as one. `--allow-duplicate` sends it anyway.

**3. Send it once**

It sends the decision once and never retries. When the request was sent but no answer came back, the decision may have been saved: the command exits 3 and asks you to look with `actual adr list` before you run `create` again.

**4. Finish a file's save**

With `--file`, a scope in the file's header is set on the new decision, and an accepted save then publishes it. Both files are renamed to the names Actual AI's sync uses for the new decision, and their headers take its id and the status it was saved with.

`--status` works as it does for `adr new`: accepted at a terminal, draft with no person at one. A file saved as a draft stops governing locally until you publish it and Actual AI's sync pull request rewrites its files. `--deciders` belongs to `adr new`; a decision saved from flags has no Deciders line, and a file keeps its own.

## Publish, change and archive

These commands act on your organization's decisions in Actual AI and take a decision's id as `actual adr list` prints it. Each one checks the decision's state by the web app's rules first and sends nothing when the state doesn't allow the change.

| Command | What it does |
| - | - |
| `actual adr publish <id>` | Publishes a draft so it governs |
| `actual adr unpublish <id>` | Moves an active decision back to draft |
| `actual adr update <id>` | Changes the title, context, policies, policy levels or scope |
| `actual adr delete <id>` | Archives an active decision or a draft, as Delete does in the web app |
| `actual adr restore <id>` | Restores an archived decision to the list it was archived from |
| `actual adr accept <id>` | Accepts a suggestion |
| `actual adr reject <id> --reason <TEXT>` | Rejects a suggestion; the reason, up to 10,000 characters, is saved with it |

A change to the repository's rule files arrives through Actual AI's sync pull request.

To change a decision's policies, read their ids with `show`, then give `update` the whole list you want:

```bash theme={null}
actual adr show <id>
actual adr update <id> --level <policy-id>=SHOULD
actual adr update <id> --policy "<policy-id>=MUST: Services store relational data in Postgres." \
                       --policy "MAY: Analytics jobs read from a Postgres replica."
actual adr update <id> --scope 'services/**' --scope '!services/legacy/**'
```

With `--policy`, prefix a policy's id and `=` to keep it, write a new policy with no id, and leave a policy out to remove it. `--level` changes one policy's level and can't be combined with `--policy`. `--context` replaces the whole context, and `--clear-scope` applies the decision to its whole repository again. Editing the policy list can give the policies new ids, so take the ids for your next edit from the output `update` prints or from `actual adr show`.

## Exit codes

Every `actual adr` command takes `--json`, which prints its result as JSON on standard output. Errors go to standard error.

| Exit code | Meaning |
| - | - |
| 0 | Done |
| 1 | A decision failed a check: the local save check, a `--policy` or `--level` that doesn't parse, Actual AI's refusal of its content, `adr check`, or `create`'s duplicate refusal |
| 2 | Signed out, a sign-in without access to the decision, no connected repository could be chosen, or a value refused as the command line is read |
| 3 | Actual AI couldn't be reached or answered with another error, no decision has that id, the decision can't take the change, or a `create` whose outcome is unknown |
| 5 | A local file couldn't be read or written |

[actual adr](https://docs.actual.ai/cli/adr.md) lists every subcommand with its flags.


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