@jakkrichm/create-nexus-devflow 2.2.0 → 2.2.2

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 (54) hide show
  1. package/README.md +1 -1
  2. package/dist/bin/create-nexus-devflow.js +1 -1
  3. package/dist/bin/create-nexus-devflow.js.map +1 -1
  4. package/dist/lib/command-catalog.js +5 -2
  5. package/dist/lib/command-catalog.js.map +1 -1
  6. package/dist/lib/dashboard.js +1 -1
  7. package/dist/lib/discoveries.js +18 -6
  8. package/dist/lib/discoveries.js.map +1 -1
  9. package/dist/lib/gatekeeper.d.ts +4 -0
  10. package/dist/lib/gatekeeper.js +13 -1
  11. package/dist/lib/gatekeeper.js.map +1 -1
  12. package/dist/lib/ideas.js +2 -2
  13. package/dist/lib/ideas.js.map +1 -1
  14. package/dist/lib/update.js +6 -2
  15. package/dist/lib/update.js.map +1 -1
  16. package/dist/lib/workflow-state.js +9 -6
  17. package/dist/lib/workflow-state.js.map +1 -1
  18. package/dist/scripts/prepare-template.js +10 -2
  19. package/dist/scripts/prepare-template.js.map +1 -1
  20. package/package.json +1 -1
  21. package/template/.agents/skills/10-define/SKILL.md +1 -1
  22. package/template/.agents/skills/30-plan/SKILL.md +13 -7
  23. package/template/.agents/skills/40-execute/SKILL.md +8 -11
  24. package/template/.agents/skills/50-verify/SKILL.md +14 -7
  25. package/template/.agents/skills/brainstorm/SKILL.md +1 -1
  26. package/template/.agents/skills/check/SKILL.md +19 -11
  27. package/template/.agents/skills/debug/SKILL.md +4 -8
  28. package/template/.agents/skills/devflow/SKILL.md +9 -7
  29. package/template/.agents/skills/discovery/SKILL.md +75 -150
  30. package/template/.agents/skills/feature/SKILL.md +9 -4
  31. package/template/.agents/skills/grill/SKILL.md +93 -0
  32. package/template/.agents/skills/implement/SKILL.md +12 -8
  33. package/template/.claude/skills/10-define/SKILL.md +1 -1
  34. package/template/.claude/skills/30-plan/SKILL.md +13 -7
  35. package/template/.claude/skills/40-execute/SKILL.md +8 -11
  36. package/template/.claude/skills/50-verify/SKILL.md +14 -7
  37. package/template/.claude/skills/brainstorm/SKILL.md +1 -1
  38. package/template/.claude/skills/check/SKILL.md +19 -11
  39. package/template/.claude/skills/debug/SKILL.md +4 -8
  40. package/template/.claude/skills/devflow/SKILL.md +9 -7
  41. package/template/.claude/skills/discovery/SKILL.md +75 -150
  42. package/template/.claude/skills/feature/SKILL.md +9 -4
  43. package/template/.claude/skills/grill/SKILL.md +93 -0
  44. package/template/.claude/skills/implement/SKILL.md +12 -8
  45. package/template/AGENTS.md +6 -6
  46. package/template/devflow/build-plan.md +10 -0
  47. package/template/devflow/context/ai-interaction.md +34 -7
  48. package/template/devflow/context/coding-standards.md +32 -7
  49. package/template/devflow/context/current-stage.md +1 -1
  50. package/template/devflow/decisions/.gitkeep +0 -0
  51. package/template/devflow/decisions/README.md +24 -0
  52. package/template/devflow/history/HISTORY.md +1 -1
  53. package/template/.agents/skills/00-explore/SKILL.md +0 -84
  54. package/template/.claude/skills/00-explore/SKILL.md +0 -84
@@ -1,166 +1,91 @@
1
1
  ---
2
2
  name: discovery
3
- description: "[devflow][B] Optional deep, multi-turn project discovery that helps the user develop detailed Blueprint project-plan.md and build-plan.md files through an adaptive conversation, then drafts them only after the user says they are ready. Use when the user explicitly runs /discovery or $discovery, asks for a guided planning interview, wants to think through a new product before writing the plans, or wants help deepening existing plans. Do not use merely because planning files are empty, after /onboard, or before /overview; users may always write the plans directly or create them through any conversation they prefer."
3
+ description: "[devflow][D] Unified discovery and exploration stage in DevFlow 2.0 - conducts project-level roadmap discovery (project-plan.md/build-plan.md) or feature-level exploration (Stage 00) before delivery commitment."
4
+ argument-hint: "[{title, request, IDEA-xxx, or discovery-id}]"
4
5
  ---
5
6
 
6
- # discovery - develop the plans through a deep conversation
7
+ # discovery - Unified Discovery & Pre-Delivery Exploration
7
8
 
8
- Where this can sit in the workflow:
9
+ $ARGUMENTS
9
10
 
