@cliangdev/flux-plugin 0.1.0 → 0.2.0-dev.359209a

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 (113) hide show
  1. package/README.md +55 -22
  2. package/agents/coder.md +317 -0
  3. package/agents/critic.md +174 -0
  4. package/agents/researcher.md +146 -0
  5. package/agents/verifier.md +149 -0
  6. package/bin/install.cjs +390 -0
  7. package/commands/breakdown.md +48 -10
  8. package/commands/dashboard.md +29 -0
  9. package/commands/flux.md +218 -94
  10. package/commands/implement.md +167 -17
  11. package/commands/linear.md +172 -0
  12. package/commands/prd.md +997 -82
  13. package/manifest.json +16 -0
  14. package/package.json +17 -11
  15. package/skills/agent-creator/SKILL.md +2 -0
  16. package/skills/epic-template/SKILL.md +2 -0
  17. package/skills/flux-orchestrator/SKILL.md +68 -76
  18. package/skills/prd-writer/SKILL.md +761 -0
  19. package/skills/ux-ui-design/SKILL.md +346 -0
  20. package/skills/ux-ui-design/references/design-tokens.md +359 -0
  21. package/src/__tests__/version.test.ts +37 -0
  22. package/src/adapters/local/.gitkeep +0 -0
  23. package/src/dashboard/__tests__/api.test.ts +211 -0
  24. package/src/dashboard/browser.ts +35 -0
  25. package/src/dashboard/public/app.js +869 -0
  26. package/src/dashboard/public/index.html +90 -0
  27. package/src/dashboard/public/styles.css +807 -0
  28. package/src/dashboard/public/vendor/highlight.css +10 -0
  29. package/src/dashboard/public/vendor/highlight.min.js +8422 -0
  30. package/src/dashboard/public/vendor/marked.min.js +2210 -0
  31. package/src/dashboard/server.ts +296 -0
  32. package/src/dashboard/watchers.ts +83 -0
  33. package/src/server/__tests__/config.test.ts +163 -0
  34. package/src/server/adapters/__tests__/a-client-linear.test.ts +197 -0
  35. package/src/server/adapters/__tests__/adapter-factory.test.ts +230 -0
  36. package/src/server/adapters/__tests__/dependency-ops.test.ts +429 -0
  37. package/src/server/adapters/__tests__/document-ops.test.ts +306 -0
  38. package/src/server/adapters/__tests__/linear-adapter.test.ts +91 -0
  39. package/src/server/adapters/__tests__/linear-config.test.ts +425 -0
  40. package/src/server/adapters/__tests__/linear-criteria-parser.test.ts +287 -0
  41. package/src/server/adapters/__tests__/linear-description-test.ts +238 -0
  42. package/src/server/adapters/__tests__/linear-epic-crud.test.ts +496 -0
  43. package/src/server/adapters/__tests__/linear-mappers-description.test.ts +276 -0
  44. package/src/server/adapters/__tests__/linear-mappers-epic.test.ts +294 -0
  45. package/src/server/adapters/__tests__/linear-mappers-prd.test.ts +300 -0
  46. package/src/server/adapters/__tests__/linear-mappers-task.test.ts +197 -0
  47. package/src/server/adapters/__tests__/linear-prd-crud.test.ts +620 -0
  48. package/src/server/adapters/__tests__/linear-stats.test.ts +450 -0
  49. package/src/server/adapters/__tests__/linear-task-crud.test.ts +534 -0
  50. package/src/server/adapters/__tests__/linear-types.test.ts +243 -0
  51. package/src/server/adapters/__tests__/status-ops.test.ts +441 -0
  52. package/src/server/adapters/factory.ts +90 -0
  53. package/src/server/adapters/index.ts +9 -0
  54. package/src/server/adapters/linear/adapter.ts +1141 -0
  55. package/src/server/adapters/linear/client.ts +169 -0
  56. package/src/server/adapters/linear/config.ts +152 -0
  57. package/src/server/adapters/linear/helpers/criteria-parser.ts +197 -0
  58. package/src/server/adapters/linear/helpers/index.ts +7 -0
  59. package/src/server/adapters/linear/index.ts +16 -0
  60. package/src/server/adapters/linear/mappers/description.ts +136 -0
  61. package/src/server/adapters/linear/mappers/epic.ts +81 -0
  62. package/src/server/adapters/linear/mappers/index.ts +27 -0
  63. package/src/server/adapters/linear/mappers/prd.ts +178 -0
  64. package/src/server/adapters/linear/mappers/task.ts +82 -0
  65. package/src/server/adapters/linear/types.ts +264 -0
  66. package/src/server/adapters/local-adapter.ts +1009 -0
  67. package/src/server/adapters/types.ts +293 -0
  68. package/src/server/config.ts +73 -0
  69. package/src/server/db/__tests__/queries.test.ts +473 -0
  70. package/src/server/db/ids.ts +17 -0
  71. package/src/server/db/index.ts +69 -0
  72. package/src/server/db/queries.ts +142 -0
  73. package/src/server/db/refs.ts +60 -0
  74. package/src/server/db/schema.ts +97 -0
  75. package/src/server/db/sqlite.ts +10 -0
  76. package/src/server/index.ts +81 -0
  77. package/src/server/tools/__tests__/crud.test.ts +411 -0
  78. package/src/server/tools/__tests__/get-version.test.ts +27 -0
  79. package/src/server/tools/__tests__/mcp-interface.test.ts +479 -0
  80. package/src/server/tools/__tests__/query.test.ts +405 -0
  81. package/src/server/tools/__tests__/z-configure-linear.test.ts +511 -0
  82. package/src/server/tools/__tests__/z-get-linear-url.test.ts +108 -0
  83. package/src/server/tools/configure-linear.ts +373 -0
  84. package/src/server/tools/create-epic.ts +44 -0
  85. package/src/server/tools/create-prd.ts +40 -0
  86. package/src/server/tools/create-task.ts +47 -0
  87. package/src/server/tools/criteria.ts +50 -0
  88. package/src/server/tools/delete-entity.ts +76 -0
  89. package/src/server/tools/dependencies.ts +55 -0
  90. package/src/server/tools/get-entity.ts +240 -0
  91. package/src/server/tools/get-linear-url.ts +28 -0
  92. package/src/server/tools/get-stats.ts +52 -0
  93. package/src/server/tools/get-version.ts +20 -0
  94. package/src/server/tools/index.ts +158 -0
  95. package/src/server/tools/init-project.ts +108 -0
  96. package/src/server/tools/query-entities.ts +167 -0
  97. package/src/server/tools/render-status.ts +219 -0
  98. package/src/server/tools/update-entity.ts +140 -0
  99. package/src/server/tools/update-status.ts +166 -0
  100. package/src/server/utils/__tests__/mcp-response.test.ts +331 -0
  101. package/src/server/utils/logger.ts +9 -0
  102. package/src/server/utils/mcp-response.ts +254 -0
  103. package/src/server/utils/status-transitions.ts +160 -0
  104. package/src/status-line/__tests__/status-line.test.ts +215 -0
  105. package/src/status-line/index.ts +147 -0
  106. package/src/utils/__tests__/chalk-import.test.ts +32 -0
  107. package/src/utils/__tests__/display.test.ts +97 -0
  108. package/src/utils/__tests__/status-renderer.test.ts +310 -0
  109. package/src/utils/display.ts +62 -0
  110. package/src/utils/status-renderer.ts +214 -0
  111. package/src/version.ts +5 -0
  112. package/dist/server/index.js +0 -86929
  113. package/skills/prd-template/SKILL.md +0 -240
