@relipa/ai-flow-kit 0.1.1 → 0.1.2-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.
Files changed (253) hide show
  1. package/README.md +0 -0
  2. package/bin/aiflow.js +55 -2
  3. package/bin/ak.js +0 -0
  4. package/custom/mcp-presets/README.md +204 -237
  5. package/custom/mcp-presets/backlog.json +0 -0
  6. package/custom/mcp-presets/figma-desktop.json +0 -0
  7. package/custom/mcp-presets/figma.json +0 -0
  8. package/custom/mcp-presets/gitnexus.json +0 -0
  9. package/custom/mcp-presets/google-sheets.json +0 -0
  10. package/custom/mcp-presets/jira.json +0 -0
  11. package/custom/prompts/bug-fix.md +0 -0
  12. package/custom/prompts/feature.md +0 -0
  13. package/custom/prompts/investigation.md +0 -0
  14. package/custom/rules/code-style.md +0 -0
  15. package/custom/rules/java/code-style.md +0 -0
  16. package/custom/rules/java/naming.md +0 -0
  17. package/custom/rules/java/review-checklist.md +0 -0
  18. package/custom/rules/java/spring-boot-examples.md +0 -0
  19. package/custom/rules/javascript/code-style.md +0 -0
  20. package/custom/rules/javascript/naming.md +0 -0
  21. package/custom/rules/ml-conventions.md +88 -0
  22. package/custom/rules/ml-review-checklist.md +14 -0
  23. package/custom/rules/naming.md +0 -0
  24. package/custom/rules/php/code-style.md +0 -0
  25. package/custom/rules/php/naming.md +0 -0
  26. package/custom/rules/project-conventions.md +0 -0
  27. package/custom/rules/review-checklist.md +0 -0
  28. package/custom/skills/deploy-model/SKILL.md +90 -0
  29. package/custom/skills/design-experiment/SKILL.md +88 -0
  30. package/custom/skills/evaluate-model/SKILL.md +93 -0
  31. package/custom/skills/explore-data/SKILL.md +87 -0
  32. package/custom/skills/figma-to-component/SKILL.md +0 -0
  33. package/custom/skills/frame-ml-problem/SKILL.md +88 -0
  34. package/custom/skills/generate-spec/SKILL.md +0 -0
  35. package/custom/skills/impact-analysis/SKILL.md +0 -0
  36. package/custom/skills/improve-algorithm/SKILL.md +74 -0
  37. package/custom/skills/investigate-bug/SKILL.md +0 -0
  38. package/custom/skills/read-study-requirement/SKILL.md +0 -0
  39. package/custom/skills/report-customer/SKILL.md +0 -0
  40. package/custom/skills/review-plan/SKILL.md +0 -0
  41. package/custom/skills/train-model/SKILL.md +78 -0
  42. package/custom/templates/laravel.md +0 -0
  43. package/custom/templates/nestjs.md +0 -0
  44. package/custom/templates/nextjs.md +0 -0
  45. package/custom/templates/nodejs-express.md +0 -0
  46. package/custom/templates/php-plain.md +0 -0
  47. package/custom/templates/php.md +0 -0
  48. package/custom/templates/python-django.md +0 -0
  49. package/custom/templates/python-fastapi.md +0 -0
  50. package/custom/templates/python-ml.md +273 -0
  51. package/custom/templates/python.md +0 -0
  52. package/custom/templates/reactjs.md +0 -0
  53. package/custom/templates/shared/gate-workflow.md +0 -0
  54. package/custom/templates/shared/ml-gate-workflow.md +103 -0
  55. package/custom/templates/spring-boot.md +0 -0
  56. package/custom/templates/tools/claude.md +0 -0
  57. package/custom/templates/tools/copilot.md +0 -0
  58. package/custom/templates/tools/cursor.md +0 -0
  59. package/custom/templates/tools/gemini.md +0 -0
  60. package/custom/templates/tools/generic.md +0 -0
  61. package/custom/templates/vue-nuxt.md +0 -0
  62. package/docs/common/AIFLOW.md +512 -512
  63. package/docs/common/CHANGELOG.md +0 -0
  64. package/docs/common/QUICK_START.md +0 -0
  65. package/docs/common/ai-integration.md +0 -0
  66. package/docs/common/cli-reference.md +0 -0
  67. package/docs/common/configuration.md +0 -0
  68. package/docs/common/getting-started.md +0 -0
  69. package/docs/common/troubleshooting.md +0 -0
  70. package/docs/common/workflows/bug-fix.md +0 -0
  71. package/docs/common/workflows/feature.md +0 -0
  72. package/docs/common/workflows/figma.md +0 -0
  73. package/docs/common/workflows/impact-analysis.md +0 -0
  74. package/docs/common/workflows/investigation.md +0 -0
  75. package/docs/common/workflows/refactor.md +0 -0
  76. package/docs/project/ARCHITECTURE.md +0 -0
  77. package/index.js +0 -0
  78. package/package.json +1 -1
  79. package/scripts/checkpoint.js +0 -0
  80. package/scripts/config.js +0 -0
  81. package/scripts/context.js +0 -0
  82. package/scripts/create-score-excel.js +0 -0
  83. package/scripts/detect.js +239 -239
  84. package/scripts/doctor.js +192 -218
  85. package/scripts/gitnexus-worker.js +0 -0
  86. package/scripts/guide.js +0 -0
  87. package/scripts/hooks/block-git-write.js +0 -0
  88. package/scripts/hooks/session-start.js +0 -0
  89. package/scripts/hooks/session-stop.js +0 -0
  90. package/scripts/init.js +1112 -1009
  91. package/scripts/link-resolver.js +0 -0
  92. package/scripts/memory.js +0 -0
  93. package/scripts/prompt.js +538 -538
  94. package/scripts/remove.js +0 -0
  95. package/scripts/task.js +546 -546
  96. package/scripts/telemetry/cli.js +0 -0
  97. package/scripts/telemetry/config.js +0 -0
  98. package/scripts/telemetry/crypto.js +0 -0
  99. package/scripts/telemetry/flush.js +0 -0
  100. package/scripts/telemetry/record.js +0 -0
  101. package/scripts/update.js +10 -7
  102. package/scripts/use.js +33 -12
  103. package/scripts/validate.js +0 -0
  104. package/upstream/.claude-plugin/marketplace.json +0 -0
  105. package/upstream/.claude-plugin/plugin.json +0 -0
  106. package/upstream/.codex/INSTALL.md +0 -0
  107. package/upstream/.cursor-plugin/plugin.json +0 -0
  108. package/upstream/.gitattributes +0 -0
  109. package/upstream/.github/FUNDING.yml +0 -0
  110. package/upstream/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  111. package/upstream/.github/ISSUE_TEMPLATE/config.yml +0 -0
  112. package/upstream/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  113. package/upstream/.github/ISSUE_TEMPLATE/platform_support.md +0 -0
  114. package/upstream/.github/PULL_REQUEST_TEMPLATE.md +0 -0
  115. package/upstream/.opencode/INSTALL.md +0 -0
  116. package/upstream/.opencode/plugins/superpowers.js +0 -0
  117. package/upstream/.version-bump.json +0 -0
  118. package/upstream/AGENTS.md +0 -0
  119. package/upstream/CHANGELOG.md +0 -0
  120. package/upstream/CLAUDE.md +0 -0
  121. package/upstream/CODE_OF_CONDUCT.md +0 -0
  122. package/upstream/GEMINI.md +0 -0
  123. package/upstream/LICENSE +0 -0
  124. package/upstream/README.md +0 -0
  125. package/upstream/RELEASE-NOTES.md +0 -0
  126. package/upstream/agents/code-reviewer.md +0 -0
  127. package/upstream/commands/brainstorm.md +0 -0
  128. package/upstream/commands/execute-plan.md +0 -0
  129. package/upstream/commands/write-plan.md +0 -0
  130. package/upstream/docs/README.codex.md +0 -0
  131. package/upstream/docs/README.opencode.md +0 -0
  132. package/upstream/docs/plans/2025-11-22-opencode-support-design.md +0 -0
  133. package/upstream/docs/plans/2025-11-22-opencode-support-implementation.md +0 -0
  134. package/upstream/docs/plans/2025-11-28-skills-improvements-from-user-feedback.md +0 -0
  135. package/upstream/docs/plans/2026-01-17-visual-brainstorming.md +0 -0
  136. package/upstream/docs/superpowers/plans/2026-01-22-document-review-system.md +0 -0
  137. package/upstream/docs/superpowers/plans/2026-02-19-visual-brainstorming-refactor.md +0 -0
  138. package/upstream/docs/superpowers/plans/2026-03-11-zero-dep-brainstorm-server.md +0 -0
  139. package/upstream/docs/superpowers/plans/2026-03-23-codex-app-compatibility.md +0 -0
  140. package/upstream/docs/superpowers/specs/2026-01-22-document-review-system-design.md +0 -0
  141. package/upstream/docs/superpowers/specs/2026-02-19-visual-brainstorming-refactor-design.md +0 -0
  142. package/upstream/docs/superpowers/specs/2026-03-11-zero-dep-brainstorm-server-design.md +0 -0
  143. package/upstream/docs/superpowers/specs/2026-03-23-codex-app-compatibility-design.md +0 -0
  144. package/upstream/docs/testing.md +0 -0
  145. package/upstream/docs/windows/polyglot-hooks.md +0 -0
  146. package/upstream/gemini-extension.json +0 -0
  147. package/upstream/hooks/hooks-cursor.json +0 -0
  148. package/upstream/hooks/hooks.json +0 -0
  149. package/upstream/hooks/run-hook.cmd +0 -0
  150. package/upstream/hooks/session-start +0 -0
  151. package/upstream/package.json +0 -0
  152. package/upstream/scripts/bump-version.sh +0 -0
  153. package/upstream/skills/brainstorming/SKILL.md +0 -0
  154. package/upstream/skills/brainstorming/scripts/frame-template.html +0 -0
  155. package/upstream/skills/brainstorming/scripts/helper.js +0 -0
  156. package/upstream/skills/brainstorming/scripts/server.cjs +0 -0
  157. package/upstream/skills/brainstorming/scripts/start-server.sh +0 -0
  158. package/upstream/skills/brainstorming/scripts/stop-server.sh +0 -0
  159. package/upstream/skills/brainstorming/spec-document-reviewer-prompt.md +0 -0
  160. package/upstream/skills/brainstorming/visual-companion.md +0 -0
  161. package/upstream/skills/dispatching-parallel-agents/SKILL.md +0 -0
  162. package/upstream/skills/executing-plans/SKILL.md +0 -0
  163. package/upstream/skills/finishing-a-development-branch/SKILL.md +0 -0
  164. package/upstream/skills/receiving-code-review/SKILL.md +0 -0
  165. package/upstream/skills/requesting-code-review/SKILL.md +0 -0
  166. package/upstream/skills/requesting-code-review/code-reviewer.md +0 -0
  167. package/upstream/skills/subagent-driven-development/SKILL.md +0 -0
  168. package/upstream/skills/subagent-driven-development/code-quality-reviewer-prompt.md +0 -0
  169. package/upstream/skills/subagent-driven-development/implementer-prompt.md +0 -0
  170. package/upstream/skills/subagent-driven-development/spec-reviewer-prompt.md +0 -0
  171. package/upstream/skills/systematic-debugging/CREATION-LOG.md +0 -0
  172. package/upstream/skills/systematic-debugging/SKILL.md +0 -0
  173. package/upstream/skills/systematic-debugging/condition-based-waiting-example.ts +0 -0
  174. package/upstream/skills/systematic-debugging/condition-based-waiting.md +0 -0
  175. package/upstream/skills/systematic-debugging/defense-in-depth.md +0 -0
  176. package/upstream/skills/systematic-debugging/find-polluter.sh +0 -0
  177. package/upstream/skills/systematic-debugging/root-cause-tracing.md +0 -0
  178. package/upstream/skills/systematic-debugging/test-academic.md +0 -0
  179. package/upstream/skills/systematic-debugging/test-pressure-1.md +0 -0
  180. package/upstream/skills/systematic-debugging/test-pressure-2.md +0 -0
  181. package/upstream/skills/systematic-debugging/test-pressure-3.md +0 -0
  182. package/upstream/skills/tdd-lean/SKILL.md +0 -0
  183. package/upstream/skills/test-driven-development/SKILL.md +0 -0
  184. package/upstream/skills/test-driven-development/testing-anti-patterns.md +0 -0
  185. package/upstream/skills/using-git-worktrees/SKILL.md +0 -0
  186. package/upstream/skills/using-superpowers/SKILL.md +0 -0
  187. package/upstream/skills/using-superpowers/references/codex-tools.md +0 -0
  188. package/upstream/skills/using-superpowers/references/copilot-tools.md +0 -0
  189. package/upstream/skills/using-superpowers/references/gemini-tools.md +0 -0
  190. package/upstream/skills/verification-before-completion/SKILL.md +0 -0
  191. package/upstream/skills/writing-plans/SKILL.md +0 -0
  192. package/upstream/skills/writing-plans/plan-document-reviewer-prompt.md +0 -0
  193. package/upstream/skills/writing-skills/SKILL.md +0 -0
  194. package/upstream/skills/writing-skills/anthropic-best-practices.md +0 -0
  195. package/upstream/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +0 -0
  196. package/upstream/skills/writing-skills/graphviz-conventions.dot +0 -0
  197. package/upstream/skills/writing-skills/persuasion-principles.md +0 -0
  198. package/upstream/skills/writing-skills/render-graphs.js +0 -0
  199. package/upstream/skills/writing-skills/testing-skills-with-subagents.md +0 -0
  200. package/upstream/tests/brainstorm-server/package-lock.json +0 -0
  201. package/upstream/tests/brainstorm-server/package.json +0 -0
  202. package/upstream/tests/brainstorm-server/server.test.js +0 -0
  203. package/upstream/tests/brainstorm-server/windows-lifecycle.test.sh +0 -0
  204. package/upstream/tests/brainstorm-server/ws-protocol.test.js +0 -0
  205. package/upstream/tests/claude-code/README.md +0 -0
  206. package/upstream/tests/claude-code/analyze-token-usage.py +0 -0
  207. package/upstream/tests/claude-code/run-skill-tests.sh +0 -0
  208. package/upstream/tests/claude-code/test-document-review-system.sh +0 -0
  209. package/upstream/tests/claude-code/test-helpers.sh +0 -0
  210. package/upstream/tests/claude-code/test-subagent-driven-development-integration.sh +0 -0
  211. package/upstream/tests/claude-code/test-subagent-driven-development.sh +0 -0
  212. package/upstream/tests/explicit-skill-requests/prompts/action-oriented.txt +0 -0
  213. package/upstream/tests/explicit-skill-requests/prompts/after-planning-flow.txt +0 -0
  214. package/upstream/tests/explicit-skill-requests/prompts/claude-suggested-it.txt +0 -0
  215. package/upstream/tests/explicit-skill-requests/prompts/i-know-what-sdd-means.txt +0 -0
  216. package/upstream/tests/explicit-skill-requests/prompts/mid-conversation-execute-plan.txt +0 -0
  217. package/upstream/tests/explicit-skill-requests/prompts/please-use-brainstorming.txt +0 -0
  218. package/upstream/tests/explicit-skill-requests/prompts/skip-formalities.txt +0 -0
  219. package/upstream/tests/explicit-skill-requests/prompts/subagent-driven-development-please.txt +0 -0
  220. package/upstream/tests/explicit-skill-requests/prompts/use-systematic-debugging.txt +0 -0
  221. package/upstream/tests/explicit-skill-requests/run-all.sh +0 -0
  222. package/upstream/tests/explicit-skill-requests/run-claude-describes-sdd.sh +0 -0
  223. package/upstream/tests/explicit-skill-requests/run-extended-multiturn-test.sh +0 -0
  224. package/upstream/tests/explicit-skill-requests/run-haiku-test.sh +0 -0
  225. package/upstream/tests/explicit-skill-requests/run-multiturn-test.sh +0 -0
  226. package/upstream/tests/explicit-skill-requests/run-test.sh +0 -0
  227. package/upstream/tests/opencode/run-tests.sh +0 -0
  228. package/upstream/tests/opencode/setup.sh +0 -0
  229. package/upstream/tests/opencode/test-plugin-loading.sh +0 -0
  230. package/upstream/tests/opencode/test-priority.sh +0 -0
  231. package/upstream/tests/opencode/test-tools.sh +0 -0
  232. package/upstream/tests/skill-triggering/prompts/dispatching-parallel-agents.txt +0 -0
  233. package/upstream/tests/skill-triggering/prompts/executing-plans.txt +0 -0
  234. package/upstream/tests/skill-triggering/prompts/requesting-code-review.txt +0 -0
  235. package/upstream/tests/skill-triggering/prompts/systematic-debugging.txt +0 -0
  236. package/upstream/tests/skill-triggering/prompts/test-driven-development.txt +0 -0
  237. package/upstream/tests/skill-triggering/prompts/writing-plans.txt +0 -0
  238. package/upstream/tests/skill-triggering/run-all.sh +0 -0
  239. package/upstream/tests/skill-triggering/run-test.sh +0 -0
  240. package/upstream/tests/subagent-driven-dev/go-fractals/design.md +0 -0
  241. package/upstream/tests/subagent-driven-dev/go-fractals/plan.md +0 -0
  242. package/upstream/tests/subagent-driven-dev/go-fractals/scaffold.sh +0 -0
  243. package/upstream/tests/subagent-driven-dev/run-test.sh +0 -0
  244. package/upstream/tests/subagent-driven-dev/svelte-todo/design.md +0 -0
  245. package/upstream/tests/subagent-driven-dev/svelte-todo/plan.md +0 -0
  246. package/upstream/tests/subagent-driven-dev/svelte-todo/scaffold.sh +0 -0
  247. package/custom/mcp-presets/playwright.json +0 -11
  248. package/custom/rules/test-patterns.md +0 -105
  249. package/custom/skills/automation-testing/SKILL.md +0 -168
  250. package/custom/skills/automation-testing/templates/BasePage.ts +0 -30
  251. package/custom/skills/automation-testing/templates/playwright.config.ts +0 -21
  252. package/custom/skills/automation-testing/templates/repos.json +0 -8
  253. package/scripts/score_members.js +0 -320