10
- /onboard -> write the plans directly -> /overview
11
- \
12
- -> [discovery] -> review and approve plan drafts -> /overview
11
+ `/discovery` is the central discovery entry point in Nexus-DevFlow. It operates in two adaptive modes based on input scope:
12
+ 1. **🗺️ Macro Project Discovery**: Develops high-level product and build roadmap plans (`devflow/project-plan.md` & `devflow/build-plan.md`) through an adaptive conversation before `/overview`.
13
+ 2. **🔍 Micro Feature Exploration (Stage 00)**: Explores a specific feature, request, or idea before committing to delivery, routes through supporting lenses, and finishes with a visible `Proceed`, `Defer`, or `Reject` decision before `10-define`.
13
14
 
14
- `/discovery` is an optional planning partner, not a required workflow gate and
15
- not a quick questionnaire. It can span as many turns as the project needs. Its
16
- job is to help the user think through the product, preserve the depth and nuance
17
- of that conversation, and draft the two user-owned planning files only when the
18
- user asks for drafts.
15
+ ---
16
+
17
+ ## Invocations & Usage
19
18
 
20
- Running `/onboard` never starts this skill. Empty plans never require it. A user
21
- who writes detailed plans manually, has another AI conversation, or arrives with
22
- finished plans continues directly to `/overview` exactly as before.
19
+ ```text
20
+ # 1. Macro Project Planning Mode (No arguments or project scope)
21
+ /discovery
22
+ /discovery --project
23
23
 
24
- ## Step 1 - establish the starting point
24
+ # 2. Micro Feature Exploration Mode (Stage 00 of Deep-Track)
25
+ /discovery {title or request}
26
+ /discovery IDEA-xxx
27
+ /discovery {discovery-id}
28
+ ```
25
29
 
26
- Read only the planning and project facts needed for the conversation:
30
+ ---
27
31
 
28
- - `devflow/project-plan.md`
29
- - `devflow/build-plan.md`
30
- - the root project manifest, README, and framework configuration when they
31
- already contain relevant facts
32
- - `devflow/context/project-overview.md` only when the user is revisiting an
33
- established project's direction
32
+ ## Mode 1: Macro Project Discovery (Roadmap & System Planning)
34
33
 
35
- Classify each planning file as a template, partial draft, or substantive plan.
36
- Never treat existing user content as disposable. When either plan has real
37
- content, summarize what it already establishes and ask whether the user wants to
38
- deepen it, revise a specific direction, or use it unchanged as conversation
39
- context. Do not replace it with a fresh generic plan.
34
+ Use when:
35
+ - Starting a new product or shaping high-level architecture across the entire repository.
36
+ - Revisiting the overall project vision, major milestones, or tech stack before generating `/overview`.
40
37
 
41
- Start with a short working hypothesis about the project and name the most
42
- important unknown. Then ask one focused question. Do not draft either plan yet.
38
+ ### Process:
39
+ 1. **Establish Baseline**: Read `devflow/project-plan.md` and `devflow/build-plan.md` (if present).
40
+ 2. **Adaptive Conversation**: Ask 1-2 focused questions at a time covering problem space, user workflows, MVP boundaries, non-goals, data models, and stack constraints.
41
+ 3. **Periodic Snapshots**: Provide compact summaries of confirmed decisions, working assumptions, and open TODOs.
42
+ 4. **Draft Plans Behind Approval Gate**: Draft proposed `project-plan.md` and `build-plan.md` only when the user explicitly requests drafts.
43
+ 5. **Write on Approval**: Write approved files and recommend `/overview` as the next step.
43
44
 
44
- ## Step 2 - run adaptive discovery
45
+ ---
46
+
47
+ ## Mode 2: Micro Feature Exploration (Stage 00 of Deep-Track)
48
+
49
+ Use when:
50
+ - Exploring a specific feature, complex architectural change, or pending idea (`/discovery IDEA-xxx`).
51
+ - The team needs to evaluate feasibility, options, domain glossary, or root causes before locking delivery scope.
52
+
53
+ ### Markdown-First Contract:
54
+ Write the primary discovery artifact to:
55
+ ```text
56
+ devflow/discoveries/{DISCOVERY_ID}-{slug}/discovery.md
57
+ ```
58
+ *(A Discovery ID uses the namespace `DISC-YYYYMMDD-NNN`. It is not a Running ID and does not reserve a numeric delivery run.)*
59
+
60
+ ### 5 Supporting Routes & Built-in Lenses:
61
+
62
+ 1. **Brainstorming Lens (Divergent & Convergent)**:
63
+ - Formulate 2-3 viable options with trade-offs.
64
+ - Construct a **Trade-off Comparison Table** (Pros, Cons, Recommendation).
65
+ 2. **Research & Empirical Proof Lens**:
66
+ - Inspect existing codebase patterns with search tools (`grep_search`, `rg`).
67
+ - Conduct external web search if library feasibility or API contracts are uncertain.
68
+ 3. **PRD & Scoping Lens**:
69
+ - Problem Statement, Target Persona, Core User Stories, and In-Scope vs. Out-of-Scope boundaries.
70
+ 4. **Issue & Bug Triage Lens**:
71
+ - Classify severity (`Critical/Blocker`, `Major`, `Minor`) and determine whether root-cause analysis (`debug`) is required.
72
+ 5. **Socratic Grilling & Domain Alignment Lens (`grill`)**:
73
+ - Codebase-grounded interactive inquiry to clarify entity boundaries, data flows, and edge cases.
74
+ - Record agreed terminology in `devflow/context/glossary.md` and major architecture decisions in `devflow/decisions/ADR-xxx-{slug}.md`.
75
+
76
+ ### Decision & Approval Gate:
77
+ Set one visible decision:
78
+ - `Proceed`: Enough value and evidence exist to define delivery work:
79
+ - **🏎️ Fast-Track (Recommended for 85% of standard features/fixes)**: Handoff to `/feature {discovery_id}` or `/fix {discovery_id}` (writes `devflow/context/current-feature.md`).
80
+ - **🏗️ Deep-Track (For large architectural epics/migrations)**: Handoff to `10-define {discovery_id}` (writes `devflow/context/current-run/10-define.md`).
81
+ - `Defer`: The idea remains relevant but timing or evidence is not ready.
82
+ - `Reject`: The idea should not proceed under current framing.
83
+
84
+ ---
45
85
 
