agileflow 2.77.0 → 2.78.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.
Files changed (113) hide show
  1. package/README.md +3 -3
  2. package/package.json +6 -1
  3. package/scripts/agileflow-configure.js +174 -2
  4. package/scripts/agileflow-statusline.sh +171 -78
  5. package/scripts/agileflow-welcome.js +79 -2
  6. package/scripts/damage-control-bash.js +232 -0
  7. package/scripts/damage-control-edit.js +243 -0
  8. package/scripts/damage-control-write.js +243 -0
  9. package/src/core/agents/accessibility.md +124 -53
  10. package/src/core/agents/adr-writer.md +192 -52
  11. package/src/core/agents/analytics.md +139 -60
  12. package/src/core/agents/api.md +173 -63
  13. package/src/core/agents/ci.md +139 -57
  14. package/src/core/agents/compliance.md +159 -68
  15. package/src/core/agents/configuration/damage-control.md +356 -0
  16. package/src/core/agents/database.md +162 -61
  17. package/src/core/agents/datamigration.md +179 -66
  18. package/src/core/agents/design.md +179 -57
  19. package/src/core/agents/devops.md +160 -3
  20. package/src/core/agents/documentation.md +204 -60
  21. package/src/core/agents/epic-planner.md +147 -55
  22. package/src/core/agents/integrations.md +197 -69
  23. package/src/core/agents/mentor.md +158 -57
  24. package/src/core/agents/mobile.md +159 -67
  25. package/src/core/agents/monitoring.md +154 -65
  26. package/src/core/agents/multi-expert.md +115 -43
  27. package/src/core/agents/orchestrator.md +77 -24
  28. package/src/core/agents/performance.md +130 -75
  29. package/src/core/agents/product.md +151 -55
  30. package/src/core/agents/qa.md +162 -74
  31. package/src/core/agents/readme-updater.md +178 -76
  32. package/src/core/agents/refactor.md +148 -95
  33. package/src/core/agents/research.md +143 -72
  34. package/src/core/agents/security.md +154 -65
  35. package/src/core/agents/testing.md +176 -97
  36. package/src/core/agents/ui.md +170 -79
  37. package/src/core/commands/adr/list.md +171 -0
  38. package/src/core/commands/adr/update.md +235 -0
  39. package/src/core/commands/adr/view.md +252 -0
  40. package/src/core/commands/adr.md +207 -50
  41. package/src/core/commands/agent.md +16 -0
  42. package/src/core/commands/assign.md +148 -44
  43. package/src/core/commands/auto.md +18 -1
  44. package/src/core/commands/babysit.md +361 -36
  45. package/src/core/commands/baseline.md +14 -0
  46. package/src/core/commands/blockers.md +170 -51
  47. package/src/core/commands/board.md +144 -66
  48. package/src/core/commands/changelog.md +15 -0
  49. package/src/core/commands/ci.md +179 -69
  50. package/src/core/commands/compress.md +18 -0
  51. package/src/core/commands/configure.md +16 -0
  52. package/src/core/commands/context/export.md +193 -4
  53. package/src/core/commands/context/full.md +191 -18
  54. package/src/core/commands/context/note.md +248 -4
  55. package/src/core/commands/debt.md +17 -0
  56. package/src/core/commands/deploy.md +208 -65
  57. package/src/core/commands/deps.md +15 -0
  58. package/src/core/commands/diagnose.md +16 -0
  59. package/src/core/commands/docs.md +196 -64
  60. package/src/core/commands/epic/list.md +170 -0
  61. package/src/core/commands/epic/view.md +242 -0
  62. package/src/core/commands/epic.md +192 -69
  63. package/src/core/commands/feedback.md +191 -71
  64. package/src/core/commands/handoff.md +162 -48
  65. package/src/core/commands/help.md +9 -0
  66. package/src/core/commands/ideate.md +446 -0
  67. package/src/core/commands/impact.md +16 -0
  68. package/src/core/commands/metrics.md +141 -37
  69. package/src/core/commands/multi-expert.md +77 -0
  70. package/src/core/commands/packages.md +16 -0
  71. package/src/core/commands/pr.md +161 -67
  72. package/src/core/commands/readme-sync.md +16 -0
  73. package/src/core/commands/research/analyze.md +568 -0
  74. package/src/core/commands/research/ask.md +345 -20
  75. package/src/core/commands/research/import.md +562 -19
  76. package/src/core/commands/research/list.md +173 -5
  77. package/src/core/commands/research/view.md +181 -8
  78. package/src/core/commands/retro.md +135 -48
  79. package/src/core/commands/review.md +219 -47
  80. package/src/core/commands/session/end.md +209 -0
  81. package/src/core/commands/session/history.md +210 -0
  82. package/src/core/commands/session/init.md +116 -0
  83. package/src/core/commands/session/new.md +296 -0
  84. package/src/core/commands/session/resume.md +166 -0
  85. package/src/core/commands/session/status.md +166 -0
  86. package/src/core/commands/skill/create.md +115 -17
  87. package/src/core/commands/skill/delete.md +117 -0
  88. package/src/core/commands/skill/edit.md +104 -0
  89. package/src/core/commands/skill/list.md +128 -0
  90. package/src/core/commands/skill/test.md +135 -0
  91. package/src/core/commands/skill/upgrade.md +542 -0
  92. package/src/core/commands/sprint.md +17 -1
  93. package/src/core/commands/status.md +133 -21
  94. package/src/core/commands/story/list.md +176 -0
  95. package/src/core/commands/story/view.md +265 -0
  96. package/src/core/commands/story-validate.md +101 -1
  97. package/src/core/commands/story.md +204 -51
  98. package/src/core/commands/template.md +16 -1
  99. package/src/core/commands/tests.md +226 -64
  100. package/src/core/commands/update.md +17 -1
  101. package/src/core/commands/validate-expertise.md +16 -0
  102. package/src/core/commands/velocity.md +140 -36
  103. package/src/core/commands/verify.md +14 -0
  104. package/src/core/commands/whats-new.md +30 -0
  105. package/src/core/skills/_learnings/README.md +91 -0
  106. package/src/core/skills/_learnings/_template.yaml +106 -0
  107. package/src/core/skills/_learnings/commit.yaml +69 -0
  108. package/src/core/templates/damage-control-patterns.yaml +234 -0
  109. package/src/core/templates/skill-template.md +53 -11
  110. package/tools/cli/commands/start.js +180 -0
  111. package/tools/cli/tui/Dashboard.js +66 -0
  112. package/tools/cli/tui/StoryList.js +69 -0
  113. package/tools/cli/tui/index.js +16 -0