@@ -1,512 +1,512 @@
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
- Verify implementation works
32
- │ Code done
33
-
34
- ⛩️ GATE 4 — AI Self-Review [AI + DEV]
35
- AI runs: verification + impact-analysis + checklist
36
- AI generates: task-summary.md
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
- - **`aiflow task next`**: Approve the current gate, generate `task-summary.md`, clear active context, and prepare the task for a fresh session (Recommended to avoid context pollution).
69
-
70
- ### Pro-Tip: Fresh Session Workflow
71
- For the best AI performance, run `aiflow task next` after every gate approval, then open a **new chatbox** and type "continue". This clears out long chat history that might confuse the AI.
72
-
73
- ---
74
-
75
- ## Gate Details
76
-
77
- ---
78
-
79
- ### ⛩️ GATE 1 — AI Analyze Requirement
80
-
81
- **Who performs:** AI (analyze) + DEV (review & approve)
82
-
83
- **Trigger:**
84
- ```bash
85
- aiflow use PROJ-33 # load ticket (fast mode, default)
86
- aiflow use PROJ-33 --full # load ticket, force full analysis
87
- aiflow use --file task.md # load task from local text/json file
88
- claude # open Claude → AI auto-starts Gate 1
89
- ```
90
-
91
- > `aiflow prompt` is optional — use it only when pasting into Claude Desktop/Web.
92
- >
93
- > **Tool Support:**
94
- > - **Claude Code:** AI auto-starts Gate 1 via SessionStart hook.
95
- > - **Cursor:** Instructions in `.cursorrules` enforce the Gate Workflow.
96
- > - **Gemini CLI:** Rules in `GEMINI.md` guide the session.
97
- > - **Copilot:** Instructions in `.github/copilot-instructions.md`.
98
-
99
- **Gate 1 Modes:**
100
-
101
- | Mode | Flag | When to use | Output |
102
- |------|------|-------------|--------|
103
- | `fast` (default) | _(none)_ | Standard tickets, clear intent | Lite 3-section doc (Summary, Files, Estimate). Target < 5 min |
104
- | `full` | `--full` | Complex tickets, force deep analysis | Full 6-section requirement doc |
105
- | `auto` | _(legacy)_ | Same as fast | |
106
-
107
- **What AI does (in order):**
108
-
109
- | Step | Action | Purpose |
110
- |------|--------|---------|
111
- | 1 | Load ticket from `.aiflow/context/current.json` | Get PM's requirements, comments |
112
- | 2 | Read `CLAUDE.md` + source code | Understand architecture, tech stack, patterns |
113
- | 3 | Investigate related files & data flow | Identify affected areas, dependencies |
114
- | 4 | Ask clarifying questions (one at a time) | Ensure full understanding |
115
- | 5 | Write `plan/[ticket-id]/requirement.md` | Structured requirement document |
116
-
117
- **AI asks questions when:**
118
- - Business requirements are vague or ambiguous
119
- - Acceptance criteria are not measurable
120
- - Edge cases are discovered in source code
121
- - Multiple approaches are possible and need input
122
- - Impact on existing features is unclear
123
-
124
- **Requirement Document Output (`plan/[ticket-id]/requirement.md`):**
125
-
126
- ```
127
- ├── 1. Requirements Summary
128
- │ ├── Description (AI's understanding in technical language)
129
- │ ├── Current behavior / Business goal
130
- │ ├── Acceptance Criteria (refined, measurable)
131
- │ └── Context & Constraints
132
- ├── 2. Source Code Analysis
133
- │ ├── Related files & their roles
134
- │ ├── Data flow diagram
135
- │ ├── Existing patterns to follow
136
- │ └── Current test coverage
137
- ├── 3. Proposed Solution & Approach
138
- │ ├── Option A (recommended) — pros/cons
139
- │ ├── Option B (alternative) — pros/cons
140
- │ ├── Chosen approach & rationale
141
- │ ├── Files to create/modify
142
- │ └── Database changes (if any)
143
- ├── 4. Impact Analysis
144
- │ ├── Impact level (Low/Medium/High)
145
- │ ├── Affected areas
146
- │ ├── Breaking changes
147
- │ └── Risks & mitigations
148
- ├── 5. Effort Estimate
149
- │ ├── Task breakdown with size (S/M/L/XL)
150
- │ └── Sub-task split for XL tasks
151
- └── 6. Testing Plan
152
- ├── Unit tests
153
- ├── Integration tests
154
- └── Manual test cases
155
- ```
156
-
157
- **Gate 1 Display:**
158
-
159
- ```
160
- ⏸️ GATE 1: REQUIREMENT DOCUMENT READY
161
-
162
- Summary:
163
- - Type: [feature / bug-fix / refactor]
164
- - Impact: [Low / Medium / High]
165
- - Estimate: [S / M / L / XL]
166
- - Approach: [brief description]
167
- - Files affected: [N] files
168
-
169
- → Review: plan/[ticket-id]/requirement.md
170
- → Type APPROVED to proceed
171
- → Or provide feedback to update
172
- ```
173
-
174
- **Gate 1 Output:**
175
- - `plan/[ticket-id]/requirement.md` approved by DEV
176
- - DEV has typed "APPROVED"
177
-
178
- ---
179
-
180
- ### ⛩️ GATE 2 — Implementation Plan
181
-
182
- **Who performs:** AI (create plan) + DEV (review & approve)
183
-
184
- **What AI does:**
185
-
186
- 1. Read the approved requirement document
187
- 2. **Invoke** `superpowers:writing-plans` → create detailed implementation plan
188
- 3. Break down into TDD tasks: test first → implement → verify
189
- 4. Define verification strategy (evidence before claims)
190
- 5. Present plan and wait for APPROVED
191
-
192
- **Implementation Plan Structure:**
193
-
194
- ```
195
- ├── Task Breakdown (TDD Order)
196
- │ ├── Task 1: Write test for [scenario]
197
- │ ├── Task 2: Implement [component]
198
- │ ├── Task 3: Write test for [next scenario]
199
- │ └── ...
200
- └── Test Commands
201
- ```
202
-
203
- **Gate 2 Display:**
204
-
205
- ```
206
- ⏸️ GATE 2: IMPLEMENTATION PLAN READY
207
-
208
- Tasks: [N] | Verification: [N] | Test-first tasks: [N]
209
-
210
- → Type APPROVED to start coding
211
- → Or provide feedback to adjust
212
- ```
213
-
214
- **Gate 2 Output:**
215
- - Implementation plan approved by DEV
216
- - DEV has typed "APPROVED"
217
-
218
- ---
219
-
220
- ### ⛩️ GATE 3 — Code Generation
221
-
222
- **Who performs:** AI
223
-
224
- **Only runs after Gate 2 APPROVED.**
225
-
226
- **Mandatory Order:**
227
-
228
- #### Feature task:
229
- 1. Complex feature (3+ files) → `superpowers:subagent-driven-development`
230
- 2. `superpowers:test-driven-development` — write tests FIRST
231
- 3. Run tests → confirm FAIL
232
- 4. Implement code → tests PASS
233
- 5. Verify implementation works
234
-
235
- #### Bug fix task (extra):
236
- 1. `superpowers:systematic-debugging` — trace root cause, NO guessing
237
- 2. `investigate-bug` skill — trace Controller→Service→Repository
238
- 3. Then TDD: write test to reproduce bug → fix → tests PASS
239
-
240
- #### Refactor task (extra):
241
- 1. Ensure tests cover current behavior
242
- 2. Refactor in small steps — keep tests green continuously
243
-
244
- **Fast Mode (tdd-lean):**
245
- In fast mode, AI uses the `tdd-lean` skill instead of per-test TDD to save massive token costs:
246
- 1. **Batch Red:** Write ALL tests at once. Run once. (Confirm all fail).
247
- 2. **Batch Green:** Implement ALL code at once. Run once. (Confirm all pass).
248
- 3. **Discipline:** After every run, discard full stack traces and keep ONLY the summary line.
249
-
250
- **Gate 3 Output:**
251
- - Code implementation finished
252
- - All tests PASS
253
- - Verified (evidence provided)
254
-
255
- ---
256
-
257
- ### ⛩️ GATE 4 — AI Self-Review
258
-
259
- **Who performs:** AI (self-review) + DEV (final approve)
260
-
261
- **AI runs in mandatory order:**
262
-
263
- | Step | Action | Required Result |
264
- |------|--------|------------|
265
- | 1 | `superpowers:verification-before-completion` | All tests PASS |
266
- | 2 | `impact-analysis` skill | No breaking changes outside scope |
267
- | 3 | `custom/rules/review-checklist.md` | All items ticked |
268
- | 4 | Create `plan/[ticket-id]/summary.md` | File exists and is complete |
269
-
270
- **If any step fails → AI fixes it first, without showing DEV.**
271
-
272
- **Summary report output:**
273
-
274
- ```
275
- plan/[ticket-id]/summary.md
276
- ├── List of changed files + reasons
277
- ├── Acceptance Criteria → results (Done/Not Done)
278
- ├── Tests: quantity, coverage
279
- ├── Impact Analysis: level (Low/Medium/High)
280
- └── Review Checklist: N/N items ✅
281
- ```
282
-
283
- **Gate 4 Display:**
284
- ```
285
- ⏸️ GATE 4: WAITING FOR DEV REVIEW
286
-
287
- Tests: ✅ [N] passed
288
- Impact: [Low/Medium/High]
289
- Checklist: [N/N] ✅
290
- Summary: plan/[ticket-id]/summary.md
291
-
292
- Type APPROVED if OK
293
- Type BUG: [description] if there are issues
294
- ```
295
-
296
- **DEV Response:**
297
- - `APPROVED` → move to Gate 5
298
- - `BUG: coding bug` → AI fixes → repeat Gate 4
299
- - `BUG: requirement bug` → AI updates requirement doc → back to Gate 1
300
-
301
- **Gate 4 Output:**
302
- - `plan/[ticket-id]/summary.md` completed
303
- - DEV has typed "APPROVED"
304
-
305
- ---
306
-
307
- ### ⛩️ GATE 5 — Peer Review & Pull Request
308
-
309
- **Who performs:** DEV + Peer reviewer
310
-
311
- **Only runs after Gate 4 APPROVED.**
312
-
313
- **AI invokes:** `superpowers:requesting-code-review`
314
-
315
- **AI guides PR creation:**
316
-
317
- ```markdown
318
- ## Pull Request Template
319
-
320
- **Title:** [feat/fix/refactor]: [PROJ-XX] [Short description]
321
-
322
- **Description:**
323
- Closes [PROJ-XX]
324
-
325
- ### Changes
326
- - [File A] — [what changed]
327
- - [File B] — [what changed]
328
-
329
- ### Acceptance Criteria
330
- - [x] [Criteria 1]
331
- - [x] [Criteria 2]
332
-
333
- ### Testing
334
- - Unit tests: [N] cases
335
- - Integration tests: [N] cases
336
- - Manual test: [tested manually?]
337
-
338
- ### Impact
339
- [Low/Medium/High] — [short description]
340
-
341
- ### Reviewer notes
342
- [Anything special for the reviewer to notice]
343
- ```
344
-
345
- **Peer reviewer checks:**
346
- - Code logic matches requirement document
347
- - Tests are sufficient and meaningful
348
- - No security issues
349
- - Acceptable performance
350
- - Follows team conventions
351
-
352
- **Gate 5 Output:**
353
- - PR created with full description
354
- - Peer reviewer APPROVED
355
- - Merged into main/develop
356
-
357
- ---
358
-
359
- ## Workflow by Task Type
360
-
361
- ### Bug Fix
362
- ```
363
- Gate 1 (AI analyzes bug: root cause hypothesis + solution + impact + estimate)
364
- → Gate 2 (implementation plan: test reproduce bug → fix → verify)
365
- → Gate 3 (systematic-debugging + investigate-bug + TDD fix)
366
- → Gate 4 (verify fix + no regression)
367
- → Gate 5 (peer review + PR)
368
- ```
369
-
370
- ### Feature
371
- ```
372
- Gate 1 (AI analyzes feature: architecture + solution options + impact + estimate)
373
- → Gate 2 (implementation plan: TDD task breakdown)
374
- → Gate 3 (TDD: test first, implement, subagent if complex)
375
- → Gate 4 (verify all AC done + impact check)
376
- → Gate 5 (peer review + PR)
377
- ```
378
-
379
- ### Investigation
380
- ```
381
- Gate 1 (AI investigates: analyze scope, trace code, document findings + recommendations)
382
- → DEV reviews → APPROVED
383
- → DONE (no Gates 2-5, create new ticket if action needed)
384
- ```
385
-
386
- ### Refactor
387
- ```
388
- Gate 1 (AI analyzes: current state, target state, impact + estimate)
389
- → Gate 2 (implementation plan: ensure tests cover behavior → refactor steps)
390
- → Gate 3 (TDD: cover behavior → refactor → tests green)
391
- → Gate 4 (verify no regressions)
392
- → Gate 5 (peer review + PR)
393
- ```
394
-
395
- ### Impact Analysis
396
- ```
397
- Gate 1 (AI analyzes: dependency map, risk level, breaking changes, recommendations)
398
- → DEV reviews → APPROVED
399
- → DONE (no Gates 2-5, implementation needs a separate ticket)
400
- ```
401
-
402
- ---
403
-
404
- ## Skills Used in Workflow
405
-
406
- | Skill | Gate | Purpose |
407
- |-------|------|---------|
408
- | `read-study-requirement` | Gate 1 | AI reads, analyzes, asks questions, outputs requirement doc |
409
- | `superpowers:systematic-debugging` | Gate 1 (bug) | Trace root cause hypothesis |
410
- | `generate-spec` | Gate 2 | Create implementation plan |
411
- | `superpowers:writing-plans` | Gate 2 | Detailed TDD task breakdown |
412
- | `investigate-bug` | Gate 3 (bug) | Trace data flow per framework |
413
- | `superpowers:test-driven-development` | Gate 3 | TDD workflow |
414
- | `superpowers:subagent-driven-development` | Gate 3 (complex) | Parallel implementation |
415
- | `review-plan` | Gate 4 | Orchestrate self-review |
416
- | `superpowers:verification-before-completion` | Gate 4 | Verify tests pass |
417
- | `impact-analysis` | Gate 4 | Check breaking changes |
418
- | `superpowers:requesting-code-review` | Gate 5 | Peer review workflow |
419
-
420
- ---
421
-
422
- ## Commands Reference
423
-
424
- ```bash
425
- # Setup (once per project)
426
- aiflow init --framework spring-boot --adapter backlog
427
-
428
- # Per task (2 commands only)
429
- aiflow use PROJ-33 # load ticket context (full analysis)
430
- aiflow use PROJ-33 --fast # fast mode: lite Gate 1 (< 5 min)
431
- aiflow use PROJ-33 --full # force full Gate 1 analysis
432
- claude # AI auto-starts Gate 1
433
-
434
- # Optional: generate prompt for Claude Desktop/Web
435
- aiflow prompt bug-fix # generate prompt to paste
436
- aiflow prompt feature --output p.md # save prompt to file
437
-
438
- # Task switching (multiple tasks in same repo)
439
- aiflow task status # view active + pending tasks
440
- aiflow task pause # pause current task
441
- aiflow task pause --note "waiting for PM"
442
- aiflow task switch PROJ-99 # pause current + switch
443
- aiflow task resume PROJ-33 # resume a paused task
444
-
445
- # Utilities
446
- aiflow context show # view active context
447
- aiflow memory save "key" "value" # save team knowledge
448
- aiflow doctor # health check
449
- aiflow guide # view quickstart guide
450
-
451
- # Telemetry (team leads)
452
- aiflow telemetry status # view status
453
- aiflow telemetry enable # setup tracking
454
- aiflow telemetry disable # disable tracking
455
- ```
456
-
457
- ---
458
-
459
- ## Multi-AI Environment Setup
460
-
461
- 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.
462
-
463
- ### How to Switch Tools
464
- 1. **Analyze (Gate 1)** using Claude Code CLI (great for deep codebase scans).
465
- 2. **Review** the `requirement.md` file.
466
- 3. **Open Cursor** to perform the coding (Gate 3).
467
- 4. Cursor will automatically read `.cursorrules`, detect the active ticket, and see that Gate 1 is already finished.
468
- 5. Cursor will proceed to Gate 2 or 3 as appropriate.
469
-
470
- ### Instruction Files Created
471
- | Tool | File Name | Purpose |
472
- |------|-----------|---------|
473
- | Claude Code | `CLAUDE.md` | Primary rules for the CLI tool. |
474
- | Cursor AI | `.cursorrules` | Project-wide rules for Cursor. |
475
- | Gemini CLI | `GEMINI.md` | Context for Gemini sessions. |
476
- | Copilot | `.github/copilot-instructions.md` | Custom instructions for Copilot. |
477
-
478
- ---
479
-
480
- ## FAQ
481
-
482
- **Q: PM didn't write enough on the ticket, what happens?**
483
- 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.
484
-
485
- **Q: Does AI just check format or actually understand the requirement?**
486
- 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.
487
-
488
- **Q: Gate 1 is taking too long for a simple ticket. What can I do?**
489
- 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.
490
-
491
- **Q: Can I skip Gate 2 for simple tasks?**
492
- A: No. Gate 2 can be brief (simple plan), but DEV must still type "APPROVED" to confirm the approach.
493
-
494
- **Q: AI reports test failures at Gate 4, what to do?**
495
- 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.
496
-
497
- **Q: What's the difference between a requirement bug and a coding bug?**
498
- A: Requirement bug = wrong/missing in requirement doc → back to Gate 1. Coding bug = wrong code but correct requirement → fix at Gate 4.
499
-
500
- **Q: Who performs peer review (Gate 5)?**
501
- A: Another developer in the team. Not the code author. The reviewer uses the `superpowers:receiving-code-review` skill.
502
-
503
- **Q: Can I work on two tasks in the same repo at the same time?**
504
- 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.
505
-
506
- **Q: If I resume a task, will Claude know which gate to start at?**
507
- 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.
508
- **Q: Can I resume a Gate 3 (Code Generation) task in a new chatbox?**
509
- A: Yes. Gate 3 progress is saved via `[x]` checkboxes in `plan/[id]/plan.md`. If you open a new chatbox and say "continue", the AI will automatically skip completed tasks and pick up exactly where it left off.
510
-
511
- **Q: How does AI estimate effort?**
512
- 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
+ Verify implementation works
32
+ │ Code done
33
+
34
+ ⛩️ GATE 4 — AI Self-Review [AI + DEV]
35
+ AI runs: verification + impact-analysis + checklist
36
+ AI generates: task-summary.md
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
+ - **`aiflow task next`**: Approve the current gate, generate `task-summary.md`, clear active context, and prepare the task for a fresh session (Recommended to avoid context pollution).
69
+
70
+ ### Pro-Tip: Fresh Session Workflow
71
+ For the best AI performance, run `aiflow task next` after every gate approval, then open a **new chatbox** and type "continue". This clears out long chat history that might confuse the AI.
72
+
73
+ ---
74
+
75
+ ## Gate Details
76
+
77
+ ---
78
+
79
+ ### ⛩️ GATE 1 — AI Analyze Requirement
80
+
81
+ **Who performs:** AI (analyze) + DEV (review & approve)
82
+
83
+ **Trigger:**
84
+ ```bash
85
+ aiflow use PROJ-33 # load ticket (fast mode, default)
86
+ aiflow use PROJ-33 --full # load ticket, force full analysis
87
+ aiflow use --file task.md # load task from local text/json file
88
+ claude # open Claude → AI auto-starts Gate 1
89
+ ```
90
+
91
+ > `aiflow prompt` is optional — use it only when pasting into Claude Desktop/Web.
92
+ >
93
+ > **Tool Support:**
94
+ > - **Claude Code:** AI auto-starts Gate 1 via SessionStart hook.
95
+ > - **Cursor:** Instructions in `.cursorrules` enforce the Gate Workflow.
96
+ > - **Gemini CLI:** Rules in `GEMINI.md` guide the session.
97
+ > - **Copilot:** Instructions in `.github/copilot-instructions.md`.
98
+
99
+ **Gate 1 Modes:**
100
+
101
+ | Mode | Flag | When to use | Output |
102
+ |------|------|-------------|--------|
103
+ | `fast` (default) | _(none)_ | Standard tickets, clear intent | Lite 3-section doc (Summary, Files, Estimate). Target < 5 min |
104
+ | `full` | `--full` | Complex tickets, force deep analysis | Full 6-section requirement doc |
105
+ | `auto` | _(legacy)_ | Same as fast | |
106
+
107
+ **What AI does (in order):**
108
+
109
+ | Step | Action | Purpose |
110
+ |------|--------|---------|
111
+ | 1 | Load ticket from `.aiflow/context/current.json` | Get PM's requirements, comments |
112
+ | 2 | Read `CLAUDE.md` + source code | Understand architecture, tech stack, patterns |
113
+ | 3 | Investigate related files & data flow | Identify affected areas, dependencies |
114
+ | 4 | Ask clarifying questions (one at a time) | Ensure full understanding |
115
+ | 5 | Write `plan/[ticket-id]/requirement.md` | Structured requirement document |
116
+
117
+ **AI asks questions when:**
118
+ - Business requirements are vague or ambiguous
119
+ - Acceptance criteria are not measurable
120
+ - Edge cases are discovered in source code
121
+ - Multiple approaches are possible and need input
122
+ - Impact on existing features is unclear
123
+
124
+ **Requirement Document Output (`plan/[ticket-id]/requirement.md`):**
125
+
126
+ ```
127
+ ├── 1. Requirements Summary
128
+ │ ├── Description (AI's understanding in technical language)
129
+ │ ├── Current behavior / Business goal
130
+ │ ├── Acceptance Criteria (refined, measurable)
131
+ │ └── Context & Constraints
132
+ ├── 2. Source Code Analysis
133
+ │ ├── Related files & their roles
134
+ │ ├── Data flow diagram
135
+ │ ├── Existing patterns to follow
136
+ │ └── Current test coverage
137
+ ├── 3. Proposed Solution & Approach
138
+ │ ├── Option A (recommended) — pros/cons
139
+ │ ├── Option B (alternative) — pros/cons
140
+ │ ├── Chosen approach & rationale
141
+ │ ├── Files to create/modify
142
+ │ └── Database changes (if any)
143
+ ├── 4. Impact Analysis
144
+ │ ├── Impact level (Low/Medium/High)
145
+ │ ├── Affected areas
146
+ │ ├── Breaking changes
147
+ │ └── Risks & mitigations
148
+ ├── 5. Effort Estimate
149
+ │ ├── Task breakdown with size (S/M/L/XL)
150
+ │ └── Sub-task split for XL tasks
151
+ └── 6. Testing Plan
152
+ ├── Unit tests
153
+ ├── Integration tests
154
+ └── Manual test cases
155
+ ```
156
+
157
+ **Gate 1 Display:**
158
+
159
+ ```
160
+ ⏸️ GATE 1: REQUIREMENT DOCUMENT READY
161
+
162
+ Summary:
163
+ - Type: [feature / bug-fix / refactor]
164
+ - Impact: [Low / Medium / High]
165
+ - Estimate: [S / M / L / XL]
166
+ - Approach: [brief description]
167
+ - Files affected: [N] files
168
+
169
+ → Review: plan/[ticket-id]/requirement.md
170
+ → Type APPROVED to proceed
171
+ → Or provide feedback to update
172
+ ```
173
+
174
+ **Gate 1 Output:**
175
+ - `plan/[ticket-id]/requirement.md` approved by DEV
176
+ - DEV has typed "APPROVED"
177
+
178
+ ---
179
+
180
+ ### ⛩️ GATE 2 — Implementation Plan
181
+
182
+ **Who performs:** AI (create plan) + DEV (review & approve)
183
+
184
+ **What AI does:**
185
+
186
+ 1. Read the approved requirement document
187
+ 2. **Invoke** `superpowers:writing-plans` → create detailed implementation plan
188
+ 3. Break down into TDD tasks: test first → implement → verify
189
+ 4. Define verification strategy (evidence before claims)
190
+ 5. Present plan and wait for APPROVED
191
+
192
+ **Implementation Plan Structure:**
193
+
194
+ ```
195
+ ├── Task Breakdown (TDD Order)
196
+ │ ├── Task 1: Write test for [scenario]
197
+ │ ├── Task 2: Implement [component]
198
+ │ ├── Task 3: Write test for [next scenario]
199
+ │ └── ...
200
+ └── Test Commands
201
+ ```
202
+
203
+ **Gate 2 Display:**
204
+
205
+ ```
206
+ ⏸️ GATE 2: IMPLEMENTATION PLAN READY
207
+
208
+ Tasks: [N] | Verification: [N] | Test-first tasks: [N]
209
+
210
+ → Type APPROVED to start coding
211
+ → Or provide feedback to adjust
212
+ ```
213
+
214
+ **Gate 2 Output:**
215
+ - Implementation plan approved by DEV
216
+ - DEV has typed "APPROVED"
217
+
218
+ ---
219
+
220
+ ### ⛩️ GATE 3 — Code Generation
221
+
222
+ **Who performs:** AI
223
+
224
+ **Only runs after Gate 2 APPROVED.**
225
+
226
+ **Mandatory Order:**
227
+
228
+ #### Feature task:
229
+ 1. Complex feature (3+ files) → `superpowers:subagent-driven-development`
230
+ 2. `superpowers:test-driven-development` — write tests FIRST
231
+ 3. Run tests → confirm FAIL
232
+ 4. Implement code → tests PASS
233
+ 5. Verify implementation works
234
+
235
+ #### Bug fix task (extra):
236
+ 1. `superpowers:systematic-debugging` — trace root cause, NO guessing
237
+ 2. `investigate-bug` skill — trace Controller→Service→Repository
238
+ 3. Then TDD: write test to reproduce bug → fix → tests PASS
239
+
240
+ #### Refactor task (extra):
241
+ 1. Ensure tests cover current behavior
242
+ 2. Refactor in small steps — keep tests green continuously
243
+
244
+ **Fast Mode (tdd-lean):**
245
+ In fast mode, AI uses the `tdd-lean` skill instead of per-test TDD to save massive token costs:
246
+ 1. **Batch Red:** Write ALL tests at once. Run once. (Confirm all fail).
247
+ 2. **Batch Green:** Implement ALL code at once. Run once. (Confirm all pass).
248
+ 3. **Discipline:** After every run, discard full stack traces and keep ONLY the summary line.
249
+
250
+ **Gate 3 Output:**
251
+ - Code implementation finished
252
+ - All tests PASS
253
+ - Verified (evidence provided)
254
+
255
+ ---
256
+
257
+ ### ⛩️ GATE 4 — AI Self-Review
258
+
259
+ **Who performs:** AI (self-review) + DEV (final approve)
260
+
261
+ **AI runs in mandatory order:**
262
+
263
+ | Step | Action | Required Result |
264
+ |------|--------|------------|
265
+ | 1 | `superpowers:verification-before-completion` | All tests PASS |
266
+ | 2 | `impact-analysis` skill | No breaking changes outside scope |
267
+ | 3 | `custom/rules/review-checklist.md` | All items ticked |
268
+ | 4 | Create `plan/[ticket-id]/summary.md` | File exists and is complete |
269
+
270
+ **If any step fails → AI fixes it first, without showing DEV.**
271
+
272
+ **Summary report output:**
273
+
274
+ ```
275
+ plan/[ticket-id]/summary.md
276
+ ├── List of changed files + reasons
277
+ ├── Acceptance Criteria → results (Done/Not Done)
278
+ ├── Tests: quantity, coverage
279
+ ├── Impact Analysis: level (Low/Medium/High)
280
+ └── Review Checklist: N/N items ✅
281
+ ```
282
+
283
+ **Gate 4 Display:**
284
+ ```
285
+ ⏸️ GATE 4: WAITING FOR DEV REVIEW
286
+
287
+ Tests: ✅ [N] passed
288
+ Impact: [Low/Medium/High]
289
+ Checklist: [N/N] ✅
290
+ Summary: plan/[ticket-id]/summary.md
291
+
292
+ Type APPROVED if OK
293
+ Type BUG: [description] if there are issues
294
+ ```
295
+
296
+ **DEV Response:**
297
+ - `APPROVED` → move to Gate 5
298
+ - `BUG: coding bug` → AI fixes → repeat Gate 4
299
+ - `BUG: requirement bug` → AI updates requirement doc → back to Gate 1
300
+
301
+ **Gate 4 Output:**
302
+ - `plan/[ticket-id]/summary.md` completed
303
+ - DEV has typed "APPROVED"
304
+
305
+ ---
306
+
307
+ ### ⛩️ GATE 5 — Peer Review & Pull Request
308
+
309
+ **Who performs:** DEV + Peer reviewer
310
+
311
+ **Only runs after Gate 4 APPROVED.**
312
+
313
+ **AI invokes:** `superpowers:requesting-code-review`
314
+
315
+ **AI guides PR creation:**
316
+
317
+ ```markdown
318
+ ## Pull Request Template
319
+
320
+ **Title:** [feat/fix/refactor]: [PROJ-XX] [Short description]
321
+
322
+ **Description:**
323
+ Closes [PROJ-XX]
324
+
325
+ ### Changes
326
+ - [File A] — [what changed]
327
+ - [File B] — [what changed]
328
+
329
+ ### Acceptance Criteria
330
+ - [x] [Criteria 1]
331
+ - [x] [Criteria 2]
332
+
333
+ ### Testing
334
+ - Unit tests: [N] cases
335
+ - Integration tests: [N] cases
336
+ - Manual test: [tested manually?]
337
+
338
+ ### Impact
339
+ [Low/Medium/High] — [short description]
340
+
341
+ ### Reviewer notes
342
+ [Anything special for the reviewer to notice]
343
+ ```
344
+
345
+ **Peer reviewer checks:**
346
+ - Code logic matches requirement document
347
+ - Tests are sufficient and meaningful
348
+ - No security issues
349
+ - Acceptable performance
350
+ - Follows team conventions
351
+
352
+ **Gate 5 Output:**
353
+ - PR created with full description
354
+ - Peer reviewer APPROVED
355
+ - Merged into main/develop
356
+
357
+ ---
358
+
359
+ ## Workflow by Task Type
360
+
361
+ ### Bug Fix
362
+ ```
363
+ Gate 1 (AI analyzes bug: root cause hypothesis + solution + impact + estimate)
364
+ → Gate 2 (implementation plan: test reproduce bug → fix → verify)
365
+ → Gate 3 (systematic-debugging + investigate-bug + TDD fix)
366
+ → Gate 4 (verify fix + no regression)
367
+ → Gate 5 (peer review + PR)
368
+ ```
369
+
370
+ ### Feature
371
+ ```
372
+ Gate 1 (AI analyzes feature: architecture + solution options + impact + estimate)
373
+ → Gate 2 (implementation plan: TDD task breakdown)
374
+ → Gate 3 (TDD: test first, implement, subagent if complex)
375
+ → Gate 4 (verify all AC done + impact check)
376
+ → Gate 5 (peer review + PR)
377
+ ```
378
+
379
+ ### Investigation
380
+ ```
381
+ Gate 1 (AI investigates: analyze scope, trace code, document findings + recommendations)
382
+ → DEV reviews → APPROVED
383
+ → DONE (no Gates 2-5, create new ticket if action needed)
384
+ ```
385
+
386
+ ### Refactor
387
+ ```
388
+ Gate 1 (AI analyzes: current state, target state, impact + estimate)
389
+ → Gate 2 (implementation plan: ensure tests cover behavior → refactor steps)
390
+ → Gate 3 (TDD: cover behavior → refactor → tests green)
391
+ → Gate 4 (verify no regressions)
392
+ → Gate 5 (peer review + PR)
393
+ ```
394
+
395
+ ### Impact Analysis
396
+ ```
397
+ Gate 1 (AI analyzes: dependency map, risk level, breaking changes, recommendations)
398
+ → DEV reviews → APPROVED
399
+ → DONE (no Gates 2-5, implementation needs a separate ticket)
400
+ ```
401
+
402
+ ---
403
+
404
+ ## Skills Used in Workflow
405
+
406
+ | Skill | Gate | Purpose |
407
+ |-------|------|---------|
408
+ | `read-study-requirement` | Gate 1 | AI reads, analyzes, asks questions, outputs requirement doc |
409
+ | `superpowers:systematic-debugging` | Gate 1 (bug) | Trace root cause hypothesis |
410
+ | `generate-spec` | Gate 2 | Create implementation plan |
411
+ | `superpowers:writing-plans` | Gate 2 | Detailed TDD task breakdown |
412
+ | `investigate-bug` | Gate 3 (bug) | Trace data flow per framework |
413
+ | `superpowers:test-driven-development` | Gate 3 | TDD workflow |
414
+ | `superpowers:subagent-driven-development` | Gate 3 (complex) | Parallel implementation |
415
+ | `review-plan` | Gate 4 | Orchestrate self-review |
416
+ | `superpowers:verification-before-completion` | Gate 4 | Verify tests pass |
417
+ | `impact-analysis` | Gate 4 | Check breaking changes |
418
+ | `superpowers:requesting-code-review` | Gate 5 | Peer review workflow |
419
+
420
+ ---
421
+
422
+ ## Commands Reference
423
+
424
+ ```bash
425
+ # Setup (once per project)
426
+ aiflow init --framework spring-boot --adapter backlog
427
+
428
+ # Per task (2 commands only)
429
+ aiflow use PROJ-33 # load ticket context (full analysis)
430
+ aiflow use PROJ-33 --fast # fast mode: lite Gate 1 (< 5 min)
431
+ aiflow use PROJ-33 --full # force full Gate 1 analysis
432
+ claude # AI auto-starts Gate 1
433
+
434
+ # Optional: generate prompt for Claude Desktop/Web
435
+ aiflow prompt bug-fix # generate prompt to paste
436
+ aiflow prompt feature --output p.md # save prompt to file
437
+
438
+ # Task switching (multiple tasks in same repo)
439
+ aiflow task status # view active + pending tasks
440
+ aiflow task pause # pause current task
441
+ aiflow task pause --note "waiting for PM"
442
+ aiflow task switch PROJ-99 # pause current + switch
443
+ aiflow task resume PROJ-33 # resume a paused task
444
+
445
+ # Utilities
446
+ aiflow context show # view active context
447
+ aiflow memory save "key" "value" # save team knowledge
448
+ aiflow doctor # health check
449
+ aiflow guide # view quickstart guide
450
+
451
+ # Telemetry (team leads)
452
+ aiflow telemetry status # view status
453
+ aiflow telemetry enable # setup tracking
454
+ aiflow telemetry disable # disable tracking
455
+ ```
456
+
457
+ ---
458
+
459
+ ## Multi-AI Environment Setup
460
+
461
+ 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.
462
+
463
+ ### How to Switch Tools
464
+ 1. **Analyze (Gate 1)** using Claude Code CLI (great for deep codebase scans).
465
+ 2. **Review** the `requirement.md` file.
466
+ 3. **Open Cursor** to perform the coding (Gate 3).
467
+ 4. Cursor will automatically read `.cursorrules`, detect the active ticket, and see that Gate 1 is already finished.
468
+ 5. Cursor will proceed to Gate 2 or 3 as appropriate.
469
+
470
+ ### Instruction Files Created
471
+ | Tool | File Name | Purpose |
472
+ |------|-----------|---------|
473
+ | Claude Code | `CLAUDE.md` | Primary rules for the CLI tool. |
474
+ | Cursor AI | `.cursorrules` | Project-wide rules for Cursor. |
475
+ | Gemini CLI | `GEMINI.md` | Context for Gemini sessions. |
476
+ | Copilot | `.github/copilot-instructions.md` | Custom instructions for Copilot. |
477
+
478
+ ---
479
+
480
+ ## FAQ
481
+
482
+ **Q: PM didn't write enough on the ticket, what happens?**
483
+ 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.
484
+
485
+ **Q: Does AI just check format or actually understand the requirement?**
486
+ 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.
487
+
488
+ **Q: Gate 1 is taking too long for a simple ticket. What can I do?**
489
+ 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.
490
+
491
+ **Q: Can I skip Gate 2 for simple tasks?**
492
+ A: No. Gate 2 can be brief (simple plan), but DEV must still type "APPROVED" to confirm the approach.
493
+
494
+ **Q: AI reports test failures at Gate 4, what to do?**
495
+ 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.
496
+
497
+ **Q: What's the difference between a requirement bug and a coding bug?**
498
+ A: Requirement bug = wrong/missing in requirement doc → back to Gate 1. Coding bug = wrong code but correct requirement → fix at Gate 4.
499
+
500
+ **Q: Who performs peer review (Gate 5)?**
501
+ A: Another developer in the team. Not the code author. The reviewer uses the `superpowers:receiving-code-review` skill.
502
+
503
+ **Q: Can I work on two tasks in the same repo at the same time?**
504
+ 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.
505
+
506
+ **Q: If I resume a task, will Claude know which gate to start at?**
507
+ 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.
508
+ **Q: Can I resume a Gate 3 (Code Generation) task in a new chatbox?**
509
+ A: Yes. Gate 3 progress is saved via `[x]` checkboxes in `plan/[id]/plan.md`. If you open a new chatbox and say "continue", the AI will automatically skip completed tasks and pick up exactly where it left off.
510
+
511
+ **Q: How does AI estimate effort?**
512
+ 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).