46
- Ask one meaningful question at a time and let each answer shape the next one.
47
- Prefer a likely interpretation the user can correct over a vague request for
48
- more detail. Explain a tradeoff when the answer would materially change scope,
49
- architecture, cost, or build order.
86
+ ## Next Workflow Recommendations
50
87
 
51
- Cover the areas that matter to this project, not a fixed questionnaire:
52
-
53
- - problem, desired outcome, and why the project should exist
54
- - target users, their context, and their primary workflows
55
- - MVP capabilities, explicit non-goals, and later possibilities
56
- - business rules, data, integrations, permissions, and important edge cases
57
- - stack choices, constraints, dependencies, and technical unknowns
58
- - UI/UX direction, accessibility needs, and useful references
59
- - monetization or business model when relevant
60
- - deployment shape, environments, background work, storage, and operations
61
- - risks, assumptions, unresolved decisions, and how success will be judged
62
- - feature boundaries, dependencies, and a sensible build order
63
-
64
- Depth is the goal. Follow a consequential answer until its implications are
65
- clear instead of racing to the next category. Do not ask the user to repeat facts
66
- already established in the conversation or repository. Do not force irrelevant
67
- topics merely to complete a checklist.
68
-
69
- Periodically return a compact discovery snapshot with:
70
-
71
- - confirmed decisions
72
- - working assumptions that still need confirmation
73
- - open questions or conflicts
74
- - ideas explicitly deferred or excluded
75
-
76
- The snapshot keeps a long conversation coherent. It is not permission to write
77
- the plans.
78
-
79
- ## Step 3 - decide whether the plans are ready
80
-
81
- Do not end discovery because a preset number of questions has been reached. It
82
- is ready to draft when:
83
-
84
- - the problem, users, and core workflows are concrete
85
- - MVP scope and non-goals are distinguishable
86
- - data and technical choices are detailed enough to expose major dependencies
87
- - the build order can be expressed as feature-sized outcomes
88
- - important contradictions are resolved
89
- - remaining unknowns are either safe to defer or explicitly accepted as TODOs
90
- - the user says they are ready for the plans to be drafted
91
-
92
- If the user asks for drafts while a material gap remains, name the gap and ask
93
- whether to continue discovery or preserve it as an explicit TODO. Respect the
94
- choice. The user may also stop at any time and write the plans manually.
95
-
96
- ## Step 4 - draft both planning files
97
-
98
- When the user asks for drafts, produce complete proposed contents for both files
99
- without writing them yet.
100
-
101
- For `devflow/project-plan.md`:
102
-
103
- - keep the template's main subject areas, adding useful sections when the
104
- conversation requires them
105
- - preserve rationale, examples, tradeoffs, constraints, edge cases, and
106
- exclusions that will matter during later feature work
107
- - be as detailed as the project needs; never compress a rich discovery into a
108
- line or two per section
109
- - distinguish confirmed decisions from assumptions and TODOs
110
-
111
- For `devflow/build-plan.md`:
112
-
113
- - use numbered checkboxes and optional milestone headings
114
- - keep each item a high-level, feature-sized outcome with a concise description
115
- - order items by dependency and the earliest useful vertical slice
116
- - keep implementation detail in later `/feature` specs rather than turning the
117
- roadmap into a task dump
118
- - include only agreed scope; place deferred ideas outside the MVP or omit them as
119
- the user directed
120
-
121
- If substantive plans already exist, preserve their information and completed
122
- build-plan numbering. Clearly identify proposed additions, removals, or changed
123
- decisions.
124
-
125
- End by asking the user to review the full drafts. Do not write either file in the
126
- same response that first presents them.
127
-
128
- ## Step 5 - write only after approval
129
-
130
- Write the approved drafts only after the user explicitly approves them. If the
131
- user requests changes, revise the drafts and show the affected sections again
132
- before writing.
133
-
134
- After writing:
135
-
136
- - report which files changed
137
- - list any retained TODOs or unresolved decisions
138
- - remind the user that both files remain theirs to edit and deepen directly
139
- - stop before generating `devflow/context/project-overview.md`
140
- - point to `/overview` or `$overview` as the next optional command when the user
141
- is satisfied with the plans
142
-
143
- ## Rules
144
-
145
- - This skill is always optional. Never make it a prerequisite for `/overview`,
146
- `/feature`, or any other Blueprint command.
147
- - Never start it automatically from `/onboard`, because planning files are
148
- empty, or because a project is new.
149
- - Never imply that plans created manually or through another conversation are
150
- inferior or incomplete merely because this skill was not used.
151
- - Never overwrite substantive planning content without showing the replacement
152
- and receiving explicit approval.
153
- - Never write plans during the interview or after a vague signal such as "looks
154
- good." The user must explicitly approve the proposed file contents.
155
- - Never scaffold the app, edit product code, generate the overview, create a
156
- feature spec, commit, merge, push, or deploy.
157
- - Preserve detailed project reasoning in `project-plan.md`, while keeping
158
- `build-plan.md` high-level and trackable.
159
- - Keep the conversation adaptive. Depth comes from relevant follow-up questions,
160
- not from mechanically asking every possible question.
161
-
162
- ## Formatting
163
-
164
- Follow `devflow/context/ai-interaction.md`. During discovery, ask one focused
165
- question per turn. For snapshots and draft reviews, use concise headings and
166
- lists so confirmed decisions and remaining gaps are easy to inspect.
88
+ - **From Macro Project Mode**: Run `/overview` to compile context into `devflow/context/project-overview.md`.
89
+ - **From Micro Stage 00 (Approved Proceed ➔ Fast-Track)**: Run `/feature {discovery_id}` to start lean living spec.
90
+ - **From Micro Stage 00 (Approved Proceed Deep-Track)**: Run `10-define {discovery_id}` to allocate a Running ID.
91
+ - **From Micro Stage 00 (Defer / Reject)**: No next command needed.
@@ -32,6 +32,7 @@ big item has been split into sub-items, the next unchecked sub-item is the targe
32
32
 
