Skip to content

Quickstart

The adr CLI validates a decision corpus, scaffolds new records, explains which decisions govern a file, renders the decision graph, migrates an existing MADR corpus in place, emits the ARB operations queue, and runs the deterministic evaluator.

Add the CLI to a project, or run it one-off. It exposes the adr binary.

Terminal window
# one-off, no install — always name the package
npx @adrkit/cli lint
npx @adrkit/cli explain src/payments/api.ts
# or add it to the project and drive it from a script
npm install --save-dev @adrkit/cli
npm pkg set scripts.adr=adr
npm run adr -- lint
# or install globally, for a bare `adr` on your PATH
npm install -g @adrkit/cli
adr lint

The examples below are written as bare adr … for readability. A local install does not put adr on your shell PATH; run it through your package script, such as npm run adr -- lint.

If you have no docs/adr/ yet, start here: adr new creates the directory and writes the first record, so it is the bootstrap step as well as the everyday one. Running adr lint first on a repository with no corpus exits 2 with Corpus directory not found: 'docs/adr'.

Scaffold a record with the next sequential id and valid frontmatter.

Terminal window
adr new "Use server-side rendering for authenticated routes"
# choose a starting status (accepted/superseded need extra fields and are refused)
adr new "Adopt OpenTelemetry" --status proposed

That writes docs/adr/0001-use-server-side-rendering-for-authenticated-routes.md with affects: []. Filling affects in is what makes the decision locatable by CI and agents — a record with no affects is advisory only. Each entry is a type plus a pattern:

affects:
- type: path
pattern: "apps/web/app/**"
- type: package
pattern: "next@>=16"

type is one of path, package, api, resource, entity, or data. See the JSON Schema reference for the full field list.

Validate every record under docs/adr/ against the schema, enforce unique ids, flag dangling references between records (supersedes / supersededBy / relatesTo / conflictsWith), and warn when an accepted record declares a conflict via conflictsWith.

Terminal window
adr lint
# lint a specific directory or files
adr lint --dir docs/adr
adr lint docs/adr/0001-record-architecture-decisions-in-git.md
# machine-readable output for CI
adr lint --json

adr lint exits non-zero when it finds errors, so it drops straight into a CI gate.

Explain what governs a file — adr explain

Section titled “Explain what governs a file — adr explain”

Print every decision that matches a path, and the matcher that fired. Only accepted records are reported as governing; matched proposals and superseded, rejected, or deprecated records are listed under their own headings so a rejected decision is never presented as binding.

Terminal window
adr explain packages/core/src/schema/adr.schema.ts
adr explain package.json --json

Inspect the decision graph interactively, or emit deterministic DOT, Mermaid, or JSON for another tool. Bare adr graph shows a compact terminal instrument when stdout is a TTY and preserves DOT when piped or redirected.

Terminal window
# interactive overview, then one readable neighborhood
adr graph
adr graph --focus 0014
# GitHub-compatible Mermaid source
adr graph --format mermaid > decisions.mmd
# styled Graphviz DOT rendered to SVG
adr graph --format dot | dot -Tsvg > decisions.svg
# structured JSON
adr graph --format json

Adopt an existing MADR corpus — adr migrate

Section titled “Adopt an existing MADR corpus — adr migrate”

Migrate a MADR corpus in place, additively and non-destructively. The migration is one-way; round-trip sync is deliberately unsupported (ADR-0008).

Status, date, and deciders are read from MADR 3.x YAML frontmatter, MADR 2.x * Status: header bullets, and Nygard ## Status sections, so an already-accepted corpus does not import as a backlog of proposals attributed to nobody.

Terminal window
# preview without writing
adr migrate --from madr --dry-run
# apply
adr migrate --from madr --dir docs/adr

Corpus discovery requires <id>-<slug>.md filenames. If your MADR files use descriptive names, migration warns that the records will not be discoverable — pass --rename to move each file to a discoverable name as part of the run:

Terminal window
adr migrate --from madr --dir docs/adr --rename