@@ -1,4 +1,5 @@
1
1
  ---
2
+ name: flux:breakdown
2
3
  description: Break approved PRD into dependency-ordered epics and tasks
3
4
  allowed-tools: mcp__flux__*, Read, AskUserQuestion
4
5
  ---
@@ -15,12 +16,26 @@ Check if arguments were provided:
15
16
 
16
17
  ## Pre-checks
17
18
 
18
- 1. Call `get_project_context` to ensure Flux is initialized
19
- - If not initialized, tell user: "Run `/flux` first to initialize the project."
19
+ 1. If no ref provided, call `query_entities` with type=prd, status=APPROVED
20
+ - If error with `code: "PROJECT_NOT_INITIALIZED"`, tell user: "Run `/flux` first to initialize the project." and exit.
20
21
 
21
- 2. If no ref provided, call `query_entities` with type=prd, status=APPROVED
22
+ 2. If query successful but no approved PRDs found:
22
23
  - If no approved PRDs, tell user: "No approved PRDs found. Approve a PRD first or run `/flux:prd` to create one."
23
- - If multiple approved PRDs, use AskUserQuestion to let user select which one
24
+ - If multiple approved PRDs, use AskUserQuestion to let user select:
25
+ ```json
26
+ {
27
+ "questions": [{
28
+ "question": "Which PRD would you like to break down?",
29
+ "header": "Select PRD",
30
+ "options": [
31
+ {"label": "{PRD-1 title}", "description": "{ref} - {brief description}"},
32
+ {"label": "{PRD-2 title}", "description": "{ref} - {brief description}"}
33
+ ],
34
+ "multiSelect": false
35
+ }]
36
+ }
37
+ ```
38
+ Note: Dynamically populate options from the query results.
24
39
 