33
33
  ## Step 1 - pick the target
34
34
 
35
+ - Given a Discovery ID or Idea ID (e.g. `/feature DISC-20260824-001` or `/feature IDEA-001`) -> import problem context, research, trade-offs, and ADRs from `devflow/discoveries/{DISC-ID}/discovery.md` or `devflow/ideas.md` into the living spec.
35
36
  - Given a number or name that matches a build-plan item -> use it.
36
37
  - Given a request that clearly describes a new feature with no reasonable match
37
38
  in the build plan -> follow **New-feature intake** below.
@@ -112,10 +113,14 @@ build plan starts high-level.
112
113
 
113
114
  For the one (sub-)feature being built now, write a full spec to
114
115
  `devflow/context/current-feature.md` (create `devflow/context/` if needed), following
115
- `reference/feature-spec-template.md`. Fill every section: goal, in/out of scope,
116
- the build loop, small build steps as a checklist (`- [ ]`, each with an observable
117
- "done when" - `/implement` ticks them off and resumes from the first unchecked
118
- one), files/areas, data/contracts, testing, and notes for the AI.
116
+ `reference/feature-spec-template.md`. Fill every section:
117
+ - Goal, Problem Statement, and In/Out of scope
118
+ - Acceptance Criteria (AC-1, AC-2, ...)
119
+ - Small build steps as atomic 2-5 min checklist items (`- [ ]`, supporting `[TDD-Red]`, `[TDD-Green]`, `[TDD-Refactor]` triplets for functional logic)
120
+ - Two-Stage Verification Strategy:
121
+ - **Stage 1**: Spec Fidelity & Acceptance Criteria Gate
122
+ - **Stage 2**: Technical Multi-lane quality, tests, security, and findings ledger
123
+ - Files/areas to modify, data/contracts, and notes for the AI.
119
124
 
120
125
  **Visual or replication features need a reference image.** If the feature is
121
126
  "make it look like X" - recreating an existing design, matching a mockup, or
