Normalize ALL ADRs under docs/specs/** into the canonical ADR v2 structure, preserving all information while enforcing structural consistency. Process ADRs in controlled batches with full idempotency and progress tracking.
Anti-Hallucination Strategy:
| Artifact | Path | Purpose |
|---|---|---|
| ADR Source | docs/specs/**/adr/*.md |
All markdown files in adr/ subdirectories |
| Progress Tracker | docs/reference/adr-checklist.md |
Idempotent checklist of all ADRs |
| Template Reference | See ADR V2 TEMPLATE section below | Canonical section order |
Trigger: Always runs first.
docs/specs/ recursively for:
.md files inside any adr/ subdirectorydocs/specs/**/adr/*.mdADR-### (in H1 header or content)1
Found: ADR-014 | "Event Sourcing Strategy" | docs/specs/shared/adr/014-event-sourcing.md
Trigger: After discovery completes.
docs/reference/adr-checklist.md[x] entries exactly as-isdocs/specs/shared/adr/014-event-sourcing.md)docs/specs/shared/adr/001-architecture.md)
```Trigger: After checklist is current.
[ ] entriesTrigger: User confirms batch selection.
For each ADR in the batch:
Map existing content to ADR v2 sections using this decision tree:
| Original Section/Content | Maps To |
|---|---|
| Problem statement, background, motivation | Context |
| What we chose, the decision itself | Decision |
| Why we chose this, pros, justification | Rationale |
| MUST/MUST NOT, constraints, rules | Constraints |
| NFRs, performance, latency, consistency | Quality Attributes |
| Domains affected, contexts impacted | Bounded Contexts Impacted |
| Trade-offs, impacts, what changes, complexity | Consequences |
| Implementation guidance, alternatives, monitoring | Fold into nearest section or Additional Notes |
-)TBD placeholderBefore writing, validate:
If any check fails → FLAG and STOP. Do not write invalid output.
Trigger: All batch ADRs pass verification.
docs/reference/adr-checklist.md:
[x]Report completion:
1
2
3
4
5
6
7
BATCH COMPLETE: 3 ADRs processed
✓ ADR-014: Event Sourcing Strategy
✓ ADR-015: CQRS Implementation
✓ ADR-016: Domain Events
Remaining: 9 unchecked ADRs
Next: Run prompt again to process next batch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# ADR-###: <Title>
**Status:** Proposed | Accepted | Deprecated | Superseded
**Version:** 1.0
**Date:** YYYY-MM-DD
**Supersedes:** ADR-### (if applicable)
**Related ADRs:** ADR-###, ADR-### (if any)
**Related PRDs:** PRD-### (if any)
---
## Context
[Problem domain this bounded context covers, forces at play, why a decision is needed]
## Decision
[The architectural approach chosen, e.g., DDD + hexagonal + CQRS + UoW + outbox]
## Rationale
[Why this decision was made, key reasoning, supporting evidence]
## Constraints
[MUST/MUST NOT rules that flow from this decision — critical for generator choices]
- MUST use Nx
- MUST use SEA™ pipeline
- MUST generate all runtime code from manifests
- MUST NOT ...
## Quality Attributes
[Non-functional requirements affected: latency, consistency, auditability, etc.]
## Bounded Contexts Impacted
[List of bounded contexts/domains affected by this decision]
## Consequences
[Trade-offs, what complexity this adds (more files, more discipline), what it enables]
Why this structure: Manifests need runtime decisions (db/bus/outbox/DI), and ADR is the right place to constrain them. The Constraints section is particularly critical for downstream code generation.
tools/adr_refactor.ts (TypeScript, Node.js)
1
2
3
4
5
6
7
8
9
10
11
# Default: Process 3 ADRs
pnpm adr:refactor
# Override batch size
pnpm adr:refactor --limit 5
# Preview mode (no file writes)
pnpm adr:refactor --dry-run
# Combine flags
pnpm adr:refactor --dry-run --limit 1
remark / unified for safe markdown parsing| Scenario | Expected Behavior |
|---|---|
| Run twice consecutively | Second run processes NEXT batch, not same batch |
| Re-run after partial completion | Resumes from first unchecked item |
| Run on fully-processed repo | No changes made, reports “All ADRs normalized” |
| Manually uncheck item in todo.md | That ADR gets reprocessed on next run |
| Check | Validation |
|---|---|
| No content loss | diff original vs new shows only structural changes |
| Section order | H2 headings match template order exactly |
| Metadata format | Regex validates bold field format |
| Link validity | All *.md links resolve to existing files |
| Condition | Behavior |
|---|---|
| ADR has unparseable markdown | Skip, log error, don’t mark as complete |
| ADR missing ID in filename/content | Skip, log warning |
| Checklist file locked/unwritable | Fail fast with clear error message |
✓ Another developer can read any ADR and understand the architectural guardrails
✓ All ADRs have identical structure for automated downstream processing
✓ Manifests and SEA™ pipeline can reliably extract constraints from ADRs
✓ No human review needed for structural compliance after normalization
COMMAND: Begin with Phase 1 (Discovery). Report findings before proceeding.