@relipa/ai-flow-kit 0.0.5 → 0.0.6-beta.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.
@@ -1,462 +1,501 @@
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).
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
+ ## Task Management (Context Switching)
61
+
62
+ AI Flow Kit allows you to manage multiple tasks in the same repository without losing gate progress.
63
+
64
+ - **`aiflow task status`**: Show active and pending tasks.
65
+ - **`aiflow task pause`**: Save current context and gate progress to `.aiflow/tasks/<taskId>/`.
66
+ - **`aiflow task switch <id>`**: Pause current task and switch to another.
67
+ - **`aiflow task resume <id>`**: Restore context and gate state. AI auto-resumes from the correct gate.
68
+
69
+ ---
70
+
71
+ ## Gate Details
72
+
73
+ ---
74
+
75
+ ### ⛩️ GATE 1 — AI Analyze Requirement
76
+
77
+ **Who performs:** AI (analyze) + DEV (review & approve)
78
+
79
+ **Trigger:**
80
+ ```bash
81
+ aiflow use PROJ-33 # load ticket (fast mode, default)
82
+ aiflow use PROJ-33 --full # load ticket, force full analysis
83
+ aiflow use --file task.md # load task from local text/json file
84
+ claude # open Claude AI auto-starts Gate 1
85
+ ```
86
+
87
+ > `aiflow prompt` is optional use it only when pasting into Claude Desktop/Web.
88
+ >
89
+ > **Tool Support:**
90
+ > - **Claude Code:** AI auto-starts Gate 1 via SessionStart hook.
91
+ > - **Cursor:** Instructions in `.cursorrules` enforce the Gate Workflow.
92
+ > - **Gemini CLI:** Rules in `GEMINI.md` guide the session.
93
+ > - **Copilot:** Instructions in `.github/copilot-instructions.md`.
94
+
95
+ **Gate 1 Modes:**
96
+
97
+ | Mode | Flag | When to use | Output |
98
+ |------|------|-------------|--------|
99
+ | `fast` (default) | _(none)_ | Standard tickets, clear intent | Lite 3-section doc (Summary, Files, Estimate). Target < 5 min |
100
+ | `full` | `--full` | Complex tickets, force deep analysis | Full 6-section requirement doc |
101
+ | `auto` | _(legacy)_ | Same as fast | |
102
+
103
+ **What AI does (in order):**
104
+
105
+ | Step | Action | Purpose |
106
+ |------|--------|---------|
107
+ | 1 | Load ticket from `.aiflow/context/current.json` | Get PM's requirements, comments |
108
+ | 2 | Read `CLAUDE.md` + source code | Understand architecture, tech stack, patterns |
109
+ | 3 | Investigate related files & data flow | Identify affected areas, dependencies |
110
+ | 4 | Ask clarifying questions (one at a time) | Ensure full understanding |
111
+ | 5 | Write `plan/[ticket-id]/requirement.md` | Structured requirement document |
112
+
113
+ **AI asks questions when:**
114
+ - Business requirements are vague or ambiguous
115
+ - Acceptance criteria are not measurable
116
+ - Edge cases are discovered in source code
117
+ - Multiple approaches are possible and need input
118
+ - Impact on existing features is unclear
119
+
120
+ **Requirement Document Output (`plan/[ticket-id]/requirement.md`):**
121
+
122
+ ```
123
+ ├── 1. Requirements Summary
124
+ │ ├── Description (AI's understanding in technical language)
125
+ ├── Current behavior / Business goal
126
+ │ ├── Acceptance Criteria (refined, measurable)
127
+ │ └── Context & Constraints
128
+ ├── 2. Source Code Analysis
129
+ │ ├── Related files & their roles
130
+ │ ├── Data flow diagram
131
+ │ ├── Existing patterns to follow
132
+ │ └── Current test coverage
133
+ ├── 3. Proposed Solution & Approach
134
+ │ ├── Option A (recommended) — pros/cons
135
+ │ ├── Option B (alternative) pros/cons
136
+ │ ├── Chosen approach & rationale
137
+ │ ├── Files to create/modify
138
+ │ └── Database changes (if any)
139
+ ├── 4. Impact Analysis
140
+ │ ├── Impact level (Low/Medium/High)
141
+ │ ├── Affected areas
142
+ │ ├── Breaking changes
143
+ │ └── Risks & mitigations
144
+ ├── 5. Effort Estimate
145
+ │ ├── Task breakdown with size (S/M/L/XL)
146
+ │ └── Sub-task split for XL tasks
147
+ └── 6. Testing Plan
148
+ ├── Unit tests
149
+ ├── Integration tests
150
+ └── Manual test cases
151
+ ```
152
+
153
+ **Gate 1 Display:**
154
+
155
+ ```
156
+ ⏸️ GATE 1: REQUIREMENT DOCUMENT READY
157
+
158
+ Summary:
159
+ - Type: [feature / bug-fix / refactor]
160
+ - Impact: [Low / Medium / High]
161
+ - Estimate: [S / M / L / XL]
162
+ - Approach: [brief description]
163
+ - Files affected: [N] files
164
+
165
+ Review: plan/[ticket-id]/requirement.md
166
+ → Type APPROVED to proceed
167
+ Or provide feedback to update
168
+ ```
169
+
170
+ **Gate 1 Output:**
171
+ - `plan/[ticket-id]/requirement.md` approved by DEV
172
+ - DEV has typed "APPROVED"
173
+
174
+ ---
175
+
176
+ ### ⛩️ GATE 2 — Implementation Plan
177
+
178
+ **Who performs:** AI (create plan) + DEV (review & approve)
179
+
180
+ **What AI does:**
181
+
182
+ 1. Read the approved requirement document
183
+ 2. **Invoke** `superpowers:writing-plans` → create detailed implementation plan
184
+ 3. Break down into TDD tasks: test first implement → verify
185
+ 4. Define commit strategy (small, focused commits)
186
+ 5. Present plan and wait for APPROVED
187
+
188
+ **Implementation Plan Structure:**
189
+
190
+ ```
191
+ ├── Task Breakdown (TDD Order)
192
+ │ ├── Task 1: Write test for [scenario]
193
+ │ ├── Task 2: Implement [component]
194
+ │ ├── Task 3: Write test for [next scenario]
195
+ │ └── ...
196
+ ├── Commit Strategy
197
+ └── Test Commands
198
+ ```
199
+
200
+ **Gate 2 Display:**
201
+
202
+ ```
203
+ ⏸️ GATE 2: IMPLEMENTATION PLAN READY
204
+
205
+ Tasks: [N] | Commits: [N] | Test-first tasks: [N]
206
+
207
+ Type APPROVED to start coding
208
+ Or provide feedback to adjust
209
+ ```
210
+
211
+ **Gate 2 Output:**
212
+ - Implementation plan approved by DEV
213
+ - DEV has typed "APPROVED"
214
+
215
+ ---
216
+
217
+ ### ⛩️ GATE 3 Code Generation
218
+
219
+ **Who performs:** AI
220
+
221
+ **Only runs after Gate 2 APPROVED.**
222
+
223
+ **Mandatory Order:**
224
+
225
+ #### Feature task:
226
+ 1. Complex feature (3+ files) → `superpowers:subagent-driven-development`
227
+ 2. `superpowers:test-driven-development` write tests FIRST
228
+ 3. Run tests → confirm FAIL
229
+ 4. Implement code tests PASS
230
+ 5. Commit each small step
231
+
232
+ #### Bug fix task (extra):
233
+ 1. `superpowers:systematic-debugging` trace root cause, NO guessing
234
+ 2. `investigate-bug` skill — trace Controller→Service→Repository
235
+ 3. Then TDD: write test to reproduce bug → fix → tests PASS
236
+
237
+ #### Refactor task (extra):
238
+ 1. Ensure tests cover current behavior
239
+ 2. Refactor in small steps — keep tests green continuously
240
+
241
+ **Gate 3 Output:**
242
+ - Code implementation finished
243
+ - All tests PASS
244
+ - Committed
245
+
246
+ ---
247
+
248
+ ### ⛩️ GATE 4 — AI Self-Review
249
+
250
+ **Who performs:** AI (self-review) + DEV (final approve)
251
+
252
+ **AI runs in mandatory order:**
253
+
254
+ | Step | Action | Required Result |
255
+ |------|--------|------------|
256
+ | 1 | `superpowers:verification-before-completion` | All tests PASS |
257
+ | 2 | `impact-analysis` skill | No breaking changes outside scope |
258
+ | 3 | `custom/rules/review-checklist.md` | All items ticked |
259
+ | 4 | Create `plan/[ticket-id]/summary.md` | File exists and is complete |
260
+
261
+ **If any step fails → AI fixes it first, without showing DEV.**
262
+
263
+ **Summary report output:**
264
+
265
+ ```
266
+ plan/[ticket-id]/summary.md
267
+ ├── List of changed files + reasons
268
+ ├── Acceptance Criteriaresults (Done/Not Done)
269
+ ├── Tests: quantity, coverage
270
+ ├── Impact Analysis: level (Low/Medium/High)
271
+ └── Review Checklist: N/N items ✅
272
+ ```
273
+
274
+ **Gate 4 Display:**
275
+ ```
276
+ ⏸️ GATE 4: WAITING FOR DEV REVIEW
277
+
278
+ Tests: ✅ [N] passed
279
+ Impact: [Low/Medium/High]
280
+ Checklist: [N/N] ✅
281
+ Summary: plan/[ticket-id]/summary.md
282
+
283
+ Type APPROVED if OK
284
+ Type BUG: [description] if there are issues
285
+ ```
286
+
287
+ **DEV Response:**
288
+ - `APPROVED` move to Gate 5
289
+ - `BUG: coding bug` → AI fixes → repeat Gate 4
290
+ - `BUG: requirement bug` → AI updates requirement doc → back to Gate 1
291
+
292
+ **Gate 4 Output:**
293
+ - `plan/[ticket-id]/summary.md` completed
294
+ - DEV has typed "APPROVED"
295
+
296
+ ---
297
+
298
+ ### ⛩️ GATE 5 — Peer Review & Pull Request
299
+
300
+ **Who performs:** DEV + Peer reviewer
301
+
302
+ **Only runs after Gate 4 APPROVED.**
303
+
304
+ **AI invokes:** `superpowers:requesting-code-review`
305
+
306
+ **AI guides PR creation:**
307
+
308
+ ```markdown
309
+ ## Pull Request Template
310
+
311
+ **Title:** [feat/fix/refactor]: [PROJ-XX] [Short description]
312
+
313
+ **Description:**
314
+ Closes [PROJ-XX]
315
+
316
+ ### Changes
317
+ - [File A] [what changed]
318
+ - [File B] — [what changed]
319
+
320
+ ### Acceptance Criteria
321
+ - [x] [Criteria 1]
322
+ - [x] [Criteria 2]
323
+
324
+ ### Testing
325
+ - Unit tests: [N] cases
326
+ - Integration tests: [N] cases
327
+ - Manual test: [tested manually?]
328
+
329
+ ### Impact
330
+ [Low/Medium/High] — [short description]
331
+
332
+ ### Reviewer notes
333
+ [Anything special for the reviewer to notice]
334
+ ```
335
+
336
+ **Peer reviewer checks:**
337
+ - Code logic matches requirement document
338
+ - Tests are sufficient and meaningful
339
+ - No security issues
340
+ - Acceptable performance
341
+ - Follows team conventions
342
+
343
+ **Gate 5 Output:**
344
+ - PR created with full description
345
+ - Peer reviewer APPROVED
346
+ - Merged into main/develop
347
+
348
+ ---
349
+
350
+ ## Workflow by Task Type
351
+
352
+ ### Bug Fix
353
+ ```
354
+ Gate 1 (AI analyzes bug: root cause hypothesis + solution + impact + estimate)
355
+ → Gate 2 (implementation plan: test reproduce bug → fix → verify)
356
+ Gate 3 (systematic-debugging + investigate-bug + TDD fix)
357
+ → Gate 4 (verify fix + no regression)
358
+ Gate 5 (peer review + PR)
359
+ ```
360
+
361
+ ### Feature
362
+ ```
363
+ Gate 1 (AI analyzes feature: architecture + solution options + impact + estimate)
364
+ → Gate 2 (implementation plan: TDD task breakdown)
365
+ Gate 3 (TDD: test first, implement, subagent if complex)
366
+ → Gate 4 (verify all AC done + impact check)
367
+ Gate 5 (peer review + PR)
368
+ ```
369
+
370
+ ### Investigation
371
+ ```
372
+ Gate 1 (AI investigates: analyze scope, trace code, document findings + recommendations)
373
+ → DEV reviews → APPROVED
374
+ DONE (no Gates 2-5, create new ticket if action needed)
375
+ ```
376
+
377
+ ### Refactor
378
+ ```
379
+ Gate 1 (AI analyzes: current state, target state, impact + estimate)
380
+ Gate 2 (implementation plan: ensure tests cover behavior → refactor steps)
381
+ Gate 3 (TDD: cover behavior refactor tests green)
382
+ Gate 4 (verify no regressions)
383
+ Gate 5 (peer review + PR)
384
+ ```
385
+
386
+ ### Impact Analysis
387
+ ```
388
+ Gate 1 (AI analyzes: dependency map, risk level, breaking changes, recommendations)
389
+ → DEV reviews → APPROVED
390
+ → DONE (no Gates 2-5, implementation needs a separate ticket)
391
+ ```
392
+
393
+ ---
394
+
395
+ ## Skills Used in Workflow
396
+
397
+ | Skill | Gate | Purpose |
398
+ |-------|------|---------|
399
+ | `read-study-requirement` | Gate 1 | AI reads, analyzes, asks questions, outputs requirement doc |
400
+ | `superpowers:systematic-debugging` | Gate 1 (bug) | Trace root cause hypothesis |
401
+ | `generate-spec` | Gate 2 | Create implementation plan |
402
+ | `superpowers:writing-plans` | Gate 2 | Detailed TDD task breakdown |
403
+ | `investigate-bug` | Gate 3 (bug) | Trace data flow per framework |
404
+ | `superpowers:test-driven-development` | Gate 3 | TDD workflow |
405
+ | `superpowers:subagent-driven-development` | Gate 3 (complex) | Parallel implementation |
406
+ | `review-plan` | Gate 4 | Orchestrate self-review |
407
+ | `superpowers:verification-before-completion` | Gate 4 | Verify tests pass |
408
+ | `impact-analysis` | Gate 4 | Check breaking changes |
409
+ | `superpowers:requesting-code-review` | Gate 5 | Peer review workflow |
410
+
411
+ ---
412
+
413
+ ## Commands Reference
414
+
415
+ ```bash
416
+ # Setup (once per project)
417
+ aiflow init --framework spring-boot --adapter backlog
418
+
419
+ # Per task (2 commands only)
420
+ aiflow use PROJ-33 # load ticket context (full analysis)
421
+ aiflow use PROJ-33 --fast # fast mode: lite Gate 1 (< 5 min)
422
+ aiflow use PROJ-33 --full # force full Gate 1 analysis
423
+ claude # AI auto-starts Gate 1
424
+
425
+ # Optional: generate prompt for Claude Desktop/Web
426
+ aiflow prompt bug-fix # generate prompt to paste
427
+ aiflow prompt feature --output p.md # save prompt to file
428
+
429
+ # Task switching (multiple tasks in same repo)
430
+ aiflow task status # view active + pending tasks
431
+ aiflow task pause # pause current task
432
+ aiflow task pause --note "waiting for PM"
433
+ aiflow task switch PROJ-99 # pause current + switch
434
+ aiflow task resume PROJ-33 # resume a paused task
435
+
436
+ # Utilities
437
+ aiflow context show # view active context
438
+ aiflow memory save "key" "value" # save team knowledge
439
+ aiflow doctor # health check
440
+ aiflow guide # view quickstart guide
441
+
442
+ # Telemetry (team leads)
443
+ aiflow telemetry status # view status
444
+ aiflow telemetry enable # setup tracking
445
+ aiflow telemetry disable # disable tracking
446
+ ```
447
+
448
+ ---
449
+
450
+ ## Multi-AI Environment Setup
451
+
452
+ 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.
453
+
454
+ ### How to Switch Tools
455
+ 1. **Analyze (Gate 1)** using Claude Code CLI (great for deep codebase scans).
456
+ 2. **Review** the `requirement.md` file.
457
+ 3. **Open Cursor** to perform the coding (Gate 3).
458
+ 4. Cursor will automatically read `.cursorrules`, detect the active ticket, and see that Gate 1 is already finished.
459
+ 5. Cursor will proceed to Gate 2 or 3 as appropriate.
460
+
461
+ ### Instruction Files Created
462
+ | Tool | File Name | Purpose |
463
+ |------|-----------|---------|
464
+ | Claude Code | `CLAUDE.md` | Primary rules for the CLI tool. |
465
+ | Cursor AI | `.cursorrules` | Project-wide rules for Cursor. |
466
+ | Gemini CLI | `GEMINI.md` | Context for Gemini sessions. |
467
+ | Copilot | `.github/copilot-instructions.md` | Custom instructions for Copilot. |
468
+
469
+ ---
470
+
471
+ ## FAQ
472
+
473
+ **Q: PM didn't write enough on the ticket, what happens?**
474
+ 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.
475
+
476
+ **Q: Does AI just check format or actually understand the requirement?**
477
+ 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.
478
+
479
+ **Q: Gate 1 is taking too long for a simple ticket. What can I do?**
480
+ A: Use `aiflow use TICKET-ID --fast` before opening Claude. Fast mode skips the Q&A loop and outputs a lean 3-section requirement doc. Best suited for tickets with ≥ 3 clear, measurable acceptance criteria and no ambiguity. Target: Gate 1 done in < 5 minutes.
481
+
482
+ **Q: Can I skip Gate 2 for simple tasks?**
483
+ A: No. Gate 2 can be brief (simple plan), but DEV must still type "APPROVED" to confirm the approach.
484
+
485
+ **Q: AI reports test failures at Gate 4, what to do?**
486
+ 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.
487
+
488
+ **Q: What's the difference between a requirement bug and a coding bug?**
489
+ A: Requirement bug = wrong/missing in requirement doc → back to Gate 1. Coding bug = wrong code but correct requirement → fix at Gate 4.
490
+
491
+ **Q: Who performs peer review (Gate 5)?**
492
+ A: Another developer in the team. Not the code author. The reviewer uses the `superpowers:receiving-code-review` skill.
493
+
494
+ **Q: Can I work on two tasks in the same repo at the same time?**
495
+ A: Yes. Use `aiflow task pause` to save your current progress, then `aiflow use <new-ticket>` to start the new task. Resume later with `aiflow task resume <ticket-id>`. The gate progress is saved automatically — Claude will resume from the correct gate instead of restarting Gate 1.
496
+
497
+ **Q: If I resume a task, will Claude know which gate to start at?**
498
+ A: Yes. The SessionStart hook reads `.aiflow/tasks/<taskId>/task-state.json` and injects gate-aware instructions. If Gate 1 was already approved, Claude will skip to Gate 2, and so on.
499
+
500
+ **Q: How does AI estimate effort?**
501
+ 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).