25
40
  3. If ref provided, call `get_entity` with the ref
26
41
  - Verify status is APPROVED
@@ -77,9 +92,21 @@ Which approach do you prefer?
77
92
 
78
93
  1. Get PRD entity with `get_entity` including `include: ['epics']`
79
94
  2. Read full PRD content from `folder_path + '/prd.md'` using Read tool
80
- 3. If PRD already has epics, inform user:
81
- - "This PRD already has {count} epics. Continue adding more or start fresh?"
82
- - Use AskUserQuestion with options: "Add more epics", "View existing", "Start fresh (delete existing)"
95
+ 3. If PRD already has epics, inform user and use AskUserQuestion:
96
+ ```json
97
+ {
98
+ "questions": [{
99
+ "question": "This PRD already has {count} epics. What would you like to do?",
100
+ "header": "Epics",
101
+ "options": [
102
+ {"label": "Add more epics", "description": "Keep existing epics and add new ones"},
103
+ {"label": "View existing", "description": "See current epic structure before deciding"},
104
+ {"label": "Start fresh", "description": "Delete existing epics and recreate from scratch"}
105
+ ],
106
+ "multiSelect": false
107
+ }]
108
+ }
109
+ ```
83
110
 
84
111
  ### Step 2: Analyze & Identify Epics
85
112
 