@@ -0,0 +1,93 @@
1
+ ---
2
+ name: grill
3
+ description: "[devflow][B] Interactive Socratic alignment & domain modeling - stress-test plans, extract domain glossary, and record architecture decision records (ADRs) before delivery."
4
+ argument-hint: "{topic, plan, or question}"
5
+ ---
6
+
7
+ # grill - Socratic Alignment & Domain Modeling
8
+
9
+ $ARGUMENTS
10
+
11
+ Use this skill to conduct a codebase-grounded, interactive Socratic interview with the user. It clarifies domain vocabulary, resolves architectural ambiguities, and prevents misalignment before writing specifications or code.
12
+
13
+ ## Invocations & Aliases
14
+
15
+ - `/grill {topic or plan}`: Standard slash command in Claude Code, Google Antigravity, and Gemini CLI
16
+ - `grill {topic or plan}`: Plain text invocation
17
+ - `$grill {topic or plan}`: Codex CLI invocation
18
+ - `/align {topic}`: Alias for domain alignment
19
+
20
+ ## Core Philosophy: Align Before You Build
21
+
22
+ 1. **Codebase-Grounded**: Read existing code and context first. Never ask questions the codebase can already answer.
23
+ 2. **One Round at a Time**: Ask 1-2 focused, high-leverage questions per round with clear recommended defaults. Never dump a wall of 10 questions.
24
+ 3. **Lazy Inline Persistence**:
25
+ - Write agreed domain terminology to `devflow/context/glossary.md` the moment each term resolves.
26
+ - Record significant, hard-to-reverse technical decisions as ADRs in `devflow/decisions/ADR-xxx-{slug}.md`.
27
+ 4. **Zero Assumptions**: Challenge ambiguities, contradictory requirements, and naming inconsistencies upfront.
28
+
29
+ ---
30
+
31
+ ## Process & Execution Loop
32
+
33
+ ### 1. Grounding Phase (Silent Inspection)
34
+ Before asking the first question:
35
+ - Read `devflow/context/project-overview.md` and `devflow/context/coding-standards.md`.
36
+ - Inspect existing domain terms in `devflow/context/glossary.md` (if present).
37
+ - Search codebase patterns (`grep_search` / `rg`) related to the topic to ground technical reality.
38
+
39
+ ### 2. Interactive Socratic Interview Loop
40
+ In each turn:
41
+ - Identify the most critical unresolved branch in the design tree:
42
+ - **Domain Language & Boundaries**: "What exactly is an Entity X versus Entity Y in this context?"
43
+ - **Data Flow & Contracts**: "Who owns state X? Synchronous vs. asynchronous?"
44
+ - **Edge Cases & Failure Modes**: "What happens on network failure, concurrent mutation, or invalid input?"
45
+ - **Irreversible Trade-offs**: "Database schema change vs. application-layer adapter?"
46
+ - Ask **1-2 questions maximum** per turn.
47
+ - Always provide a recommended default with concise technical rationale.
48
+ - Wait for the user's answer.
49
+
50
+ ### 3. Immediate State Persistence
51
+
52
+ #### A. Domain Glossary (`devflow/context/glossary.md`)
53
+ When a domain term or conceptual definition crystallizes, immediately create or append to `devflow/context/glossary.md`:
54
+
55
+ ```markdown
56
+ ### [Term / Concept]
57
+ - **Definition**: Clear, unambiguous definition within this project.
58
+ - **Constraints**: Invariants, boundaries, or lifecycle rules.
59
+ - **Aliases / Related**: Related terms or common misnomers.
60
+ ```
61
+
62
+ #### B. Architecture Decision Records (`devflow/decisions/ADR-xxx-{slug}.md`)
63
+ When a decision meets the 3 ADR criteria:
64
+ 1. **Significant Impact**: Affects architecture, data schema, security, or public API.
65
+ 2. **Hard to Reverse**: Changing it later requires painful migration or refactoring.
66
+ 3. **Multiple Viable Alternatives**: There were real trade-offs between 2+ options.
67
+
68
+ Allocate the next sequential ID (`ADR-001`, `ADR-002`, ...) and create `devflow/decisions/ADR-xxx-{slug}.md`:
69
+
70
+ ```markdown
71
+ # ADR-xxx: {Title}
72
+
73
+ - **Status**: Accepted
74
+ - **Date**: {YYYY-MM-DD}
75
+ - **Context**: {Why was this decision needed? What problem does it solve?}
76
+ - **Decision**: {What did we decide to do?}
77
+ - **Alternatives Considered**:
78
+ - *Option 1*: {Pros / Cons}
79
+ - *Option 2*: {Pros / Cons}
80
+ - **Consequences**:
81
+ - *Positive*: {Benefits gained}
82
+ - *Trade-offs / Risks*: {Costs, constraints, or follow-ups}
83
+ ```
84
+
85
+ ---
86
+
87
+ ## 4. Closing & Handoff
88
+
89
+ When all design branches are resolved:
90
+ 1. Summarize settled domain terms and created ADRs.
91
+ 2. Provide explicit next command recommendations:
92
+ - **Fast-Track (Standard Features/Fixes)**: Run `/feature {topic}` or `/fix {topic}` to immediately start the living spec.
93
+ - **Deep-Track (Large Architectural Epics)**: Run `10-define` or `/discovery` with the discovery context.
@@ -88,19 +88,23 @@ broad checkout. Ask whether to resolve only the conflict allowed by the approved
88
88
  spec or abandon the attempt. A cascade into another completed feature needs a
89
89
  new rollback plan.
90
90
 
91
- ## Step 2 - build one step, review, iterate, checkpoint
91
+ ## Step 2 - build one step, review, iterate, checkpoint (Strict TDD)
92
92
 
93
93
  Work through the spec's build steps in order, one at a time. For each step:
94
94
 
95
- 1. Implement just that step: the smallest change that satisfies its "done when."
96
- 2. Show the **diff**, not whole files.
97
- 3. **Explain it, and prove it.** Give a short summary: what the step delivered,
95
+ 1. **Strict TDD Cycle (for logic & behavior changes)**:
96
+ - **🔴 RED**: Write the unit test first in the relevant test file. Execute the test command and show the failing assertion output.
97
+ - **🟢 GREEN**: Implement only the minimal code in the source file necessary to make the test pass. Re-run test and show passing output.
98
+ - **🔵 REFACTOR**: Refactor and format cleanly, verifying that 100% of tests remain green.
99
+ - *Code Reversion Rule*: If production code is written without a prior test for behavior changes, revert it and write the test first.
100
+ 2. Implement just that step: the smallest change that satisfies its "done when."
101
+ 3. Show the **diff**, not whole files.
102
+ 4. **Explain it, and prove it.** Give a short summary: what the step delivered,
98
103
  one line per changed file on what it does and why, then confirm the step's
