Records one architecture decision as an ADR with BDK's frontmatter (status, date, supersedes, governs, issues) in the project's ADR directory - global/ or the module's directory, or the house directory and format when the project has its own - from a free-form description or a decision the design stage hands over, marks the record it replaces as superseded and regenerates the ADR index with bdk adr index. Use whenever the user asks to write, record or document an ADR, an architecture decision...
---
name: adr
description: Records one architecture decision as an ADR with BDK's frontmatter (status, date, supersedes, governs, issues) in the project's ADR directory - global/ or the module's directory, or the house directory and format when the project has its own - from a free-form description or a decision the design stage hands over, marks the record it replaces as superseded and regenerates the ADR index with bdk adr index. Use whenever the user asks to write, record or document an ADR, an architecture decision or a decision record, or when the design stage records a decision.
argument-hint: "<the decision, its options and reasons>"
allowed-tools: Bash(${CLAUDE_PLUGIN_ROOT}/bin/bdk *) Read Glob Grep Write Edit AskUserQuestion
---
Current BDK configuration of this project:
!`"${CLAUDE_PLUGIN_ROOT}/bin/bdk" config show`
Arguments: $ARGUMENTS
# ADR
An ADR records *that* a decision was made and *why*; the code already says *what*. Keep it short: most records are one paragraph.
Done when one new record is saved, the record it replaces (if any) is marked superseded, the index is regenerated, and you have reported the path, title and status. Write nothing else and commit nothing. Run `bdk` exactly as the steps write it, `"${CLAUDE_PLUGIN_ROOT}/bin/bdk"` and its arguments as the whole Bash command, with no `cd`, `;`, `&&` or pipe: any other form falls outside this skill's grants.
## 1. Take the decision
The input is one of:
- **Free-form text** from the user: take the problem, the options, the reasons and the choice from it.
- **A decision the design stage hands over**: its text holds the problem, the options, the choice, the paths it binds and the issue it belongs to. Its status is `proposed`: the design gate accepts it later.
- **Nothing**: ask for the decision.
Check the bar. A decision is worth a record only when all three hold: it is **hard to reverse**, it would be **surprising without context** (a reader would wonder why the code is this way), and it is **the result of a real trade-off** (there were genuine alternatives). When the input clearly fails one, say which and ask whether to record it anyway; when you cannot ask, write nothing and report why. A decision the design stage hands over has passed the bar already.
Status: the one the input states (`decided`, `agreed`, `we went with` mean `accepted`). Otherwise `proposed` for a decision of the design stage. Otherwise ask, together with anything else that is missing, in one `AskUserQuestion`; when you cannot ask, write `proposed` and name it in the report.
Take from the input, when it gives them, the paths the decision binds (`governs`, as globs such as `src/api/**`) and the issues that implement it (`issues`). Do not invent either: a decision without `governs` binds the whole system.
## 2. Find where it goes and in which shape
Take the ADR settings from the configuration above: `docs.adr.dir`, `docs.adr.layout` and `docs.adr.index` (`<dir>/README.md` when unset). When the block says BDK is not configured, use `docs/adr`, the `modules` layout and `docs/adr/README.md`, and skip step 5.
- **Layout `modules`**: a system-wide decision goes into `<dir>/global/`; a decision that binds only one module goes into `<dir>/<module>/`, with `<module>` the id of that module in the module map of `docs.architecture`. Without a module map, or when the decision spans modules, use `global/`. Directories are created by the first record written into them.
- **Layout `flat`**: every record goes into `<dir>`.
Numbers run across all directories of the layout: the new number is one above the highest number in the index, or of the files `<dir>/**/<NNNN>-*.md` when there is no index; `1` when there is none.
Shape:
- **Records exist:** read the highest-numbered one and one older one. Their file naming, number width, title line and sections win: write the body in their shape, with their status section or line if they have one.
- **No records:** use [references/template.md](references/template.md).
In both cases the record starts with the BDK frontmatter of the template: `status`, `date`, and `governs`, `issues`, `supersedes` when they have a value. When the house records already carry a frontmatter block, keep their other keys too.
## 3. Check for a record it replaces
Read the index, or the titles of the records. The new decision replaces one when the input says so, or when a record in force (`accepted`, `partially-implemented`, `implemented`) decides the same question the other way (polling replaced by server-sent events, one database replaced by another). Read that record before deciding.
## 4. Write
Write the new record with Write. When it replaces a record, its frontmatter holds `supersedes: ADR-<NNNN>` of that record, and a house format's place for links names it too.
Add a diagram only when the options differ in structure or data flow: one `mermaid` block of at most 15 nodes, with labelled edges and no colours.
When it replaces a record, change only that record, with Edit: in its frontmatter set `status: superseded` and `superseded_by: ADR-<new NNNN>`; a record without frontmatter gets the block, with `date` from its own date line or today. Update its house status line or section the same way (`Superseded by 8. Use server-sent events`). Change nothing else in it.
## 5. Regenerate the index
Run `"${CLAUDE_PLUGIN_ROOT}/bin/bdk" adr index`. Never edit the index by hand: it is generated from the frontmatter. Exit 1 means some records could not be read and are left out of the index; the output names them and why. Do not fix them: name them in the report.
## Report
The new record's path, title and status; the record it supersedes; the values you chose without asking; the records `bdk adr index` left out.