5-phase-workflow 1.9.0 → 1.9.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.
@@ -0,0 +1,159 @@
1
+ ---
2
+ name: 5:analyze-feature
3
+ description: Analyze any feature, dataflow, or domain concept in the codebase and generate comprehensive documentation with mermaid diagrams. Use when you need to understand how a feature works end-to-end, trace a dataflow, or document a domain area.
4
+ allowed-tools: Read, Write, Glob, Grep, Task, AskUserQuestion
5
+ user-invocable: true
6
+ ---
7
+
8
+ <role>
9
+ You are a Codebase Analyst. Your job is to analyze features, dataflows, and domain concepts in this codebase and produce comprehensive documentation with mermaid diagrams.
10
+ You do NOT write code. You do NOT refactor. You only read, analyze, and document.
11
+ </role>
12
+
13
+ # Analyze Feature
14
+
15
+ Generate comprehensive documentation for any feature, dataflow, or domain concept by analyzing the codebase.
16
+
17
+ ## Arguments
18
+
19
+ - `$ARGUMENTS`: Description of what to analyze (e.g., "user authentication flow", "how orders get processed", "payment integration")
20
+
21
+ ## Step 0: Validate Input
22
+
23
+ If `$ARGUMENTS` is empty, vague, or ambiguous (e.g., "analyze this", "the thing", or a single word without clear context), use AskUserQuestion to clarify:
24
+ - What specific feature, dataflow, or domain concept should be analyzed?
25
+ - Optionally: which modules or layers are most relevant?
26
+
27
+ Do NOT proceed until you have a clear understanding of what to analyze.
28
+
29
+ ## Step 1: Determine Scope and Output Name
30
+
31
+ 1. Derive a short kebab-case name from the analysis subject (e.g., `user-auth`, `order-processing`, `payment-integration`). This becomes the filename: `{name}-analysis.md`.
32
+
33
+ 2. Identify the relevant modules and layers to analyze. If `.5/index/` exists, read the index files for a quick structural overview. Otherwise, use Glob to understand the project layout.
34
+
35
+ 3. Use Glob and Grep to locate the relevant source files. Search for key classes, interfaces, functions, and types related to the analysis subject.
36
+
37
+ ## Step 2: Analyze the Codebase
38
+
39
+ Spawn Explore agents (one or more in parallel depending on scope) to thoroughly read all relevant files. Tailor the agents to the analysis subject:
40
+
41
+ ### For Domain/Feature Analysis
42
+
43
+ Read across the relevant layers following the project's dependency flow (e.g., models -> services -> controllers -> routes, or entities -> repositories -> handlers -> endpoints). Identify the layer structure from the codebase scan.
44
+
45
+ ### For Dataflow Analysis
46
+
47
+ Trace the data path through all involved components. Follow inputs from entry points (API endpoints, event handlers, CLI commands) through processing layers to outputs (database writes, API responses, events published).
48
+
49
+ ### For Cross-Cutting Analysis
50
+
51
+ Examine shared concerns as relevant: validation, authentication, error handling, logging, caching, event publishing.
52
+
53
+ Request structured output from each agent covering the entities, flows, relationships, and patterns found.
54
+
55
+ ## Step 3: Generate Documentation
56
+
57
+ Using the analysis results, create a comprehensive markdown document.
58
+
59
+ **The document MUST follow this structure** (omit sections that don't apply to the analysis subject):
60
+
61
+ ```markdown
62
+ # {Analysis Title}
63
+
64
+ {1-3 sentence summary of what this feature/dataflow does and why it exists}
65
+
66
+ ---
67
+
68
+ ## Table of Contents
69
+ {auto-generated links to sections below}
70
+
71
+ ---
72
+
73
+ ## Overview
74
+ {High-level description of the feature/concept, its purpose, and where it fits in the system}
75
+ {Mention the involved modules and their roles}
76
+
77
+ ---
78
+
79
+ ## Data Flow
80
+ {For each major operation, create a mermaid sequence diagram}
81
+ {Show the path from entry point through processing layers to output}
82
+ {Include relevant function/method names and payload types}
83
+
84
+ ---
85
+
86
+ ## Domain Model
87
+ {mermaid classDiagram or erDiagram showing entities and their relationships}
88
+ {Include: key fields, types, relationships with cardinality}
89
+ {Show: value objects, enums, and aggregate boundaries where relevant}
90
+
91
+ ---
92
+
93
+ ## Operations
94
+
95
+ ### Writes (Commands/Mutations)
96
+ {Table: Operation | Handler/Service | Description | Key Validation}
97
+
98
+ ### Reads (Queries)
99
+ {Table: Query | Handler/Service | Description | Return Type}
100
+
101
+ ---
102
+
103
+ ## API / Entry Points
104
+ {Table: Method | Path/Topic/Command | Handler | Description}
105
+
106
+ ---
107
+
108
+ ## Event Flow
109
+ {If async events are involved (Kafka, RabbitMQ, webhooks, etc.)}
110
+ {mermaid sequence diagram showing event production/consumption}
111
+ {Include: event names, topics, consumer handlers}
112
+
113
+ ---
114
+
115
+ ## Module Dependencies
116
+ {mermaid graph showing which modules depend on which}
117
+ {Use subgraphs to group by domain or layer}
118
+
119
+ ---
120
+
121
+ ## Key Implementation Details
122
+ {Notable patterns, edge cases, business rules worth highlighting}
123
+ {Reference specific classes/functions and file paths}
124
+ ```
125
+
126
+ ### Mermaid Diagram Guidelines
127
+
128
+ - **Sequence diagrams** (`sequenceDiagram`): For request/response flows across layers
129
+ - **Class diagrams** (`classDiagram`): For domain model relationships and aggregate structure
130
+ - **ER diagrams** (`erDiagram`): For persistence model relationships
131
+ - **Flowcharts** (`flowchart TD`): For decision trees, validation flows, state machines
132
+ - **Graph diagrams** (`graph LR` or `graph TD`): For module dependencies, component trees
133
+ - Keep node labels short but descriptive
134
+ - Use subgraphs to group related nodes by module or layer
135
+ - Use dotted lines (`-.->`) for optional/indirect relationships
136
+
137
+ ## Step 4: Write File
138
+
139
+ 1. Write the documentation using the Write tool to `.5/analysis/{name}-analysis.md`.
140
+
141
+ 2. Report to the user:
142
+ ```
143
+ Analysis saved to .5/analysis/{name}-analysis.md
144
+
145
+ Sections included:
146
+ - {list of sections that were generated}
147
+ - {N} mermaid diagrams
148
+
149
+ Modules analyzed: {list of modules examined}
150
+ ```
151
+
152
+ ## Important Notes
153
+
154
+ - Read ALL relevant files thoroughly before writing -- do not guess or assume
155
+ - Every mermaid diagram must be syntactically valid
156
+ - Reference specific class/function names and file paths so the reader can navigate to the source
157
+ - Focus on the specific feature/dataflow requested, not the entire codebase
158
+ - Follow the data through all layers from entry point to output
159
+ - Document both the happy path and notable error/validation paths
@@ -117,6 +117,8 @@ Use `multiSelect: false` to get single focus area initially.
117
117
 
118
118
  Based on the user's focus area, explore the codebase if needed:
119
119
 
120
+ **Index shortcut:** Before spawning Explore agents or running Glob/Grep, check if `.5/index/` exists. If it does, read `.5/index/README.md` first for the generation timestamp — if fresh (under 1 day old), read the relevant index files (e.g., modules.md for scope changes, routes.md for API discussions, models.md for data model questions) to quickly gather context and skip broad scanning. If outdated, inform the user they can run `.5/index/rebuild-index.sh` to refresh it. If `.5/index/` does not exist, inform the user they can run `/5:reconfigure` to generate it. In both missing/outdated cases, fall back to Glob/Grep or Explore agents for exploration.
121
+
120
122
  **For technical constraint discussions:**
121
123
  - Search for similar implementations
122
124
  - Check existing patterns
@@ -207,6 +207,9 @@ Task tool call:
207
207
  {If Depends On is not "—": "This component depends on {dep-name} ({dep-file}). Read that file first to understand the exports/types you need to use."}
208
208
  {If Depends On is "—": omit this section entirely}
209
209
 
210
+ ## Codebase Context (optional)
211
+ If you need to understand how this component relates to other modules (imports, service boundaries, data flow), check `.5/index/` for quick reference — especially modules.md and libraries.md. Only if these files exist.
212
+
210
213
  ## Verify
211
214
  {Verify command(s) from plan table — executor runs these after implementation}
212
215
 
@@ -14,20 +14,22 @@ After creating the spec, you are FINISHED. You do not continue. You do not offer
14
14
  </role>
15
15
 
16
16
  <constraints>
17
- HARD CONSTRAINTS — violations waste tokens and get blocked by plan-guard:
18
- - NEVER write code, pseudo-code, or implementation snippets in any output
19
- - NEVER describe HOW something will be implemented (file contents, signatures, class structures)
20
- - NEVER create an implementation plan, file list, component breakdown, or step-by-step build guide that is Phase 2's job
21
- - NEVER suggest "shall I continue with implementation planning?" or "let me create the plan" — you are DONE after feature.md
22
- - NEVER offer to proceed to the next phase the user will invoke `/5:plan-implementation` themselves
23
- - NEVER spawn Task agents with subagent_type other than Explore
24
- - NEVER write to any file except .5/.planning-active, .5/features/{name}/codebase-scan.md, and .5/features/{name}/feature.md
25
- - NEVER call EnterPlanMode the workflow has its own planning process
26
- - NEVER use Bash to create, write, or modify files — this bypasses the plan-guard and is a constraint violation
27
- - NEVER continue past the completion message — when you output "Feature spec created at...", you are FINISHED
28
- - The feature spec describes WHAT and WHY, never HOW
29
- - If you feel the urge to plan implementation or write code, STOP — ask a clarifying question instead
30
- - Your output is a SPECIFICATION, not a design document. No code. No file layouts. No API shapes. No implementation plans.
17
+ HARD CONSTRAINTS:
18
+ - Do NOT write code or pseudo-code describe behavior and data shapes in natural language or tables
19
+ - Do NOT create implementation plans, file lists, or step-by-step build guides — that is Phase 2's job
20
+ - Do NOT offer to proceed to the next phase the user will invoke `/5:plan-implementation` themselves
21
+ - Do NOT spawn Task agents with subagent_type other than Explore
22
+ - Do NOT write to any file except .5/.planning-active, .5/features/{name}/codebase-scan.md, and .5/features/{name}/feature.md
23
+ - Do NOT call EnterPlanMode the workflow has its own planning process
24
+ - Do NOT use Bash to create, write, or modify files — this bypasses the plan-guard
25
+ - Do NOT continue past the completion message when you output "Feature spec created at...", you are FINISHED
26
+
27
+ WHAT IS ALLOWED:
28
+ - Name existing classes, modules, services, and patterns
29
+ - Describe entity fields with domain types
30
+ - Reference existing patterns as models
31
+ - Mention affected methods or APIs by name
32
+ - Include data shape tables with field names and types — these are part of the requirement
31
33
  </constraints>
32
34
 
33
35
  <write-rules>
@@ -42,11 +44,10 @@ Any other Write target WILL be blocked by the plan-guard hook. Do not attempt it
42
44
  Use the template structure from `.claude/templates/workflow/FEATURE-SPEC.md`.
43
45
 
44
46
  **Content rules for feature.md:**
45
- - Requirements use natural language ("The system shall..."), NOT code
46
- - Affected Components lists module/domain names, NOT file paths
47
- - NO code snippets, NO pseudo-code, NO type definitions
48
- - Entity definitions describe data CONCEPTS, not DB schemas or TypeScript interfaces
49
- - Acceptance criteria describe observable behavior, NOT test code
47
+ - Write naturally reference existing classes, modules, and patterns by name for precision
48
+ - Entity definitions include field names and domain types — these define the requirement
49
+ - Acceptance criteria describe observable behavior
50
+ - No code blocks, no pseudo-code, no class hierarchy designs
50
51
  </output-format>
51
52
 
52
53
  <collaboration-strategy>
@@ -129,12 +130,13 @@ Analyze the codebase for a feature specification session.
129
130
  **Feature Description:** {paste the user's feature description}
130
131
 
131
132
  **Your Task:**
132
- 1. Explore project structure to identify modules/components
133
- 2. Find existing implementations similar to this feature
134
- 3. Identify coding patterns and conventions
135
- 4. Find reusable components or patterns
136
- 5. Identify affected files/modules
137
- 6. Run `git branch --show-current` to get the current branch name
133
+ 1. Check if `.5/index/` exists. If it does, read `.5/index/README.md` first — it includes a generation timestamp. If the index is fresh (under 1 day old), read the relevant index files (e.g., modules.md, routes.md, models.md) as your structural overview and skip broad Glob scans for information already covered. If the index is outdated (over 1 day old), note in your report that the user should run `.5/index/rebuild-index.sh` to refresh it, then use it anyway (stale is better than nothing). If `.5/index/` does not exist at all, note in your report that the user can run `/5:reconfigure` to generate it, then proceed with Glob/Grep exploration as below.
134
+ 2. Explore project structure to identify modules/components
135
+ 3. Find existing implementations similar to this feature
136
+ 4. Identify coding patterns and conventions
137
+ 5. Find reusable components or patterns
138
+ 6. Identify affected files/modules
139
+ 7. Run `git branch --show-current` to get the current branch name
138
140
 
139
141
  **Report Format:**
140
142
  - Current git branch name
@@ -192,7 +194,7 @@ Targeted exploration for feature planning.
192
194
 
193
195
  ### Step 4: Create Feature Specification
194
196
 
195
- > **ROLE CHECK:** You are writing a SPECIFICATION (WHAT/WHY), not a design document (HOW). Zero code, zero file paths to create, zero signatures. After writing feature.md you are DONE — do NOT proceed to implementation planning or coding.
197
+ > **ROLE CHECK:** You are writing a FEATURE SPECIFICATION. After writing feature.md you are DONE — do NOT proceed to implementation planning or coding.
196
198
 
197
199
  **Extract ticket ID from git branch:**
198
200
  - The Explore agent from Step 2 already ran `git branch --show-current` — find the branch name in its results
@@ -208,25 +210,14 @@ Write to `.5/features/{name}/feature.md` using Write tool, where `{name}` is eit
208
210
 
209
211
  Use the template structure from `.claude/templates/workflow/FEATURE-SPEC.md`.
210
212
 
211
- Populate all sections:
212
- - Ticket ID & Summary
213
- - Problem Statement
214
- - Visual Overview (optional mermaid diagramssee below)
215
- - Requirements (functional and non-functional)
216
- - Constraints
217
- - Affected Components (from exploration)
218
- - Acceptance Criteria
219
- - Alternatives Considered
220
- - Decisions (from the conversation) — label each with **[DECIDED]**, **[FLEXIBLE]**, or **[DEFERRED]**
221
-
222
- **Visual Overview (optional mermaid diagrams):**
223
- Include mermaid diagrams in the spec when they add clarity. Use your judgment:
224
- - **Flow diagrams**: When the feature involves a multi-step process or state transitions
225
- - **Entity relationship diagrams**: When new data concepts relate to existing ones
226
- - **Component interaction diagrams**: When multiple modules/services communicate
227
- - **Sequence diagrams**: When the order of operations between actors matters
228
-
229
- Simple features (single-component changes, straightforward CRUD) typically do not need diagrams. Do not add diagrams for the sake of having them. Diagrams describe WHAT happens, not HOW it is implemented. No class diagrams, no file-level architecture diagrams, no code-level sequence diagrams.
213
+ Populate the sections from the template. Key guidance:
214
+ - **Overview**: Write a short narrative (3-5 sentences) merging the problem and the solution
215
+ - **What Changes**: Group by logical concern, not by module layer. Name existing classes and patterns. Use entity tables where new data models are introduced
216
+ - **Existing Patterns to Follow**: Be specific these are the highest-value pointers for Phase 2
217
+ - **Scope**: Be explicit about what's in and what's out
218
+ - **Decisions**: Label each from the conversation
219
+ - **Diagrams**: Include only when they add clarity. Simple features don't need them
220
+ - **Alternatives**: Only include if genuinely discussed and the reasoning matters. Delete if empty
230
221
 
231
222
  **Decision labeling rules:**
232
223
  - **[DECIDED]**: The user gave a clear, specific answer → Phase 2 planner and Phase 3 agents MUST honor exactly
@@ -110,11 +110,11 @@ This activates (or refreshes) the plan-guard hook which prevents accidental sour
110
110
 
111
111
  ### Step 1: Load Feature Spec *(skip if live context)*
112
112
 
113
- **If live context:** You already have the feature spec discussion in your conversation history. Extract ticket ID, requirements, acceptance criteria, affected components, and decisions from what was discussed. Output `✓ Step 1 skipped (live context)` and proceed to Step 1b.
113
+ **If live context:** You already have the feature spec discussion in your conversation history. Extract ticket ID, what changes (by logical concern), acceptance criteria, existing patterns to follow, scope, and decisions from what was discussed. Output `✓ Step 1 skipped (live context)` and proceed to Step 1b.
114
114
 
115
115
  **If no live context:** Read `.5/features/{feature-name}/feature.md` (where `{feature-name}` is the argument provided).
116
116
 
117
- Extract: Ticket ID, requirements (functional and non-functional), acceptance criteria, affected components, and **decisions**.
117
+ Extract: Ticket ID, overview, what changes (each logical concern), existing patterns to follow, constraints, scope, acceptance criteria, and **decisions**.
118
118
 
119
119
  **Decision labels from feature spec:**
120
120
  - **[DECIDED]** items are locked — your plan MUST honor them exactly. Do not override or reinterpret.
@@ -160,13 +160,14 @@ Quick codebase scan for implementation planning.
160
160
  Focus scan on {projectType}-relevant directories and patterns.
161
161
 
162
162
  **Your Task:**
163
- 1. Find source directories and understand project structure
164
- 2. Identify where similar components live (models, services, controllers, tests)
165
- 3. Note naming conventions from existing files
166
- 4. Find example files that can serve as patterns for new components
167
- 5. Identify the project's test framework, test file conventions, and test directory structure (e.g., __tests__/, tests/, *.test.ts, *.spec.ts, test_*.py)
168
- 6. Detect e2e test framework and config (Cypress, Playwright, Selenium, Supertest, etc.) look for config files like playwright.config.ts, cypress.config.js, e2e/ directories
169
- 7. Detect integration test patterns (test containers, in-memory DBs, API test helpers, fixtures) — look for setup files, docker-compose.test.yml, test utilities
163
+ 1. Check if `.5/index/` exists. If it does, read `.5/index/README.md` first — it includes a generation timestamp. If the index is fresh (under 1 day old), read the relevant index files (modules.md, models.md, libraries.md, etc.) for project structure and component locations, then focus Glob/Grep on naming conventions, pattern files, and test framework details not covered by the index. If the index is outdated (over 1 day old), note in your report that the user should run `.5/index/rebuild-index.sh` to refresh it, then use it anyway. If `.5/index/` does not exist at all, note in your report that the user can run `/5:reconfigure` to generate it, then scan from scratch as below.
164
+ 2. Find source directories and understand project structure
165
+ 3. Identify where similar components live (models, services, controllers, tests)
166
+ 4. Note naming conventions from existing files
167
+ 5. Find example files that can serve as patterns for new components
168
+ 6. Identify the project's test framework, test file conventions, and test directory structure (e.g., __tests__/, tests/, *.test.ts, *.spec.ts, test_*.py)
169
+ 7. Detect e2e test framework and config (Cypress, Playwright, Selenium, Supertest, etc.) — look for config files like playwright.config.ts, cypress.config.js, e2e/ directories
170
+ 8. Detect integration test patterns (test containers, in-memory DBs, API test helpers, fixtures) — look for setup files, docker-compose.test.yml, test utilities
170
171
 
171
172
  **Report Format:**
172
173
  - Project structure (key directories)
@@ -91,7 +91,7 @@ Check if `.5/features/${feature_name}/state.json` already exists:
91
91
 
92
92
  ### Step 4: Analyze and Scope Check
93
93
 
94
- 1. **Identify affected files** using Glob and Grep
94
+ 1. **Identify affected files:** If `.5/index/` exists, read `.5/index/README.md` first for the generation timestamp — if fresh (under 1 day old), read the relevant index files (modules.md, routes.md, models.md) to quickly locate affected areas, then confirm with targeted Glob/Grep. If the index is outdated, note that the user can run `.5/index/rebuild-index.sh` to refresh it. If no index exists, note that the user can run `/5:reconfigure` to generate it. In both cases, fall back to Glob and Grep directly.
95
95
  2. **Determine skills needed** based on task type
96
96
  3. **List components** (max 5 for quick mode)
97
97
 
@@ -261,6 +261,7 @@ Task tool call:
261
261
  For each component:
262
262
 
263
263
  **If creating a new file:**
264
+ 0. If `.5/index/` exists, check modules.md or libraries.md to find where similar components live — this narrows your Glob search.
264
265
  1. Find a similar file using Glob (e.g., *Service.ts for services)
265
266
  2. Read it to understand the pattern (imports, structure, exports)
266
267
  3. Create the new file following that pattern
@@ -0,0 +1,60 @@
1
+ ---
2
+ name: 5:synchronize-agents
3
+ description: Synchronize user-generated skills, rules, and custom content between Claude Code and Codex runtimes
4
+ allowed-tools: Bash, Read, AskUserQuestion
5
+ user-invocable: true
6
+ model: haiku
7
+ context: fork
8
+ ---
9
+
10
+ <role>
11
+ You are a Runtime Synchronizer. You run the sync script and report results.
12
+ You do NOT modify files manually. After reporting, you are DONE.
13
+ </role>
14
+
15
+ # Synchronize Agent Runtimes
16
+
17
+ Synchronizes user-generated content (skills, commands, agents, rules) between the Claude Code (`.claude/`) and Codex (`.codex/`) runtimes.
18
+
19
+ ## Step 1: Locate the Sync Script
20
+
21
+ The script is `bin/sync-agents.js` in the workflow package. Find it by checking these paths in order:
22
+
23
+ 1. `./bin/sync-agents.js` (development checkout / project root)
24
+ 2. `./node_modules/5-phase-workflow/bin/sync-agents.js` (local npm install)
25
+
26
+ Read `.5/version.json` if available — its location confirms the project root.
27
+
28
+ Store the resolved path for the following steps.
29
+
30
+ If the script cannot be found, tell the user: "Sync script not found. Update the workflow first: `npx 5-phase-workflow --upgrade`" and **stop**.
31
+
32
+ ## Step 2: Dry Run
33
+
34
+ Run the script in dry-run mode to preview what will be synced:
35
+
36
+ ```bash
37
+ node {script-path} --dry-run
38
+ ```
39
+
40
+ If the script exits with a non-zero code (missing runtime, no content), show the output and **stop**.
41
+
42
+ If there are no actionable changes (everything in sync), report that and **stop**.
43
+
44
+ ## Step 3: Confirm with User
45
+
46
+ Show the dry-run output. Ask: "Proceed with synchronization?"
47
+
48
+ If the user declines, stop.
49
+
50
+ ## Step 4: Execute Sync
51
+
52
+ ```bash
53
+ node {script-path}
54
+ ```
55
+
56
+ ## Step 5: Report
57
+
58
+ Show the script output. Summarize what was synced.
59
+
60
+ Note: This command works identically from both Claude Code (`/5:synchronize-agents`) and Codex (`$5-synchronize-agents`). The script auto-detects the project root.
@@ -1,135 +1,100 @@
1
1
  <!-- TEMPLATE RULES:
2
- - Requirements use natural language, not code
3
- - Affected Components lists module/domain names, not file paths
4
- - Entity definitions describe data concepts, not schemas or interfaces
5
- - Acceptance criteria describe observable behavior, not test assertions
6
- - NO code, pseudo-code, or implementation details anywhere in this document
7
- - Visual Overview section is OPTIONAL delete it if the feature doesn't benefit from diagrams
8
- - Mermaid diagrams describe WHAT happens, not HOW it is implemented
2
+ - Write naturally
3
+ - Reference existing classes, modules, and patterns by name for precision
4
+ - Entity definitions include field names and domain types
5
+ - Acceptance criteria describe observable behavior
6
+ - No code blocks, no pseudo-code, no class hierarchy designs
7
+ - Delete any OPTIONAL section that doesn't add value for this feature
9
8
  -->
10
9
 
11
10
  # Feature: {TICKET-ID} - {Title}
12
11
 
13
- ## Ticket ID
14
- {TICKET-ID}
12
+ **Ticket:** {TICKET-ID}
15
13
 
16
- ## Summary
17
- {1-2 sentence overview: what capability is being added and who benefits}
14
+ ## Overview
18
15
 
19
- ## Problem Statement
20
- {Describe the current pain point or gap. Who experiences it and what is the impact?}
16
+ {What is the problem or gap, and what capability is being added? Write this as a short narrative
17
+ that covers who is affected, why the change matters, and what the end result looks like.}
21
18
 
22
- ## Visual Overview
23
- <!-- OPTIONAL: Include mermaid diagrams only when they add clarity to the feature.
24
- Delete this entire section if the feature is simple enough to understand without diagrams.
25
- Use whichever diagram types are relevant — you don't need all of them. -->
19
+ <!-- OPTIONAL: Include mermaid diagrams only when they add clarity.
20
+ Delete this section for simple features. Use whichever diagram type fits. -->
26
21
 
27
- <!-- Process Flow — use when the feature involves a multi-step process or state transitions -->
28
22
  ```mermaid
29
23
  flowchart TD
30
- A[Start state] --> B[Step 1]
31
- B --> C{Decision point}
32
- C -->|Yes| D[Outcome 1]
33
- C -->|No| E[Outcome 2]
24
+ A[Current state] --> B[Change]
25
+ B --> C[New capability]
34
26
  ```
35
27
 
36
- <!-- Entity Relationships — use when new data concepts relate to existing ones -->
37
- ```mermaid
38
- erDiagram
39
- ENTITY-A ||--o{ ENTITY-B : "relationship"
40
- ENTITY-B }|--|| ENTITY-C : "relationship"
41
- ```
28
+ ## What Changes
42
29
 
43
- <!-- Component Interactions use when multiple modules or services communicate -->
44
- ```mermaid
45
- sequenceDiagram
46
- actor User
47
- participant ComponentA
48
- participant ComponentB
49
- User->>ComponentA: action
50
- ComponentA->>ComponentB: interaction
51
- ComponentB-->>User: result
52
- ```
30
+ {Describe what the feature does in natural, flowing prose. Name existing classes, modules, and patterns
31
+ where relevant. Group by logical concern, not by module layer. Each subsection should tell the reader
32
+ what happens and which parts of the codebase are involved.}
53
33
 
54
- ## Requirements
34
+ ### {Logical concern 1, e.g., "New data model"}
55
35
 
56
- ### Functional Requirements
57
- - {The system shall... [describe observable behavior]}
58
- - ...
36
+ {Describe the change. Name affected modules and classes. If a new entity is introduced, describe its
37
+ fields and types in a table:}
59
38
 
60
- ### Non-Functional Requirements
61
- - {Performance, reliability, scalability, or compatibility expectations}
62
- - ...
39
+ | Field | Type | Required | Description |
40
+ |-------|------|----------|-------------|
41
+ | ... | ... | ... | ... |
63
42
 
64
- ## Constraints
65
- - {Business rules that limit the solution space}
66
- - {Technical boundaries from existing architecture}
67
- - {Timeline or resource limitations}
43
+ ### {Logical concern 2, e.g., "CRUD operations"}
68
44
 
69
- ## Affected Components
70
- - **{component/module-1}** - {What changes here}
71
- - **{component/module-2}** - {What changes here}
72
- - **{component/module-3}** - {What changes here}
73
- - ...
45
+ {Describe the behavior. Reference existing patterns to follow, e.g.,
46
+ "Follow the same approach as the UserService update flow."}
74
47
 
75
- ## Entity/Component Definitions
48
+ ### {Logical concern 3, e.g., "API exposure"}
76
49
 
77
- ### {EntityName} (if applicable)
78
- <!-- Describe the data CONCEPT, not the implementation. No TypeScript, no SQL. -->
79
- | Field | Type | Required | Description |
80
- |-------|------|----------|-------------|
81
- | id | {Entity}Id | Yes | Unique identifier |
82
- | name | String | Yes | Entity name |
83
- | ... | ... | ... | ... |
50
+ {Describe what gets exposed and how.}
84
51
 
85
52
  ### Business Rules
53
+
86
54
  - {Rule 1}
87
55
  - {Rule 2}
88
- - ...
89
56
 
90
- ## Acceptance Criteria
91
- - [ ] {Observable behavior that proves this requirement is met}
92
- - [ ] {Observable behavior that proves this requirement is met}
93
- - [ ] {Observable behavior that proves this requirement is met}
57
+ ## Existing Patterns to Follow
58
+
59
+ {List concrete patterns from the codebase that the implementation should mirror.
60
+ These are high-value pointers for Phase 2 -- be specific.}
61
+
62
+ - **{Pattern name}** -- {where it lives and what to reuse from it}
94
63
  - ...
95
64
 
96
- ## Alternatives Considered
65
+ ## Constraints
66
+
67
+ - {Business rules that limit the solution space}
68
+ - {Technical boundaries from existing architecture}
69
+
70
+ ## Scope
71
+
72
+ **In scope:**
73
+ - {What is included}
97
74
 
98
- ### Option 1: {Alternative approach}
99
- **Pros:** {Benefits}
100
- **Cons:** {Drawbacks}
101
- **Decision:** Rejected because {reason}
75
+ **Out of scope:**
76
+ - {What is explicitly excluded and why}
102
77
 
103
- ### Option 2: {Another alternative}
104
- **Pros:** {Benefits}
105
- **Cons:** {Drawbacks}
106
- **Decision:** Rejected because {reason}
78
+ ## Acceptance Criteria
107
79
 
108
- ### Chosen Approach: {Selected approach}
109
- **Rationale:** {Why this approach was chosen}
80
+ - [ ] {Observable behavior that proves a requirement is met}
81
+ - [ ] ...
110
82
 
111
83
  ## Decisions
112
84
 
113
- <!-- Record key decisions from the spec discussion.
114
- Tag each with exactly one of: [DECIDED], [FLEXIBLE], [DEFERRED]
115
- - [DECIDED]: Locked — Phase 2 planner and Phase 3 agents MUST honor exactly
116
- - [FLEXIBLE]: Claude's discretion — planner chooses the best approach
117
- - [DEFERRED]: Out of scope — planner MUST NOT include in the plan
118
- -->
85
+ <!-- Tag each: [DECIDED] = locked, [FLEXIBLE] = planner chooses, [DEFERRED] = not in this iteration -->
119
86
 
120
- ### {Topic: brief description of what was decided}
121
- **Context:** {Why this decision came up}
122
- **Decision:** {What was decided} **[DECIDED]**
87
+ - **{Topic}:** {What was decided and why} **[DECIDED]**
88
+ - **{Topic}:** {General direction, planner chooses specifics} **[FLEXIBLE]**
89
+ - **{Topic}:** {Not addressing now -- reason} **[DEFERRED]**
123
90
 
124
- ### {Topic: area left to implementer's discretion}
125
- **Context:** {What was discussed}
126
- **Decision:** {General direction, implementer chooses specifics} **[FLEXIBLE]**
91
+ <!-- OPTIONAL: Only include if alternatives were genuinely discussed and the reasoning matters -->
92
+ ## Alternatives Considered
127
93
 
128
- ### {Topic: explicitly deferred item}
129
- **Context:** {Why it was raised}
130
- **Decision:** {Not addressing now — reason} **[DEFERRED]**
94
+ - **{Alternative}:** Rejected because {reason}
95
+ - **{Chosen approach}:** Selected because {reason}
131
96
 
132
97
  ## Next Steps
133
- After approval:
134
- 1. Run `/clear` to reset context
98
+
99
+ 1. Run `/clear` to reset context (optional)
135
100
  2. Run `/5:plan-implementation {TICKET-ID}-{description}`