Skip to content

Commit 20da565

Browse files
Copilottschmclaude
authored
Add Architecture Decision Record (ADR) system with AI-powered automation (#212)
* Initial plan * Add Architecture Decision Records (ADR) system to project Co-authored-by: tschm <2046079+tschm@users.noreply.github.com> * Clarify ADR naming conventions and use consistent examples Co-authored-by: tschm <2046079+tschm@users.noreply.github.com> * Add AI-powered ADR creation workflow and make adr command - Create .github/workflows/adr-create.md agentic workflow - Add `make adr` command for easy ADR creation - Update docs/adr/README.md with workflow instructions - Update main README.md to mention make adr - Fix review comment: use consistent example filename Co-authored-by: tschm <2046079+tschm@users.noreply.github.com> * Fix gh-aw compilation error: remove unsupported create-pr safe-output The create-pr safe-output is not supported in the current gh-aw version. Since the workflow already has contents:write and pull-requests:write permissions, it can create PRs directly without needing safe-outputs. Co-authored-by: tschm <2046079+tschm@users.noreply.github.com> * Fix invalid 'contents' toolset in adr-create.md agent workflow 'contents' is not a valid gh-aw toolset; 'repos' already covers reading and writing repository files. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix adr-create.md: use safe-outputs for PR creation instead of write permissions Strict mode disallows 'contents: write'; replace with 'contents: read' and 'safe-outputs: create-pull-request:' as required by gh-aw. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Signed-off-by: Thomas Schmelzer <thomas.schmelzer@gmail.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tschm <2046079+tschm@users.noreply.github.com> Co-authored-by: Thomas Schmelzer <thomas.schmelzer@gmail.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 28340cf commit 20da565

File tree

6 files changed

+382
-1
lines changed

6 files changed

+382
-1
lines changed

.github/workflows/adr-create.md

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
---
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
title:
6+
description: "ADR title (e.g., 'Use PostgreSQL for data storage')"
7+
required: true
8+
type: string
9+
context:
10+
description: "Brief context or problem statement (optional)"
11+
required: false
12+
type: string
13+
14+
description: "Create a new Architecture Decision Record (ADR) with AI assistance"
15+
16+
engine: copilot
17+
18+
permissions:
19+
contents: read
20+
21+
tools:
22+
github:
23+
toolsets: [repos, pull_requests]
24+
25+
safe-outputs:
26+
create-pull-request:
27+
28+
network:
29+
allowed:
30+
- defaults
31+
32+
timeout-minutes: 10
33+
---
34+
35+
# Create Architecture Decision Record (ADR)
36+
37+
You are tasked with creating a new Architecture Decision Record (ADR) for the Rhiza project.
38+
39+
## Input Parameters
40+
41+
- **Title**: {{ inputs.title }}
42+
- **Context** (if provided): {{ inputs.context }}
43+
44+
## Project Context
45+
46+
This is a Rhiza-based Python project that maintains ADRs in `docs/adr/`. The ADR system follows these conventions:
47+
48+
- **Location**: `docs/adr/` directory
49+
- **Naming**: Files use 4-digit sequential numbering: `XXXX-title-with-hyphens.md` (e.g., `0002-use-postgresql.md`)
50+
- **Template**: `docs/adr/0000-adr-template.md` defines the standard format
51+
- **Index**: `docs/adr/README.md` maintains a table of all ADRs
52+
53+
### ADR Format
54+
55+
Each ADR must include:
56+
57+
1. **Title**: `# [NUMBER]. [TITLE]` (e.g., `# 2. Use PostgreSQL for Data Storage`)
58+
2. **Date**: Current date in `YYYY-MM-DD` format
59+
3. **Status**: `Proposed` (default for new ADRs)
60+
4. **Context**: Why is this decision needed? What problem are we solving?
61+
5. **Decision**: What approach are we taking?
62+
6. **Consequences**: What becomes easier or harder? (Positive, Neutral, Negative)
63+
64+
## Instructions
65+
66+
### Step 1: Determine ADR Number
67+
68+
1. Read `docs/adr/README.md` to find the current ADR index table
69+
2. Identify the highest numbered ADR
70+
3. Use the next sequential 4-digit number (e.g., if latest is 0001, use 0002)
71+
72+
### Step 2: Create Filename Slug
73+
74+
Convert the title to a filename-friendly slug:
75+
- Convert to lowercase
76+
- Replace spaces with hyphens
77+
- Remove special characters
78+
- Example: "Use PostgreSQL for Data Storage" → "use-postgresql-for-data-storage"
79+
80+
### Step 3: Generate ADR Content
81+
82+
Create a comprehensive ADR with the following:
83+
84+
**Context Section**:
85+
- If context was provided in inputs, use it as a starting point
86+
- Expand with research about:
87+
- Why this decision is needed for Rhiza
88+
- What problem or requirement motivates it
89+
- Current state and limitations (if applicable)
90+
- Be specific and thorough (3-5 paragraphs)
91+
92+
**Decision Section**:
93+
- Clearly state what is being decided
94+
- Explain the approach or solution
95+
- Include key technical details
96+
- List alternatives considered (if applicable)
97+
- Be concrete and actionable
98+
99+
**Consequences Section**:
100+
Analyze and document:
101+
- **Positive**: Benefits, improvements, what becomes easier
102+
- **Neutral**: Trade-offs, things that change but aren't clearly better/worse
103+
- **Negative**: Costs, limitations, what becomes harder
104+
105+
Each section should have 2-4 bullet points with substantive detail.
106+
107+
### Step 4: Create the ADR File
108+
109+
1. Copy the template: `docs/adr/0000-adr-template.md``docs/adr/XXXX-slug.md`
110+
2. Replace all template placeholders with actual content:
111+
- `[NUMBER]` → actual number
112+
- `[TITLE]` → actual title
113+
- `[YYYY-MM-DD]` → current date
114+
- `[Proposed | ...]``Proposed`
115+
- Fill in Context, Decision, and Consequences sections
116+
3. Ensure all sections are complete and well-written
117+
118+
### Step 5: Update the Index
119+
120+
Edit `docs/adr/README.md`:
121+
1. Add a new row to the ADR Index table:
122+
```
123+
| [XXXX](XXXX-slug.md) | Title | Proposed | YYYY-MM-DD |
124+
```
125+
2. Insert it in numerical order (usually at the end)
126+
3. Keep table formatting aligned
127+
128+
### Step 6: Create Pull Request
129+
130+
1. Create a new branch: `adr/XXXX-slug`
131+
2. Commit both files with message: `Add ADR-XXXX: [Title]`
132+
3. Create a pull request with:
133+
- **Title**: `ADR: [Title]`
134+
- **Description**: Brief summary of the ADR and request for review
135+
- **Labels**: `documentation`, `adr`
136+
137+
## Guidelines
138+
139+
- **Be thorough**: ADRs are permanent records. Make them comprehensive.
140+
- **Research context**: If the input context is brief, research the topic to provide fuller context.
141+
- **Consider alternatives**: Mention other approaches that were or could be considered.
142+
- **Be honest about trade-offs**: Document both benefits and costs.
143+
- **Use professional tone**: Clear, factual, objective writing.
144+
- **Follow template exactly**: Don't add or remove sections from the standard format.
145+
146+
## Example ADR Structure
147+
148+
```markdown
149+
# 2. Use PostgreSQL for Data Storage
150+
151+
Date: 2026-02-21
152+
153+
## Status
154+
155+
Proposed
156+
157+
## Context
158+
159+
Rhiza currently stores all configuration data in YAML files. As the system grows...
160+
[3-5 paragraphs explaining the problem and motivation]
161+
162+
## Decision
163+
164+
We will adopt PostgreSQL as the primary data store for Rhiza configuration data...
165+
[2-4 paragraphs detailing the decision and approach]
166+
167+
## Consequences
168+
169+
### Positive
170+
171+
- **Improved query capabilities**: PostgreSQL enables complex queries...
172+
- **Better concurrency**: ACID transactions prevent data corruption...
173+
- **Scalability**: Can handle larger datasets...
174+
175+
### Neutral
176+
177+
- **Operational complexity**: Requires PostgreSQL installation...
178+
- **Learning curve**: Team needs to learn SQL...
179+
180+
### Negative
181+
182+
- **Migration effort**: Existing YAML data must be migrated...
183+
- **Infrastructure dependency**: Requires database server...
184+
```
185+
186+
## Success Criteria
187+
188+
- ADR file created with next sequential number
189+
- All template sections filled with substantial, thoughtful content
190+
- Index updated with new ADR entry
191+
- Pull request created for review
192+
- Files follow naming conventions exactly

Makefile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,36 @@ include .rhiza/rhiza.mk
1111

1212
# Optional: developer-local extensions (not committed)
1313
-include local.mk
14+
15+
## Custom targets
16+
17+
.PHONY: adr
18+
adr: install-gh-aw ## Create a new Architecture Decision Record (ADR) using AI assistance
19+
@echo "Creating a new ADR..."
20+
@echo "This will trigger the adr-create workflow."
21+
@echo ""
22+
@read -p "Enter ADR title (e.g., 'Use PostgreSQL for data storage'): " title; \
23+
echo ""; \
24+
read -p "Enter brief context (optional, press Enter to skip): " context; \
25+
echo ""; \
26+
if [ -z "$$title" ]; then \
27+
echo "Error: Title is required"; \
28+
exit 1; \
29+
fi; \
30+
if [ -z "$$context" ]; then \
31+
gh workflow run adr-create.md -f title="$$title"; \
32+
else \
33+
gh workflow run adr-create.md -f title="$$title" -f context="$$context"; \
34+
fi; \
35+
echo ""; \
36+
echo "✅ ADR creation workflow triggered!"; \
37+
echo ""; \
38+
echo "The workflow will:"; \
39+
echo " 1. Generate the next ADR number"; \
40+
echo " 2. Create a comprehensive ADR document"; \
41+
echo " 3. Update the ADR index"; \
42+
echo " 4. Open a pull request for review"; \
43+
echo ""; \
44+
echo "Check workflow status: gh run list --workflow=adr-create.md"; \
45+
echo "View latest run: gh run view"
46+

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,22 @@ make install
116116

117117
## ✨ What You Get
118118

119-
### Core Features
119+
## 📝 Architecture Decision Records
120+
121+
This project maintains Architecture Decision Records (ADRs) to document important architectural and design decisions.
122+
123+
ADRs help preserve the reasoning behind key decisions, making it easier for current and future contributors to understand why the project is structured the way it is.
124+
125+
**Browse ADRs**: See [docs/adr/](docs/adr/) for all architecture decisions.
126+
127+
**Key decisions documented:**
128+
- [ADR-0001: Use Architecture Decision Records](docs/adr/0001-use-architecture-decision-records.md)
129+
130+
**Create a new ADR**: Use `make adr` to create a new ADR with AI assistance. The workflow will generate a comprehensive ADR document, update the index, and create a pull request for review.
131+
132+
For more information about the ADR format and how to create new records, see the [ADR README](docs/adr/README.md).
133+
134+
## 📁 Available Templates
120135

121136
- 🚀 **CI/CD Templates** - Ready-to-use GitHub Actions and GitLab CI workflows
122137
- 🧪 **Testing Framework** - Comprehensive test setup with pytest

docs/adr/0000-adr-template.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# [NUMBER]. [TITLE]
2+
3+
Date: [YYYY-MM-DD]
4+
5+
## Status
6+
7+
[Proposed | Accepted | Deprecated | Superseded by [ADR-XXXX](XXXX-title.md)]
8+
9+
## Context
10+
11+
What is the issue that we're seeing that is motivating this decision or change?
12+
13+
## Decision
14+
15+
What is the change that we're proposing and/or doing?
16+
17+
## Consequences
18+
19+
What becomes easier or more difficult to do because of this change?
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# 1. Use Architecture Decision Records
2+
3+
Date: 2026-01-01
4+
5+
## Status
6+
7+
Accepted
8+
9+
## Context
10+
11+
As the Rhiza project grows and evolves, we need a systematic way to document important architectural and design decisions. Team members (both current and future) need to understand:
12+
13+
- Why certain approaches were chosen over alternatives
14+
- What constraints or requirements influenced past decisions
15+
- The expected consequences of architectural choices
16+
- The historical context behind the current system design
17+
18+
Without such documentation, we risk:
19+
- Repeating past mistakes or debates
20+
- Making inconsistent decisions across the project
21+
- Losing institutional knowledge when team members change
22+
- Spending time explaining the same decisions repeatedly
23+
24+
## Decision
25+
26+
We will maintain Architecture Decision Records (ADRs) for architecturally significant decisions in the project.
27+
28+
**Key aspects:**
29+
30+
1. **Location**: ADRs will be stored in `docs/adr/` directory
31+
2. **Format**: Each ADR will follow the template defined in `0000-adr-template.md`
32+
3. **Naming**: Files will be named `XXXX-title-with-hyphens.md` with sequential 4-digit numbering (e.g., `0002-example-decision.md`)
33+
4. **Index**: The `docs/adr/README.md` will maintain an index of all ADRs
34+
5. **Immutability**: Once accepted, ADRs should not be modified; instead, create new ADRs that supersede old ones
35+
6. **Review**: ADRs should be reviewed and discussed before being marked as "Accepted"
36+
37+
**What qualifies as an ADR-worthy decision:**
38+
39+
- Changes to the project structure or organization
40+
- Technology or tool adoption/removal
41+
- Significant changes to development workflows or processes
42+
- Design patterns or architectural approaches
43+
- Changes to build, test, or deployment strategies
44+
45+
## Consequences
46+
47+
### Positive
48+
49+
- **Knowledge preservation**: Important decisions and their rationale are documented for future reference
50+
- **Better onboarding**: New contributors can understand why things work the way they do
51+
- **Reduced debate**: Past decisions are clearly documented, reducing repetitive discussions
52+
- **Audit trail**: Clear history of architectural evolution
53+
- **Better decision-making**: Forces thoughtful consideration of context and consequences
54+
55+
### Neutral
56+
57+
- **Process overhead**: Contributors need to write ADRs for significant decisions (but this is offset by reduced future confusion)
58+
- **Learning curve**: Team members need to learn when and how to write ADRs
59+
60+
### Negative
61+
62+
- **Initial setup time**: Creating the ADR system and first records requires upfront effort
63+
- **Maintenance**: The ADR index needs to be kept up-to-date
64+
65+
Overall, the benefits of maintaining ADRs far outweigh the minimal overhead required to keep them up-to-date.

docs/adr/README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Architecture Decision Records
2+
3+
This directory contains Architecture Decision Records (ADRs) for the Rhiza project.
4+
5+
## What is an ADR?
6+
7+
An Architecture Decision Record (ADR) is a document that captures an important architectural decision made along with its context and consequences.
8+
9+
## ADR Format
10+
11+
Each ADR follows a consistent format defined in [0000-adr-template.md](0000-adr-template.md):
12+
13+
- **Title and Number**: Sequential numbering with descriptive title
14+
- **Date**: When the decision was made
15+
- **Status**: Current state (Proposed, Accepted, Deprecated, Superseded)
16+
- **Context**: The issue or situation that motivates the decision
17+
- **Decision**: The change or approach being taken
18+
- **Consequences**: What becomes easier or harder as a result
19+
20+
## ADR Index
21+
22+
| Number | Title | Status | Date |
23+
|--------|-------|--------|------|
24+
| [0001](0001-use-architecture-decision-records.md) | Use Architecture Decision Records | Accepted | 2026-01-01 |
25+
26+
## Creating a New ADR
27+
28+
### Option 1: Using AI Assistance (Recommended)
29+
30+
The easiest way to create a new ADR is using the automated workflow:
31+
32+
```bash
33+
make adr
34+
```
35+
36+
This will:
37+
1. Prompt you for the ADR title and optional context
38+
2. Trigger an AI-powered workflow that generates a comprehensive ADR
39+
3. Automatically determine the next ADR number
40+
4. Create the ADR file with well-researched content
41+
5. Update the index table
42+
6. Open a pull request for review
43+
44+
### Option 2: Manual Creation
45+
46+
If you prefer to create an ADR manually:
47+
48+
1. Copy the template: `cp docs/adr/0000-adr-template.md docs/adr/0002-example-decision.md`
49+
2. Use the next available 4-digit number (e.g., 0002, 0003, 0004)
50+
3. Fill in all sections with relevant information
51+
4. Update this README to add your ADR to the index
52+
5. Submit via pull request for review
53+
54+
## Resources
55+
56+
- [ADR GitHub Organization](https://adr.github.io/)
57+
- [Michael Nygard's article on ADRs](https://cognitect.com/blog/2011/11/15/documenting-architecture-decisions)

0 commit comments

Comments
 (0)