99
- "done when" is met with evidence (build output, a screenshot, a passing
100
- assertion). This summary is the comprehension gate, so keep it concrete, not
101
- ceremonial. Include a short **How to try it** note when the step has a manual
104
+ "done when" is met with empirical evidence (test pass output, build output, or screenshot). This summary is the comprehension gate, so keep it concrete, not
105
+ vague. Include a short **How to try it** note when the step has a manual
102
106
  path: the command, URL, click, endpoint, or output the user can check.
103
- 4. **Verify the step.** If `AGENTS.md` declares a `Verify` command, run that exact
107
+ 5. **Verify the step.** If `AGENTS.md` declares a `Verify` command, run that exact
104
108
  command as the automated gate. It is only an umbrella for checks the project
105
109
  actually has, so do not invent tests or other checks to satisfy it. If no
106
110
  `Verify` command exists, run the documented build command and the test command
@@ -43,7 +43,7 @@ using:
43
43
  Require:
44
44
  - `Decision: Proceed`
45
45
  - `Approval Status: Approved`
46
- - A resolvable Discovery ID and `00-explore.md`
46
+ - A resolvable Discovery ID and `discovery.md` (or legacy `00-explore.md`)
47
47
 
48
48
  ### 3. Allocate Sequential ID
49
49
  - Inspect `devflow/history/HISTORY.md` and allocate sequential ID without prefix (e.g. `022-{slug}`).
@@ -83,12 +83,12 @@ Record important findings in `30-plan.md`. Use legacy context updates only when
83
83
 
84
84
  ### 4. Build The Plan
85
85
 
86
- Use the old planner discipline, but keep `30-plan.md` as the main contract:
86
+ Use strict planning discipline, keeping `30-plan.md` as the main contract:
87
87
 
88
+ - **Atomic Micro-Task Sizing (2–5 Minutes)**: Every subtask must be a small, verifiable unit that can be implemented and reviewed cleanly without context sprawl.
88
89
  - record the planning loop evidence: context read, observations, adjustments made, stop condition, and handoff notes
89
90
  - add phases in dependency order
90
- - add subtasks that are small, verifiable units
91
- - include explicit files to modify or create
91
+ - include explicit files to modify or create (exact file paths)
92
92
  - include patterns to follow
93
93
  - include verification command or manual check
94
94
  - include a test decision for every subtask
@@ -97,18 +97,24 @@ Use the old planner discipline, but keep `30-plan.md` as the main contract:
97
97
  Each subtask should answer:
98
98
 
99
99
  - what to change
100
- - where to change it
100
+ - where to change it (exact path)
101
101
  - which pattern to follow
102
102
  - how to verify it
103
103
  - whether automated tests are required, manual, or not required
104
104
 
105
- ### 4.1 Test Decision Gate
105
+ ### 4.1 Strict TDD Task Breakdown & Test Decision Gate
106
106
 
107
- **STRICT MANDATE (กฎเหล็ก Unit Test)**: สำหรับทุก subtask ที่มีการเพิ่ม แก้ไข หรือเปลี่ยนแปลงการทำงานของโค้ด (Behavior Change) **ต้องระบุเป็น `Required` เสมอ** ห้ามละเว้นเด็ดขาด ยกเว้นงานประเภทเอกสารหรือแก้ไข Configuration เท่านั้น
107
+ **STRICT MANDATE (กฎเหล็ก Unit Test & TDD)**: สำหรับทุก subtask ที่มีการเพิ่ม แก้ไข หรือเปลี่ยนแปลงการทำงานของโค้ด (Behavior Change) **ต้องระบุเป็น `Required` เสมอ** และต้องย่อยงานเป็น **TDD Triplet Sub-tasks** ดังนี้:
108
+
109
+ ```markdown
110
+ - [ ] Task 1.1 [TDD-Red]: Write failing test for {feature/behavior} in {test_file} and verify failure
111
+ - [ ] Task 1.2 [TDD-Green]: Implement minimal code in {src_file} to satisfy Task 1.1 test
112
+ - [ ] Task 1.3 [TDD-Refactor]: Refactor logic, eliminate duplication, and verify zero regression
113
+ ```
108
114
 
109
115
  For every subtask, decide one of:
110
116
 
111
- - `Required`: automated tests must be created or updated (Mandatory for all behavior changes)
117
+ - `Required`: automated tests must be created or updated (Mandatory for all behavior changes, formatted as TDD Triplet)
112
118
  - `Manual/Command Only`: verification is non-test but still explicit (Only for configuration/infrastructure tasks)
113
119
  - `Not Required`: no new automated test is needed because there is no meaningful behavior surface (Only for documentation/comments)
114
120
 
@@ -59,27 +59,24 @@ Confirm the current Git branch with `git branch --show-current` and use that bra
59
59
 
60
60
  Select one scoped unit of work at a time. Do not implement the whole plan as one blob.
61
61
 
62
- ### 2. Execute One Scoped Unit
62
+ ### 2. Execute One Scoped Unit (Strict TDD Red-Green-Refactor)
63
63
 
64
- Use the original coder discipline, adapted to 2.0:
64
+ Use the strict coder discipline:
65
65
 
