@relipa/ai-flow-kit 0.0.4 → 0.0.5-beta.1

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 (41) hide show
  1. package/{docs/README.md → README.md} +25 -18
  2. package/bin/aiflow.js +77 -7
  3. package/custom/skills/{validate-ticket → read-study-requirement}/SKILL.md +27 -17
  4. package/custom/skills/review-plan/SKILL.md +1 -1
  5. package/custom/templates/shared/gate-workflow.md +88 -75
  6. package/custom/templates/tools/claude.md +1 -1
  7. package/custom/templates/tools/copilot.md +1 -1
  8. package/custom/templates/tools/cursor.md +1 -1
  9. package/custom/templates/tools/gemini.md +1 -1
  10. package/custom/templates/tools/generic.md +1 -1
  11. package/docs/{AIFLOW.md → common/AIFLOW.md} +462 -458
  12. package/docs/{CHANGELOG.md → common/CHANGELOG.md} +132 -100
  13. package/docs/{cli-reference.md → common/cli-reference.md} +98 -28
  14. package/docs/{troubleshooting.md → common/troubleshooting.md} +15 -0
  15. package/docs/project/ARCHITECTURE.md +28 -0
  16. package/package.json +7 -5
  17. package/scripts/context.js +1 -1
  18. package/scripts/guide.js +16 -0
  19. package/scripts/hooks/session-start.js +145 -141
  20. package/scripts/init.js +168 -44
  21. package/scripts/prompt.js +431 -402
  22. package/scripts/telemetry/cli.js +243 -0
  23. package/scripts/telemetry/config.js +91 -0
  24. package/scripts/telemetry/crypto.js +20 -0
  25. package/scripts/telemetry/flush.js +162 -0
  26. package/scripts/telemetry/record.js +138 -0
  27. package/scripts/use.js +74 -31
  28. package/upstream/skills/using-superpowers/SKILL.md +14 -0
  29. package/docs/IMPLEMENTATION_SUMMARY.md +0 -330
  30. package/docs/architecture.md +0 -394
  31. package/docs/developer-overview.md +0 -126
  32. package/upstream/tests/brainstorm-server/package-lock.json +0 -36
  33. /package/docs/{QUICK_START.md → common/QUICK_START.md} +0 -0
  34. /package/docs/{ai-integration.md → common/ai-integration.md} +0 -0
  35. /package/docs/{configuration.md → common/configuration.md} +0 -0
  36. /package/docs/{getting-started.md → common/getting-started.md} +0 -0
  37. /package/docs/{workflows → common/workflows}/bug-fix.md +0 -0
  38. /package/docs/{workflows → common/workflows}/feature.md +0 -0
  39. /package/docs/{workflows → common/workflows}/impact-analysis.md +0 -0
  40. /package/docs/{workflows → common/workflows}/investigation.md +0 -0
  41. /package/docs/{workflows → common/workflows}/refactor.md +0 -0