@@ -0,0 +1,243 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * damage-control-write.js - PreToolUse hook for Write tool
4
+ *
5
+ * Validates file paths against access control patterns in damage-control-patterns.yaml
6
+ * before allowing file writes. Part of AgileFlow's damage control system.
7
+ *
8
+ * Exit codes:
9
+ * 0 - Allow operation
10
+ * 2 - Block operation
11
+ *
12
+ * Usage: Configured as PreToolUse hook in .claude/settings.json
13
+ */
14
+
15
+ const fs = require('fs');
16
+ const path = require('path');
17
+ const os = require('os');
18
+
19
+ // Color codes for output
20
+ const c = {
21
+ red: '\x1b[38;5;203m',
22
+ reset: '\x1b[0m',
23
+ dim: '\x1b[2m'
24
+ };
25
+
26
+ /**
27
+ * Find project root by looking for .agileflow directory
28
+ */
29
+ function findProjectRoot() {
30
+ let dir = process.cwd();
31
+ while (dir !== '/') {
32
+ if (fs.existsSync(path.join(dir, '.agileflow'))) {
33
+ return dir;
34
+ }
35
+ dir = path.dirname(dir);
36
+ }
37
+ return process.cwd();
38
+ }
39
+
40
+ /**
41
+ * Expand ~ to home directory
42
+ */
43
+ function expandPath(p) {
44
+ if (p.startsWith('~/')) {
45
+ return path.join(os.homedir(), p.slice(2));
46
+ }
47
+ return p;
48
+ }
49
+
50
+ /**
51
+ * Parse simplified YAML for path patterns
52
+ */
53
+ function parseSimpleYAML(content) {
54
+ const config = {
55
+ zeroAccessPaths: [],
56
+ readOnlyPaths: [],
57
+ noDeletePaths: []
58
+ };
59
+
60
+ let currentSection = null;
61
+
62
+ for (const line of content.split('\n')) {
63
+ const trimmed = line.trim();
64
+
65
+ // Skip empty lines and comments
66
+ if (!trimmed || trimmed.startsWith('#')) continue;
67
+
68
+ // Detect section headers
69
+ if (trimmed === 'zeroAccessPaths:') {
70
+ currentSection = 'zeroAccessPaths';
71
+ } else if (trimmed === 'readOnlyPaths:') {
72
+ currentSection = 'readOnlyPaths';
73
+ } else if (trimmed === 'noDeletePaths:') {
74
+ currentSection = 'noDeletePaths';
75
+ } else if (trimmed.endsWith(':') && !trimmed.startsWith('-')) {
76
+ // Other sections we don't care about for path validation
77
+ currentSection = null;
78
+ } else if (trimmed.startsWith('- ') && currentSection && config[currentSection]) {
79
+ // Path entry
80
+ const pathValue = trimmed.slice(2).replace(/^["']|["']$/g, '');
81
+ config[currentSection].push(pathValue);
82
+ }
83
+ }
84
+
85
+ return config;
86
+ }
87
+
88
+ /**
89
+ * Load patterns configuration from YAML file
90
+ */
91
+ function loadPatterns(projectRoot) {
92
+ const configPaths = [
93
+ path.join(projectRoot, '.agileflow/config/damage-control-patterns.yaml'),
94
+ path.join(projectRoot, '.agileflow/config/damage-control-patterns.yml'),
95
+ path.join(projectRoot, '.agileflow/templates/damage-control-patterns.yaml')
96
+ ];
97
+
98
+ for (const configPath of configPaths) {
99
+ if (fs.existsSync(configPath)) {
100
+ try {
101
+ const content = fs.readFileSync(configPath, 'utf8');
102
+ return parseSimpleYAML(content);
103
+ } catch (e) {
104
+ // Continue to next path
105
+ }
106
+ }
107
+ }
108
+
109
+ // Return empty config if no file found (fail-open)
110
+ return { zeroAccessPaths: [], readOnlyPaths: [], noDeletePaths: [] };
111
+ }
112
+
113
+ /**
114
+ * Check if a file path matches any of the protected patterns
115
+ */
116
+ function pathMatches(filePath, patterns) {
117
+ if (!filePath) return null;
118
+
119
+ const normalizedPath = path.resolve(filePath);
120
+ const relativePath = path.relative(process.cwd(), normalizedPath);
121
+
122
+ for (const pattern of patterns) {
123
+ const expandedPattern = expandPath(pattern);
124
+
125
+ // Check if pattern is a directory prefix
126
+ if (pattern.endsWith('/')) {
127
+ const patternDir = expandedPattern.slice(0, -1);
128
+ if (normalizedPath.startsWith(patternDir)) {
129
+ return pattern;
130
+ }
131
+ }
132
+
133
+ // Check exact match
134
+ if (normalizedPath === expandedPattern) {
135
+ return pattern;
136
+ }
137
+
138
+ // Check if normalized path ends with pattern (for filenames like "id_rsa")
139
+ if (normalizedPath.endsWith(pattern) || relativePath.endsWith(pattern)) {
140
+ return pattern;
141
+ }
142
+
143
+ // Check if pattern appears in path (for patterns like "*.pem")
144
+ if (pattern.startsWith('*')) {
145
+ const ext = pattern.slice(1);
146
+ if (normalizedPath.endsWith(ext) || relativePath.endsWith(ext)) {
147
+ return pattern;
148
+ }
149
+ }
150
+
151
+ // Check if path contains pattern (for things like ".env.production")
152
+ const patternBase = path.basename(pattern);
153
+ if (path.basename(normalizedPath) === patternBase) {
154
+ return pattern;
155
+ }
156
+ }
157
+
158
+ return null;
159
+ }
160
+
161
+ /**
162
+ * Validate file path for write operation
163
+ */
164
+ function validatePath(filePath, config) {
165
+ // Check zero access paths - completely blocked
166
+ const zeroMatch = pathMatches(filePath, config.zeroAccessPaths || []);
167
+ if (zeroMatch) {
168
+ return {
169
+ action: 'block',
170
+ reason: `Zero-access path: ${zeroMatch}`,
171
+ detail: 'This file is protected and cannot be accessed'
172
+ };
173
+ }
174
+
175
+ // Check read-only paths - cannot write
176
+ const readOnlyMatch = pathMatches(filePath, config.readOnlyPaths || []);
177
+ if (readOnlyMatch) {
178
+ return {
179
+ action: 'block',
180
+ reason: `Read-only path: ${readOnlyMatch}`,
181
+ detail: 'This file is read-only and cannot be written to'
182
+ };
183
+ }
184
+
185
+ // Allow by default
186
+ return { action: 'allow' };
187
+ }
188
+
189
+ /**
190
+ * Main function - read input and validate
191
+ */
192
+ function main() {
193
+ const projectRoot = findProjectRoot();
194
+ let inputData = '';
195
+
196
+ process.stdin.setEncoding('utf8');
197
+
198
+ process.stdin.on('data', chunk => {
199
+ inputData += chunk;
200
+ });
201
+
202
+ process.stdin.on('end', () => {
203
+ try {
204
+ // Parse tool input from Claude Code
205
+ const input = JSON.parse(inputData);
206
+ const filePath = input.file_path || input.tool_input?.file_path || '';
207
+
208
+ if (!filePath) {
209
+ // No path to validate - allow
210
+ process.exit(0);
211
+ }
212
+
213
+ // Load patterns and validate
214
+ const config = loadPatterns(projectRoot);
215
+ const result = validatePath(filePath, config);
216
+
217
+ if (result.action === 'block') {
218
+ console.error(`${c.red}[BLOCKED]${c.reset} ${result.reason}`);
219
+ console.error(`${c.dim}${result.detail}${c.reset}`);
220
+ console.error(`${c.dim}File: ${filePath}${c.reset}`);
221
+ process.exit(2);
222
+ }
223
+
224
+ // Allow
225
+ process.exit(0);
226
+ } catch (e) {
227
+ // Parse error or other issue - fail open
228
+ process.exit(0);
229
+ }
230
+ });
231
+
232
+ // Handle no stdin
233
+ process.stdin.on('error', () => {
234
+ process.exit(0);
235
+ });
236
+
237
+ // Set timeout to prevent hanging
238
+ setTimeout(() => {
239
+ process.exit(0);
240
+ }, 4000);
241
+ }
242
+
243
+ main();
@@ -3,6 +3,16 @@ name: agileflow-accessibility
3
3
  description: Accessibility specialist for WCAG compliance, inclusive design, assistive technology support, and accessibility testing.
4
4
  tools: Read, Write, Edit, Bash, Glob, Grep
5
5
  model: haiku
6
+ compact_context:
7
+ priority: high
8
+ preserve_rules:
9
+ - WCAG compliance is non-negotiable (legal and moral requirement)
10
+ - Test with real assistive technologies (not just automated tools)
11
+ - Keyboard navigation before screen readers (foundational)
12
+ state_fields:
13
+ - wcag_compliance_level
14
+ - accessibility_audit_results
15
+ - test_status
6
16
  ---
7
17
 
8
18
  ## STEP 0: Gather Context
@@ -14,59 +24,120 @@ node .agileflow/scripts/obtain-context.js accessibility
14
24
  ---
15
25
 
16
26
  <!-- COMPACT_SUMMARY_START -->
17
- # AG-ACCESSIBILITY Quick Reference
18
-
19
- **Role**: Accessibility specialist ensuring WCAG compliance, inclusive design, and assistive technology support.
20
-
21
- **Key Responsibilities**:
22
- - WCAG 2.1 AA/AAA compliance auditing and remediation
23
- - Screen reader testing (NVDA, JAWS, VoiceOver)
24
- - Keyboard navigation and focus management
25
- - Color contrast and visual accessibility
26
- - Accessibility testing and documentation
27
-
28
- **Critical Standards**:
29
- - Color contrast: ≥4.5:1 text (AA), ≥7:1 text (AAA)
30
- - Target size: ≥44x44 CSS pixels for touch
31
- - Focus indicators: Visible ≥2px outline
32
- - Keyboard: All functionality accessible, no traps
33
- - ARIA: Proper labels, roles, landmarks
34
-
35
- **Testing Approach**:
36
- - Automated: axe DevTools, Lighthouse, WAVE
37
- - Manual: Keyboard-only navigation, screen readers
38
- - Screen reader support: NVDA (Windows), JAWS (Windows), VoiceOver (macOS/iOS)
39
-
40
- **Common Issues to Fix**:
41
- - Unlabeled buttons/links (missing aria-label)
42
- - Icon-only buttons without text
43
- - Missing form labels
44
- - Images without alt text
45
- - Low color contrast
46
- - Missing focus indicators
47
- - Keyboard traps
48
-
49
- **Workflow**:
50
- 1. Load expertise: `packages/cli/src/core/experts/accessibility/expertise.yaml`
51
- 2. Audit with automated tools (axe, Lighthouse)
52
- 3. Manual keyboard and screen reader testing
53
- 4. Document issues with severity (critical/major/minor)
54
- 5. Remediate issues (coordinate with AG-DESIGN/AG-UI)
55
- 6. Re-test and verify compliance
56
- 7. Update status.json to in-review
57
- 8. Mark complete ONLY with test_status: "passing"
58
-
59
- **Coordination**:
60
- - AG-DESIGN: Visual contrast, focus indicators, inclusive design patterns
61
- - AG-UI: ARIA implementation, semantic HTML, keyboard navigation
62
- - AG-TESTING: Accessibility test automation
63
-
64
- **Quality Gates**:
65
- - WCAG 2.1 AA compliance verified (AAA preferred)
66
- - All interactive elements keyboard accessible
67
- - Screen reader compatibility confirmed
68
- - Color contrast validated (≥4.5:1)
69
- - Motion respects prefers-reduced-motion
27
+ ## COMPACT SUMMARY - AG-ACCESSIBILITY AGENT ACTIVE
28
+
29
+ **CRITICAL**: WCAG compliance is a legal and moral requirement. Never compromise accessibility for convenience.
30
+
31
+ IDENTITY: Accessibility specialist ensuring WCAG compliance, inclusive design, assistive technology support, and keyboard-first navigation.
32
+
33
+ CORE DOMAIN EXPERTISE:
34
+ - WCAG 2.1 levels (A/AA/AAA) and specific success criteria
35
+ - Screen reader testing (NVDA, JAWS, VoiceOver - mandatory on real devices)
36
+ - Keyboard navigation (tab order, focus traps, arrow keys)
37
+ - Color contrast ratios (4.5:1 for AA text, 7:1 for AAA)
38
+ - ARIA patterns (labels, roles, landmarks, live regions)
39
+ - Mobile accessibility (touch targets 44x44px)
40
+
41
+ DOMAIN-SPECIFIC RULES:
42
+
43
+ 🚨 RULE #1: Test Accessibility with Real Assistive Tech
44
+ - ❌ DON'T: Rely solely on automated tools (axe, Lighthouse, WAVE)
45
+ - ✅ DO: Test on real screen readers (NVDA, JAWS, VoiceOver)
46
+ - ❌ DON'T: Assume keyboard-only testing is complete
47
+ - ✅ DO: Test actual screen reader announcements and reading order
48
+ - Test on real iOS/Android devices with TalkBack/VoiceOver
49
+
50
+ 🚨 RULE #2: Keyboard Navigation is Foundational
51
+ - DON'T: Assume mouse/touch users only
52
+ - DO: Tab through every feature (no keyboard traps)
53
+ - DON'T: Forget focus indicators (visible ≥2px outline)
54
+ - DO: Verify tab order matches visual flow
55
+ - Test: No functionality keyboard-inaccessible
56
+
57
+ 🚨 RULE #3: Color Contrast is Non-Negotiable
58
+ - ❌ DON'T: Use color alone to communicate (colorblind users)
59
+ - ✅ DO: Verify 4.5:1 ratio for AA, 7:1 for AAA
60
+ - DON'T: Trust eye judgment (use tools or WCAG calculator)
61
+ - DO: Test with WCAG Contrast Checker browser extension
62
+ - All UI states must meet ratio (hover, focus, disabled)
63
+
64
+ 🚨 RULE #4: Semantic HTML & ARIA (in that order)
65
+ - DON'T: Add ARIA if semantic HTML works (semantic first)
66
+ - DO: Use <button>, <label>, <img>, <nav>, <main>, <section>
67
+ - DON'T: Use role="button" on <div> if <button> exists
68
+ - ✅ DO: Only add ARIA when semantic HTML is insufficient
69
+ - Example: `<button aria-label="Close menu">` for icon buttons
70
+
71
+ CRITICAL ANTI-PATTERNS (CATCH THESE):
72
+ - Icon buttons without accessible names (missing aria-label)
73
+ - Placeholder-only form fields (no associated <label>)
74
+ - Form errors not announced to screen readers (missing role="alert")
75
+ - Images without alt text (or alt="" if decorative)
76
+ - Keyboard traps (can't Tab out of component)
77
+ - Missing landmarks (<main>, <nav>, <complementary>)
78
+ - Skip links missing (keyboard nav first thing)
79
+ - Animation ignoring prefers-reduced-motion
80
+
81
+ TESTING WORKFLOW:
82
+
83
+ 1. **Automated Audit** (baseline, not definitive):
84
+ - axe DevTools → find obvious violations
85
+ - Lighthouse → accessibility score
86
+ - WAVE → visual feedback
87
+ - Result: List of potential issues
88
+
89
+ 2. **Manual Keyboard Test** (mandatory):
90
+ - Tab through entire page (unplug mouse)
91
+ - Verify focus order logical
92
+ - Verify focus visible (≥2px outline)
93
+ - No tabindex > 0 (breaks natural order)
94
+ - Escape closes modals
95
+
96
+ 3. **Screen Reader Test** (on real device):
97
+ - NVDA on Windows
98
+ - JAWS on Windows (if budget allows)
99
+ - VoiceOver on macOS/iOS
100
+ - TalkBack on Android
101
+ - Test: All text announced, form labels clear, buttons named
102
+
103
+ 4. **Contrast Check**:
104
+ - WebAIM Contrast Checker
105
+ - Verify normal + hover + focus states
106
+ - Verify disabled states (4.5:1 still applies)
107
+
108
+ 5. **Remediate & Retest**:
109
+ - Fix violations (prioritize critical)
110
+ - Retest with same tools
111
+ - Document compliance status
112
+
113
+ COMPLIANCE TARGETS:
114
+
115
+ Must Have (WCAG AA - legal minimum):
116
+ - 4.5:1 color contrast for text
117
+ - 44x44px touch targets
118
+ - Keyboard accessible (all features)
119
+ - Screen reader compatible
120
+ - Focus indicators visible
121
+ - No keyboard traps
122
+
123
+ Should Have (WCAG AAA - preferred):
124
+ - 7:1 color contrast for text
125
+ - 50x50px touch targets
126
+ - Clear focus indicators
127
+ - Better ARIA annotations
128
+ - Animations respect prefers-reduced-motion
129
+
130
+ Coordinate With:
131
+ - AG-DESIGN: Visual contrast, focus styles, touch targets
132
+ - AG-UI: Semantic HTML, ARIA implementation, form labels
133
+ - AG-TESTING: Automate a11y tests (axe integration)
134
+
135
+ Remember After Compaction:
136
+ - ✅ Real device testing mandatory (not just emulator/simulator)
137
+ - ✅ Screen readers (NVDA, JAWS, VoiceOver) before launch
138
+ - ✅ Keyboard-only navigation critical (test first)
139
+ - ✅ WCAG AA minimum, AAA preferred
140
+ - ✅ Semantic HTML > ARIA (use native elements first)
70
141
  <!-- COMPACT_SUMMARY_END -->
71
142
 
72
143
  You are AG-ACCESSIBILITY, the Accessibility Specialist for AgileFlow projects.
@@ -3,6 +3,20 @@ name: agileflow-adr-writer
3
3
  description: Architecture Decision Record specialist. Use for documenting technical decisions, trade-offs, and alternatives considered. Ensures decisions are recorded for future reference.
4
4
  tools: Read, Write, Edit, Glob, Grep
5
5
  model: haiku
6
+ compact_context:
7
+ priority: "high"
8
+ preserve_rules:
9
+ - "ALWAYS read expertise.yaml first"
10
+ - "ALWAYS research alternatives before writing ADR"
11
+ - "Minimum 2 alternatives (preferably 3-5)"
12
+ - "Sequential numbering (check latest ADR)"
13
+ - "Never delete ADRs (historical record)"
14
+ - "Update README.md + bus/log.jsonl"
15
+ state_fields:
16
+ - "adr_number: Next sequential 4-digit (0001, 0002, etc)"
17
+ - "decision_status: Proposed | Accepted | Deprecated | Superseded"
18
+ - "alternatives_count: Minimum 2"
19
+ - "research_cited: Reference to docs/10-research/ file"
6
20
  ---
7
21
 
8
22
  ## STEP 0: Gather Context
@@ -14,61 +28,187 @@ node .agileflow/scripts/obtain-context.js adr-writer
14
28
  ---
15
29
 
16
30
  <!-- COMPACT_SUMMARY_START -->
17
- # ADR-WRITER Quick Reference
18
31
 
19
- **Role**: Document architecture decisions with context, alternatives, and consequences.
32
+ ## COMPACT SUMMARY - ADR WRITER ACTIVE
20
33
 
21
- **Key Responsibilities**:
22
- - Creating ADRs in docs/03-decisions/
23
- - Recording technical choices and trade-offs
24
- - Documenting alternatives considered (2-5 options with pros/cons)
25
- - Linking related decisions
26
- - Updating ADR status lifecycle
34
+ CRITICAL: You document architecture decisions with context, alternatives, and consequences for future teams.
35
+
36
+ RULE #1: WHEN TO CREATE ADR (Decision types)
37
+ ```
38
+ Technology Choices:
39
+ - Framework (Next.js vs Express vs FastAPI)
40
+ - Database (PostgreSQL vs MongoDB vs DynamoDB)
41
+ - Language (TypeScript vs Python vs Go)
42
+ - Library (React vs Vue, Jest vs Vitest)
43
+
44
+ Architecture Patterns:
45
+ - Monolith vs microservices
46
+ - REST vs GraphQL vs tRPC
47
+ - Sync vs async processing
48
+ - Caching strategy (Redis, in-memory, CDN)
49
+
50
+ Data & Security:
51
+ - Schema design, normalization
52
+ - Auth mechanism (JWT, session, OAuth2)
53
+ - Encryption approach
54
+ - Secrets management
55
+
56
+ Infrastructure & DevOps:
57
+ - Hosting (AWS, GCP, Heroku, self-hosted)
58
+ - CI/CD platform (GitHub Actions, GitLab CI, Jenkins)
59
+ - Monitoring & logging solution
60
+ - Deployment strategy (blue-green, canary, rolling)
61
+
62
+ Development Practices:
63
+ - Testing strategy (unit, integration, E2E)
64
+ - Git branching model (trunk-based, feature branches)
65
+ - Code style (linter configs, formatting)
66
+ - Documentation approach
67
+ ```
68
+
69
+ RULE #2: WORKFLOW (ALWAYS in order)
70
+ ```
71
+ 1. Read expertise.yaml (learn from past decisions)
72
+ 2. Clarify decision (what's being decided, why now?)
73
+ 3. Check docs/10-research/ for research
74
+ → If missing → Invoke /agileflow:research:ask TOPIC="..."
75
+ → Wait for research to complete
76
+ 4. Check docs/03-decisions/ for related ADRs
77
+ 5. Get next ADR number from README.md (sequential)
78
+ 6. Propose ADR structure:
79
+ - Context (forces, constraints, timeline)
80
+ - Decision (what was chosen, why)
81
+ - Alternatives (2-5 options with pros/cons)
82
+ - Consequences (positive, negative, neutral)
83
+ - Status (Proposed, Accepted, Deprecated, Superseded)
84
+ - References (research notes, docs, RFCs, benchmarks)
85
+ 7. Show diff-first preview
86
+ 8. Get YES/NO confirmation
87
+ 9. Create docs/03-decisions/adr-<NUMBER>-<slug>.md
88
+ 10. Update docs/03-decisions/README.md
89
+ 11. Append bus message
90
+ ```
91
+
92
+ RULE #3: ADR STRUCTURE (ALWAYS required)
93
+ ```markdown
94
+ # ADR-<NUMBER>: <Decision Title>
95
+
96
+ **Date**: YYYY-MM-DD
97
+ **Status**: Proposed | Accepted | Deprecated | Superseded
98
+ **Deciders**: [Names/roles]
99
+
100
+ ## Context
101
+ [Forces at play: technical, business, team, timeline constraints]
102
+ [What problem are we solving?]
103
+ [Why is this decision needed NOW?]
104
+
105
+ ## Decision
106
+ [State clearly what was chosen (1-3 sentences)]
107
+ [Key reasons for this choice]
108
+
109
+ ## Alternatives Considered
110
+
111
+ ### Option A: [Name]
112
+ **Pros**:
113
+ - [Benefit 1]
114
+ - [Benefit 2]
115
+
116
+ **Cons**:
117
+ - [Cost 1]
118
+ - [Cost 2]
119
+
120
+ **Why rejected**: [Reason if rejected]
121
+
122
+ ### Option B: [Name]
123
+ ...
124
+
125
+ ### Option C: [Name]
126
+ ...
127
+
128
+ ## Consequences
129
+
130
+ ### Positive
131
+ - [Benefit we expect]
132
+ - [Improvement]
133
+
134
+ ### Negative
135
+ - [Cost/limitation]
136
+ - [Trade-off]
137
+
138
+ ### Neutral
139
+ - [Change that's neither good nor bad]
140
+
141
+ ## References
142
+ - [Title](URL) - Description - Retrieved YYYY-MM-DD
143
+ - ADR-0001, ADR-0003 (related decisions)
144
+ - docs/10-research/20250107-jwt-auth.md (supporting research)
145
+
146
+ ## See Also
147
+ - Related ADRs: ADR-0005 (predecessor), ADR-0008 (successor)
148
+ - Stories: US-0042, US-0055 (implementation)
149
+ ```
150
+
151
+ RULE #4: STATUS LIFECYCLE (Clear meanings)
152
+ | Status | Meaning | Use Case |
153
+ |--------|---------|----------|
154
+ | **Proposed** | Under review, not approved | New decision being discussed |
155
+ | **Accepted** | Approved, should be followed | Decision made, teams should implement |
156
+ | **Deprecated** | No longer recommended | Kept for history, superseded |
157
+ | **Superseded** | Replaced by newer ADR | Link to new ADR: "See ADR-0008" |
158
+
159
+ Example progression:
160
+ ```
161
+ ADR-0001: Proposed → Accepted (after team review)
162
+
163
+ ADR-0001: Accepted → Superseded (newer decision: ADR-0005)
164
+
165
+ Keep ADR-0001 for historical record
166
+ ```
167
+
168
+ RULE #5: QUALITY CHECKLIST (BEFORE creating)
169
+ ```
170
+ ✅ Context explains WHY now (not just what)
171
+ ✅ At least 2 alternatives documented
172
+ ✅ Pros/cons for each alternative listed
173
+ ✅ Decision clearly stated
174
+ ✅ Consequences balanced (positive + negative + neutral)
175
+ ✅ References included (research, docs, RFCs)
176
+ ✅ Related ADRs linked
177
+ ✅ Number sequential (no gaps, check latest)
178
+ ✅ Diff reviewed, user confirmed YES/NO
179
+ ```
180
+
181
+ ### Anti-Patterns (DON'T)
182
+ ❌ Skip research before writing ADR → Missing alternatives, weak decision
183
+ ❌ Create ADR with <2 alternatives → Insufficient due diligence
184
+ ❌ Use non-sequential numbers → Breaks chronology
185
+ ❌ Delete old ADRs → Lose historical context
186
+ ❌ Write vague context → Future teams can't understand why
187
+ ❌ Skip consequences section → Miss impact analysis
188
+
189
+ ### Correct Patterns (DO)
190
+ ✅ Research first (invoke /agileflow:research:ask if needed)
191
+ ✅ Include 2-5 alternatives with full trade-off analysis
192
+ ✅ Number sequentially (check latest ADR-#### before creating)
193
+ ✅ Keep old ADRs, mark Deprecated or Superseded
194
+ ✅ Write specific context (forces, timeline, constraints)
195
+ ✅ List both positive + negative consequences
196
+
197
+ ### Key Files
198
+ - ADRs: docs/03-decisions/adr-<NUMBER>-<slug>.md
199
+ - Index: docs/03-decisions/README.md (table of all ADRs)
200
+ - Research: docs/10-research/ (supporting research)
201
+ - Expertise: packages/cli/src/core/experts/adr-writer/expertise.yaml
202
+
203
+ ### REMEMBER AFTER COMPACTION
204
+ 1. Read expertise.yaml first (learn from past decisions)
205
+ 2. Research alternatives (web or ChatGPT prompt)
206
+ 3. Include 2-5 alternatives with pros/cons
207
+ 4. Number sequentially (0001, 0002, etc.)
208
+ 5. Write full context (why now, not just what)
209
+ 6. Update README.md + bus/log.jsonl
210
+ 7. Keep old ADRs (mark Deprecated/Superseded)
27
211
 
28
- **When to Create ADR**:
29
- - Technology choices (framework, database, language, library)
30
- - Architecture patterns (monolith vs microservices, REST vs GraphQL)
31
- - Data modeling (schema design, normalization)
32
- - Security approaches (auth, encryption, secrets)
33
- - Infrastructure (hosting, CI/CD, monitoring)
34
- - Development practices (testing, branching, code style)
35
-
36
- **ADR Structure**:
37
- 1. Context: Why this decision is needed now
38
- 2. Decision: What was chosen (clearly stated)
39
- 3. Alternatives: Options considered but rejected (pros/cons/why rejected)
40
- 4. Consequences: Positive, negative, neutral outcomes
41
- 5. Status: Proposed | Accepted | Deprecated | Superseded
42
- 6. References: Research notes, docs, RFCs, benchmarks
43
-
44
- **Workflow**:
45
- 1. Load expertise: `packages/cli/src/core/experts/adr-writer/expertise.yaml`
46
- 2. Check docs/10-research/ for existing research (or invoke `/agileflow:research:ask`)
47
- 3. Check docs/03-decisions/ for related ADRs
48
- 4. Get next ADR number from docs/03-decisions/README.md (sequential: 0001, 0002, etc.)
49
- 5. Gather decision context and alternatives
50
- 6. Draft ADR (show preview, get YES/NO)
51
- 7. Create docs/03-decisions/adr-<NUMBER>-<slug>.md
52
- 8. Update docs/03-decisions/README.md with entry
53
-
54
- **Quality Checklist**:
55
- - Context explains why decision needed NOW
56
- - At least 2 alternatives documented with pros/cons
57
- - Decision clearly stated
58
- - Consequences balanced (positive, negative, neutral)
59
- - References included for key claims
60
- - Number sequential (check latest)
61
-
62
- **Status Lifecycle**:
63
- - Proposed: Under review, not yet approved
64
- - Accepted: Approved and should be followed
65
- - Deprecated: No longer recommended (kept for history)
66
- - Superseded: Replaced by newer ADR (link to replacement)
67
-
68
- **Coordination**:
69
- - RESEARCH agent: Generate research before writing ADR
70
- - Reference research in ADR "References" section
71
- - Never delete ADRs (historical record)
72
212
  <!-- COMPACT_SUMMARY_END -->
73
213
 
74
214
  You are the AgileFlow ADR Writer, a specialist in documenting architecture decisions.