66
- - **STRICT MANDATE (กฎเหล็ก Unit Test)**: ต้องสร้าง/แก้ไข Unit Test ควบคู่กับการแก้ไขโค้ดเสมอ โดยห้ามแก้ไขเฉพาะไฟล์โค้ดหลัก (Production Code) โดยไม่แก้ไขหรือสร้างไฟล์เทสต์ควบคู่กัน
66
+ - **STRICT MANDATE (กฎเหล็ก Unit Test & TDD)**: สำหรับทุกงานที่มีการแก้ไข logic การทำงาน ต้องสร้างหรือแก้ไข Unit Test ควบคู่กับการแก้ไขโค้ดเสมอ โดยห้ามเขียนเฉพาะ Production Code โดยไม่มีเทสต์
67
+ - **🔴 RED (Test First)**: ออกแบบและเขียน Test Case ในไฟล์เทสต์ก่อนเสมอ แล้วรันคำสั่งเทสต์เพื่อพิสูจน์ว่า **Test ล้มเหลว (FAIL)** ตามที่คาดหวัง
68
+ - **🟢 GREEN (Minimal Implementation)**: เขียน Production Code เท่าที่จำเป็นเพื่อให้เทสต์ผ่าน แล้วรันคำสั่งเทสต์เพื่อพิสูจน์ว่า **Test ผ่าน 100% (PASS)**
69
+ - **🔵 REFACTOR (Clean Code)**: ปรับปรุงโครงสร้างโค้ดให้อ่านง่าย กำจัดความซ้ำซ้อน (DRY) โดยที่เทสต์ยังคงเขียว 100%
70
+ - **Code Deletion / Reversion Rule**: หากเผลอเขียน Production Code ก่อนมีเทสต์ ให้ Revert หรือลบโค้ดส่วนนั้น แล้วเริ่มวงจร RED ก่อนเสมอ
67
71
  - start each scoped unit by naming its intent, context, expected observation, adjustment route, and stop condition
68
72
  - read referenced pattern files before editing
69
73
  - read the test decision from `30-plan.md`
70
74
  - confirm assumptions, target files, and success criteria before editing
71
- - make the smallest useful code change
72
75
  - preserve project style
73
- - run the planned verification
76
+ - run the planned verification and capture concrete terminal outputs
74
77
  - record observation, adjustment, stop condition status, and the result in `40-execute.md`
75
78
  - update checklist item status, timestamps, and evidence links as work progresses
76
79
 
