ADR practice
Decision records: numbering gate, amendments, decisions-become-checksSignificant decisions get made in chats and PR threads, then lost — so they get re-litigated, or worse, silently violated by code written months later. Architecture decision records (ADRs — see the glossary) fix the memory problem: one short numbered document per decision, its context, and its consequences, kept append-only. This module adds the mechanical pieces that keep the practice honest at scale: a gate that prevents duplicate ADR numbers, a pipeline that turns pattern-checkable ADR decisions into actual gates — so “we decided X” becomes “CI enforces X” instead of a prose file nobody re-reads — and a gate that stops a change to a file holding an architectural contract from merging without an approved decision behind it. Without that last one, an agent asked to make a build pass will quietly rewrite the layer rules or an interface everything else depends on, and the diff looks like any other.
Decisions are numbered, immutable-once-approved records with enforced metadata (decision date, supersedes / superseded-by); numbering collisions are mechanically prevented; evolution happens by amendment or supersession, never silent rewrite; and each ADR is triaged for “decisions-become-checks” extraction — a rule pattern a gate can verify (see M1). The repository splits skeleton files, which hold the architecture’s contracts and are owned by people, from tissue, the implementation agents may change freely. Skeleton files are listed in a machine-readable inventory. A change to one merges only with recorded authority: the change updates the inventory, or a commit trailer names an approved decision record. The gate fails closed when the inventory is stale or a skeleton file is renamed, and agents treat skeleton files as read-only.
Files that hold the architecture’s contracts are protected by a second invariant:
M5 Lite — minimum useful
ADRs exist as numbered files from a template with consistent frontmatter; evolution-by-amendment is documented. Enforcement may be convention-only.
- Decisions are captured as numbered ADR files from a shared template with consistent frontmatter (a decision date and a status).
adrs-exist-numbered-from-templateWhat the audit looks for (2)- an ADR directory holds ADR-NNNN-*.md files with frontmatter
- an ADR template exists and is referenced by the instructions
- The evolution rule is written down: an approved ADR is amended (dated Amendments entry) or superseded, never silently rewritten.
amendment-discipline-documentedWhat the audit looks for (1)- the ADR conventions state amendment-or-supersession, not in-place rewrite
M5 Standard — production teams
the numbering gate runs in CI (and ideally a pre-push hook); ADR frontmatter is machine-validated (via M4); supersession metadata (supersedes / superseded_by) is required and used.
- A check fails when two ADRs claim the same number, and it runs in CI (the authority), ideally mirrored in a pre-push hook.
numbering-gate-enforcedWhat the audit looks for (2)- a CI job runs a duplicate-ADR-number check and fails on a collision
- the same check is available as a local hook
- ADR frontmatter is machine-validated, including the ADR-specific fields decision_date, supersedes, and superseded_by.
adr-frontmatter-validatedWhat the audit looks for (2)- a frontmatter checker (see M4) enforces ADR-specific required fields
- a CI job runs it on changed ADRs
- Superseding a decision updates both files: the new ADR sets supersedes and the old one sets superseded_by plus a deprecated status.
supersession-metadata-usedWhat the audit looks for (2)- superseded ADRs carry superseded_by and a deprecated/superseded status
- superseding ADRs carry supersedes pointing back
M5 Strict — regulated / compliance posture
pattern-checkable decisions are extracted into adr-rules.yaml and enforced by a checker in pre-commit + CI, each rule citing its ADR; the numbering gate is mirrored client- and server-side. Contract files are inventoried, and a change to one needs the inventory edit or an approved record, checked in CI and in a commit-msg hook.
- Pattern-checkable ADR decisions are distilled into a machine-readable rules catalog, each rule citing its ADR, and a checker enforces them on changed code in CI.
decisions-extracted-to-rulesWhat the audit looks for (2)- a rules catalog maps decisions to patterns, each linked to an ADR
- a CI check applies the rules to changed code and fails on critical violations
- The numbering gate runs both client-side (pre-push) and server-side (CI), so a duplicate cannot be pushed past a bypassed local hook.
numbering-gate-mirrored-both-rungsWhat the audit looks for (2)- a pre-push hook runs the numbering gate
- a CI job runs the identical gate as a required check
- The ADR-rule checker ships with a self-test proving it still catches known violations, run in CI so a broken rule gate fails loudly.
rule-checker-self-testedWhat the audit looks for (1)- a self-test exercises each rule shape and runs in CI
- The files that hold the architecture's contracts are listed in a machine-readable inventory, and a check blocks a change to one unless the change edits the inventory or a commit trailer names an approved decision record; the check fails when an inventory entry matches no file, and the agent instructions tell agents to read the inventory before modifying and treat those files as read-only.
skeleton-changes-need-recorded-authorityWhat the audit looks for (4)- a machine-readable inventory lists skeleton files, each with the contract it holds
- a commit-msg hook and a required CI check fail a change to a listed file that neither edits the inventory nor names an approved decision record
- the check fails closed on an inventory entry that matches no file and on a named record that does not resolve or is not approved
- the agent instructions say to read the inventory before modifying and to treat listed files as read-only
Adoption steps
- Copy
templates/ADR-template.mdas the starting point for every record underdocs/adr/, and write the amendment-or-supersession rule into your conventions. This is Lite. - Run
reference/numbering-gate/in CI, and validate ADR frontmatter with M4’s frontmatter checker, whose schema requiresdecision_date,supersedesandsuperseded_byfortype: adr. This is Standard. - Copy
templates/adr-rules.yaml, extract every pattern-checkable decision into it, and runreference/decisions-to-checks/and its self-test in pre-commit and CI; run the numbering gate in a pre-push hook as well. This is Strict. - Copy
templates/skeleton.yamlto.config/skeleton.yamland list the files that hold your contracts; add the “read before modifying” line to your agent instructions (the M0 template has it); runreference/skeleton-gate/in acommit-msghook and in CI on pull requests; and give the inventory,docs/adr/, the CI definition that runs the gate and the ownership file itself owners (mappings). This is also Strict.
Core piecesOpen
- The record —
docs/adr/ADR-NNNN-<slug>.md: zero-padded number, kebab slug, schema-validated frontmatter (decision_date,supersedes,superseded_by,status), and a conventional body (Context / Decision / Alternatives / Consequences). The frontmatter is validated by M4’s frontmatter checker (ADRs are just atype). - The numbering gate — a tiny check that fails when two files claim the
same
ADR-NNNN. Born from a real collision: two agents on parallel branches picked the same next number. Mirrored client-side (pre-push hook) and server-side (CI) so--no-verifycan’t ship a duplicate. - Amendment discipline — an approved ADR is never silently rewritten. It
evolves by appending a dated
## Amendmentsentry (bumpversion, setstatus: amended, keepdecision_datefixed) or by supersession (the new ADR setssupersedes:, the old setssuperseded_by:+status: deprecated). The de-scarring rule (M4) keeps the record clean. - Decisions-become-checks — each ADR is triaged: is any part of it a
pattern a grep can verify? Those decisions are distilled into a
machine-readable
adr-rules.yaml(each rule links back to its ADR), and a checker applies them to changed code. Two rule shapes: deny-on-match (a forbidden construct) and require-nearby (a construct that must be accompanied by a companion). The rest stay as prose (or as LLM-reviewed “semantic” rules — the unproven tier, left out here). - Skeleton files — the inventory
(
templates/skeleton.yaml) names the files whose change needs a decision: each entry is a literal path or directory, or a glob, with the contract it holds. The agent instructions tell agents to read the inventory before modifying and to treat what it lists as read-only (M0’s template carries the line). The gate (reference/skeleton-gate/) extends M1’s commit-msg marker: where the marker asks for a tag, this asks for aDecision-Record: ADR-NNNNtrailer, then resolves the record and reads its status. Only an approved (or amended) record that nothing superseded counts. Run it as acommit-msghook and as the authoritative CI check on the pull request. Own the inventory and the decision-record directory with the people who own the architecture: the gate checks that authority is recorded, not who recorded it.
In your toolsThe same rule, wired into a specific CI provider, hook manager or tracker. Shows only your stack.Open
The module invariant — numbered immutable records, a collision
gate, amendment-not-rewrite, decisions-become-checks — is tool-independent.
This file maps its mechanisms onto concrete git hook
managers, CI providers, and issue trackers. Replace
<placeholders> with your values.
The gates, per rung
| Gate | Local (hook) | CI (authority) |
|---|---|---|
| ADR numbering | pre-push: check-adr-numbers.ts | blocking; mirror of the hook so --no-verify can’t ship a duplicate |
| ADR-rule checks | pre-commit over staged code | blocking (critical) / advisory (warnings) |
| Skeleton files | commit-msg: check-skeleton-adr.ts <message-file> | blocking; the authority, over the pull request’s whole range, in a job of its own |
ADR frontmatter validity is not a separate gate here — it rides on
M4’s frontmatter checker, which enforces the
ADR-specific fields (decision_date, supersedes, superseded_by).
GitHub Actions
# .github/workflows/adr.yml
on: { pull_request: {} }
jobs:
adr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@<full-commit-sha> # v4
with: { fetch-depth: 0 }
- name: ADR numbers unique (blocking)
run: bun reference/numbering-gate/check-adr-numbers.ts
- name: ADR-rule self-test (blocking)
run: bun test reference/decisions-to-checks/adr-rules-check.test.ts
- name: ADR rules on changed code (blocking on critical)
run: RULES=.adr-rules.yaml bun reference/decisions-to-checks/adr-rules-check.ts $(git diff --name-only origin/${{ github.base_ref }}...HEAD)
skeleton:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@<full-commit-sha> # v4
with: { fetch-depth: 0, persist-credentials: false }
- uses: oven-sh/setup-bun@<full-commit-sha> # v2
with: { bun-version: <bun-version> }
- name: Skeleton files need recorded authority (blocking)
run: |
git clone -q https://github.com/jig-harness/jig "$RUNNER_TEMP/jig"
git -C "$RUNNER_TEMP/jig" checkout -q --detach <jig-commit-sha>
: > "$RUNNER_TEMP/bunfig.toml"
bun --config="$RUNNER_TEMP/bunfig.toml" --no-env-file \
"$RUNNER_TEMP/jig/modules/M5-adr-practice/reference/skeleton-gate/check-skeleton-adr.ts" \
--base "${{ github.event.pull_request.base.sha }}" --head "${{ github.event.pull_request.head.sha }}"The skeleton gate reads the pull request’s commits; it never runs their code.
Each part of the skeleton job closes a way a change could make it pass
without touching the inventory or naming a record:
- The gate’s code comes from a Jig checkout pinned to one commit, outside the checkout under review, so a change cannot replace the gate or a helper it imports. Run from that checkout, its imports (relative to its own file) resolve; a vendored copy keeps the same layout (gate README).
- The runtime’s inputs. Bun reads
bunfig.tomland.envfiles from the working directory, which is the checkout under review: apreloadthere runs before the gate, and an.envcan set variables the gate’sgitcalls obey.--configpoints Bun at an empty file instead, and--no-env-fileturns the.envloading off. - No code from the change runs first. The gate has a job of its own:
in the
adrjob a changed rule script or test runs before any later step and could move a ref that step reads. The base is the event’s commit (pull_request.base.sha), not a branch name resolved at run time.
The head is the pull request’s own head commit, not the merge commit GitHub
builds for the run: the merge commit’s message is not the author’s, and its
tree is not the one the author wrote. fetch-depth: 0 makes that commit and
the base’s history available.
GitLab CI
adr:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
script:
- bun reference/numbering-gate/check-adr-numbers.ts
- bun test reference/decisions-to-checks/adr-rules-check.test.ts
- RULES=.adr-rules.yaml bun reference/decisions-to-checks/adr-rules-check.ts $(git diff --name-only "$CI_MERGE_REQUEST_DIFF_BASE_SHA"...HEAD)
skeleton:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
inherit: { default: false }
image: <image-with-bun-and-git>@sha256:<digest>
variables: { GIT_DEPTH: 0 }
script:
- jig="$(mktemp -d)/jig" && git clone -q https://github.com/jig-harness/jig "$jig"
- git -C "$jig" checkout -q --detach <jig-commit-sha>
- bunfig="$(mktemp)"
- bun --config="$bunfig" --no-env-file "$jig/modules/M5-adr-practice/reference/skeleton-gate/check-skeleton-adr.ts" --base "$CI_MERGE_REQUEST_DIFF_BASE_SHA" --head "${CI_MERGE_REQUEST_SOURCE_BRANCH_SHA:-$CI_COMMIT_SHA}"Both jobs read CI_MERGE_REQUEST_DIFF_BASE_SHA, which exists only in a
merge-request pipeline, and a job without rules is left out of those
pipelines, so each selects merge_request_event explicitly.
As on GitHub, the gate runs from a pinned Jig checkout in a job of its own
(inherit: { default: false } keeps a shared before_script from running
the change’s code first). That also drops the default image, so the job
names its own: one that provides Bun and Git, pinned by digest. Bun’s
configuration and .env loading are pinned too,
and the head is the merge request’s own head commit: in a
merged-results pipeline CI_COMMIT_SHA is the synthetic merge commit, which
carries the target branch’s commits too. The skeleton gate reads commit
messages, so its job needs full history (GIT_DEPTH: 0), as the GitHub job’s
fetch-depth: 0 does.
Hook managers
| Manager | Wiring |
|---|---|
| lefthook | pre-push adr-numbers: run: bun reference/numbering-gate/check-adr-numbers.ts; pre-commit adr-rules: glob: "**/*.{ts,js,py,go}", run: RULES=.adr-rules.yaml bun reference/decisions-to-checks/adr-rules-check.ts {staged_files} |
| husky | .husky/pre-push runs the numbering gate; .husky/pre-commit runs the rules check over git diff --cached --name-only --diff-filter=ACM |
| pre-commit framework | a repo: local hook id: adr-numbers (always_run: true, pass_filenames: false) and one id: adr-rules with files: scoped to code |
The skeleton gate is a commit-msg hook, the one hook that sees the message
(see M1’s commit-msg marker).
<jig> is a Jig checkout pinned to one commit, the same one CI pins
(<jig>/modules/M5-adr-practice/reference/skeleton-gate/ holds the gate):
| Manager | Wiring |
|---|---|
| lefthook | commit-msg command skeleton-adr: run: bun <jig>/modules/M5-adr-practice/reference/skeleton-gate/check-skeleton-adr.ts {1} |
| husky | .husky/commit-msg: bun <jig>/modules/M5-adr-practice/reference/skeleton-gate/check-skeleton-adr.ts "$1" |
| pre-commit framework | a repo: local hook id: skeleton-adr, stages: [commit-msg], always_run: true, pass_filenames: true (the framework passes the message file) |
The numbering gate takes no file list (it scans the ADR dir), so always_run
it; the rules check takes the changed code files.
Issue trackers (amendment / supersession bookkeeping)
Supersession is a two-file edit (new ADR supersedes:, old ADR
superseded_by: + status: deprecated). Trackers help notice when it’s
needed but don’t enforce it:
| Tracker | Support |
|---|---|
| GitHub / GitLab | a PR template checkbox “if this supersedes an ADR, both files updated”; a decision label routing ADR PRs to the right reviewers |
| Linear / Jira | an ADR issue type; a hitl label (see M0 / M9) marking that the deliverable is a decision, so the autonomous run stops for human sign-off |
Ownership of the two authority paths
The skeleton gate checks that authority is recorded; who may record it is
the host’s review rule. Give the inventory (.config/skeleton.yaml), the
decision-record directory, the CI definition that runs the gate (on
GitHub the pull_request workflow is read from the change itself), and the
ownership file itself (CODEOWNERS, or wherever the host keeps the rule) to
the people who own the architecture. Leave the ownership file out and a change
that touches none of the other paths can drop their entries, so the next change
edits the inventory or approves its own record with no owner review:
| Host | Rule |
|---|---|
| GitHub | a CODEOWNERS entry for these paths, with “Require review from Code Owners” on the protected branch |
| GitLab | a CODEOWNERS section with approval required, or an approval rule scoped to these paths |
| Bitbucket / Gerrit | a default reviewer group or a path-scoped approval rule for these paths |
Writing a new ADR when a decision changes (rather than editing the old one) is the amendment/supersession discipline — cultural, backed by the de-scarring lint (M4) that keeps the record clean, not by a bot.
What this module provides:
templates/ADR-template.md— the record’s frontmatter and body, the amendment mechanism, and a worked neutral example.templates/adr-rules.yaml— the rules catalog with one example of each rule shape (deny-on-match, require-nearby).reference/numbering-gate/— fails when two ADRs share a number.reference/decisions-to-checks/— a generic interpreter that applies the rules catalog to changed files.templates/skeleton.yamlandreference/skeleton-gate/— the skeleton inventory and the gate that requires an inventory edit or an approved decision record for a change to a listed file. The practice of keeping a contract set that only people change is long established where it was observed; this blocking gate is young, so it is the Strict rung and its first weeks should be read as feedback on the inventory’s breadth.mappings.md(hook managers, CI providers, issue trackers) and the module’s maturity criteria.
Each reference gate has a paired self-test beside it. The
/jig:adr skill is the runnable
form of this practice: it writes a record, extracts its checkable rules into
the rules catalog and validates them against the interpreter’s format.
/jig:decide checks a new
question against the existing records first, and hands a ruling that clears
its bar to /jig:adr.
Deliberately left out: checking who approved a record or edited the inventory (the gate reads recorded status; ownership of those two paths is the repository’s review rule, not a script); one hand-written script per rule, because a per-rule script is what a rules catalog exists to replace; and the semantic, model-reviewed rule tier with its routing map, which stays out until a working repository has validated it — it belongs with the review harness (M7) and the learning loop (M8). Example decisions are neutral (configuration format, structured logging, fetch timeouts).