@@ -1,458 +1,462 @@
1
- # AIFLOW — Software Development Workflow with AI
2
-
3
- **Version:** 2.0.0 | **Package:** ai-flow-kit
4
-
5
- > This workflow applies to all tasks: feature, bug-fix, refactor, investigation.
6
- > **Absolute Rule: Complete Gate N → Only then can you enter Gate N+1. No exceptions.**
7
-
8
- ---
9
-
10
- ## Workflow Overview
11
-
12
- ```
13
- PM writes ticket on Backlog/Jira
14
-
15
-
16
- ⛩️ GATE 1 — AI Analyze Requirement [AI + DEV]
17
- AI loads ticket + reads source code
18
- AI asks clarifying questions until clear
19
- AI outputs: requirement.md
20
- (requirements, solution, impact analysis, estimate)
21
- DEV reviews → "APPROVED"
22
- │ APPROVED
23
-
24
- ⛩️ GATE 2 — Implementation Plan [AI + DEV]
25
- AI creates detailed coding plan (TDD steps)
26
- DEV reviews → "APPROVED"
27
- │ APPROVED
28
-
29
- ⛩️ GATE 3 — Code Generation (TDD) [AI]
30
- AI writes tests first → implement → tests pass
31
- Commit each small step
32
- │ Code done
33
-
34
- ⛩️ GATE 4 — AI Self-Review [AI + DEV]
35
- AI runs: verification + impact-analysis + checklist
36
- AI generates summary report
37
- DEV reviews → "APPROVED" or "BUG: [description]"
38
- │ APPROVED
39
-
40
- ⛩️ GATE 5 — Peer Review & PR [DEV + Peer]
41
- requesting-code-review skill
42
- Create Pull Request → merge
43
-
44
-
45
- DONE
46
- ```
47
-
48
- ---
49
-
50
- ## Roles
51
-
52
- | Role | Responsibility |
53
- |------|---------------|
54
- | **PM** | Write ticket on Backlog/Jira with description, acceptance criteria, context |
55
- | **DEV** | Trigger workflow, review AI outputs at each gate, type APPROVED or provide feedback |
56
- | **AI** | Analyze requirements, propose solutions, generate code (TDD), self-review |
57
-
58
- ---
59
-
60
- ## Gate Details
61
-
62
- ---
63
-
64
- ### ⛩️ GATE 1 — AI Analyze Requirement
65
-
66
- **Who performs:** AI (analyze) + DEV (review & approve)
67
-
68
- **Trigger:**
69
- ```bash
70
- aiflow use PROJ-33 # load ticket from Backlog/Jira
71
- claude # open Claude → AI auto-starts Gate 1
72
- ```
73
-
74
- > `aiflow prompt` is optional — use it only when pasting into Claude Desktop/Web.
75
- >
76
- > **Tool Support:**
77
- > - **Claude Code:** AI auto-starts Gate 1 via SessionStart hook.
78
- > - **Cursor:** Instructions in `.cursorrules` enforce the Gate Workflow.
79
- > - **Gemini CLI:** Rules in `GEMINI.md` guide the session.
80
- > - **Copilot:** Instructions in `.github/copilot-instructions.md`.
81
-
82
- **What AI does (in order):**
83
-
84
- | Step | Action | Purpose |
85
- |------|--------|---------|
86
- | 1 | Load ticket from `.aiflow/context/current.json` | Get PM's requirements, comments |
87
- | 2 | Read `CLAUDE.md` + source code | Understand architecture, tech stack, patterns |
88
- | 3 | Investigate related files & data flow | Identify affected areas, dependencies |
89
- | 4 | Ask clarifying questions (one at a time) | Ensure full understanding |
90
- | 5 | Write `plan/[ticket-id]/requirement.md` | Structured requirement document |
91
-
92
- **AI asks questions when:**
93
- - Business requirements are vague or ambiguous
94
- - Acceptance criteria are not measurable
95
- - Edge cases are discovered in source code
96
- - Multiple approaches are possible and need input
97
- - Impact on existing features is unclear
98
-
99
- **Requirement Document Output (`plan/[ticket-id]/requirement.md`):**
100
-
101
- ```
102
- ├── 1. Requirements Summary
103
- │ ├── Description (AI's understanding in technical language)
104
- │ ├── Current behavior / Business goal
105
- │ ├── Acceptance Criteria (refined, measurable)
106
- │ └── Context & Constraints
107
- ├── 2. Source Code Analysis
108
- │ ├── Related files & their roles
109
- │ ├── Data flow diagram
110
- │ ├── Existing patterns to follow
111
- │ └── Current test coverage
112
- ├── 3. Proposed Solution & Approach
113
- │ ├── Option A (recommended) — pros/cons
114
- │ ├── Option B (alternative) — pros/cons
115
- │ ├── Chosen approach & rationale
116
- │ ├── Files to create/modify
117
- │ └── Database changes (if any)
118
- ├── 4. Impact Analysis
119
- │ ├── Impact level (Low/Medium/High)
120
- │ ├── Affected areas
121
- │ ├── Breaking changes
122
- │ └── Risks & mitigations
123
- ├── 5. Effort Estimate
124
- │ ├── Task breakdown with size (S/M/L/XL)
125
- │ └── Sub-task split for XL tasks
126
- └── 6. Testing Plan
127
- ├── Unit tests
128
- ├── Integration tests
129
- └── Manual test cases
130
- ```
131
-
132
- **Gate 1 Display:**
133
-
134
- ```
135
- ⏸️ GATE 1: REQUIREMENT DOCUMENT READY
136
-
137
- Summary:
138
- - Type: [feature / bug-fix / refactor]
139
- - Impact: [Low / Medium / High]
140
- - Estimate: [S / M / L / XL]
141
- - Approach: [brief description]
142
- - Files affected: [N] files
143
-
144
- → Review: plan/[ticket-id]/requirement.md
145
- → Type APPROVED to proceed
146
- → Or provide feedback to update
147
- ```
148
-
149
- **Gate 1 Output:**
150
- - `plan/[ticket-id]/requirement.md` approved by DEV
151
- - DEV has typed "APPROVED"
152
-
153
- ---
154
-
155
- ### ⛩️ GATE 2 — Implementation Plan
156
-
157
- **Who performs:** AI (create plan) + DEV (review & approve)
158
-
159
- **What AI does:**
160
-
161
- 1. Read the approved requirement document
162
- 2. **Invoke** `superpowers:writing-plans` → create detailed implementation plan
163
- 3. Break down into TDD tasks: test first → implement → verify
164
- 4. Define commit strategy (small, focused commits)
165
- 5. Present plan and wait for APPROVED
166
-
167
- **Implementation Plan Structure:**
168
-
169
- ```
170
- ├── Task Breakdown (TDD Order)
171
- │ ├── Task 1: Write test for [scenario]
172
- │ ├── Task 2: Implement [component]
173
- │ ├── Task 3: Write test for [next scenario]
174
- │ └── ...
175
- ├── Commit Strategy
176
- └── Test Commands
177
- ```
178
-
179
- **Gate 2 Display:**
180
-
181
- ```
182
- ⏸️ GATE 2: IMPLEMENTATION PLAN READY
183
-
184
- Tasks: [N] | Commits: [N] | Test-first tasks: [N]
185
-
186
- → Type APPROVED to start coding
187
- → Or provide feedback to adjust
188
- ```
189
-
190
- **Gate 2 Output:**
191
- - Implementation plan approved by DEV
192
- - DEV has typed "APPROVED"
193
-
194
- ---
195
-
196
- ### ⛩️ GATE 3 — Code Generation
197
-
198
- **Who performs:** AI
199
-
200
- **Only runs after Gate 2 APPROVED.**
201
-
202
- **Mandatory Order:**
203
-
204
- #### Feature task:
205
- 1. Complex feature (3+ files) → `superpowers:subagent-driven-development`
206
- 2. `superpowers:test-driven-development` — write tests FIRST
207
- 3. Run tests → confirm FAIL
208
- 4. Implement code → tests PASS
209
- 5. Commit each small step
210
-
211
- #### Bug fix task (extra):
212
- 1. `superpowers:systematic-debugging` — trace root cause, NO guessing
213
- 2. `investigate-bug` skill — trace Controller→Service→Repository
214
- 3. Then TDD: write test to reproduce bug → fix → tests PASS
215
-
216
- #### Refactor task (extra):
217
- 1. Ensure tests cover current behavior
218
- 2. Refactor in small steps — keep tests green continuously
219
-
220
- **Gate 3 Output:**
221
- - Code implementation finished
222
- - All tests PASS
223
- - Committed
224
-
225
- ---
226
-
227
- ### ⛩️ GATE 4 — AI Self-Review
228
-
229
- **Who performs:** AI (self-review) + DEV (final approve)
230
-
231
- **AI runs in mandatory order:**
232
-
233
- | Step | Action | Required Result |
234
- |------|--------|------------|
235
- | 1 | `superpowers:verification-before-completion` | All tests PASS |
236
- | 2 | `impact-analysis` skill | No breaking changes outside scope |
237
- | 3 | `custom/rules/review-checklist.md` | All items ticked |
238
- | 4 | Create `plan/[ticket-id]/summary.md` | File exists and is complete |
239
-
240
- **If any step fails → AI fixes it first, without showing DEV.**
241
-
242
- **Summary report output:**
243
-
244
- ```
245
- plan/[ticket-id]/summary.md
246
- ├── List of changed files + reasons
247
- ├── Acceptance Criteria → results (Done/Not Done)
248
- ├── Tests: quantity, coverage
249
- ├── Impact Analysis: level (Low/Medium/High)
250
- └── Review Checklist: N/N items ✅
251
- ```
252
-
253
- **Gate 4 Display:**
254
- ```
255
- ⏸️ GATE 4: WAITING FOR DEV REVIEW
256
-
257
- Tests: ✅ [N] passed
258
- Impact: [Low/Medium/High]
259
- Checklist: [N/N] ✅
260
- Summary: plan/[ticket-id]/summary.md
261
-
262
- Type APPROVED if OK
263
- Type BUG: [description] if there are issues
264
- ```
265
-
266
- **DEV Response:**
267
- - `APPROVED` → move to Gate 5
268
- - `BUG: coding bug` → AI fixes → repeat Gate 4
269
- - `BUG: requirement bug` → AI updates requirement doc → back to Gate 1
270
-
271
- **Gate 4 Output:**
272
- - `plan/[ticket-id]/summary.md` completed
273
- - DEV has typed "APPROVED"
274
-
275
- ---
276
-
277
- ### ⛩️ GATE 5 — Peer Review & Pull Request
278
-
279
- **Who performs:** DEV + Peer reviewer
280
-
281
- **Only runs after Gate 4 APPROVED.**
282
-
283
- **AI invokes:** `superpowers:requesting-code-review`
284
-
285
- **AI guides PR creation:**
286
-
287
- ```markdown
288
- ## Pull Request Template
289
-
290
- **Title:** [feat/fix/refactor]: [PROJ-XX] [Short description]
291
-
292
- **Description:**
293
- Closes [PROJ-XX]
294
-
295
- ### Changes
296
- - [File A] — [what changed]
297
- - [File B] — [what changed]
298
-
299
- ### Acceptance Criteria
300
- - [x] [Criteria 1]
301
- - [x] [Criteria 2]
302
-
303
- ### Testing
304
- - Unit tests: [N] cases
305
- - Integration tests: [N] cases
306
- - Manual test: [tested manually?]
307
-
308
- ### Impact
309
- [Low/Medium/High] — [short description]
310
-
311
- ### Reviewer notes
312
- [Anything special for the reviewer to notice]
313
- ```
314
-
315
- **Peer reviewer checks:**
316
- - Code logic matches requirement document
317
- - Tests are sufficient and meaningful
318
- - No security issues
319
- - Acceptable performance
320
- - Follows team conventions
321
-
322
- **Gate 5 Output:**
323
- - PR created with full description
324
- - Peer reviewer APPROVED
325
- - Merged into main/develop
326
-
327
- ---
328
-
329
- ## Workflow by Task Type
330
-
331
- ### Bug Fix
332
- ```
333
- Gate 1 (AI analyzes bug: root cause hypothesis + solution + impact + estimate)
334
- → Gate 2 (implementation plan: test reproduce bug → fix → verify)
335
- → Gate 3 (systematic-debugging + investigate-bug + TDD fix)
336
- → Gate 4 (verify fix + no regression)
337
- → Gate 5 (peer review + PR)
338
- ```
339
-
340
- ### Feature
341
- ```
342
- Gate 1 (AI analyzes feature: architecture + solution options + impact + estimate)
343
- → Gate 2 (implementation plan: TDD task breakdown)
344
- → Gate 3 (TDD: test first, implement, subagent if complex)
345
- → Gate 4 (verify all AC done + impact check)
346
- → Gate 5 (peer review + PR)
347
- ```
348
-
349
- ### Investigation
350
- ```
351
- Gate 1 (AI investigates: analyze scope, trace code, document findings + recommendations)
352
- → DEV reviews → APPROVED
353
- → DONE (no Gates 2-5, create new ticket if action needed)
354
- ```
355
-
356
- ### Refactor
357
- ```
358
- Gate 1 (AI analyzes: current state, target state, impact + estimate)
359
- → Gate 2 (implementation plan: ensure tests cover behavior → refactor steps)
360
- → Gate 3 (TDD: cover behavior → refactor → tests green)
361
- → Gate 4 (verify no regressions)
362
- → Gate 5 (peer review + PR)
363
- ```
364
-
365
- ### Impact Analysis
366
- ```
367
- Gate 1 (AI analyzes: dependency map, risk level, breaking changes, recommendations)
368
- → DEV reviews → APPROVED
369
- → DONE (no Gates 2-5, implementation needs a separate ticket)
370
- ```
371
-
372
- ---
373
-
374
- ## Skills Used in Workflow
375
-
376
- | Skill | Gate | Purpose |
377
- |-------|------|---------|
378
- | `validate-ticket` | Gate 1 | AI reads, analyzes, asks questions, outputs requirement doc |
379
- | `superpowers:brainstorming` | Gate 1 | Explore solution approaches for complex problems |
380
- | `superpowers:systematic-debugging` | Gate 1 (bug) | Trace root cause hypothesis |
381
- | `generate-spec` | Gate 2 | Create implementation plan |
382
- | `superpowers:writing-plans` | Gate 2 | Detailed TDD task breakdown |
383
- | `investigate-bug` | Gate 3 (bug) | Trace data flow per framework |
384
- | `superpowers:test-driven-development` | Gate 3 | TDD workflow |
385
- | `superpowers:subagent-driven-development` | Gate 3 (complex) | Parallel implementation |
386
- | `review-plan` | Gate 4 | Orchestrate self-review |
387
- | `superpowers:verification-before-completion` | Gate 4 | Verify tests pass |
388
- | `impact-analysis` | Gate 4 | Check breaking changes |
389
- | `superpowers:requesting-code-review` | Gate 5 | Peer review workflow |
390
-
391
- ---
392
-
393
- ## Commands Reference
394
-
395
- ```bash
396
- # Setup (once per project)
397
- aiflow init --framework spring-boot --adapter backlog
398
-
399
- # Per task (2 commands only)
400
- aiflow use PROJ-33 # load ticket context
401
- claude # AI auto-starts Gate 1
402
-
403
- # Optional: generate prompt for Claude Desktop/Web
404
- aiflow prompt bug-fix # generate prompt to paste
405
- aiflow prompt feature --output p.md # save prompt to file
406
-
407
- # Utilities
408
- aiflow context show # view active context
409
- aiflow memory save "key" "value" # save team knowledge
410
- aiflow doctor # health check
411
- aiflow guide # view quickstart guide
412
- ```
413
-
414
- ---
415
-
416
- ## Multi-AI Environment Setup
417
-
418
- One of the core strengths of `ai-flow-kit` is that the **Gate Workflow** is tool-agnostic. Since state is saved in `.aiflow/context/current.json` and the `plan/` directory, you can switch tools mid-task.
419
-
420
- ### How to Switch Tools
421
- 1. **Analyze (Gate 1)** using Claude Code CLI (great for deep codebase scans).
422
- 2. **Review** the `requirement.md` file.
423
- 3. **Open Cursor** to perform the coding (Gate 3).
424
- 4. Cursor will automatically read `.cursorrules`, detect the active ticket, and see that Gate 1 is already finished.
425
- 5. Cursor will proceed to Gate 2 or 3 as appropriate.
426
-
427
- ### Instruction Files Created
428
- | Tool | File Name | Purpose |
429
- |------|-----------|---------|
430
- | Claude Code | `CLAUDE.md` | Primary rules for the CLI tool. |
431
- | Cursor AI | `.cursorrules` | Project-wide rules for Cursor. |
432
- | Gemini CLI | `GEMINI.md` | Context for Gemini sessions. |
433
- | Copilot | `.github/copilot-instructions.md` | Custom instructions for Copilot. |
434
-
435
- ---
436
-
437
- ## FAQ
438
-
439
- **Q: PM didn't write enough on the ticket, what happens?**
440
- A: AI at Gate 1 will read what's available, then ask clarifying questions one at a time until the requirement is clear enough to propose a solution.
441
-
442
- **Q: Does AI just check format or actually understand the requirement?**
443
- A: AI actively reads source code, traces data flow, identifies related files, and proposes solutions. It asks questions based on what it finds in the code — not just checking if fields exist.
444
-
445
- **Q: Can I skip Gate 2 for simple tasks?**
446
- A: No. Gate 2 can be brief (simple plan), but DEV must still type "APPROVED" to confirm the approach.
447
-
448
- **Q: AI reports test failures at Gate 4, what to do?**
449
- A: AI will try to fix them before showing DEV. If it can't, it will report the reason and ask for DEV's support.
450
-
451
- **Q: What's the difference between a requirement bug and a coding bug?**
452
- A: Requirement bug = wrong/missing in requirement doc back to Gate 1. Coding bug = wrong code but correct requirement → fix at Gate 4.
453
-
454
- **Q: Who performs peer review (Gate 5)?**
455
- A: Another developer in the team. Not the code author. The reviewer uses the `superpowers:receiving-code-review` skill.
456
-
457
- **Q: How does AI estimate effort?**
458
- A: AI analyzes the scope of changes (files affected, complexity, test requirements) and categorizes: S (< 1h), M (1-4h), L (4-8h), XL (8h+, should split).
1
+ # AIFLOW — Software Development Workflow with AI
2
+
3
+ **Version:** 2.0.0 | **Package:** ai-flow-kit
4
+
5
+ > This workflow applies to all tasks: feature, bug-fix, refactor, investigation.
6
+ > **Absolute Rule: Complete Gate N → Only then can you enter Gate N+1. No exceptions.**
7
+
8
+ ---
9
+
10
+ ## Workflow Overview
11
+
12
+ ```
13
+ PM writes ticket on Backlog/Jira
14
+
15
+
16
+ ⛩️ GATE 1 — AI Analyze Requirement [AI + DEV]
17
+ AI loads ticket + reads source code
18
+ AI asks clarifying questions until clear
19
+ AI outputs: requirement.md
20
+ (requirements, solution, impact analysis, estimate)
21
+ DEV reviews → "APPROVED"
22
+ │ APPROVED
23
+
24
+ ⛩️ GATE 2 — Implementation Plan [AI + DEV]
25
+ AI creates detailed coding plan (TDD steps)
26
+ DEV reviews → "APPROVED"
27
+ │ APPROVED
28
+
29
+ ⛩️ GATE 3 — Code Generation (TDD) [AI]
30
+ AI writes tests first → implement → tests pass
31
+ Commit each small step
32
+ │ Code done
33
+
34
+ ⛩️ GATE 4 — AI Self-Review [AI + DEV]
35
+ AI runs: verification + impact-analysis + checklist
36
+ AI generates summary report
37
+ DEV reviews → "APPROVED" or "BUG: [description]"
38
+ │ APPROVED
39
+
40
+ ⛩️ GATE 5 — Peer Review & PR [DEV + Peer]
41
+ requesting-code-review skill
42
+ Create Pull Request → merge
43
+
44
+
45
+ DONE
46
+ ```
47
+
48
+ ---
49
+
50
+ ## Roles
51
+
52
+ | Role | Responsibility |
53
+ |------|---------------|
54
+ | **PM** | Write ticket on Backlog/Jira with description, acceptance criteria, context |
55
+ | **DEV** | Trigger workflow, review AI outputs at each gate, type APPROVED or provide feedback |
56
+ | **AI** | Analyze requirements, propose solutions, generate code (TDD), self-review |
57
+
58
+ ---
59
+
60
+ ## Gate Details
61
+
62
+ ---
63
+
64
+ ### ⛩️ GATE 1 — AI Analyze Requirement
65
+
66
+ **Who performs:** AI (analyze) + DEV (review & approve)
67
+
68
+ **Trigger:**
69
+ ```bash
70
+ aiflow use PROJ-33 # load ticket from Backlog/Jira
71
+ claude # open Claude → AI auto-starts Gate 1
72
+ ```
73
+
74
+ > `aiflow prompt` is optional — use it only when pasting into Claude Desktop/Web.
75
+ >
76
+ > **Tool Support:**
77
+ > - **Claude Code:** AI auto-starts Gate 1 via SessionStart hook.
78
+ > - **Cursor:** Instructions in `.cursorrules` enforce the Gate Workflow.
79
+ > - **Gemini CLI:** Rules in `GEMINI.md` guide the session.
80
+ > - **Copilot:** Instructions in `.github/copilot-instructions.md`.
81
+
82
+ **What AI does (in order):**
83
+
84
+ | Step | Action | Purpose |
85
+ |------|--------|---------|
86
+ | 1 | Load ticket from `.aiflow/context/current.json` | Get PM's requirements, comments |
87
+ | 2 | Read `CLAUDE.md` + source code | Understand architecture, tech stack, patterns |
88
+ | 3 | Investigate related files & data flow | Identify affected areas, dependencies |
89
+ | 4 | Ask clarifying questions (one at a time) | Ensure full understanding |
90
+ | 5 | Write `plan/[ticket-id]/requirement.md` | Structured requirement document |
91
+
92
+ **AI asks questions when:**
93
+ - Business requirements are vague or ambiguous
94
+ - Acceptance criteria are not measurable
95
+ - Edge cases are discovered in source code
96
+ - Multiple approaches are possible and need input
97
+ - Impact on existing features is unclear
98
+
99
+ **Requirement Document Output (`plan/[ticket-id]/requirement.md`):**
100
+
101
+ ```
102
+ ├── 1. Requirements Summary
103
+ │ ├── Description (AI's understanding in technical language)
104
+ │ ├── Current behavior / Business goal
105
+ │ ├── Acceptance Criteria (refined, measurable)
106
+ │ └── Context & Constraints
107
+ ├── 2. Source Code Analysis
108
+ │ ├── Related files & their roles
109
+ │ ├── Data flow diagram
110
+ │ ├── Existing patterns to follow
111
+ │ └── Current test coverage
112
+ ├── 3. Proposed Solution & Approach
113
+ │ ├── Option A (recommended) — pros/cons
114
+ │ ├── Option B (alternative) — pros/cons
115
+ │ ├── Chosen approach & rationale
116
+ │ ├── Files to create/modify
117
+ │ └── Database changes (if any)
118
+ ├── 4. Impact Analysis
119
+ │ ├── Impact level (Low/Medium/High)
120
+ │ ├── Affected areas
121
+ │ ├── Breaking changes
122
+ │ └── Risks & mitigations
123
+ ├── 5. Effort Estimate
124
+ │ ├── Task breakdown with size (S/M/L/XL)
125
+ │ └── Sub-task split for XL tasks
126
+ └── 6. Testing Plan
127
+ ├── Unit tests
128
+ ├── Integration tests
129
+ └── Manual test cases
130
+ ```
131
+
132
+ **Gate 1 Display:**
133
+
134
+ ```
135
+ ⏸️ GATE 1: REQUIREMENT DOCUMENT READY
136
+
137
+ Summary:
138
+ - Type: [feature / bug-fix / refactor]
139
+ - Impact: [Low / Medium / High]
140
+ - Estimate: [S / M / L / XL]
141
+ - Approach: [brief description]
142
+ - Files affected: [N] files
143
+
144
+ → Review: plan/[ticket-id]/requirement.md
145
+ → Type APPROVED to proceed
146
+ → Or provide feedback to update
147
+ ```
148
+
149
+ **Gate 1 Output:**
150
+ - `plan/[ticket-id]/requirement.md` approved by DEV
151
+ - DEV has typed "APPROVED"
152
+
153
+ ---
154
+
155
+ ### ⛩️ GATE 2 — Implementation Plan
156
+
157
+ **Who performs:** AI (create plan) + DEV (review & approve)
158
+
159
+ **What AI does:**
160
+
161
+ 1. Read the approved requirement document
162
+ 2. **Invoke** `superpowers:writing-plans` → create detailed implementation plan
163
+ 3. Break down into TDD tasks: test first → implement → verify
164
+ 4. Define commit strategy (small, focused commits)
165
+ 5. Present plan and wait for APPROVED
166
+
167
+ **Implementation Plan Structure:**
168
+
169
+ ```
170
+ ├── Task Breakdown (TDD Order)
171
+ │ ├── Task 1: Write test for [scenario]
172
+ │ ├── Task 2: Implement [component]
173
+ │ ├── Task 3: Write test for [next scenario]
174
+ │ └── ...
175
+ ├── Commit Strategy
176
+ └── Test Commands
177
+ ```
178
+
179
+ **Gate 2 Display:**
180
+
181
+ ```
182
+ ⏸️ GATE 2: IMPLEMENTATION PLAN READY
183
+
184
+ Tasks: [N] | Commits: [N] | Test-first tasks: [N]
185
+
186
+ → Type APPROVED to start coding
187
+ → Or provide feedback to adjust
188
+ ```
189
+
190
+ **Gate 2 Output:**
191
+ - Implementation plan approved by DEV
192
+ - DEV has typed "APPROVED"
193
+
194
+ ---
195
+
196
+ ### ⛩️ GATE 3 — Code Generation
197
+
198
+ **Who performs:** AI
199
+
200
+ **Only runs after Gate 2 APPROVED.**
201
+
202
+ **Mandatory Order:**
203
+
204
+ #### Feature task:
205
+ 1. Complex feature (3+ files) → `superpowers:subagent-driven-development`
206
+ 2. `superpowers:test-driven-development` — write tests FIRST
207
+ 3. Run tests → confirm FAIL
208
+ 4. Implement code → tests PASS
209
+ 5. Commit each small step
210
+
211
+ #### Bug fix task (extra):
212
+ 1. `superpowers:systematic-debugging` — trace root cause, NO guessing
213
+ 2. `investigate-bug` skill — trace Controller→Service→Repository
214
+ 3. Then TDD: write test to reproduce bug → fix → tests PASS
215
+
216
+ #### Refactor task (extra):
217
+ 1. Ensure tests cover current behavior
218
+ 2. Refactor in small steps — keep tests green continuously
219
+
220
+ **Gate 3 Output:**
221
+ - Code implementation finished
222
+ - All tests PASS
223
+ - Committed
224
+
225
+ ---
226
+
227
+ ### ⛩️ GATE 4 — AI Self-Review
228
+
229
+ **Who performs:** AI (self-review) + DEV (final approve)
230
+
231
+ **AI runs in mandatory order:**
232
+
233
+ | Step | Action | Required Result |
234
+ |------|--------|------------|
235
+ | 1 | `superpowers:verification-before-completion` | All tests PASS |
236
+ | 2 | `impact-analysis` skill | No breaking changes outside scope |
237
+ | 3 | `custom/rules/review-checklist.md` | All items ticked |
238
+ | 4 | Create `plan/[ticket-id]/summary.md` | File exists and is complete |
239
+
240
+ **If any step fails → AI fixes it first, without showing DEV.**
241
+
242
+ **Summary report output:**
243
+
244
+ ```
245
+ plan/[ticket-id]/summary.md
246
+ ├── List of changed files + reasons
247
+ ├── Acceptance Criteria → results (Done/Not Done)
248
+ ├── Tests: quantity, coverage
249
+ ├── Impact Analysis: level (Low/Medium/High)
250
+ └── Review Checklist: N/N items ✅
251
+ ```
252
+
253
+ **Gate 4 Display:**
254
+ ```
255
+ ⏸️ GATE 4: WAITING FOR DEV REVIEW
256
+
257
+ Tests: ✅ [N] passed
258
+ Impact: [Low/Medium/High]
259
+ Checklist: [N/N] ✅
260
+ Summary: plan/[ticket-id]/summary.md
261
+
262
+ Type APPROVED if OK
263
+ Type BUG: [description] if there are issues
264
+ ```
265
+
266
+ **DEV Response:**
267
+ - `APPROVED` → move to Gate 5
268
+ - `BUG: coding bug` → AI fixes → repeat Gate 4
269
+ - `BUG: requirement bug` → AI updates requirement doc → back to Gate 1
270
+
271
+ **Gate 4 Output:**
272
+ - `plan/[ticket-id]/summary.md` completed
273
+ - DEV has typed "APPROVED"
274
+
275
+ ---
276
+
277
+ ### ⛩️ GATE 5 — Peer Review & Pull Request
278
+
279
+ **Who performs:** DEV + Peer reviewer
280
+
281
+ **Only runs after Gate 4 APPROVED.**
282
+
283
+ **AI invokes:** `superpowers:requesting-code-review`
284
+
285
+ **AI guides PR creation:**
286
+
287
+ ```markdown
288
+ ## Pull Request Template
289
+
290
+ **Title:** [feat/fix/refactor]: [PROJ-XX] [Short description]
291
+
292
+ **Description:**
293
+ Closes [PROJ-XX]
294
+
295
+ ### Changes
296
+ - [File A] — [what changed]
297
+ - [File B] — [what changed]
298
+
299
+ ### Acceptance Criteria
300
+ - [x] [Criteria 1]
301
+ - [x] [Criteria 2]
302
+
303
+ ### Testing
304
+ - Unit tests: [N] cases
305
+ - Integration tests: [N] cases
306
+ - Manual test: [tested manually?]
307
+
308
+ ### Impact
309
+ [Low/Medium/High] — [short description]
310
+
311
+ ### Reviewer notes
312
+ [Anything special for the reviewer to notice]
313
+ ```
314
+
315
+ **Peer reviewer checks:**
316
+ - Code logic matches requirement document
317
+ - Tests are sufficient and meaningful
318
+ - No security issues
319
+ - Acceptable performance
320
+ - Follows team conventions
321
+
322
+ **Gate 5 Output:**
323
+ - PR created with full description
324
+ - Peer reviewer APPROVED
325
+ - Merged into main/develop
326
+
327
+ ---
328
+
329
+ ## Workflow by Task Type
330
+
331
+ ### Bug Fix
332
+ ```
333
+ Gate 1 (AI analyzes bug: root cause hypothesis + solution + impact + estimate)
334
+ → Gate 2 (implementation plan: test reproduce bug → fix → verify)
335
+ → Gate 3 (systematic-debugging + investigate-bug + TDD fix)
336
+ → Gate 4 (verify fix + no regression)
337
+ → Gate 5 (peer review + PR)
338
+ ```
339
+
340
+ ### Feature
341
+ ```
342
+ Gate 1 (AI analyzes feature: architecture + solution options + impact + estimate)
343
+ → Gate 2 (implementation plan: TDD task breakdown)
344
+ → Gate 3 (TDD: test first, implement, subagent if complex)
345
+ → Gate 4 (verify all AC done + impact check)
346
+ → Gate 5 (peer review + PR)
347
+ ```
348
+
349
+ ### Investigation
350
+ ```
351
+ Gate 1 (AI investigates: analyze scope, trace code, document findings + recommendations)
352
+ → DEV reviews → APPROVED
353
+ → DONE (no Gates 2-5, create new ticket if action needed)
354
+ ```
355
+
356
+ ### Refactor
357
+ ```
358
+ Gate 1 (AI analyzes: current state, target state, impact + estimate)
359
+ → Gate 2 (implementation plan: ensure tests cover behavior → refactor steps)
360
+ → Gate 3 (TDD: cover behavior → refactor → tests green)
361
+ → Gate 4 (verify no regressions)
362
+ → Gate 5 (peer review + PR)
363
+ ```
364
+
365
+ ### Impact Analysis
366
+ ```
367
+ Gate 1 (AI analyzes: dependency map, risk level, breaking changes, recommendations)
368
+ → DEV reviews → APPROVED
369
+ → DONE (no Gates 2-5, implementation needs a separate ticket)
370
+ ```
371
+
372
+ ---
373
+
374
+ ## Skills Used in Workflow
375
+
376
+ | Skill | Gate | Purpose |
377
+ |-------|------|---------|
378
+ | `read-study-requirement` | Gate 1 | AI reads, analyzes, asks questions, outputs requirement doc |
379
+ | `superpowers:systematic-debugging` | Gate 1 (bug) | Trace root cause hypothesis |
380
+ | `generate-spec` | Gate 2 | Create implementation plan |
381
+ | `superpowers:writing-plans` | Gate 2 | Detailed TDD task breakdown |
382
+ | `investigate-bug` | Gate 3 (bug) | Trace data flow per framework |
383
+ | `superpowers:test-driven-development` | Gate 3 | TDD workflow |
384
+ | `superpowers:subagent-driven-development` | Gate 3 (complex) | Parallel implementation |
385
+ | `review-plan` | Gate 4 | Orchestrate self-review |
386
+ | `superpowers:verification-before-completion` | Gate 4 | Verify tests pass |
387
+ | `impact-analysis` | Gate 4 | Check breaking changes |
388
+ | `superpowers:requesting-code-review` | Gate 5 | Peer review workflow |
389
+
390
+ ---
391
+
392
+ ## Commands Reference
393
+
394
+ ```bash
395
+ # Setup (once per project)
396
+ aiflow init --framework spring-boot --adapter backlog
397
+
398
+ # Per task (2 commands only)
399
+ aiflow use PROJ-33 # load ticket context
400
+ claude # AI auto-starts Gate 1
401
+
402
+ # Optional: generate prompt for Claude Desktop/Web
403
+ aiflow prompt bug-fix # generate prompt to paste
404
+ aiflow prompt feature --output p.md # save prompt to file
405
+
406
+ # Utilities
407
+ aiflow context show # view active context
408
+ aiflow memory save "key" "value" # save team knowledge
409
+ aiflow doctor # health check
410
+ aiflow guide # view quickstart guide
411
+
412
+ # Telemetry (team leads)
413
+ aiflow telemetry status # view status
414
+ aiflow telemetry enable # setup tracking
415
+ aiflow telemetry disable # disable tracking
416
+ ```
417
+
418
+ ---
419
+
420
+ ## Multi-AI Environment Setup
421
+
422
+ One of the core strengths of `ai-flow-kit` is that the **Gate Workflow** is tool-agnostic. Since state is saved in `.aiflow/context/current.json` and the `plan/` directory, you can switch tools mid-task.
423
+
424
+ ### How to Switch Tools
425
+ 1. **Analyze (Gate 1)** using Claude Code CLI (great for deep codebase scans).
426
+ 2. **Review** the `requirement.md` file.
427
+ 3. **Open Cursor** to perform the coding (Gate 3).
428
+ 4. Cursor will automatically read `.cursorrules`, detect the active ticket, and see that Gate 1 is already finished.
429
+ 5. Cursor will proceed to Gate 2 or 3 as appropriate.
430
+
431
+ ### Instruction Files Created
432
+ | Tool | File Name | Purpose |
433
+ |------|-----------|---------|
434
+ | Claude Code | `CLAUDE.md` | Primary rules for the CLI tool. |
435
+ | Cursor AI | `.cursorrules` | Project-wide rules for Cursor. |
436
+ | Gemini CLI | `GEMINI.md` | Context for Gemini sessions. |
437
+ | Copilot | `.github/copilot-instructions.md` | Custom instructions for Copilot. |
438
+
439
+ ---
440
+
441
+ ## FAQ
442
+
443
+ **Q: PM didn't write enough on the ticket, what happens?**
444
+ A: AI at Gate 1 will read what's available, then ask clarifying questions one at a time until the requirement is clear enough to propose a solution.
445
+
446
+ **Q: Does AI just check format or actually understand the requirement?**
447
+ A: AI actively reads source code, traces data flow, identifies related files, and proposes solutions. It asks questions based on what it finds in the code — not just checking if fields exist.
448
+
449
+ **Q: Can I skip Gate 2 for simple tasks?**
450
+ A: No. Gate 2 can be brief (simple plan), but DEV must still type "APPROVED" to confirm the approach.
451
+
452
+ **Q: AI reports test failures at Gate 4, what to do?**
453
+ A: AI will try to fix them before showing DEV. If it can't, it will report the reason and ask for DEV's support.
454
+
455
+ **Q: What's the difference between a requirement bug and a coding bug?**
456
+ A: Requirement bug = wrong/missing in requirement doc → back to Gate 1. Coding bug = wrong code but correct requirement → fix at Gate 4.
457
+
458
+ **Q: Who performs peer review (Gate 5)?**
459
+ A: Another developer in the team. Not the code author. The reviewer uses the `superpowers:receiving-code-review` skill.
460
+
461
+ **Q: How does AI estimate effort?**
462
+ A: AI analyzes the scope of changes (files affected, complexity, test requirements) and categorizes: S (< 1h), M (1-4h), L (4-8h), XL (8h+, should split).