/adrkit:adr-backfill [files-or-directories...]from adrkit — decision memory
Audits code, documentation, and git history for unrecorded architecture decisions, producing a deduplicated evidence report. Accepts optional file/directory arguments to scope the audit.
Ships in adrkit — decision memory. Installing the plugin adds it to Claude Code.
Try, in order: $ADRKIT_CLI, then ./node_modules/.bin/adr, then adr on
PATH. @adrkit/cli is normally a dev dependency, so a bare adr is often not
on PATH.
Before executing the resolved CLI, canonicalize its path. If it is inside the target worktree, do not treat its presence as trust: in an inherited repository, ask the caller to confirm that the repository and its installed dependencies are trusted. If they decline or cannot confirm, do not execute that binary. Prefer the separately configured read-only MCP server when available; otherwise continue evidence discovery only with every corpus-reconciliation conclusion marked unverified.
The CLI is required to reconcile candidates with an existing adrkit corpus. If
all three forms fail, continue evidence discovery only when the caller wants it,
but label every existing-decision conclusion unverified and tell the user to
install @adrkit/cli. Never parse ADR frontmatter by hand as a substitute:
invalid records can drop out of the corpus, glob matchers need the real
resolver, and inbound @adr markers are otherwise invisible.
Audit $ARGUMENTS for durable decisions that were made but never recorded.
Establish a contained, bounded source inventory.
.. paths. Inventory symlinks, but do not follow a
symlink whose target resolves outside the worktree.Route existing decision formats before using judgment.
Resolve the corpus directory once. A corpus path explicitly identified in
$ARGUMENTS wins; otherwise use $ADRKIT_DIR when set; otherwise use
docs/adr. Refer to the result as ADR_DIR and pass it to every CLI call.
For a MADR corpus, recommend the deterministic read-only preview:
adr migrate --from madr --dir "$ADR_DIR" --dry-run
Do not model-convert files the CLI can migrate additively while preserving their status and body.
For an adrkit corpus, run these through the trusted resolved CLI:
adr lint --dir "$ADR_DIR"
adr graph --dir "$ADR_DIR" --format json
adr queue --dir "$ADR_DIR" --format json
Interpret the exit code instead of discarding output. Exit 0 is clean.
Exit 1 is a complete findings report: read it, and treat absence claims as
unverified until the corpus errors are repaired. Exit 2 is a usage error
or unreachable corpus; report it verbatim and stop reconciliation.
Collect evidence, not guesses.
git log -S,
git log -G, and blame where useful.path:line spans and immutable commit ids. No evidence means
no candidate.Apply the admission rule. Keep a candidate only when a future maintainer
would otherwise need to reverse-engineer it, a viable alternative existed,
the consequence is durable, the evidence supports the claim, and likely
affects paths can be named. Exclude routine mechanics, accidental patterns,
generated defaults, and duplicate descriptions.
Deduplicate against decision memory.
Run the check with flags before an option terminator and pass each path as a separately quoted argument:
adr check --dir "$ADR_DIR" --json -- <quoted-candidate-paths...>
Use MCP only after confirming its configured ADRKIT_MCP_CWD canonicalizes
to this worktree root and its ADRKIT_MCP_DIR resolves to this exact
ADR_DIR. The tools do not accept a corpus directory per call. If either
configured value is hidden or differs, do not use MCP for reconciliation;
use the trusted CLI or classify the result unverified.
With that identity confirmed, use get_decision_context(files[]) and
search_decisions, including status: ["rejected"].
Do not use list_superseded to search rejected records: it returns only
records whose status is superseded and never rejected ones.
Classify candidates as covered, amendment-or-supersession, new, or
unverified.
Keep status honest.
draft.proposed record after human selection, never an automatically accepted
one.Return the report.
Scope and coverage ledger.
Existing corpus state and relevant history. When no corpus exists, or
when no record in any bucket covers the corpus directory, say so and
offer the bootstrap record — the process decision to keep decisions in
git and the tooling decision to enforce them with adrkit. It is an
offer, not a candidate: keep it out of the candidate table and out of
every backfillHandoff, and name plain /adr-draft. Adopting adrkit is
never a supersession of the decision to record decisions; reserve
supersedes for a prior tooling record.
Detect that record through the CLI, never by reading frontmatter. A
corpus directory that does not exist exits 2; one that exists but
holds no record exits 0 with an empty result. Both mean the same
thing here, and the offer is both decisions. Once at least one record
exists, run:
adr lint --dir "$ADR_DIR"
adr check --dir "$ADR_DIR" --json -- "$ADR_DIR/<one-existing-record>.md"
Read the exit code before the buckets, and then read all three
buckets. Only on exit 0 does an empty result mean the record is
absent rather than unreadable. adr check's exit code is scoped to the
paths it was handed, not to the corpus, so a malformed record elsewhere
leaves it at 0 with an empty result — the corpus-wide adr lint above
is what must reach exit 0 first. An unmigrated MADR corpus is the case
that punishes skipping this: nothing parses, every bucket is empty, and
the corpus reports frontmatter-fence errors at exit 1 even when one
unparsed record is the process decision. Migrate first, then detect.
Then read every bucket, because governing holds accepted alone:
| Bucket | Statuses | Offer |
|---|---|---|
governing | accepted | The tooling decision only, relatesTo that record |
activeProposals | draft, proposed | Nothing — it is already proposed; name ratification as the next step |
history | rejected, superseded, deprecated | Nothing — report the record and never re-propose it |
| all three empty | — | Both the process and the tooling decision |
/adr-draft writes new records as proposed, so this offer's own
output lands in activeProposals. Reading governing by itself would
make backfill re-offer the record it just produced, and would re-propose
a decision a team explicitly rejected.
Say in the offer that the record must carry an affects matcher
covering the corpus directory (type: path, pattern matching
$ADR_DIR). Drafting scaffolds affects: [], and a record that binds
nothing is invisible to the detection above — every bucket comes back
empty and the next audit offers the same decision again. The matcher is
what makes the record findable, not its id or its title.
Candidate table: key, decision, confidence, evidence, likely affects,
blast radius, and reconciliation.
One evidence card per candidate: context, apparent choice, alternatives, consequences, citations, gaps, and status treatment.
Excluded observations and why they failed admission.
A short prioritized review list, naming a missing bootstrap record as an offer rather than a candidate.
For each selectable candidate, include this copy-ready block:
backfillHandoff:
candidateKey: BF-001
title: <imperative decision title>
corpusDir: <resolved ADR_DIR>
candidatePaths: [<existing concrete repo-relative file; never a glob>]
sourceArtifact: <primary repo-relative source>
citations: [<path:line or commit>]
missingEvidence: [<known gap>]
affects:
- type: path
pattern: <repo-relative glob>
alternatives: [<observed alternative>]
reconciliation: new|amendment-or-supersession
reconciliationSnapshot:
corpusFingerprint: <QueueReport v1 corpusFingerprint>
governing: [<accepted ADR id>]
activeProposals: [<draft or proposed ADR id>]
history: [<rejected, superseded, or deprecated ADR id>]
statusTreatment: proposed
Every candidatePaths entry must be a contained, existing file used during
reconciliation. Never put an affects glob in candidatePaths.
Build reconciliationSnapshot from one final adr check over exactly
those candidatePaths; do not include decisions matched only by other
candidates or scoped files. The partition key is exactly history, never
historical.
Do not emit a handoff for covered or unverified candidates.
Read-only. Do not create or edit records. After a human selects one candidate,
direct them to /adr-draft <candidateKey>. Keep the complete handoff in context
so that command can create exactly one evidence-backed proposed record. If the
handoff is no longer available, it must stop rather than reconstruct provenance.
Files this command reads when invoked
What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
5 commands in this plugin
/adr-checkResolve the CLI firstCheck the current change, or a plan, against the decisions that govern it and report a verdict per decision. Read-only./adr-contextResolve the CLI firstLoad the architecture decisions that govern the paths you are about to change, before planning against them. Read-only./adr-draftResolve the CLI firstDraft one new ADR from a current decision or a selected backfill handoff. Writes a single new record, as proposed./adr-queueResolve the CLI firstShow the review queue — every decision still proposed, with its SLA state — so open questions are visible before they are planned around. Read-only.npx claudepluginhub mbeacom/adrkit --plugin adrkitOther plugins' commands for the same job