@@ -141,9 +168,20 @@ Ready to create these epics?
141
168
  ```
142
169
 
143
170
  Use AskUserQuestion only when uncertain:
144
- - Create all epics (Recommended)
145
- - Modify structure first
146
- - Add/remove epics
171
+ ```json
172
+ {
173
+ "questions": [{
174
+ "question": "Ready to create these epics?",
175
+ "header": "Confirm",
176
+ "options": [
177
+ {"label": "Create all epics (Recommended)", "description": "Proceed with the proposed structure"},
178
+ {"label": "Modify structure first", "description": "Adjust epic boundaries or dependencies"},
179
+ {"label": "Add/remove epics", "description": "Change the number of epics"}
180
+ ],
181
+ "multiSelect": false
182
+ }]
183
+ }
184
+ ```
147
185
 
148
186
  ### Step 4: Create Epics
149
187
 
@@ -0,0 +1,29 @@
1
+ ---
2
+ name: flux:dashboard
3
+ description: Open the Flux Dashboard to visualize PRDs, epics, and tasks
4
+ allowed-tools: Bash
5
+ ---
6
+
7
+ # Flux Dashboard
8
+
9
+ Launch the Flux Dashboard web interface to visualize project status.
10
+
11
+ ## Instructions
12
+
13
+ Run the dashboard server:
14
+
15
+ ```bash
16
+ bunx @cliangdev/flux-plugin dashboard
17
+ ```
18
+
19
+ This will:
20
+ 1. Start the dashboard server on port 3333 (or next available)
21
+ 2. Open the dashboard in the default browser
22
+
23
+ The dashboard shows:
24
+ - All PRDs with their epics and tasks
25
+ - Status indicators and progress
26
+ - Dependency graph visualization
27
+ - Detailed views for each entity
28
+
29
+ Tell the user the dashboard is starting and they can close it with Ctrl+C when done.
package/commands/flux.md CHANGED
@@ -1,112 +1,236 @@
1
1
  ---
2
+ name: flux
2
3
  description: AI-first workflow orchestration for spec-driven development
3
- allowed-tools: mcp__flux__*
4
+ allowed-tools: mcp__plugin_flux_flux__*, AskUserQuestion, Read, Write
4
5
  ---
5
6
 
6
- # Flux Orchestrator
7
+ # Flux Command
7
8
 
8
- You are the Flux orchestrator. Your job is to detect the project state and guide the user through the appropriate workflow.
9
+ You are the Flux orchestrator - the main entry point for all Flux operations. Your job is to:
10
+ 1. Detect project state and guide users to the appropriate next action
11
+ 2. Route to specialized commands based on user input
12
+ 3. Provide intelligent suggestions based on workflow state
9
13
 
10
- ## Step 0: Check for Version Subcommand
14
+ ## Available Commands
11
15
 
12
- First, check if the user requested version information:
13
- - `/flux version` - Show version information
16
+ | Command | Description |
17
+ |---------|-------------|
18
+ | `/flux` | Show project status and suggest next action |
19
+ | `/flux:prd` | Create or refine PRDs through guided interview |
20
+ | `/flux:breakdown` | Break approved PRD into dependency-ordered epics and tasks |
21
+ | `/flux:implement` | Implement tasks with TDD workflow using specialized coding agents |
22
+ | `/flux:linear` | Connect Flux project to Linear for issue tracking |
14
23
 
15
- If the argument is "version":
24
+ ## Subcommand Routing
16
25
 
17
- 1. Call the `get_version` MCP tool
18
- 2. Display the version information in a friendly format:
19
- ```
20
- Flux Plugin v{version}
21
- Package: @cliangdev/{name}
22
- ```
23
- 3. Exit (do not proceed to project state check)
26
+ When user provides arguments, route to the appropriate command:
24
27
 
25
- ## Step 1: Check Project State
28
+ | User Input | Action |
29
+ |------------|--------|
30
+ | `/flux` | Show status (see Main Flow) |
31
+ | `/flux version` | Call `get_version` and display result |
32
+ | `/flux status` | Call `render_status` with `{view: "full"}` |
33
+ | `/flux prd` or `/flux prd ...` | Delegate to `/flux:prd` with any additional args |
34
+ | `/flux breakdown` or `/flux breakdown ...` | Delegate to `/flux:breakdown` with any additional args |
35
+ | `/flux implement` or `/flux implement ...` | Delegate to `/flux:implement` with any additional args |
36
+ | `/flux linear` | Delegate to `/flux:linear` |
37
+ | `/flux help` | Show available commands and their purposes |
38
+
39
+ ## Available MCP Tools
40
+
41
+ These tools are available for programmatic access:
42
+
43
+ **Entity Management:**
44
+ - `create_prd`, `create_epic`, `create_task` - Create entities
45
+ - `update_entity`, `update_status`, `delete_entity` - Modify entities
46
+ - `get_entity`, `query_entities` - Retrieve entities
47
+
48
+ **Project:**
49
+ - `init_project` - Initialize new Flux project
50
+ - `get_stats` - Get entity counts by status
51
+ - `get_version` - Get plugin version
52
+ - `render_status` - Visual project status with progress bars
53
+
54
+ **Relationships:**
55
+ - `add_dependency`, `remove_dependency` - Task/epic dependencies
56
+ - `add_criteria`, `mark_criteria_met` - Acceptance criteria
57
+
58
+ **Integration:**
59
+ - `configure_linear` - Connect to Linear (interactive mode supported)
60
+
61
+ ## Main Flow
62
+
63
+ ### Step 0: Check for Subcommands
64
+
65
+ First, check if the user provided arguments (e.g., `/flux prd`, `/flux implement FP-T1`).
66
+ If so, route to the appropriate command as described in Subcommand Routing above.
67
+
68
+ ### Step 1: Check Project State
69
+
70
+ If no subcommand, call `render_status` with `{view: "summary"}` to show current state.
71
+
72
+ ### Step 2: Route Based on Response
73
+
74
+ **If error with `code: "PROJECT_NOT_INITIALIZED"`:**
75
+ → Guide through initialization (see Initialization Flow below)
26
76
 
27
- If no subcommand was provided, call the `get_project_context` MCP tool to check if this is a Flux project.
77
+ **If success:**
78
+ → Display the rendered status
79
+ → Analyze workflow state and suggest the most appropriate next action (see Workflow States)
80
+ → If multiple actions are possible, use AskUserQuestion to let user choose
28
81
 
29
- ## Step 2: Handle Result
82
+ ## Initialization Flow
30
83
 
31
- ### If `initialized: false` (New Project)
84
+ Use the `AskUserQuestion` tool for all questions during initialization.
85
+
86
+ ### Step 1: Confirm Initialization
87
+
88
+ Use AskUserQuestion:
89
+ ```json
90
+ {
91
+ "questions": [{
92
+ "question": "No Flux project found. Would you like to initialize one?",
93
+ "header": "Initialize",
94
+ "options": [
95
+ {"label": "Yes", "description": "Create a new Flux project in this directory"},
96
+ {"label": "No", "description": "Cancel initialization"}
97
+ ],
98
+ "multiSelect": false
99
+ }]
100
+ }
101
+ ```
102
+
103
+ If "No", exit with: "Run `/flux` when you're ready to set up Flux."
32
104
 
33
- This is a new project. Guide the user through initialization:
105
+ ### Step 2: Collect Project Details
34
106
 
35
- 1. Ask: "No Flux project found in this directory. Would you like to initialize one?"
36
- - If no, end with: "Run `/flux` when you're ready to set up Flux."
37
-
38
- 2. Ask: "What is the name of this project?"
39
- - Wait for response
40
-
41
- 3. Ask: "Brief vision - what does this project do? (one sentence)"
42
- - Wait for response
43
-
44
- 4. Call `init_project` tool with the name and vision
45
-
46
- 5. Display success message:
47
- ```
48
- Flux project initialized!
49
-
50
- Project: {name}
51
- Vision: {vision}
52
- Reference prefix: {ref_prefix}
53
-
54
- Created:
55
- - .flux/project.json
56
- - .flux/flux.db
57
-
58
- Next: Run /flux:prd to start planning your first PRD.
59
- ```
60
-
61
- ### If Project Exists (Initialized)
62
-
63
- This is an existing Flux project. Show status and suggest next action:
64
-
65
- 1. Call `get_stats` to get entity counts
66
-
67
- 2. Display status summary:
68
- ```
69
- Project: {name}
70
- Vision: {vision}
71
-
72
- Status:
73
- - PRDs: {total} ({draft} draft, {pending_review} in review, {approved} approved)
74
- - Epics: {total} ({pending} pending, {in_progress} active, {completed} done)
75
- - Tasks: {total} ({pending} pending, {in_progress} active, {completed} done)
76
- ```
77
-
78
- 3. Determine and suggest next action based on state:
79
-
80
- **If no PRDs exist:**
81
- > "No PRDs yet. Run `/flux:prd` to create your first product requirements document."
82
-
83
- **If PRDs exist with DRAFT status:**
84
- > "You have draft PRDs. Review them and run `/flux:prd refine` or submit for review."
85
-
86
- **If PRDs in PENDING_REVIEW:**
87
- > "PRDs pending review. The critique agent will analyze feasibility and risks."
88
-
89
- **If PRDs in REVIEWED status:**
90
- > "Critique complete. Review feedback, then approve or revise the PRD."
91
-
92
- **If PRDs APPROVED but no epics:**
93
- > "PRDs approved! Run `/flux:breakdown` to break them into epics and tasks."
94
-
95
- **If PRDs BREAKDOWN_READY with epics/tasks:**
96
- > "Ready to implement! Run `/flux:implement` to start working on tasks."
97
-
98
- **If tasks exist with PENDING status:**
99
- > "Tasks ready. Run `/flux:implement` to start working."
100
-
101
- **If tasks IN_PROGRESS:**
102
- > "Implementation in progress. Run `/flux:implement` to continue."
103
-
104
- **If all tasks COMPLETED:**
105
- > "All tasks complete! Review your work and create a PR."
107
+ Use AskUserQuestion with text input (user will select "Other" to type):
108
+ - Ask for project name
109
+ - Ask for project vision (brief description)
110
+
111
+ ### Step 3: Select Storage Backend
112
+
113
+ Use AskUserQuestion:
114
+ ```json
115
+ {
116
+ "questions": [{
117
+ "question": "Where should Flux store data?",
118
+ "header": "Storage",
119
+ "options": [
120
+ {"label": "Local (Recommended)", "description": "SQLite database in .flux/ - offline-first, no setup required"},
121
+ {"label": "Linear", "description": "Sync with Linear for team collaboration and issue tracking"}
122
+ ],
123
+ "multiSelect": false
124
+ }]
125
+ }
126
+ ```
127
+
128
+ ### Step 4: Ask About Tool Permissions
129
+
130
+ Use AskUserQuestion:
131
+ ```json
132
+ {
133
+ "questions": [{
134
+ "question": "Add Flux tools to allow list? This prevents permission prompts for Flux operations.",
135
+ "header": "Permissions",
136
+ "options": [
137
+ {"label": "Yes (Recommended)", "description": "Allow all Flux MCP tools without prompting"},
138
+ {"label": "No", "description": "Ask for permission each time"}
139
+ ],
140
+ "multiSelect": false
141
+ }]
142
+ }
143
+ ```
144
+
145
+ If "Yes", update the settings file:
146
+
147
+ 1. Read `.claude/settings.local.json` (create if doesn't exist)
148
+ 2. Parse JSON (or start with `{"permissions": {"allow": []}}` if empty/missing)
149
+ 3. Add `"mcp__plugin_flux_flux__*"` to `permissions.allow` array if not already present
150
+ 4. Write back to `.claude/settings.local.json`
151
+
152
+ Example result:
153
+ ```json
154
+ {
155
+ "permissions": {
156
+ "allow": ["mcp__plugin_flux_flux__*"]
157
+ }
158
+ }
159
+ ```
160
+
161
+ Confirm to user: "Flux tools added to allow list. No more permission prompts for Flux operations."
162
+
163
+ ### Step 5: Initialize Project
164
+
165
+ Call `init_project` with collected values:
166
+ - `name`: project name
167
+ - `vision`: project vision
168
+ - `adapter`: "local" or "linear"
169
+
170
+ ### Step 6: Next Steps
171
+
172
+ Display success message, then:
173
+
174
+ - **If Local**: "Project initialized! Run `/flux:prd` to create your first PRD."
175
+ - **If Linear**: "Project initialized! Now run `/flux:linear` to connect to Linear."
176
+
177
+ ## Workflow States
178
+
179
+ Detect current state and suggest the appropriate next action:
180
+
181
+ | State | Detection | Next Action |
182
+ |-------|-----------|-------------|
183
+ | No PRDs | `prds.total == 0` | `/flux:prd` to create first PRD |
184
+ | Draft PRDs | PRDs in DRAFT | Review and refine or submit for review |
185
+ | Pending Review | PRDs in PENDING_REVIEW | Critique agent will analyze |
186
+ | Reviewed | PRDs in REVIEWED | Address feedback, approve or revise |
187
+ | Approved | PRDs in APPROVED, no epics | `/flux:breakdown` to create epics |
188
+ | Breakdown Ready | PRDs in BREAKDOWN_READY | `/flux:implement` to start coding |
189
+ | In Progress | Tasks IN_PROGRESS | Continue with `/flux:implement` |
190
+ | Complete | All tasks COMPLETED | Create PR |
191
+
192
+ ## Confidence-Based Autonomy
193
+
194
+ When determining actions:
195
+
196
+ | Confidence | Behavior |
197
+ |------------|----------|
198
+ | > 80% | Auto-execute, inform user |
199
+ | 50-80% | Suggest action, wait for confirmation |
200
+ | < 50% | Ask clarifying question |
201
+
202
+ ## Help Output
203
+
204
+ When user runs `/flux help`, display:
205
+
206
+ ```
207
+ Flux - AI-first workflow orchestration
208
+
209
+ Commands:
210
+ /flux Show project status and next action
211
+ /flux:prd Create or refine PRDs
212
+ /flux:breakdown Break PRD into epics and tasks
213
+ /flux:implement Implement tasks with TDD
214
+ /flux:linear Connect to Linear
215
+
216
+ Shortcuts:
217
+ /flux prd Same as /flux:prd
218
+ /flux breakdown Same as /flux:breakdown
219
+ /flux implement Same as /flux:implement
220
+ /flux status Show detailed project status
221
+ /flux version Show plugin version
222
+
223
+ Workflow:
224
+ 1. /flux Initialize project (first time)
225
+ 2. /flux:prd Create your first PRD
226
+ 3. /flux:breakdown Break PRD into tasks
227
+ 4. /flux:implement Start coding with TDD
228
+ ```
106
229
 
107
230
  ## Guidelines
108
231
 
109
- - Be concise - users want quick status, not essays
110
- - One question at a time during initialization
111
- - Show actionable next steps
112
- - Use the MCP tools, don't read filesystem directly
232
+ - Use `AskUserQuestion` tool for all user choices during initialization
233
+ - Be concise - show status and one clear next action
234
+ - Use `render_status` for visual project overview
235
+ - Apply confidence-based autonomy for decisions
236
+ - When user input matches a subcommand pattern, delegate immediately without calling render_status first
@@ -1,4 +1,5 @@
1
1
  ---
2
+ name: flux:implement
2
3
  description: Implement epics and tasks with orchestrator/subagent architecture
3
4
  allowed-tools: mcp__flux__*, Read, Bash, Task, AskUserQuestion
4
5
  ---
@@ -52,8 +53,7 @@ The orchestrator resolves all refs to tasks, builds a dependency-ordered queue,
52
53
 
53
54
  ## Pre-checks
54
55
 
55
- 1. Call `get_project_context` to ensure Flux is initialized
56
- 2. Parse arguments and resolve to tasks:
56
+ 1. Parse arguments and resolve to tasks (if any tool returns `PROJECT_NOT_INITIALIZED` error, tell user: "Run `/flux` first to initialize the project." and exit):
57
57
  - No args: Query for next PENDING task with no blockers
58
58
  - PRD ref(s): Expand to all epics → all tasks
59
59
  - Epic ref(s): Expand to all tasks
@@ -61,8 +61,100 @@ The orchestrator resolves all refs to tasks, builds a dependency-ordered queue,
61
61
  - Mixed refs: Resolve each, deduplicate, merge
62
62
  - `tag:{name}`: Query PRDs by tag → expand all
63
63
 
64
+ 2. Git state check (REQUIRED before any implementation):
65
+ - Run `git status` to check for uncommitted changes
66
+ - If dirty working tree: Ask user whether to commit, stash, or abort
67
+ - Never proceed with uncommitted changes
68
+
64
69
  ## Workflow
65
70
 
71
+ ### Step 0: Git Branch Setup
72
+
73
+ **Always start from latest main with a fresh branch.** This ensures clean PRs and avoids merge conflicts.
74
+
75
+ #### 0.1 Ensure Clean State
76
+
77
+ ```bash
78
+ # Check for uncommitted changes
79
+ git status --porcelain
80
+ ```
81
+
82
+ If output is non-empty, use AskUserQuestion:
83
+ ```json
84
+ {
85
+ "questions": [{
86
+ "question": "You have uncommitted changes. How would you like to proceed?",
87
+ "header": "Git Status",
88
+ "options": [
89
+ {"label": "Commit them first", "description": "Stage and commit current changes before starting"},
90
+ {"label": "Stash them", "description": "Stash changes temporarily, restore after implementation"},
91
+ {"label": "Abort implementation", "description": "Stop here and handle changes manually"}
92
+ ],
93
+ "multiSelect": false
94
+ }]
95
+ }
96
+ ```
97
+
98
+ #### 0.2 Create Feature Branch from Latest Main
99
+
100
+ ```bash
101
+ # Fetch latest and create branch
102
+ git fetch origin main
103
+ git checkout -b {branch-name} origin/main
104
+ ```
105
+
106
+ #### 0.3 Branch Naming Convention
107
+
108
+ | Scope | Branch Name | Example |
109
+ |-------|-------------|---------|
110
+ | `tag:xxx` | `feat/tag-{tag}` | `feat/tag-phase-3` |
111
+ | Single PRD | `feat/{prd-ref}` | `feat/FLUX-P3` |
112
+ | Multiple PRDs | `feat/{first-prd-ref}` | `feat/FLUX-P3` |
113
+ | Single Epic | `feat/{epic-ref}` | `feat/FLUX-E14` |
114
+ | Multiple Epics | `feat/{first-epic-ref}` | `feat/FLUX-E14` |
115
+ | Single Task | `feat/{task-ref}` | `feat/FLUX-T31` |
116
+ | Multiple Tasks | `feat/{first-task-ref}` | `feat/FLUX-T31` |
117
+ | No args (next task) | `feat/{task-ref}` | `feat/FLUX-T42` |
118
+ | Mixed refs | `feat/{highest-level-ref}` | `feat/FLUX-P3` (PRD > Epic > Task) |
119
+
120
+ **Priority for mixed refs**: Use the highest-level entity (PRD > Epic > Task). If multiple of the same level, use the first one alphabetically.
121
+
122
+ #### 0.4 Handle Existing Branch
123
+
124
+ If the branch already exists:
125
+ ```bash
126
+ # Check if branch exists
127
+ git rev-parse --verify feat/FLUX-P3 2>/dev/null
128
+ ```
129
+
130
+ If branch exists, use AskUserQuestion:
131
+ ```json
132
+ {
133
+ "questions": [{
134
+ "question": "Branch 'feat/FLUX-P3' already exists. What would you like to do?",
135
+ "header": "Branch",
136
+ "options": [
137
+ {"label": "Continue on existing (Recommended)", "description": "Resume work on the existing branch"},
138
+ {"label": "Delete and recreate", "description": "Start fresh from latest main"},
139
+ {"label": "Use different name", "description": "Create a new branch with a different name"}
140
+ ],
141
+ "multiSelect": false
142
+ }]
143
+ }
144
+ ```
145
+
146
+ #### Example Output
147
+
148
+ ```
149
+ Git Setup:
150
+ ✓ Working tree clean
151
+ ✓ Fetched origin/main
152
+ ✓ Created branch: feat/tag-phase-3
153
+ └── Based on: origin/main (abc1234)
154
+
155
+ Ready to implement 3 PRDs (tag: phase-3)
156
+ ```
157
+
66
158
  ### Step 1: Gather Context
67
159
 
68
160
  Resolve all refs to a unified task list:
@@ -184,31 +276,87 @@ When spawning a coding subagent, provide this context:
184
276
  - Epic: {epic.ref} - {epic.title}
185
277
  - PRD: {prd.ref} (read if more context needed)
186
278
 
279
+ ## Project Skill (APPLY THESE PATTERNS)
280
+ {skillContent || "No project-specific skill found. Use general best practices for this language."}
281
+
187
282
  ## Workflow
188
- 1. Auto-detect project type and apply matching skill
283
+ 1. Apply the project skill patterns above (if provided)
189
284
  2. Write tests for each [auto] criterion FIRST
190
- 3. Implement until all tests pass
191
- 4. For [manual] criteria, document verification steps
192
- 5. Commit with message: "{task.ref}: {brief description}"
193
- 6. Report back: COMPLETED or BLOCKED (with reason)
285
+ 3. Write tests for critical components (business logic, data transformations, error paths)
286
+ 4. Implement until all tests pass
287
+ 5. For [manual] criteria, document verification steps
288
+ 6. Commit with message: "{task.ref}: {brief description}"
289
+ 7. Report back: COMPLETED or BLOCKED (with reason)
290
+
291
+ ## Code Quality Requirements
292
+ - Write clean, modular, testable code
293
+ - Small focused functions with clear separation of concerns
294
+ - Inject dependencies for testability
295
+ - NO unnecessary comments - let code be self-documenting
296
+ - Comments only for non-obvious "why", never for "what"
297
+ - No commented-out code
194
298
 
195
299
  ## Files to Focus On
196
300
  {relevantFiles}
197
301
  ```
