Use to create, review, update, or replace ADRs under docs/adr/, or when a change selects a library, framework, database, protocol, hosting, or tool among real alternatives; picks an architectural pattern; sets a durable constraint not obvious from code; or reverses a previous decision. Not for local implementation details understandable from the code.
---
name: adr
description: >
Use to create, review, update, or replace ADRs under docs/adr/, or when a change
selects a library, framework, database, protocol, hosting, or tool among real alternatives;
picks an architectural pattern; sets a durable constraint not obvious from code; or reverses
a previous decision. Not for local implementation details understandable from the code.
---
# Architecture Decision Records
Record a broad decision in `docs/adr/` in the same task that makes it; create the directory if it does not exist.
`tsdd` owns the tests, this skill owns the rationale. New ADRs use [MADR](https://github.com/adr/madr), unless the
repository already has ADRs in another format: then follow that repository's format and file naming, and adopt MADR
only when asked. In a repository with MADR ADRs or none yet, every ADR present is a decision in force: there is no
status, and a decision that is not implemented yet is not an ADR.
## Decision Test
Write an ADR when a future maintainer would ask "why this approach instead of the obvious alternative?" and the Why
spans several files, components, or future changes, or is costly to reverse. Considering alternatives alone does not
justify one for a local, easily reversible choice; use code, tests, or a comment.
## Inspect First
1. Read the titles of the existing ADRs, then search them for the topic, the chosen option, and the rejected
alternatives.
2. If an ADR already covers the decision, make the code follow it instead of writing a duplicate.
3. If the decision reverses or materially changes an existing ADR, replace it as described under Write.
## Write
These steps apply to a repository with no ADRs yet or with MADR ADRs. If its ADRs use another format, write in that
format with its own template and naming, and replace ADRs the way it does.
1. Copy [references/template.md](references/template.md) to `docs/adr/NNNN_words.md`: NNNN is a number that no ADR
file has ever had in git history, normally the highest number ever used plus one (`0001` in an empty directory);
`git log --diff-filter=A --name-only -- docs/adr` lists the used numbers, including those of deleted ADRs. The words
are lowercase and underscore-separated unless the existing files differ. The ID comes from the file name, and an
ADR file is never renamed.
2. An ADR has no front matter and no status: the date and the history are git's. The title line is
`# <short title>` without an ID. Write the ADR in the change that implements the decision, so that it is true when
it merges.
3. Fill the template and delete its source comment. Add MADR's full-variant sections only when the minimal ones are
too compressed.
4. To replace a decision, write a new ADR whose Considered Options names the dropped approach and why it was dropped,
and delete the old ADR in the same change; git keeps its history. When only a detail of an existing ADR is
replaced and its Chosen option still holds, delete just that detail from it, and write a new ADR only when the new
detail's reason meets the Decision Test. When the Chosen option itself changed, replace the whole ADR.
5. To correct or extend a decision that still holds, edit its ADR in place; keep no list of amendments.
6. Write a related ADR as a body link (`[title](NNNN_words.md)`, under More Information), never as bare "ADR-NNNN"
text, so that link checks find a broken one. Fix every link that points at a deleted ADR.
## Writing Rules
- Record Why, not What or How; link to requirement sources and tests instead of copying them.
- List under Considered Options only the alternatives that were actually considered; never add padding options.
- Make the Chosen option sentence carry the justification, and state the accepted trade-off in Consequences.
- Write in English for public repositories, short enough that future agents read it.
## Non-Goals
No ADRs for ordinary refactors, language or framework defaults without a project-specific reason, test cases or
acceptance criteria, narrow code comments, or scratch plans.