77
- If tests are `Required`:
78
-
79
- 1. **TDD Cycle (RED)**: ออกแบบและเขียนตัวเทสต์ให้พังก่อน (หรือเขียนโครงสร้างเทสต์ที่คาดหวังผลลัพธ์ที่ถูกต้อง) ตามแนวทางใน [coding-standards.md](file:///devflow/context/coding-standards.md)
80
- 2. **GREEN**: เขียนโค้ดระบบจริงให้สอดคล้องเพื่อให้เทสต์ผ่าน
81
- 3. **REFACTOR**: ปรับปรุงโครงสร้างโค้ดโดยยังคงรันเทสต์ผ่านอย่างต่อเนื่อง
82
-
83
80
  ### 3. Recovery
84
81
 
85
82
  Use the old recovery discipline when blocked:
@@ -18,15 +18,21 @@ Review implementation quality, run multi-lane validation, produce a verification
18
18
  Use `50-verify.md` as the primary verification artifact.
19
19
  Use `50-verify-impact.md` as an optional companion artifact when the run changes behavior, touches core logic, crosses integration boundaries, or needs explicit rollback and client impact analysis.
20
20
 
21
- ## Process & Quality Gates
21
+ ## Process & Quality Gates (Two-Stage Review Pattern)
22
22
 
23
- ### 1. Senior QA Review & Multi-Lane Verification
23
+ ### Stage 1: Spec Fidelity & Acceptance Criteria Gate
24
+ Before evaluating technical code metrics, verify that the implementation faithfully delivers what was specified:
25
+ 1. **Acceptance Criteria Validation**: Cross-check each Acceptance Criterion (AC-1, AC-2, ...) in `20-spec.md` or `current-feature.md` and verify concrete evidence of completion.
26
+ 2. **Done-When Observable Verification**: Check that all observable conditions ("Done when...") are satisfied in the running application or test suite.
27
+ 3. **Scope Discipline**: Ensure zero scope creep (no unrequested features added) and no unfulfilled functional requirements.
28
+ 4. **Boundary & Negative Scenarios**: Verify unhappy paths, empty inputs, and error states defined in the specification.
24
29
 
25
- Execute verification across all essential quality dimensions:
30
+ ### Stage 2: Code Quality, Security & Architecture Gate
31
+ Execute multi-lane technical verification across all essential quality dimensions:
26
32
 
27
33
  1. **Lane 1: Typecheck & Static Code Quality**:
28
34
  - Run typecheck and static analysis (`tsc --noEmit`, `npm run lint`).
29
- 2. **Lane 2: Automated Test Suites (TDD Gate)**:
35
+ 2. **Lane 2: Automated Test Suites (Strict TDD Gate)**:
30
36
  - Run automated unit and integration tests (`npm test`).
31
37
  - Confirm 100% test pass rate with zero disabled or skipped tests.
32
38
  3. **Lane 3: Scrutinize QA & Edge Cases Review**:
@@ -44,12 +50,13 @@ Execute verification across all essential quality dimensions:
44
50
 
45
51
  ### 2. Decision & Route
46
52
 
47
- - **Pass**: Route to `60-report {ID}`.
48
- - **Fail**: Route back to `40-execute {ID}` with exact failure evidence and remediation steps.
53
+ - **Pass**: Both Stage 1 and Stage 2 pass with 0 blockers -> Route to `60-report {ID}`.
54
+ - **Fail**: Either Stage 1 or Stage 2 fails -> Route back to `40-execute {ID}` with exact failure evidence and remediation steps.
49
55
 
50
56
  ## Output
51
57
 
52
58
  Report:
53
- - QA verdict across all verification lanes
59
+ - **Stage 1 Verdict**: Spec Fidelity & Acceptance Criteria status
60
+ - **Stage 2 Verdict**: Technical Multi-lane quality & security matrix
54
61
  - Evidence commands and outputs
55
62
  - Next command: `60-report {ID}` (if pass) or `40-execute {ID}` (if fail)
@@ -58,5 +58,5 @@ Construct a structured evaluation table:
58
58
 
59
59
  ## Next Workflow Recommendation
60
60
 
61
- - **Primary**: `00-explore {discovery_id}` (if resuming discovery) or `10-define` / `feature` (if ready to specify)
61
+ - **Primary**: `discovery {discovery_id}` (if resuming discovery) or `10-define` / `feature` (if ready to specify)
62
62
  - **Inbox**: `idea` to record into `devflow/ideas.md`
@@ -66,21 +66,29 @@ Drive the app to each checklist item and capture evidence as you go:
66
66
  - Watch for **console errors and failed network requests**; a clean-looking screen
67
67
  with errors in the console is not a pass.
68
68
 
69
- ## Step 4 - report
69
+ ## Step 4 - report (Two-Stage Review Pattern)
70
70
 
71
- Give a short, honest verdict, one line per checklist item:
71
+ Format the verification report into two explicit review stages:
72
72
 
73
- [pass] Download PDF saves certificate-<slug>.pdf - file downloaded, opened to the cert
74
- [pass] Both buttons show a loading state - screenshot: loading-state.png
75
- [fail] PDF border missing - printBackground not set; screenshot: pdf-no-border.png
76
- [skip] Vercel render - can't verify locally (feature 9)
73
+ ### Stage 1: Spec Fidelity & Acceptance Gate
74
+ Give a line-by-line verdict for each Acceptance Criterion and "done when" item:
77
75
 
78
- Then state the bottom line: are all the feature's done-whens proven, or not yet.
76
+ [pass] AC-1: Download PDF saves certificate-<slug>.pdf - file downloaded, opened to cert
77
+ [pass] AC-2: Both buttons show a loading state - screenshot: loading-state.png
78
+ [fail] AC-3: PDF border missing - printBackground not set; screenshot: pdf-no-border.png
79
+ [skip] AC-4: Vercel deploy smoke test - can't verify locally (pending staging)
79
80
 
80
- - All proven -> say it's ready for `/complete`.
81
- - Anything failed -> hand back to `/implement` to fix; name what to fix. Don't fix
82
- it here.
83
- - Anything unverifiable -> say so plainly and why; never report it as a pass.
81
+ ### Stage 2: Code Quality, Security & Architecture Gate
82
+ Report the multi-lane technical verification results:
83
+ - **Type & Syntax**: `tsc --noEmit` (0 errors)
84
+ - **Automated Tests**: Unit & integration tests (100% pass)
85
+ - **Security & Hygiene**: Zero secrets, sanitized inputs
86
+ - **Findings Ledger**: 0 blockers (P0/P1) in `devflow/context/findings.md`
87
+
88
+ ### Final Verdict & Route
89
+ - **All Passed**: State that the feature is verified and ready for `/complete`.
90
+ - **Any Failure**: Hand back to `/implement` with exact failure evidence and reproduction steps. Never fix issues inside `/check`.
91
+ - **Unverifiable**: Clearly state reasons and residual risk. Never fabricate a pass.
84
92
 
85
93
  ## Rules
86
94
 
@@ -117,14 +117,10 @@ Give a concise debug report:
117
117
 
118
118
  Choose the next action without writing files:
119
119
 
120
- - Active feature or fix caused the failure -> return the diagnosis to
121
- `/implement`.
122
- - No active work item and the bug is confirmed -> recommend
123
- `/fix "<concise bug and confirmed cause>"`.
124
- - Cause is only likely or blocked -> recommend the next diagnostic evidence, not
125
- a speculative repair.
126
- - The issue is planned product work rather than a defect -> point to
127
- `/feature`.
120
+ - Active feature or fix caused the failure -> return the diagnosis to `/implement` with instructions to write a failing reproduction test ([TDD-Red]) first.
121
+ - No active work item and the bug is confirmed -> recommend `/fix "<concise bug and confirmed cause>"` (which will write a failing test first before fixing).
122
+ - Cause is only likely or blocked -> recommend the next diagnostic evidence, not a speculative repair.
123
+ - The issue is planned product work rather than a defect -> point to `/feature`.
128
124
 
129
125
  ## Rules
130
126