198
302
 
199
- ## Skill Auto-Detection
303
+ **Note:** The orchestrator MUST discover and include skill content before spawning. See "Skill Discovery & Application" section above.
304
+
305
+ ## Skill Discovery & Application
306
+
307
+ Before spawning a coding subagent, discover and load relevant project skills.
308
+
309
+ ### Step 1: Detect Project Type
310
+
311
+ Check for project indicator files:
312
+
313
+ ```bash
314
+ ls -la | head -20
315
+ ```
316
+
317
+ | File Found | Project Type |
318
+ |------------|--------------|
319
+ | `go.mod` | Go |
320
+ | `tsconfig.json` | TypeScript |
321
+ | `pom.xml` / `build.gradle` | Java/Spring |
322
+ | `package.json` + react | React |
323
+ | `Cargo.toml` | Rust |
324
+ | `requirements.txt` / `pyproject.toml` | Python |
325
+
326
+ ### Step 2: Search for Matching Skills
327
+
328
+ Check `.claude/skills/` for project-specific skills:
329
+
330
+ ```bash
331
+ # List available skills
332
+ ls .claude/skills/ 2>/dev/null || echo "No skills directory"
333
+ ```
334
+
335
+ **Skill matching patterns:**
336
+
337
+ | Project Type | Skill Search Patterns |
338
+ |--------------|----------------------|
339
+ | Go | `golang*`, `go-*`, `go_*` |
340
+ | TypeScript | `typescript*`, `ts-*`, `ts_*` |
341
+ | Java/Spring | `java*`, `spring*`, `springboot*` |
342
+ | React | `react*`, `ui-*`, `frontend*` |
343
+ | Rust | `rust*` |
344
+ | Python | `python*`, `py-*` |
345
+
346
+ ### Step 3: Load Skill Content
347
+
348
+ If a matching skill is found, read its content:
349
+
350
+ ```bash
351
+ # Read skill content
352
+ cat .claude/skills/{skill-name}/SKILL.md
353
+ ```
200
354
 
