@comfanion/workflow 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +185 -0
- package/bin/cli.js +406 -0
- package/package.json +50 -0
- package/src/build-info.json +16 -0
- package/src/opencode/ARCHITECTURE.md +255 -0
- package/src/opencode/FLOW.yaml +900 -0
- package/src/opencode/agents/analyst.md +141 -0
- package/src/opencode/agents/architect.md +177 -0
- package/src/opencode/agents/change-manager.md +263 -0
- package/src/opencode/agents/dev.md +171 -0
- package/src/opencode/agents/module-docs.md +628 -0
- package/src/opencode/agents/pm.md +157 -0
- package/src/opencode/agents/researcher.md +254 -0
- package/src/opencode/agents/sm.md +184 -0
- package/src/opencode/agents/workflow-orchestrator.md +249 -0
- package/src/opencode/checklists/architecture-checklist.md +166 -0
- package/src/opencode/checklists/code-review-checklist.md +151 -0
- package/src/opencode/checklists/prd-checklist.md +140 -0
- package/src/opencode/checklists/requirements-checklist.md +86 -0
- package/src/opencode/checklists/story-checklist.md +137 -0
- package/src/opencode/commands/architecture.md +68 -0
- package/src/opencode/commands/archive.md +146 -0
- package/src/opencode/commands/change.md +169 -0
- package/src/opencode/commands/clarify.md +132 -0
- package/src/opencode/commands/code-review.md +96 -0
- package/src/opencode/commands/coding-standards.md +102 -0
- package/src/opencode/commands/dev-story.md +80 -0
- package/src/opencode/commands/diagram.md +152 -0
- package/src/opencode/commands/epics.md +52 -0
- package/src/opencode/commands/help.md +139 -0
- package/src/opencode/commands/jira-sync.md +58 -0
- package/src/opencode/commands/module-docs.md +158 -0
- package/src/opencode/commands/prd.md +63 -0
- package/src/opencode/commands/quick.md +166 -0
- package/src/opencode/commands/requirements.md +49 -0
- package/src/opencode/commands/research.md +113 -0
- package/src/opencode/commands/sprint-plan.md +59 -0
- package/src/opencode/commands/stories.md +61 -0
- package/src/opencode/commands/validate.md +84 -0
- package/src/opencode/commands/workflow-status.md +150 -0
- package/src/opencode/config.yaml +223 -0
- package/src/opencode/opencode.json +36 -0
- package/src/opencode/skills/acceptance-criteria/SKILL.md +212 -0
- package/src/opencode/skills/adr-writing/SKILL.md +241 -0
- package/src/opencode/skills/architecture-design/SKILL.md +183 -0
- package/src/opencode/skills/architecture-validation/SKILL.md +199 -0
- package/src/opencode/skills/archiving/SKILL.md +191 -0
- package/src/opencode/skills/changelog/SKILL.md +280 -0
- package/src/opencode/skills/code-review/SKILL.md +193 -0
- package/src/opencode/skills/coding-standards/SKILL.md +430 -0
- package/src/opencode/skills/diagram-creation/SKILL.md +273 -0
- package/src/opencode/skills/doc-todo/SKILL.md +325 -0
- package/src/opencode/skills/epic-writing/SKILL.md +291 -0
- package/src/opencode/skills/jira-integration/SKILL.md +560 -0
- package/src/opencode/skills/methodologies/SKILL.md +376 -0
- package/src/opencode/skills/module-documentation/SKILL.md +214 -0
- package/src/opencode/skills/prd-validation/SKILL.md +164 -0
- package/src/opencode/skills/prd-writing/SKILL.md +104 -0
- package/src/opencode/skills/requirements-gathering/SKILL.md +132 -0
- package/src/opencode/skills/requirements-validation/SKILL.md +141 -0
- package/src/opencode/skills/research-methodology/SKILL.md +140 -0
- package/src/opencode/skills/sprint-planning/SKILL.md +217 -0
- package/src/opencode/skills/story-writing/SKILL.md +574 -0
- package/src/opencode/skills/test-design/SKILL.md +313 -0
- package/src/opencode/skills/translation/SKILL.md +411 -0
- package/src/opencode/templates/CHANGELOG.md +82 -0
- package/src/opencode/templates/adr-template.md +115 -0
- package/src/opencode/templates/architecture-template.md +362 -0
- package/src/opencode/templates/change-proposal-template.md +186 -0
- package/src/opencode/templates/epic-template.md +151 -0
- package/src/opencode/templates/git-workflow-template.md +384 -0
- package/src/opencode/templates/integration-tests-template.md +265 -0
- package/src/opencode/templates/jira-cache-template.yaml +103 -0
- package/src/opencode/templates/module-index-template.md +139 -0
- package/src/opencode/templates/module-test-cases-template.md +230 -0
- package/src/opencode/templates/prd-acceptance-criteria-template.md +124 -0
- package/src/opencode/templates/prd-template.md +479 -0
- package/src/opencode/templates/requirements-template.md +132 -0
- package/src/opencode/templates/sprint-status-template.yaml +84 -0
- package/src/opencode/templates/story-template.md +437 -0
- package/src/opencode/templates/testing-standards-template.md +359 -0
- package/src/opencode/workflows/dev-story/instructions.md +529 -0
- package/src/repo-structure/.gitattributes +64 -0
- package/src/repo-structure/CONTRIBUTING.md +182 -0
- package/src/repo-structure/README.md +77 -0
- package/src/repo-structure/docs/README.md +62 -0
- package/src/repo-structure/docs/api/README.md +43 -0
- package/src/repo-structure/docs/architecture/README.md +36 -0
- package/src/repo-structure/docs/architecture/adr/README.md +53 -0
- package/src/repo-structure/docs/architecture/diagrams/README.md +59 -0
- package/src/repo-structure/docs/coding-standards/README.md +52 -0
- package/src/repo-structure/docs/confluence/README.md +43 -0
- package/src/repo-structure/docs/requirements/README.md +28 -0
- package/src/repo-structure/docs/sprint-artifacts/README.md +76 -0
- package/src/repo-structure/docs/sprint-artifacts/backlog/README.md +24 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://opencode.ai/config.json",
|
|
3
|
+
|
|
4
|
+
"instructions": [
|
|
5
|
+
".opencode/FLOW.yaml",
|
|
6
|
+
"docs/requirements/requirements.md",
|
|
7
|
+
"docs/prd.md",
|
|
8
|
+
"docs/architecture.md"
|
|
9
|
+
],
|
|
10
|
+
|
|
11
|
+
"agent": {
|
|
12
|
+
"build": {
|
|
13
|
+
"mode": "primary",
|
|
14
|
+
"description": "Default development agent with full tool access",
|
|
15
|
+
"model": "anthropic/claude-sonnet-4-20250514"
|
|
16
|
+
},
|
|
17
|
+
"plan": {
|
|
18
|
+
"mode": "primary",
|
|
19
|
+
"description": "Planning agent - analyzes without making changes",
|
|
20
|
+
"model": "anthropic/claude-sonnet-4-20250514",
|
|
21
|
+
"permission": {
|
|
22
|
+
"edit": "ask",
|
|
23
|
+
"bash": "ask"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
"permission": {
|
|
29
|
+
"bash": {
|
|
30
|
+
"*": "allow",
|
|
31
|
+
"rm -rf *": "deny",
|
|
32
|
+
"git push --force*": "ask",
|
|
33
|
+
"git reset --hard*": "ask"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: acceptance-criteria
|
|
3
|
+
description: How to write testable acceptance criteria using Given/When/Then format
|
|
4
|
+
license: MIT
|
|
5
|
+
compatibility: opencode
|
|
6
|
+
metadata:
|
|
7
|
+
domain: quality-assurance
|
|
8
|
+
format: gherkin
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Acceptance Criteria Writing Skill
|
|
12
|
+
|
|
13
|
+
## When to Use
|
|
14
|
+
|
|
15
|
+
Use this skill when you need to:
|
|
16
|
+
- Write acceptance criteria for FRs in PRD
|
|
17
|
+
- Write AC for epics and stories
|
|
18
|
+
- Define testable behavior specifications
|
|
19
|
+
- Create QA test scenarios
|
|
20
|
+
|
|
21
|
+
## Given/When/Then Format
|
|
22
|
+
|
|
23
|
+
### Structure
|
|
24
|
+
|
|
25
|
+
```gherkin
|
|
26
|
+
Given [precondition/context]
|
|
27
|
+
When [action/trigger]
|
|
28
|
+
Then [expected outcome]
|
|
29
|
+
And [additional outcome]
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Example
|
|
33
|
+
|
|
34
|
+
```gherkin
|
|
35
|
+
AC1: Successful product creation
|
|
36
|
+
Given a merchant is authenticated
|
|
37
|
+
And the merchant has permission to create products
|
|
38
|
+
When the merchant submits a valid product with:
|
|
39
|
+
- name: "Test Product"
|
|
40
|
+
- price: 100.00 UAH
|
|
41
|
+
- SKU: "TEST-001"
|
|
42
|
+
Then a new product is created with status "pending"
|
|
43
|
+
And the product is assigned a unique ID
|
|
44
|
+
And an event "product.created" is published
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## AC Quality Checklist
|
|
48
|
+
|
|
49
|
+
Each acceptance criterion must be:
|
|
50
|
+
- [ ] **Testable** - Can be verified as pass/fail
|
|
51
|
+
- [ ] **Independent** - Doesn't depend on other AC execution order
|
|
52
|
+
- [ ] **Specific** - Exact expected behavior, not vague
|
|
53
|
+
- [ ] **Complete** - Covers one complete scenario
|
|
54
|
+
|
|
55
|
+
## Types of Acceptance Criteria
|
|
56
|
+
|
|
57
|
+
### 1. Happy Path AC
|
|
58
|
+
Normal, successful flow.
|
|
59
|
+
|
|
60
|
+
```gherkin
|
|
61
|
+
Given valid input
|
|
62
|
+
When action performed
|
|
63
|
+
Then success result
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 2. Edge Case AC
|
|
67
|
+
Boundary conditions.
|
|
68
|
+
|
|
69
|
+
```gherkin
|
|
70
|
+
Given input at boundary (min/max/empty)
|
|
71
|
+
When action performed
|
|
72
|
+
Then appropriate handling
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 3. Error Case AC
|
|
76
|
+
Invalid input or failure scenarios.
|
|
77
|
+
|
|
78
|
+
```gherkin
|
|
79
|
+
Given invalid input
|
|
80
|
+
When action attempted
|
|
81
|
+
Then error returned with message
|
|
82
|
+
And no side effects occur
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### 4. Security AC
|
|
86
|
+
Authorization and authentication.
|
|
87
|
+
|
|
88
|
+
```gherkin
|
|
89
|
+
Given user without permission
|
|
90
|
+
When action attempted
|
|
91
|
+
Then access denied (403)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### 5. Performance AC
|
|
95
|
+
Non-functional behavior.
|
|
96
|
+
|
|
97
|
+
```gherkin
|
|
98
|
+
Given 1000 concurrent requests
|
|
99
|
+
When action performed
|
|
100
|
+
Then response time < 200ms p95
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## AC for Different Artifacts
|
|
104
|
+
|
|
105
|
+
### PRD Level (High-level)
|
|
106
|
+
|
|
107
|
+
```markdown
|
|
108
|
+
## FR-001: Product Creation
|
|
109
|
+
|
|
110
|
+
**Acceptance Criteria:**
|
|
111
|
+
- [ ] Merchant can create product with required fields
|
|
112
|
+
- [ ] Product validation rejects invalid data
|
|
113
|
+
- [ ] Created product appears in product list
|
|
114
|
+
- [ ] Product creation event is published
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Epic Level (Feature-level)
|
|
118
|
+
|
|
119
|
+
```markdown
|
|
120
|
+
## Acceptance Criteria
|
|
121
|
+
|
|
122
|
+
- [ ] All CRUD operations for products work
|
|
123
|
+
- [ ] Validation rules are enforced
|
|
124
|
+
- [ ] Events are published for all state changes
|
|
125
|
+
- [ ] API follows REST conventions
|
|
126
|
+
- [ ] Unit test coverage > 80%
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Story Level (Detailed)
|
|
130
|
+
|
|
131
|
+
```markdown
|
|
132
|
+
## Acceptance Criteria
|
|
133
|
+
|
|
134
|
+
### AC1: Create product with valid data
|
|
135
|
+
**Given** authenticated merchant with "product:create" permission
|
|
136
|
+
**When** POST /api/v1/products with valid payload
|
|
137
|
+
**Then** 201 Created returned
|
|
138
|
+
**And** product has generated UUID
|
|
139
|
+
**And** product status is "pending"
|
|
140
|
+
**And** "product.created" event published to Kafka
|
|
141
|
+
|
|
142
|
+
### AC2: Reject invalid product data
|
|
143
|
+
**Given** authenticated merchant
|
|
144
|
+
**When** POST /api/v1/products with missing "name"
|
|
145
|
+
**Then** 400 Bad Request returned
|
|
146
|
+
**And** error response contains validation details
|
|
147
|
+
**And** no product is created
|
|
148
|
+
|
|
149
|
+
### AC3: Reject unauthorized access
|
|
150
|
+
**Given** authenticated user without "product:create" permission
|
|
151
|
+
**When** POST /api/v1/products
|
|
152
|
+
**Then** 403 Forbidden returned
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Common Mistakes to Avoid
|
|
156
|
+
|
|
157
|
+
1. **Too vague**: "System works correctly" → Define WHAT "correctly" means
|
|
158
|
+
2. **Multiple scenarios in one AC**: Split into separate ACs
|
|
159
|
+
3. **Implementation details**: "Use PostgreSQL" → Focus on WHAT, not HOW
|
|
160
|
+
4. **Missing error cases**: Always include negative scenarios
|
|
161
|
+
5. **No measurable outcome**: "Fast response" → "< 200ms"
|
|
162
|
+
|
|
163
|
+
## AC Templates
|
|
164
|
+
|
|
165
|
+
### CRUD Operations
|
|
166
|
+
|
|
167
|
+
```gherkin
|
|
168
|
+
# Create
|
|
169
|
+
Given valid [entity] data
|
|
170
|
+
When POST /api/v1/[entities]
|
|
171
|
+
Then 201 Created with [entity] details
|
|
172
|
+
|
|
173
|
+
# Read
|
|
174
|
+
Given existing [entity] with ID
|
|
175
|
+
When GET /api/v1/[entities]/{id}
|
|
176
|
+
Then 200 OK with [entity] details
|
|
177
|
+
|
|
178
|
+
# Update
|
|
179
|
+
Given existing [entity] with ID
|
|
180
|
+
When PUT /api/v1/[entities]/{id} with updates
|
|
181
|
+
Then 200 OK with updated [entity]
|
|
182
|
+
|
|
183
|
+
# Delete
|
|
184
|
+
Given existing [entity] with ID
|
|
185
|
+
When DELETE /api/v1/[entities]/{id}
|
|
186
|
+
Then 204 No Content
|
|
187
|
+
And [entity] no longer retrievable
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Validation
|
|
191
|
+
|
|
192
|
+
```gherkin
|
|
193
|
+
Given [entity] with invalid [field]
|
|
194
|
+
When create/update attempted
|
|
195
|
+
Then 400 Bad Request
|
|
196
|
+
And error identifies [field] and reason
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Authorization
|
|
200
|
+
|
|
201
|
+
```gherkin
|
|
202
|
+
Given user with role [role]
|
|
203
|
+
When accessing [resource]
|
|
204
|
+
Then [allowed/denied] based on permissions
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Related Skills
|
|
208
|
+
|
|
209
|
+
- `story-writing` - For complete user stories
|
|
210
|
+
- `epic-writing` - For epic-level AC
|
|
211
|
+
- `prd-writing` - For FR-level AC
|
|
212
|
+
- `integration-testing` - For test implementation
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: adr-writing
|
|
3
|
+
description: How to write Architecture Decision Records (ADRs) documenting technical decisions and rationale
|
|
4
|
+
license: MIT
|
|
5
|
+
compatibility: opencode
|
|
6
|
+
metadata:
|
|
7
|
+
domain: software-architecture
|
|
8
|
+
artifacts: docs/architecture/adr/
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# ADR Writing Skill
|
|
12
|
+
|
|
13
|
+
## When to Use
|
|
14
|
+
|
|
15
|
+
Use this skill when you need to:
|
|
16
|
+
- Document a significant architectural decision
|
|
17
|
+
- Record the rationale behind a technical choice
|
|
18
|
+
- Track decision history over time
|
|
19
|
+
- Communicate decisions to the team
|
|
20
|
+
|
|
21
|
+
## When to Write an ADR
|
|
22
|
+
|
|
23
|
+
Write an ADR when:
|
|
24
|
+
- Choosing between multiple valid approaches
|
|
25
|
+
- Making a decision that affects multiple modules
|
|
26
|
+
- Selecting a technology or framework
|
|
27
|
+
- Defining a pattern to follow consistently
|
|
28
|
+
- Making a trade-off between quality attributes
|
|
29
|
+
|
|
30
|
+
## ADR Template
|
|
31
|
+
|
|
32
|
+
```markdown
|
|
33
|
+
# ADR-NNN: [Decision Title]
|
|
34
|
+
|
|
35
|
+
**Status:** Proposed | Accepted | Deprecated | Superseded by ADR-XXX
|
|
36
|
+
**Date:** YYYY-MM-DD
|
|
37
|
+
**Deciders:** [Names of people involved]
|
|
38
|
+
**Technical Story:** [Link to epic/story if applicable]
|
|
39
|
+
|
|
40
|
+
## Context
|
|
41
|
+
|
|
42
|
+
[Describe the situation that led to this decision. What is the problem?
|
|
43
|
+
What forces are at play? What constraints exist?]
|
|
44
|
+
|
|
45
|
+
## Decision
|
|
46
|
+
|
|
47
|
+
[State the decision clearly. What are we going to do?]
|
|
48
|
+
|
|
49
|
+
## Consequences
|
|
50
|
+
|
|
51
|
+
### Positive
|
|
52
|
+
- [Benefit 1]
|
|
53
|
+
- [Benefit 2]
|
|
54
|
+
|
|
55
|
+
### Negative
|
|
56
|
+
- [Drawback 1]
|
|
57
|
+
- [Drawback 2]
|
|
58
|
+
|
|
59
|
+
### Neutral
|
|
60
|
+
- [Side effect that is neither good nor bad]
|
|
61
|
+
|
|
62
|
+
## Alternatives Considered
|
|
63
|
+
|
|
64
|
+
### Alternative 1: [Name]
|
|
65
|
+
[Brief description]
|
|
66
|
+
- **Pros:** [advantages]
|
|
67
|
+
- **Cons:** [disadvantages]
|
|
68
|
+
- **Rejected because:** [reason]
|
|
69
|
+
|
|
70
|
+
### Alternative 2: [Name]
|
|
71
|
+
[Brief description]
|
|
72
|
+
- **Pros:** [advantages]
|
|
73
|
+
- **Cons:** [disadvantages]
|
|
74
|
+
- **Rejected because:** [reason]
|
|
75
|
+
|
|
76
|
+
## References
|
|
77
|
+
|
|
78
|
+
- [Link to relevant documentation]
|
|
79
|
+
- [Link to research or benchmarks]
|
|
80
|
+
|
|
81
|
+
## Notes
|
|
82
|
+
|
|
83
|
+
[Any additional context, caveats, or follow-up actions]
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Naming Convention
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
ADR-NNN-short-description.md
|
|
90
|
+
|
|
91
|
+
Examples:
|
|
92
|
+
- ADR-001-use-postgresql.md
|
|
93
|
+
- ADR-002-event-driven-integration.md
|
|
94
|
+
- ADR-003-modular-monolith-architecture.md
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Status Lifecycle
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
Proposed → Accepted → (Deprecated | Superseded)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
- **Proposed:** Under discussion
|
|
104
|
+
- **Accepted:** Decision made and in effect
|
|
105
|
+
- **Deprecated:** No longer relevant (system changed)
|
|
106
|
+
- **Superseded:** Replaced by a newer ADR
|
|
107
|
+
|
|
108
|
+
## Good ADR Examples
|
|
109
|
+
|
|
110
|
+
### Example: Database Choice
|
|
111
|
+
|
|
112
|
+
```markdown
|
|
113
|
+
# ADR-001: Use PostgreSQL as Primary Database
|
|
114
|
+
|
|
115
|
+
**Status:** Accepted
|
|
116
|
+
**Date:** 2026-01-15
|
|
117
|
+
**Deciders:** Tech Lead, Architect
|
|
118
|
+
|
|
119
|
+
## Context
|
|
120
|
+
|
|
121
|
+
We need a primary database for the marketplace system.
|
|
122
|
+
Requirements:
|
|
123
|
+
- ACID transactions for orders
|
|
124
|
+
- Complex queries for product search
|
|
125
|
+
- JSON support for flexible attributes
|
|
126
|
+
- Proven reliability at scale
|
|
127
|
+
|
|
128
|
+
## Decision
|
|
129
|
+
|
|
130
|
+
Use PostgreSQL 17+ with AWS RDS.
|
|
131
|
+
|
|
132
|
+
## Consequences
|
|
133
|
+
|
|
134
|
+
### Positive
|
|
135
|
+
- Strong ACID guarantees
|
|
136
|
+
- Excellent JSON/JSONB support
|
|
137
|
+
- GIN indexes for full-text search
|
|
138
|
+
- Team expertise exists
|
|
139
|
+
|
|
140
|
+
### Negative
|
|
141
|
+
- Requires careful schema design
|
|
142
|
+
- Scaling writes is harder than NoSQL
|
|
143
|
+
- AWS RDS costs
|
|
144
|
+
|
|
145
|
+
## Alternatives Considered
|
|
146
|
+
|
|
147
|
+
### MySQL
|
|
148
|
+
- Pros: Simpler, cheaper
|
|
149
|
+
- Cons: Weaker JSON support, fewer features
|
|
150
|
+
- Rejected: JSON operations are critical for us
|
|
151
|
+
|
|
152
|
+
### MongoDB
|
|
153
|
+
- Pros: Flexible schema, easy scaling
|
|
154
|
+
- Cons: No ACID across documents, eventual consistency
|
|
155
|
+
- Rejected: Need strong consistency for orders
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Example: Integration Pattern
|
|
159
|
+
|
|
160
|
+
```markdown
|
|
161
|
+
# ADR-002: Event-Driven Integration Between Modules
|
|
162
|
+
|
|
163
|
+
**Status:** Accepted
|
|
164
|
+
**Date:** 2026-01-16
|
|
165
|
+
**Deciders:** Architect, Tech Lead
|
|
166
|
+
|
|
167
|
+
## Context
|
|
168
|
+
|
|
169
|
+
Modules need to communicate. Options:
|
|
170
|
+
1. Direct API calls (synchronous)
|
|
171
|
+
2. Event-driven (asynchronous)
|
|
172
|
+
3. Shared database (anti-pattern)
|
|
173
|
+
|
|
174
|
+
## Decision
|
|
175
|
+
|
|
176
|
+
Use Kafka for event-driven integration between modules.
|
|
177
|
+
Modules publish domain events, others subscribe.
|
|
178
|
+
|
|
179
|
+
## Consequences
|
|
180
|
+
|
|
181
|
+
### Positive
|
|
182
|
+
- Loose coupling between modules
|
|
183
|
+
- Better scalability
|
|
184
|
+
- Natural audit trail
|
|
185
|
+
- Resilient to failures
|
|
186
|
+
|
|
187
|
+
### Negative
|
|
188
|
+
- Eventual consistency complexity
|
|
189
|
+
- Need idempotent consumers
|
|
190
|
+
- Additional infrastructure (Kafka)
|
|
191
|
+
- Harder to debug
|
|
192
|
+
|
|
193
|
+
## Alternatives Considered
|
|
194
|
+
|
|
195
|
+
### Direct HTTP Calls
|
|
196
|
+
- Rejected: Creates tight coupling, cascading failures
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Directory Structure
|
|
200
|
+
|
|
201
|
+
```
|
|
202
|
+
docs/architecture/adr/
|
|
203
|
+
├── ADR-001-use-postgresql.md
|
|
204
|
+
├── ADR-002-event-driven-integration.md
|
|
205
|
+
├── ADR-003-modular-monolith.md
|
|
206
|
+
├── ADR-004-hexagonal-architecture.md
|
|
207
|
+
└── README.md # Index of all ADRs
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## ADR Index (README.md)
|
|
211
|
+
|
|
212
|
+
```markdown
|
|
213
|
+
# Architecture Decision Records
|
|
214
|
+
|
|
215
|
+
| ADR | Title | Status | Date |
|
|
216
|
+
|-----|-------|--------|------|
|
|
217
|
+
| [ADR-001](ADR-001-use-postgresql.md) | Use PostgreSQL | Accepted | 2026-01-15 |
|
|
218
|
+
| [ADR-002](ADR-002-event-driven-integration.md) | Event-driven integration | Accepted | 2026-01-16 |
|
|
219
|
+
| [ADR-003](ADR-003-modular-monolith.md) | Modular monolith | Accepted | 2026-01-17 |
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Quality Checklist
|
|
223
|
+
|
|
224
|
+
Before finalizing ADR:
|
|
225
|
+
- [ ] Context explains the problem clearly
|
|
226
|
+
- [ ] Decision is stated unambiguously
|
|
227
|
+
- [ ] Consequences include both positive and negative
|
|
228
|
+
- [ ] At least 2 alternatives were considered
|
|
229
|
+
- [ ] Alternatives explain why they were rejected
|
|
230
|
+
- [ ] Status is set correctly
|
|
231
|
+
- [ ] Date and deciders are recorded
|
|
232
|
+
|
|
233
|
+
## Output
|
|
234
|
+
|
|
235
|
+
Save to: `docs/architecture/adr/ADR-NNN-description.md`
|
|
236
|
+
Update: `docs/architecture/adr/README.md` (index)
|
|
237
|
+
|
|
238
|
+
## Related Skills
|
|
239
|
+
|
|
240
|
+
- `architecture-design` - For overall architecture
|
|
241
|
+
- `architecture-validation` - For validating ADRs exist
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: architecture-design
|
|
3
|
+
description: How to design system architecture following hexagonal/DDD patterns with proper module boundaries
|
|
4
|
+
license: MIT
|
|
5
|
+
compatibility: opencode
|
|
6
|
+
metadata:
|
|
7
|
+
domain: software-architecture
|
|
8
|
+
patterns: hexagonal, ddd, modular-monolith
|
|
9
|
+
artifacts: docs/architecture.md
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Architecture Design Skill
|
|
13
|
+
|
|
14
|
+
## When to Use
|
|
15
|
+
|
|
16
|
+
Use this skill when you need to:
|
|
17
|
+
- Design new system architecture
|
|
18
|
+
- Define module/service boundaries
|
|
19
|
+
- Create data ownership model
|
|
20
|
+
- Design integration points
|
|
21
|
+
- Document architectural decisions
|
|
22
|
+
|
|
23
|
+
## Reference
|
|
24
|
+
|
|
25
|
+
Always check project standards: `@CLAUDE.md`
|
|
26
|
+
|
|
27
|
+
## Template
|
|
28
|
+
|
|
29
|
+
Use template at: `@.opencode/templates/architecture-template.md`
|
|
30
|
+
|
|
31
|
+
## Architecture Principles
|
|
32
|
+
|
|
33
|
+
### 1. Hexagonal Architecture (Ports & Adapters)
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
┌─────────────────────────────────────────────────────┐
|
|
37
|
+
│ Infrastructure │
|
|
38
|
+
│ ┌───────────────────────────────────────────────┐ │
|
|
39
|
+
│ │ Application │ │
|
|
40
|
+
│ │ ┌─────────────────────────────────────────┐ │ │
|
|
41
|
+
│ │ │ Domain │ │ │
|
|
42
|
+
│ │ │ (Business Logic - NO dependencies!) │ │ │
|
|
43
|
+
│ │ └─────────────────────────────────────────┘ │ │
|
|
44
|
+
│ │ Use Cases (Orchestration) │ │
|
|
45
|
+
│ └───────────────────────────────────────────────┘ │
|
|
46
|
+
│ Adapters (HTTP, DB, Kafka, External) │
|
|
47
|
+
└─────────────────────────────────────────────────────┘
|
|
48
|
+
|
|
49
|
+
Dependency Direction: Infrastructure → Application → Domain
|
|
50
|
+
(NEVER reverse!)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 2. Module Structure
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
module/
|
|
57
|
+
├── domain/ # Business logic ONLY
|
|
58
|
+
│ ├── aggregate/ # Entities with business rules
|
|
59
|
+
│ ├── valueobject/ # Immutable value objects
|
|
60
|
+
│ ├── service/ # Domain services
|
|
61
|
+
│ ├── repository/ # Repository INTERFACES (ports)
|
|
62
|
+
│ └── event/ # Domain events
|
|
63
|
+
├── application/ # Use cases
|
|
64
|
+
│ └── usecase/
|
|
65
|
+
│ └── CreateEntity/
|
|
66
|
+
│ ├── inport.go # Interface
|
|
67
|
+
│ ├── dto.go # Command & Result
|
|
68
|
+
│ ├── handler.go # Orchestration
|
|
69
|
+
│ └── mappers.go # Explicit mapping
|
|
70
|
+
└── infrastructure/ # Adapters
|
|
71
|
+
├── repo/ # DB implementations
|
|
72
|
+
├── http/ # HTTP handlers
|
|
73
|
+
└── kafka/ # Event publishers
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 3. Module Boundaries
|
|
77
|
+
|
|
78
|
+
Each module must have:
|
|
79
|
+
- **Single responsibility** - One business capability
|
|
80
|
+
- **Explicit data ownership** - Clear which entities it owns
|
|
81
|
+
- **Defined interfaces** - API contracts for communication
|
|
82
|
+
- **No cross-module imports** - Communicate via Kafka/HTTP only
|
|
83
|
+
|
|
84
|
+
## Design Process
|
|
85
|
+
|
|
86
|
+
### Step 1: Identify Bounded Contexts
|
|
87
|
+
|
|
88
|
+
From PRD, identify:
|
|
89
|
+
1. Major business capabilities
|
|
90
|
+
2. Data ownership boundaries
|
|
91
|
+
3. Team boundaries (Conway's Law)
|
|
92
|
+
|
|
93
|
+
### Step 2: Define Module Contracts
|
|
94
|
+
|
|
95
|
+
For each module:
|
|
96
|
+
```yaml
|
|
97
|
+
module: catalog
|
|
98
|
+
responsibility: Product and category management
|
|
99
|
+
owns:
|
|
100
|
+
- Product
|
|
101
|
+
- Category
|
|
102
|
+
- Attribute
|
|
103
|
+
consumes:
|
|
104
|
+
- merchant.created (from Merchant module)
|
|
105
|
+
produces:
|
|
106
|
+
- product.created
|
|
107
|
+
- product.updated
|
|
108
|
+
- category.created
|
|
109
|
+
api:
|
|
110
|
+
- POST /api/v1/products
|
|
111
|
+
- GET /api/v1/products/{id}
|
|
112
|
+
- GET /api/v1/categories
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Step 3: Design Data Model
|
|
116
|
+
|
|
117
|
+
For each owned entity:
|
|
118
|
+
- Primary key strategy (UUID recommended)
|
|
119
|
+
- Required fields
|
|
120
|
+
- Indexes (for query patterns)
|
|
121
|
+
- Relationships
|
|
122
|
+
- Audit fields (created_at, updated_at, version)
|
|
123
|
+
|
|
124
|
+
### Step 4: Design Events
|
|
125
|
+
|
|
126
|
+
For state changes:
|
|
127
|
+
```yaml
|
|
128
|
+
event: product.created
|
|
129
|
+
version: "1.0"
|
|
130
|
+
payload:
|
|
131
|
+
product_id: uuid
|
|
132
|
+
merchant_id: uuid
|
|
133
|
+
name: string
|
|
134
|
+
created_at: timestamp
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Step 5: Document Decisions (ADRs)
|
|
138
|
+
|
|
139
|
+
Use skill: `adr-writing`
|
|
140
|
+
|
|
141
|
+
## NFR Mapping
|
|
142
|
+
|
|
143
|
+
Map each NFR to architectural solution:
|
|
144
|
+
|
|
145
|
+
| NFR | Architectural Support |
|
|
146
|
+
|-----|----------------------|
|
|
147
|
+
| Response < 200ms | Caching (Redis), connection pooling |
|
|
148
|
+
| 99.9% availability | K8s HA, health checks, circuit breakers |
|
|
149
|
+
| 1000 RPS | Horizontal scaling, async processing |
|
|
150
|
+
| Data security | TLS, encryption at rest, audit logs |
|
|
151
|
+
|
|
152
|
+
## Architecture Checklist
|
|
153
|
+
|
|
154
|
+
Before completing:
|
|
155
|
+
- [ ] All PRD functional areas have architectural home
|
|
156
|
+
- [ ] All NFRs have concrete architectural support
|
|
157
|
+
- [ ] Module boundaries are clear
|
|
158
|
+
- [ ] Data ownership is explicit (each entity has ONE owner)
|
|
159
|
+
- [ ] No circular dependencies between modules
|
|
160
|
+
- [ ] Integration points are well-defined
|
|
161
|
+
- [ ] ADRs exist for major decisions
|
|
162
|
+
- [ ] Aligns with CLAUDE.md patterns
|
|
163
|
+
- [ ] Diagrams included (context, container, component)
|
|
164
|
+
|
|
165
|
+
## Anti-patterns to Avoid
|
|
166
|
+
|
|
167
|
+
1. **Distributed monolith** - Modules that must deploy together
|
|
168
|
+
2. **Shared database** - Multiple modules accessing same tables
|
|
169
|
+
3. **Circular dependencies** - Module A depends on B depends on A
|
|
170
|
+
4. **God module** - One module doing everything
|
|
171
|
+
5. **Anemic domain** - Business logic in services, not entities
|
|
172
|
+
|
|
173
|
+
## Output
|
|
174
|
+
|
|
175
|
+
Save to: `docs/architecture.md`
|
|
176
|
+
|
|
177
|
+
## Related Skills
|
|
178
|
+
|
|
179
|
+
- `adr-writing` - For architecture decisions
|
|
180
|
+
- `data-modeling` - For database design
|
|
181
|
+
- `api-design` - For REST API contracts
|
|
182
|
+
- `event-design` - For Kafka event schemas
|
|
183
|
+
- `architecture-validation` - For validation
|