|
| 1 | +# ADR Integration Guide |
| 2 | + |
| 3 | +Architecture Decision Records capture the *why* behind significant technical decisions. This guide covers when to write them, where to store them, and how they integrate with flow-code. |
| 4 | + |
| 5 | +## When to Create an ADR |
| 6 | + |
| 7 | +Write an ADR when making a decision that would be expensive to reverse: |
| 8 | + |
| 9 | +- **Technology choices** — frameworks, libraries, major dependencies |
| 10 | +- **Architectural patterns** — data model design, API style, auth strategy |
| 11 | +- **Infrastructure decisions** — hosting, build tools, deployment approach |
| 12 | +- **Pattern changes** — moving from one approach to another (e.g., REST to GraphQL) |
| 13 | + |
| 14 | +Do NOT write ADRs for routine implementation choices, obvious decisions, or throwaway prototypes. |
| 15 | + |
| 16 | +## Where to Store ADRs |
| 17 | + |
| 18 | +Use `docs/decisions/` with sequential numbering: |
| 19 | + |
| 20 | +``` |
| 21 | +docs/decisions/ |
| 22 | + ADR-001-use-libsql-for-storage.md |
| 23 | + ADR-002-wave-checkpoint-execution-model.md |
| 24 | + ADR-003-teams-file-locking-protocol.md |
| 25 | +``` |
| 26 | + |
| 27 | +Use the template at `references/adr-template.md` as your starting point. |
| 28 | + |
| 29 | +## Referencing ADRs in Task Specs |
| 30 | + |
| 31 | +When a task implements or depends on an architectural decision, reference the ADR in the task spec: |
| 32 | + |
| 33 | +```bash |
| 34 | +flowctl task create --title "Implement file locking" \ |
| 35 | + --spec "Implements ADR-003. See docs/decisions/ADR-003-teams-file-locking-protocol.md" |
| 36 | +``` |
| 37 | + |
| 38 | +In inline code, link to the ADR near the relevant implementation: |
| 39 | + |
| 40 | +``` |
| 41 | +// Auth strategy per ADR-002. See docs/decisions/ADR-002-auth-strategy.md |
| 42 | +``` |
| 43 | + |
| 44 | +## Integration with /flow-code:plan |
| 45 | + |
| 46 | +During planning, ADRs surface naturally at two points: |
| 47 | + |
| 48 | +1. **Plan creation** — When `/flow-code:plan` encounters an architectural decision, create the ADR as a task in the epic. The ADR task should complete before implementation tasks that depend on it. |
| 49 | + |
| 50 | +2. **Plan review** — `/flow-code:plan-review` should verify that significant architectural decisions have corresponding ADRs. Missing ADRs are a review finding. |
| 51 | + |
| 52 | +### Example: ADR as a Plan Task |
| 53 | + |
| 54 | +``` |
| 55 | +Epic: fn-50-migrate-to-graphql |
| 56 | + Task 1: Write ADR-005 documenting REST-to-GraphQL migration rationale |
| 57 | + Task 2: Implement GraphQL schema (depends on Task 1) |
| 58 | + Task 3: Migrate endpoints (depends on Task 2) |
| 59 | +``` |
| 60 | + |
| 61 | +## ADR Lifecycle |
| 62 | + |
| 63 | +``` |
| 64 | +PROPOSED -> ACCEPTED -> SUPERSEDED by ADR-XXX |
| 65 | + -> DEPRECATED |
| 66 | +``` |
| 67 | + |
| 68 | +Never delete old ADRs. When a decision changes, write a new ADR that supersedes the old one. The historical record is the whole point. |
0 commit comments