@dzhechkov/keysarium 1.1.2 → 1.3.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 +7 -2
- package/package.json +10 -2
- package/templates/.claude/commands/brain-export.md +97 -20
- package/templates/.claude/commands/brain-import.md +75 -4
- package/templates/.claude/commands/dream.md +101 -0
- package/templates/.claude/commands/feature-adr.md +92 -0
- package/templates/.claude/commands/init-platform.md +161 -0
- package/templates/.claude/commands/learning-stats.md +130 -0
- package/templates/.claude/commands/workers.md +140 -0
- package/templates/.claude/rules/background-workers.md +72 -0
- package/templates/.claude/rules/dream-cycles.md +90 -0
- package/templates/.claude/rules/feature-adr-conventions.md +82 -0
- package/templates/.claude/rules/reward-learning.md +124 -0
- package/templates/.claude/shards/feature-adr.shard.md +98 -0
- package/templates/.claude/skills/feature-adr/SKILL.md +252 -0
- package/templates/.claude/skills/feature-adr/examples/sample-feature-output.md +257 -0
- package/templates/.claude/skills/feature-adr/modules/00-complexity-router.md +114 -0
- package/templates/.claude/skills/feature-adr/modules/01-requirements.md +113 -0
- package/templates/.claude/skills/feature-adr/modules/02-research.md +92 -0
- package/templates/.claude/skills/feature-adr/modules/03-adr.md +135 -0
- package/templates/.claude/skills/feature-adr/modules/04-ddd.md +114 -0
- package/templates/.claude/skills/feature-adr/modules/05-architecture.md +149 -0
- package/templates/.claude/skills/feature-adr/modules/06-implementation-plan.md +129 -0
- package/templates/.claude/skills/feature-adr/modules/07-code.md +126 -0
- package/templates/.claude/skills/feature-adr/modules/08-qe.md +167 -0
- package/templates/.claude/skills/feature-adr/references/adr-template.md +102 -0
- package/templates/.claude/skills/feature-adr/references/c4-template.md +120 -0
- package/templates/.claude/skills/feature-adr/references/complexity-matrix.md +139 -0
- package/templates/.claude/skills/feature-adr/references/qe-checklist.md +86 -0
- package/templates/CLAUDE.md +135 -8
- package/templates/docs/feature-adr/01-architecture.md +750 -0
- package/templates/docs/feature-adr/02-functionality.md +712 -0
- package/templates/docs/feature-adr/03-deployment-guide.md +614 -0
- package/templates/docs/feature-adr/04-admin-guide.md +564 -0
- package/templates/docs/feature-adr/05-user-guide.md +508 -0
- package/templates/docs/feature-adr/06-user-flows.md +1101 -0
- package/templates/docs/improvement-directions.md +16 -16
- package/templates/docs/keysarium/01-deployment-guide.md +21 -12
- package/templates/docs/keysarium/02-admin-guide.md +204 -3
- package/templates/docs/keysarium/03-user-guide.md +224 -0
- package/templates/docs/keysarium/05-architecture.md +181 -0
- package/templates/docs/keysarium/06-user-flows.md +235 -0
- package/templates/docs/keysarium-core/01-architecture.md +559 -0
- package/templates/docs/keysarium-core/02-functionality.md +953 -0
- package/templates/docs/keysarium-core/03-deployment-guide.md +625 -0
- package/templates/docs/keysarium-core/04-admin-guide.md +529 -0
- package/templates/docs/keysarium-core/05-user-guide.md +599 -0
- package/templates/docs/keysarium-core/06-user-flows.md +804 -0
- package/templates/lib/background-workers.md +278 -0
- package/templates/lib/dream-engine.md +460 -0
- package/templates/lib/judge-attestation.md +322 -0
- package/templates/lib/memory-protocol.md +344 -0
- package/templates/lib/platform-adapters.md +100 -0
- package/templates/lib/platform-templates/copilot.md +134 -0
- package/templates/lib/platform-templates/cursor.md +95 -0
- package/templates/lib/platform-templates/opencode.md +155 -0
- package/templates/lib/reward-tracker.md +256 -0
- package/templates/lib/witness-chain.md +372 -0
- package/templates/lib/worker-templates/brain-export.md +187 -0
- package/templates/lib/worker-templates/consolidate.md +180 -0
- package/templates/lib/worker-templates/dream-cycle.md +154 -0
- package/templates/lib/worker-templates/health-check.md +255 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
# Sample Output: M-tier Feature — "Add User Notifications"
|
|
2
|
+
|
|
3
|
+
> This example shows the expected output structure for a medium-complexity feature.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Step 0: Complexity Assessment
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
Feature: Add email and in-app notifications for order status changes
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
| Dimension | Score | Reasoning |
|
|
14
|
+
|-----------|-------|-----------|
|
|
15
|
+
| Files affected | 2 (M) | ~8 files: model, service, controller, templates, tests |
|
|
16
|
+
| Domains touched | 2 (M) | Orders domain + Notifications domain |
|
|
17
|
+
| New integrations | 2 (M) | Email service (SendGrid) |
|
|
18
|
+
| Breaking changes | 1 (S) | No breaking changes |
|
|
19
|
+
| New data models | 2 (M) | Notification entity + preferences |
|
|
20
|
+
| Cross-cutting concerns | 1 (S) | None |
|
|
21
|
+
|
|
22
|
+
**Total: 10 → Tier M**
|
|
23
|
+
|
|
24
|
+
Active steps: 0, 1, 3, 5(light), 6, 7, 8
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Step 1: Requirements
|
|
29
|
+
|
|
30
|
+
```markdown
|
|
31
|
+
# Requirements: User Notifications
|
|
32
|
+
|
|
33
|
+
## Stakeholders
|
|
34
|
+
- End user: receives notifications
|
|
35
|
+
- Product owner: defines notification triggers
|
|
36
|
+
- Ops team: monitors delivery rates
|
|
37
|
+
|
|
38
|
+
## Functional Requirements
|
|
39
|
+
|
|
40
|
+
FR-1: Order status notification
|
|
41
|
+
Priority: MUST
|
|
42
|
+
Acceptance: Given a user with email notifications enabled,
|
|
43
|
+
When their order status changes,
|
|
44
|
+
Then they receive an email within 5 minutes.
|
|
45
|
+
|
|
46
|
+
FR-2: In-app notification
|
|
47
|
+
Priority: MUST
|
|
48
|
+
Acceptance: Given a user is logged in,
|
|
49
|
+
When a notification is created,
|
|
50
|
+
Then it appears in the notification bell within 10 seconds.
|
|
51
|
+
|
|
52
|
+
FR-3: Notification preferences
|
|
53
|
+
Priority: SHOULD
|
|
54
|
+
Acceptance: Given a user in settings,
|
|
55
|
+
When they toggle notification types,
|
|
56
|
+
Then only enabled types are delivered.
|
|
57
|
+
|
|
58
|
+
FR-4: Notification history
|
|
59
|
+
Priority: COULD
|
|
60
|
+
Acceptance: Given a user in notification center,
|
|
61
|
+
When they scroll,
|
|
62
|
+
Then they see paginated notification history.
|
|
63
|
+
|
|
64
|
+
## Constraints
|
|
65
|
+
- Must use existing SendGrid account
|
|
66
|
+
- Must not exceed 10K emails/day (current plan limit)
|
|
67
|
+
- Must follow existing event-driven architecture
|
|
68
|
+
|
|
69
|
+
## Scope
|
|
70
|
+
- IN: Order status emails, in-app notifications, preferences
|
|
71
|
+
- OUT: Push notifications (mobile), SMS, marketing emails
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Step 3: ADR
|
|
77
|
+
|
|
78
|
+
```markdown
|
|
79
|
+
# ADR-001: Notification Delivery Strategy
|
|
80
|
+
|
|
81
|
+
## Status
|
|
82
|
+
Accepted
|
|
83
|
+
|
|
84
|
+
## Context
|
|
85
|
+
We need to deliver notifications both via email and in-app.
|
|
86
|
+
The question is whether to send synchronously or asynchronously.
|
|
87
|
+
|
|
88
|
+
## Decision Drivers
|
|
89
|
+
- Order status changes happen in bursts (batch processing)
|
|
90
|
+
- Email delivery latency is acceptable within 5 minutes
|
|
91
|
+
- System should not slow down order processing
|
|
92
|
+
|
|
93
|
+
## Considered Options
|
|
94
|
+
|
|
95
|
+
### Option 1: Synchronous delivery
|
|
96
|
+
Send notification during order status update request.
|
|
97
|
+
- ✅ Simple implementation
|
|
98
|
+
- ❌ Slows down order status updates
|
|
99
|
+
- ❌ Email failures block the request
|
|
100
|
+
|
|
101
|
+
### Option 2: Async via existing job queue
|
|
102
|
+
Publish notification event, worker processes it.
|
|
103
|
+
- ✅ Non-blocking for order processing
|
|
104
|
+
- ✅ Retry on failure
|
|
105
|
+
- ✅ Uses existing Bull queue infrastructure
|
|
106
|
+
- ❌ Slight delay (acceptable per requirements)
|
|
107
|
+
|
|
108
|
+
## Decision
|
|
109
|
+
We chose **Option 2: Async via job queue** because it matches our existing
|
|
110
|
+
event-driven architecture and meets the 5-minute SLA with room to spare.
|
|
111
|
+
|
|
112
|
+
## Consequences
|
|
113
|
+
### Positive
|
|
114
|
+
- Order processing unaffected by notification delivery
|
|
115
|
+
- Built-in retry and dead-letter handling
|
|
116
|
+
### Negative
|
|
117
|
+
- Need to monitor queue depth for capacity planning
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Step 5: Architecture (Light)
|
|
123
|
+
|
|
124
|
+
```markdown
|
|
125
|
+
# Architecture: User Notifications
|
|
126
|
+
|
|
127
|
+
## Component Diagram
|
|
128
|
+
|
|
129
|
+
```mermaid
|
|
130
|
+
graph TB
|
|
131
|
+
subgraph "API Server"
|
|
132
|
+
OrderService[OrderService]
|
|
133
|
+
NotifService[NotificationService]
|
|
134
|
+
NotifController[NotificationController]
|
|
135
|
+
PrefsController[PreferencesController]
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
subgraph "Workers"
|
|
139
|
+
EmailWorker[EmailNotificationWorker]
|
|
140
|
+
InAppWorker[InAppNotificationWorker]
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
OrderService -->|"publish event"| Queue[(Bull Queue)]
|
|
144
|
+
Queue -->|"consume"| EmailWorker
|
|
145
|
+
Queue -->|"consume"| InAppWorker
|
|
146
|
+
EmailWorker -->|"send"| SendGrid[SendGrid API]
|
|
147
|
+
InAppWorker -->|"write"| DB[(Database)]
|
|
148
|
+
NotifController -->|"read"| DB
|
|
149
|
+
PrefsController -->|"read/write"| DB
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## API Endpoints
|
|
153
|
+
- GET /api/notifications — list user notifications (paginated)
|
|
154
|
+
- PATCH /api/notifications/:id/read — mark as read
|
|
155
|
+
- GET /api/preferences/notifications — get preferences
|
|
156
|
+
- PUT /api/preferences/notifications — update preferences
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## Step 6: Implementation Plan
|
|
162
|
+
|
|
163
|
+
```markdown
|
|
164
|
+
# Implementation Plan
|
|
165
|
+
|
|
166
|
+
## Tasks
|
|
167
|
+
|
|
168
|
+
TASK-1: Create Notification model + migration
|
|
169
|
+
Files: models/notification.ts, migrations/add-notifications.ts
|
|
170
|
+
Depends: none
|
|
171
|
+
Test: Migration runs, model validates
|
|
172
|
+
|
|
173
|
+
TASK-2: Create NotificationPreference model + migration
|
|
174
|
+
Files: models/notification-preference.ts, migrations/add-notification-prefs.ts
|
|
175
|
+
Depends: none
|
|
176
|
+
Test: Migration runs, defaults created for existing users
|
|
177
|
+
|
|
178
|
+
TASK-3: Create NotificationService
|
|
179
|
+
Files: services/notification.service.ts
|
|
180
|
+
Depends: TASK-1, TASK-2
|
|
181
|
+
Test: Unit tests for create/read/mark-read/filter-by-prefs
|
|
182
|
+
|
|
183
|
+
TASK-4: Create notification workers
|
|
184
|
+
Files: workers/email-notification.worker.ts, workers/in-app-notification.worker.ts
|
|
185
|
+
Depends: TASK-3
|
|
186
|
+
Test: Worker processes event, creates notification, sends email mock
|
|
187
|
+
|
|
188
|
+
TASK-5: Add event publishing to OrderService
|
|
189
|
+
Files: services/order.service.ts (modify)
|
|
190
|
+
Depends: TASK-4
|
|
191
|
+
Test: Order status change publishes notification event
|
|
192
|
+
|
|
193
|
+
TASK-6: Create API endpoints
|
|
194
|
+
Files: controllers/notification.controller.ts, controllers/preferences.controller.ts
|
|
195
|
+
Depends: TASK-3
|
|
196
|
+
Test: API returns notifications, updates preferences
|
|
197
|
+
|
|
198
|
+
TASK-7: Write integration tests
|
|
199
|
+
Files: tests/notifications.integration.test.ts
|
|
200
|
+
Depends: TASK-4, TASK-5, TASK-6
|
|
201
|
+
Test: Full flow: order change → event → worker → notification visible via API
|
|
202
|
+
|
|
203
|
+
## Parallel Groups
|
|
204
|
+
Group 1: TASK-1, TASK-2 (parallel)
|
|
205
|
+
Group 2: TASK-3 (after Group 1)
|
|
206
|
+
Group 3: TASK-4, TASK-5, TASK-6 (parallel, after Group 2)
|
|
207
|
+
Group 4: TASK-7 (after Group 3)
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## Step 8: QE Report
|
|
213
|
+
|
|
214
|
+
```markdown
|
|
215
|
+
# QE Report: User Notifications
|
|
216
|
+
|
|
217
|
+
## Summary
|
|
218
|
+
- Tests: 14/14 (100%)
|
|
219
|
+
- Review findings: 0 🔴, 2 🟡, 1 🔵
|
|
220
|
+
- Requirements: 3/3 MUST passed, 1/1 SHOULD passed
|
|
221
|
+
|
|
222
|
+
## Review Findings
|
|
223
|
+
🟡 WARNING: NotificationService.create() doesn't validate notification type enum
|
|
224
|
+
🟡 WARNING: Email template uses inline styles instead of project's template engine
|
|
225
|
+
🔵 SUGGESTION: Consider adding index on notifications.user_id + created_at
|
|
226
|
+
|
|
227
|
+
## Acceptance Criteria
|
|
228
|
+
| Req | Status | Evidence |
|
|
229
|
+
|-----|--------|----------|
|
|
230
|
+
| FR-1 | ✅ PASS | Integration test: order_status_email_notification |
|
|
231
|
+
| FR-2 | ✅ PASS | Integration test: in_app_notification_created |
|
|
232
|
+
| FR-3 | ✅ PASS | Unit test: filters_by_user_preferences |
|
|
233
|
+
| FR-4 | ✅ PASS | API test: paginated_notification_history |
|
|
234
|
+
|
|
235
|
+
## Verdict
|
|
236
|
+
⚠️ CONDITIONAL APPROVAL — fix 2 warnings before merge
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## Final Directory Structure
|
|
242
|
+
|
|
243
|
+
```
|
|
244
|
+
features/add-user-notifications/
|
|
245
|
+
├── 00_complexity_assessment.md
|
|
246
|
+
├── 01_requirements.md
|
|
247
|
+
├── 03_adr/
|
|
248
|
+
│ └── 001-notification-delivery-strategy.md
|
|
249
|
+
├── 05_architecture.md
|
|
250
|
+
├── 06_implementation_plan.md
|
|
251
|
+
├── 07_code_changes/
|
|
252
|
+
│ └── change_manifest.md
|
|
253
|
+
├── 08_qe_report.md
|
|
254
|
+
├── diagrams/
|
|
255
|
+
│ └── architecture-c4.mermaid
|
|
256
|
+
└── README.md
|
|
257
|
+
```
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Step 0: Complexity Router
|
|
2
|
+
|
|
3
|
+
> Classify the feature into S/M/L/XL tier and determine which pipeline steps to activate.
|
|
4
|
+
|
|
5
|
+
## When
|
|
6
|
+
|
|
7
|
+
Always runs first. Takes ~30 seconds. Uses haiku model.
|
|
8
|
+
|
|
9
|
+
## Input
|
|
10
|
+
|
|
11
|
+
- Feature description (from user or issue)
|
|
12
|
+
- Current codebase context (project structure, tech stack)
|
|
13
|
+
|
|
14
|
+
## Protocol
|
|
15
|
+
|
|
16
|
+
### 1. Analyze Feature Scope
|
|
17
|
+
|
|
18
|
+
Evaluate the feature against 6 dimensions:
|
|
19
|
+
|
|
20
|
+
| Dimension | S (1pt) | M (2pt) | L (3pt) | XL (4pt) |
|
|
21
|
+
|-----------|---------|---------|---------|----------|
|
|
22
|
+
| **Files affected** | 1-3 | 4-10 | 11-30 | 30+ |
|
|
23
|
+
| **Domains touched** | 1 | 1-2 | 2-4 | 4+ |
|
|
24
|
+
| **New integrations** | 0 | 0-1 | 1-3 | 3+ |
|
|
25
|
+
| **Breaking changes** | 0 | 0 | 0-2 | 2+ |
|
|
26
|
+
| **New data models** | 0 | 0-1 | 1-3 | 3+ |
|
|
27
|
+
| **Cross-cutting concerns** | 0 | 0-1 | 1-2 | 3+ |
|
|
28
|
+
|
|
29
|
+
Cross-cutting concerns: auth, logging, caching, i18n, error handling, etc.
|
|
30
|
+
|
|
31
|
+
### 2. Score and Classify
|
|
32
|
+
|
|
33
|
+
Sum all dimension scores:
|
|
34
|
+
|
|
35
|
+
| Total Score | Tier | Label |
|
|
36
|
+
|-------------|------|-------|
|
|
37
|
+
| 6-8 | **S** | Small — localized change |
|
|
38
|
+
| 9-13 | **M** | Medium — bounded feature |
|
|
39
|
+
| 14-19 | **L** | Large — multi-domain feature |
|
|
40
|
+
| 20-24 | **XL** | Extra Large — cross-cutting system change |
|
|
41
|
+
|
|
42
|
+
### 3. Override Rules
|
|
43
|
+
|
|
44
|
+
The router may override the score-based classification:
|
|
45
|
+
|
|
46
|
+
- If **any single dimension = XL (4pt)** → minimum tier is L
|
|
47
|
+
- If **breaking changes > 0** → minimum tier is M
|
|
48
|
+
- If user explicitly requests a tier → use that tier
|
|
49
|
+
- If feature description mentions "refactor", "migration", "redesign" → bias toward L/XL
|
|
50
|
+
|
|
51
|
+
### 4. Determine Active Steps
|
|
52
|
+
|
|
53
|
+
Load `references/complexity-matrix.md` for the full matrix. Summary:
|
|
54
|
+
|
|
55
|
+
| Step | S | M | L | XL |
|
|
56
|
+
|------|---|---|---|-----|
|
|
57
|
+
| 0 Complexity Router | ✓ | ✓ | ✓ | ✓ |
|
|
58
|
+
| 1 Requirements | ✓ light | ✓ | ✓ | ✓ |
|
|
59
|
+
| 2 Research | - | - | ✓ | ✓ |
|
|
60
|
+
| 3 ADR | - | ✓ (1 ADR) | ✓ (N ADRs) | ✓ (N ADRs) |
|
|
61
|
+
| 4 DDD | - | - | ✓ | ✓ |
|
|
62
|
+
| 5 Architecture | - | ✓ light | ✓ | ✓ |
|
|
63
|
+
| 6 Implementation Plan | ✓ inline | ✓ | ✓ | ✓ |
|
|
64
|
+
| 7 Code | ✓ | ✓ | ✓ | ✓ |
|
|
65
|
+
| 8 QE | ✓ smoke | ✓ | ✓ | ✓ full |
|
|
66
|
+
|
|
67
|
+
### 5. Calculate Time Budget
|
|
68
|
+
|
|
69
|
+
| Tier | Total Budget | Distribution |
|
|
70
|
+
|------|-------------|--------------|
|
|
71
|
+
| S | 15 min | R:2 P:0 I:10 Q:3 |
|
|
72
|
+
| M | 45 min | R:5 P:10 I:20 Q:10 |
|
|
73
|
+
| L | 2 hours | R:15 P:30 I:45 Q:30 |
|
|
74
|
+
| XL | 4+ hours | R:30 P:60 I:90 Q:60 |
|
|
75
|
+
|
|
76
|
+
R = Requirements, P = Planning (ADR+DDD+Arch), I = Implementation, Q = QE
|
|
77
|
+
|
|
78
|
+
## Output
|
|
79
|
+
|
|
80
|
+
Set the following variables:
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
{COMPLEXITY_TIER} = S | M | L | XL
|
|
84
|
+
{ACTIVE_STEPS} = [0, 1, 6, 7, 8] # example for S
|
|
85
|
+
{TIME_BUDGET} = { requirements: 2, planning: 0, implementation: 10, qe: 3 }
|
|
86
|
+
{DIMENSION_SCORES} = { files: 1, domains: 1, integrations: 1, breaking: 1, models: 1, crosscutting: 1 }
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Create artifact: `features/<slug>/00_complexity_assessment.md`
|
|
90
|
+
|
|
91
|
+
## Checkpoint 0 Format
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
═══════════════════════════════════════════════════════
|
|
95
|
+
⏸️ STEP 0/8: Complexity Router Complete
|
|
96
|
+
<promise>FEATURE_ADR_ROUTED</promise>
|
|
97
|
+
Tier: {COMPLEXITY_TIER} | Active Steps: {ACTIVE_STEPS}
|
|
98
|
+
|
|
99
|
+
Feature classified as {TIER} based on: {top 2-3 scoring dimensions}
|
|
100
|
+
Pipeline: {ACTIVE_STEPS count} steps, estimated {TIME_BUDGET total}
|
|
101
|
+
|
|
102
|
+
• "ок" — proceed with this tier
|
|
103
|
+
• "повысь" — bump to next tier
|
|
104
|
+
• "понизь" — drop to lower tier
|
|
105
|
+
═══════════════════════════════════════════════════════
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Quality Gates
|
|
109
|
+
|
|
110
|
+
- [ ] All 6 dimensions evaluated with explicit reasoning
|
|
111
|
+
- [ ] Override rules checked
|
|
112
|
+
- [ ] Active steps list matches tier definition
|
|
113
|
+
- [ ] Time budget calculated
|
|
114
|
+
- [ ] User confirmed tier before proceeding
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Step 1: Requirements Gathering
|
|
2
|
+
|
|
3
|
+
> Transform vague feature description into structured, actionable requirements.
|
|
4
|
+
|
|
5
|
+
## When
|
|
6
|
+
|
|
7
|
+
Always runs. Adapts depth by tier:
|
|
8
|
+
- **S:** 3-5 bullet points, inline (no file)
|
|
9
|
+
- **M/L/XL:** Full structured document
|
|
10
|
+
|
|
11
|
+
## Model
|
|
12
|
+
|
|
13
|
+
sonnet (analytical work, not creative)
|
|
14
|
+
|
|
15
|
+
## Input
|
|
16
|
+
|
|
17
|
+
- Feature description from user
|
|
18
|
+
- `{COMPLEXITY_TIER}` from Step 0
|
|
19
|
+
- Codebase context (project structure, existing patterns)
|
|
20
|
+
|
|
21
|
+
## Protocol
|
|
22
|
+
|
|
23
|
+
### 1. Load Explore Skill (M/L/XL only)
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
Read: .claude/skills/explore/SKILL.md
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Use the explore skill to clarify ambiguous requirements through adaptive questioning.
|
|
30
|
+
For S-tier: skip explore, extract requirements directly from description.
|
|
31
|
+
|
|
32
|
+
### 2. Identify Stakeholders
|
|
33
|
+
|
|
34
|
+
| Question | Why |
|
|
35
|
+
|----------|-----|
|
|
36
|
+
| Who is the end user? | Drives UX decisions |
|
|
37
|
+
| Who is the developer consumer? | Drives API design |
|
|
38
|
+
| Who approves delivery? | Defines done criteria |
|
|
39
|
+
|
|
40
|
+
### 3. Extract Functional Requirements
|
|
41
|
+
|
|
42
|
+
For each requirement:
|
|
43
|
+
```
|
|
44
|
+
FR-{N}: {Description}
|
|
45
|
+
Priority: MUST | SHOULD | COULD
|
|
46
|
+
Acceptance Criteria:
|
|
47
|
+
- Given [context], When [action], Then [outcome]
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 4. Extract Non-Functional Requirements (M+ only)
|
|
51
|
+
|
|
52
|
+
| Category | Questions |
|
|
53
|
+
|----------|-----------|
|
|
54
|
+
| Performance | Latency targets? Throughput? |
|
|
55
|
+
| Security | Auth? Data sensitivity? |
|
|
56
|
+
| Scalability | Expected load? Growth? |
|
|
57
|
+
| Compatibility | Browser/OS/API versions? |
|
|
58
|
+
| Accessibility | WCAG level? |
|
|
59
|
+
|
|
60
|
+
### 5. Identify Constraints
|
|
61
|
+
|
|
62
|
+
- Technical: language, framework, existing patterns to follow
|
|
63
|
+
- Business: timeline, budget, compliance
|
|
64
|
+
- Organizational: team capabilities, review process
|
|
65
|
+
|
|
66
|
+
### 6. Define Scope Boundaries
|
|
67
|
+
|
|
68
|
+
Explicitly state:
|
|
69
|
+
- **In scope:** What this feature DOES
|
|
70
|
+
- **Out of scope:** What this feature does NOT do (but someone might assume)
|
|
71
|
+
- **Dependencies:** What must exist before this feature works
|
|
72
|
+
- **Dependents:** What will break if this feature changes
|
|
73
|
+
|
|
74
|
+
## Output
|
|
75
|
+
|
|
76
|
+
### For S-tier (inline)
|
|
77
|
+
Set `{REQUIREMENTS}` variable with 3-5 bullets. No file created.
|
|
78
|
+
|
|
79
|
+
### For M/L/XL
|
|
80
|
+
Create `features/<slug>/01_requirements.md` with:
|
|
81
|
+
- Stakeholders
|
|
82
|
+
- Functional requirements (FR-1..N) with acceptance criteria
|
|
83
|
+
- Non-functional requirements (L/XL)
|
|
84
|
+
- Constraints
|
|
85
|
+
- Scope boundaries
|
|
86
|
+
- Open questions (if any remain)
|
|
87
|
+
|
|
88
|
+
Set `{REQUIREMENTS}` variable with structured data.
|
|
89
|
+
|
|
90
|
+
## Checkpoint 1 Format
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
═══════════════════════════════════════════════════════
|
|
94
|
+
⏸️ STEP 1/8: Requirements Complete
|
|
95
|
+
<promise>FEATURE_ADR_REQUIREMENTS_GATHERED</promise>
|
|
96
|
+
Tier: {COMPLEXITY_TIER}
|
|
97
|
+
|
|
98
|
+
{N} functional requirements identified
|
|
99
|
+
{M} constraints, {K} open questions
|
|
100
|
+
|
|
101
|
+
• "ок" — proceed
|
|
102
|
+
• "добавь [requirement]" — add more
|
|
103
|
+
• "убери [requirement]" — remove
|
|
104
|
+
═══════════════════════════════════════════════════════
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Quality Gates
|
|
108
|
+
|
|
109
|
+
- [ ] All requirements have acceptance criteria (M+)
|
|
110
|
+
- [ ] Scope boundaries explicitly defined
|
|
111
|
+
- [ ] No ambiguous terms ("fast", "good", "flexible") without quantification
|
|
112
|
+
- [ ] Dependencies identified
|
|
113
|
+
- [ ] User confirmed requirements before proceeding
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Step 2: Research — Analogues & Patterns
|
|
2
|
+
|
|
3
|
+
> Research existing patterns in codebase and external best practices before designing.
|
|
4
|
+
|
|
5
|
+
## When
|
|
6
|
+
|
|
7
|
+
L/XL tiers only. Can run **in parallel** with Step 3 (ADR).
|
|
8
|
+
|
|
9
|
+
## Model
|
|
10
|
+
|
|
11
|
+
sonnet (research synthesis)
|
|
12
|
+
|
|
13
|
+
## Input
|
|
14
|
+
|
|
15
|
+
- `{REQUIREMENTS}` from Step 1
|
|
16
|
+
- `{COMPLEXITY_TIER}` from Step 0
|
|
17
|
+
- Codebase access
|
|
18
|
+
|
|
19
|
+
## Protocol
|
|
20
|
+
|
|
21
|
+
### 1. Codebase Pattern Research (Agent 1 — sonnet)
|
|
22
|
+
|
|
23
|
+
Search the current codebase for:
|
|
24
|
+
|
|
25
|
+
| What | How |
|
|
26
|
+
|------|-----|
|
|
27
|
+
| Similar features | Grep for related domain terms, find analogous implementations |
|
|
28
|
+
| Established patterns | How does existing code handle similar problems? |
|
|
29
|
+
| Shared utilities | What existing helpers, services, or abstractions can be reused? |
|
|
30
|
+
| Test patterns | How are similar features tested? |
|
|
31
|
+
| Data access patterns | How do similar features access data? |
|
|
32
|
+
|
|
33
|
+
Document each finding with file path + line reference.
|
|
34
|
+
|
|
35
|
+
### 2. External Pattern Research (Agent 2 — sonnet)
|
|
36
|
+
|
|
37
|
+
Research external analogues:
|
|
38
|
+
|
|
39
|
+
| What | How |
|
|
40
|
+
|------|-----|
|
|
41
|
+
| Industry patterns | How do similar products solve this? |
|
|
42
|
+
| Framework conventions | What does the framework recommend? |
|
|
43
|
+
| Library options | Are there well-maintained libraries for this? |
|
|
44
|
+
| Anti-patterns | What are known pitfalls to avoid? |
|
|
45
|
+
|
|
46
|
+
Use `goap-research-ed25519` for verified research if the feature involves:
|
|
47
|
+
- Security-sensitive decisions
|
|
48
|
+
- Compliance requirements
|
|
49
|
+
- Performance-critical paths
|
|
50
|
+
|
|
51
|
+
### 3. Synthesize Findings
|
|
52
|
+
|
|
53
|
+
Combine both research streams into:
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
## Pattern Summary
|
|
57
|
+
1. Codebase has [N] similar implementations using [pattern]
|
|
58
|
+
2. Framework recommends [approach] for this type of feature
|
|
59
|
+
3. Key libraries considered: [list with trade-offs]
|
|
60
|
+
4. Anti-patterns to avoid: [list]
|
|
61
|
+
|
|
62
|
+
## Recommendation
|
|
63
|
+
Based on research, the recommended approach is [X] because [reasons].
|
|
64
|
+
Alternative considered: [Y], rejected because [reasons].
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Agent Swarm (2 parallel, sonnet)
|
|
68
|
+
|
|
69
|
+
| Agent | Task | Model |
|
|
70
|
+
|-------|------|-------|
|
|
71
|
+
| Agent 1 | Codebase pattern research | sonnet |
|
|
72
|
+
| Agent 2 | External analogues research | sonnet |
|
|
73
|
+
|
|
74
|
+
After both complete, synthesize results sequentially.
|
|
75
|
+
|
|
76
|
+
## Output
|
|
77
|
+
|
|
78
|
+
Create `features/<slug>/02_research.md` with:
|
|
79
|
+
- Codebase patterns found (with file references)
|
|
80
|
+
- External patterns researched
|
|
81
|
+
- Library evaluation (if applicable)
|
|
82
|
+
- Anti-patterns identified
|
|
83
|
+
- Recommended approach
|
|
84
|
+
|
|
85
|
+
Set `{RESEARCH_FINDINGS}` variable.
|
|
86
|
+
|
|
87
|
+
## Quality Gates
|
|
88
|
+
|
|
89
|
+
- [ ] At least 3 codebase patterns examined
|
|
90
|
+
- [ ] External patterns verified (not hallucinated)
|
|
91
|
+
- [ ] Trade-offs documented for each alternative
|
|
92
|
+
- [ ] Clear recommendation with rationale
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Step 3: Architecture Decision Records
|
|
2
|
+
|
|
3
|
+
> Document each significant architectural decision with context, alternatives, and rationale.
|
|
4
|
+
|
|
5
|
+
## When
|
|
6
|
+
|
|
7
|
+
M+ tiers. Depth varies:
|
|
8
|
+
- **M:** 1 ADR for the main decision
|
|
9
|
+
- **L/XL:** N ADRs for each significant decision
|
|
10
|
+
|
|
11
|
+
Can run **in parallel** with Step 2 (Research) for L/XL tiers.
|
|
12
|
+
|
|
13
|
+
## Model
|
|
14
|
+
|
|
15
|
+
opus (complex reasoning for trade-off analysis)
|
|
16
|
+
|
|
17
|
+
## Input
|
|
18
|
+
|
|
19
|
+
- `{REQUIREMENTS}` from Step 1
|
|
20
|
+
- `{RESEARCH_FINDINGS}` from Step 2 (if available — may arrive later in parallel)
|
|
21
|
+
- Codebase context
|
|
22
|
+
|
|
23
|
+
## Protocol
|
|
24
|
+
|
|
25
|
+
### 1. Identify Decisions
|
|
26
|
+
|
|
27
|
+
Scan requirements for decision points:
|
|
28
|
+
|
|
29
|
+
| Signal | Example |
|
|
30
|
+
|--------|---------|
|
|
31
|
+
| Technology choice | "Which database/queue/framework?" |
|
|
32
|
+
| Pattern choice | "Repository vs. Active Record?" |
|
|
33
|
+
| Integration strategy | "REST vs. GraphQL vs. gRPC?" |
|
|
34
|
+
| Data modeling | "Normalized vs. denormalized?" |
|
|
35
|
+
| Deployment strategy | "Monolith vs. microservice?" |
|
|
36
|
+
| Trade-off | "Consistency vs. availability?" |
|
|
37
|
+
|
|
38
|
+
For M-tier: pick the SINGLE most impactful decision.
|
|
39
|
+
For L/XL: identify ALL decisions, prioritize by impact.
|
|
40
|
+
|
|
41
|
+
### 2. Draft ADR per Decision
|
|
42
|
+
|
|
43
|
+
Use template from `references/adr-template.md`:
|
|
44
|
+
|
|
45
|
+
```markdown
|
|
46
|
+
# ADR-{NNN}: {Title}
|
|
47
|
+
|
|
48
|
+
## Status
|
|
49
|
+
Proposed | Accepted | Superseded by ADR-{M}
|
|
50
|
+
|
|
51
|
+
## Context
|
|
52
|
+
What is the issue that we're seeing that is motivating this decision?
|
|
53
|
+
|
|
54
|
+
## Decision Drivers
|
|
55
|
+
- {driver 1}
|
|
56
|
+
- {driver 2}
|
|
57
|
+
|
|
58
|
+
## Considered Options
|
|
59
|
+
1. {Option A} — {1-line summary}
|
|
60
|
+
2. {Option B} — {1-line summary}
|
|
61
|
+
3. {Option C} — {1-line summary}
|
|
62
|
+
|
|
63
|
+
## Decision
|
|
64
|
+
We chose **{Option X}** because...
|
|
65
|
+
|
|
66
|
+
## Consequences
|
|
67
|
+
### Positive
|
|
68
|
+
- ...
|
|
69
|
+
### Negative
|
|
70
|
+
- ...
|
|
71
|
+
### Risks
|
|
72
|
+
- ...
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 3. Evaluate Alternatives
|
|
76
|
+
|
|
77
|
+
For each ADR, evaluate alternatives using a decision matrix:
|
|
78
|
+
|
|
79
|
+
| Criterion | Weight | Option A | Option B | Option C |
|
|
80
|
+
|-----------|--------|----------|----------|----------|
|
|
81
|
+
| Simplicity | 3 | ⭐⭐⭐ | ⭐⭐ | ⭐ |
|
|
82
|
+
| Performance | 2 | ⭐⭐ | ⭐⭐⭐ | ⭐⭐ |
|
|
83
|
+
| Maintainability | 3 | ⭐⭐ | ⭐⭐ | ⭐⭐⭐ |
|
|
84
|
+
| Team familiarity | 2 | ⭐⭐⭐ | ⭐ | ⭐⭐ |
|
|
85
|
+
|
|
86
|
+
If decision involves complex trade-offs, load `problem-solver-enhanced` for TRIZ analysis.
|
|
87
|
+
|
|
88
|
+
### 4. Validate Against Requirements
|
|
89
|
+
|
|
90
|
+
Each ADR must trace back to specific requirements:
|
|
91
|
+
- Which FR-{N} does this decision support?
|
|
92
|
+
- Does the decision satisfy all relevant NFRs?
|
|
93
|
+
- Does the decision respect constraints?
|
|
94
|
+
|
|
95
|
+
## Anti-Patterns
|
|
96
|
+
|
|
97
|
+
| Anti-Pattern | Detection | Fix |
|
|
98
|
+
|-------------|-----------|-----|
|
|
99
|
+
| Only one alternative | Less than 2 options considered | Require ≥2 alternatives |
|
|
100
|
+
| No consequences | Missing positive/negative analysis | BLOCK until filled |
|
|
101
|
+
| Decision without context | Why is unclear | Add context section |
|
|
102
|
+
| Premature optimization | Choosing complex option for hypothetical scale | Prefer simpler option |
|
|
103
|
+
|
|
104
|
+
## Output
|
|
105
|
+
|
|
106
|
+
Create `features/<slug>/03_adr/` directory with:
|
|
107
|
+
- `001-{decision-slug}.md` for each ADR
|
|
108
|
+
- Each ADR follows the template
|
|
109
|
+
|
|
110
|
+
Set `{ADR_DECISIONS}` variable with list of decisions.
|
|
111
|
+
|
|
112
|
+
## Checkpoint Format
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
═══════════════════════════════════════════════════════
|
|
116
|
+
⏸️ STEP 3/8: ADR Complete
|
|
117
|
+
Tier: {COMPLEXITY_TIER}
|
|
118
|
+
|
|
119
|
+
{N} architectural decisions documented:
|
|
120
|
+
1. ADR-001: {title} → chose {option}
|
|
121
|
+
2. ADR-002: {title} → chose {option}
|
|
122
|
+
|
|
123
|
+
• "ок" — proceed
|
|
124
|
+
• "пересмотри ADR-{N}" — reconsider decision
|
|
125
|
+
• "добавь ADR для [topic]" — add new decision
|
|
126
|
+
═══════════════════════════════════════════════════════
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Quality Gates
|
|
130
|
+
|
|
131
|
+
- [ ] Every ADR has ≥2 alternatives considered
|
|
132
|
+
- [ ] Every ADR has consequences (positive + negative)
|
|
133
|
+
- [ ] Every ADR traces to requirements
|
|
134
|
+
- [ ] Decision matrix used for non-trivial choices
|
|
135
|
+
- [ ] No premature optimization detected
|