201
- The coding subagent detects project type and applies matching skills:
355
+ ### Step 4: Pass Skill to Subagent
202
356
 
203
- | Detection | Skill | Patterns Applied |
204
- |-----------|-------|------------------|
205
- | `pom.xml` | `springboot-patterns` | DDD, transactions, Java style |
206
- | `tsconfig.json` | `typescript-patterns` | Async/await, typed errors |
207
- | `package.json` + React | `ui-patterns` | Components, Tailwind, dark mode |
208
- | `go.mod` | Go patterns | Error handling, interfaces |
209
- | `Cargo.toml` | Rust patterns | Result types, ownership |
357
+ Include the skill content in the coding subagent prompt (see template below).
210
358
 
211
- Detection happens at subagent spawn time by checking project root files.
359
+ **Important:** If no matching skill is found, the subagent falls back to general best practices for that language.
212
360
 
213
361
  ## Status Management
214
362
 
@@ -312,3 +460,5 @@ Action needed: Resolve blockers, then run `/flux:implement FP-T45`
312
460
  - **Fail fast**: Report blockers immediately
313
461
  - **One commit per task**: Keep history clean
314
462
  - **TDD always**: Tests before implementation
463
+ - **Test critical components**: Not just acceptance criteria - test business logic, transformations, error paths
464
+ - **Clean code**: Modular, testable, self-documenting - no unnecessary comments