@lumenflow/cli 2.17.0 → 2.18.1

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 (72) hide show
  1. package/README.md +24 -23
  2. package/dist/gates.js +56 -6
  3. package/dist/gates.js.map +1 -1
  4. package/dist/hooks/enforcement-generator.js +3 -3
  5. package/dist/init.js +1 -1
  6. package/dist/orchestrate-initiative.js +4 -3
  7. package/dist/orchestrate-initiative.js.map +1 -1
  8. package/dist/orchestrate-monitor.js +2 -1
  9. package/dist/orchestrate-monitor.js.map +1 -1
  10. package/dist/public-manifest.js +11 -4
  11. package/dist/public-manifest.js.map +1 -1
  12. package/dist/spawn-list.js +1 -0
  13. package/dist/spawn-list.js.map +1 -1
  14. package/dist/wu-block.js +89 -45
  15. package/dist/wu-block.js.map +1 -1
  16. package/dist/wu-brief.js +40 -0
  17. package/dist/wu-brief.js.map +1 -0
  18. package/dist/wu-claim-cloud.js +61 -0
  19. package/dist/wu-claim-cloud.js.map +1 -0
  20. package/dist/wu-claim.js +234 -57
  21. package/dist/wu-claim.js.map +1 -1
  22. package/dist/wu-cleanup-cloud.js +76 -0
  23. package/dist/wu-cleanup-cloud.js.map +1 -0
  24. package/dist/wu-cleanup.js +42 -19
  25. package/dist/wu-cleanup.js.map +1 -1
  26. package/dist/wu-create-cloud.js +40 -0
  27. package/dist/wu-create-cloud.js.map +1 -0
  28. package/dist/wu-create.js +137 -53
  29. package/dist/wu-create.js.map +1 -1
  30. package/dist/wu-delegate.js +21 -0
  31. package/dist/wu-delegate.js.map +1 -0
  32. package/dist/wu-delete.js +102 -61
  33. package/dist/wu-delete.js.map +1 -1
  34. package/dist/wu-done-auto-cleanup.js +5 -16
  35. package/dist/wu-done-auto-cleanup.js.map +1 -1
  36. package/dist/wu-done-cloud.js +46 -0
  37. package/dist/wu-done-cloud.js.map +1 -0
  38. package/dist/wu-done.js +186 -44
  39. package/dist/wu-done.js.map +1 -1
  40. package/dist/wu-edit.js +217 -55
  41. package/dist/wu-edit.js.map +1 -1
  42. package/dist/wu-prep.js +1 -1
  43. package/dist/wu-prep.js.map +1 -1
  44. package/dist/wu-recover.js +128 -55
  45. package/dist/wu-recover.js.map +1 -1
  46. package/dist/wu-release.js +99 -45
  47. package/dist/wu-release.js.map +1 -1
  48. package/dist/wu-spawn.js +108 -42
  49. package/dist/wu-spawn.js.map +1 -1
  50. package/dist/wu-state-cloud.js +39 -0
  51. package/dist/wu-state-cloud.js.map +1 -0
  52. package/dist/wu-unblock.js +99 -49
  53. package/dist/wu-unblock.js.map +1 -1
  54. package/package.json +8 -7
  55. package/templates/core/.lumenflow/constraints.md.template +31 -4
  56. package/templates/core/LUMENFLOW.md.template +31 -9
  57. package/templates/core/ai/onboarding/agent-invocation-guide.md.template +21 -13
  58. package/templates/core/ai/onboarding/agent-safety-card.md.template +2 -2
  59. package/templates/core/ai/onboarding/docs-generation.md.template +1 -1
  60. package/templates/core/ai/onboarding/lumenflow-force-usage.md.template +1 -1
  61. package/templates/core/ai/onboarding/quick-ref-commands.md.template +235 -66
  62. package/templates/core/ai/onboarding/rapid-prototyping.md +2 -2
  63. package/templates/core/ai/onboarding/starting-prompt.md.template +124 -24
  64. package/templates/core/ai/onboarding/troubleshooting-wu-done.md.template +11 -0
  65. package/templates/core/ai/onboarding/vendor-support.md.template +58 -69
  66. package/templates/vendors/claude/.claude/skills/context-management/SKILL.md.template +3 -3
  67. package/templates/vendors/claude/.claude/skills/design-first/SKILL.md.template +151 -0
  68. package/templates/vendors/claude/.claude/skills/initiative-management/SKILL.md.template +8 -8
  69. package/templates/vendors/claude/.claude/skills/library-first/SKILL.md.template +1 -0
  70. package/templates/vendors/claude/.claude/skills/multi-agent-coordination/SKILL.md.template +5 -5
  71. package/templates/vendors/claude/.claude/skills/orchestration/SKILL.md.template +19 -16
  72. package/templates/vendors/claude/.claude/skills/tdd-workflow/SKILL.md.template +2 -0
@@ -2,10 +2,10 @@
2
2
 
3
3
  **Last updated:** {{DATE}}
4
4
 
5
- Complete reference for all CLI commands. Organized by category for quick discovery.
5
+ Reference for CLI commands. Organized by category for quick discovery.
6
6
 
7
- > **Tip (WU-1358):** For complete option lists, always run `<package_manager> <command> --help`.
8
- > This shows all available flags including inline options that may not appear in generated docs.
7
+ > **Rule (WU-1358, WU-1530):** Always run `<command> --help` before first use of any unfamiliar command.
8
+ > This document may not include all available options or may contain outdated examples.
9
9
  >
10
10
  > ```bash
11
11
  > # Examples
@@ -14,27 +14,49 @@ Complete reference for all CLI commands. Organized by category for quick discove
14
14
  > yarn wu:create --help
15
15
  > ```
16
16
 
17
+ ## Help-First Usage Examples By Category
18
+
19
+ Run `--help` first, then run the real command with explicit flags.
20
+
21
+ | Category | Help-First Example | Real Command Example |
22
+ | ------------------- | ------------------------------------- | ------------------------------------------------------------------------ |
23
+ | Setup & Development | `pnpm bootstrap --help` | `pnpm bootstrap` |
24
+ | WU Lifecycle | `pnpm wu:claim --help` | `pnpm wu:claim --id WU-1561 --lane "Operations: Tooling"` |
25
+ | WU Maintenance | `pnpm wu:recover --help` | `pnpm wu:recover --id WU-1561` |
26
+ | Gates & Quality | `pnpm gates --help` | `pnpm gates --docs-only` |
27
+ | Memory & Sessions | `pnpm mem:checkpoint --help` | `pnpm mem:checkpoint --wu WU-1561` |
28
+ | State Management | `pnpm state:doctor --help` | `pnpm state:doctor --json` |
29
+ | Dependencies | `pnpm deps:add --help` | `pnpm deps:add --pkg zod` |
30
+ | Plans | `pnpm plan:link --help` | `pnpm plan:link --id INIT-021 --plan lumenflow://plans/INIT-021-plan.md` |
31
+ | Initiatives | `pnpm initiative:status --help` | `pnpm initiative:status --id INIT-021` |
32
+ | Orchestration | `pnpm orchestrate:init-status --help` | `pnpm orchestrate:init-status --id INIT-021` |
33
+ | Metrics & Flow | `pnpm flow:report --help` | `pnpm flow:report` |
34
+ | Documentation | `pnpm docs:validate --help` | `pnpm docs:validate` |
35
+ | Release | `pnpm pre-release:check --help` | `pnpm pre-release:check` |
36
+ | Agent Utilities | `pnpm agent:issues-query --help` | `pnpm agent:issues-query` |
37
+
17
38
  ---
18
39
 
19
40
  ## Setup & Development
20
41
 
21
42
  **For this monorepo (development):**
22
43
 
23
- | Command | Description |
24
- | -------------------------- | --------------------------------------- |
25
- | `pnpm setup` | Install deps and build CLI (first time) |
26
- | `pnpm build` | Build all packages |
27
- | `pnpm build:dist` | Build distribution packages |
28
- | `pnpm dev` | Start development mode |
29
- | `pnpm clean` | Clean build artifacts and caches |
30
- | `pnpm pack:all` | Pack all packages for distribution |
31
- | `pnpm lumenflow:init` | Scaffold LumenFlow in a project |
32
- | `pnpm docs:sync` | Sync agent docs (for upgrades) |
33
- | `pnpm sync:templates` | Sync templates to project |
34
- | `pnpm lumenflow:upgrade` | Upgrade LumenFlow packages |
35
- | `pnpm lumenflow:doctor` | Diagnose LumenFlow configuration |
36
- | `pnpm lumenflow:integrate` | Generate enforcement hooks for client |
37
- | `pnpm lumenflow commands` | List all available CLI commands |
44
+ | Command | Description |
45
+ | -------------------------- | ------------------------------------------------- |
46
+ | `pnpm setup` | Install deps and build CLI (first time) |
47
+ | `pnpm bootstrap` | Build CLI with dependency closure (worktree-safe) |
48
+ | `pnpm build` | Build all packages |
49
+ | `pnpm build:dist` | Build distribution packages |
50
+ | `pnpm dev` | Start development mode |
51
+ | `pnpm clean` | Clean build artifacts and caches |
52
+ | `pnpm pack:all` | Pack all packages for distribution |
53
+ | `pnpm lumenflow:init` | Scaffold LumenFlow in a project |
54
+ | `pnpm docs:sync` | Sync agent docs (for upgrades) |
55
+ | `pnpm sync:templates` | Sync templates to project |
56
+ | `pnpm lumenflow:upgrade` | Upgrade LumenFlow packages |
57
+ | `pnpm lumenflow:doctor` | Diagnose LumenFlow configuration |
58
+ | `pnpm lumenflow:integrate` | Generate enforcement hooks for client |
59
+ | `npx lumenflow commands` | List all available CLI commands |
38
60
 
39
61
  **For external projects (end users):**
40
62
 
@@ -55,19 +77,21 @@ pnpm exec lumenflow --client all # All clients
55
77
 
56
78
  ## WU Lifecycle
57
79
 
58
- | Command | Description |
59
- | --------------------------------------------- | ---------------------------------------------- |
60
- | `pnpm wu:create --id WU-XXX --lane <Lane> ..` | Create new WU spec (see required fields below) |
61
- | `pnpm wu:claim --id WU-XXX --lane <Lane>` | Claim WU and create worktree |
62
- | `pnpm wu:prep --id WU-XXX` | Run gates in worktree, prep for wu:done |
63
- | `pnpm wu:done --id WU-XXX` | Complete WU (merge, stamp, cleanup) from main |
64
- | `pnpm wu:edit --id WU-XXX --field value` | Edit WU spec fields |
65
- | `pnpm wu:block --id WU-XXX --reason "..."` | Block WU with reason |
66
- | `pnpm wu:unblock --id WU-XXX` | Unblock WU |
67
- | `pnpm wu:release --id WU-XXX` | Release orphaned WU (in_progress to ready) |
68
- | `pnpm wu:status --id WU-XXX` | Show WU status, location, valid commands |
69
- | `pnpm wu:spawn --id WU-XXX --client <client>` | Generate sub-agent spawn prompt |
70
- | `pnpm wu:spawn --id WU-XXX --no-context` | Spawn prompt without memory context injection |
80
+ | Command | Description |
81
+ | ---------------------------------------------- | ------------------------------------------------ |
82
+ | `pnpm wu:create --id WU-XXX --lane <Lane> ..` | Create new WU spec (see required fields below) |
83
+ | `pnpm wu:claim --id WU-XXX --lane <Lane>` | Claim WU and create worktree (default) |
84
+ | `pnpm wu:claim --id WU-XXX --lane <L> --cloud` | Claim WU in cloud/branch-pr mode (no worktree) |
85
+ | `pnpm wu:prep --id WU-XXX` | Run gates, prep for wu:done |
86
+ | `pnpm wu:done --id WU-XXX` | Complete WU (merge or PR, stamp, cleanup) |
87
+ | `pnpm wu:edit --id WU-XXX --description "..."` | Edit WU spec fields (run --help for all flags) |
88
+ | `pnpm wu:block --id WU-XXX --reason "..."` | Block WU with reason |
89
+ | `pnpm wu:unblock --id WU-XXX` | Unblock WU |
90
+ | `pnpm wu:release --id WU-XXX` | Release orphaned WU (in_progress to ready) |
91
+ | `pnpm wu:status --id WU-XXX` | Show WU status, location, valid commands |
92
+ | `pnpm wu:brief --id WU-XXX --client <client>` | Generate handoff prompt (does not execute) |
93
+ | `pnpm wu:brief --id WU-XXX --no-context` | Generate prompt without memory context injection |
94
+ | `pnpm wu:delegate --id WU-XXX --parent-wu <P>` | Generate prompt and record delegation lineage |
71
95
 
72
96
  ### WU Maintenance
73
97
 
@@ -101,39 +125,86 @@ pnpm exec lumenflow --client all # All clients
101
125
  | `pnpm lane:health` | Check lane config health |
102
126
  | `pnpm lane:suggest --paths "..."` | Suggest lane for code paths |
103
127
 
128
+ Before rerunning `wu:prep` after docs-heavy edits, format touched docs first:
129
+ `pnpm prettier --write <changed-doc-paths...>`.
130
+
104
131
  ---
105
132
 
106
133
  ## Memory & Sessions
107
134
 
108
- | Command | Description |
109
- | ----------------------------------- | ----------------------------------- |
110
- | `pnpm mem:init --wu WU-XXX` | Initialize memory for WU |
111
- | `pnpm mem:start --wu WU-XXX` | Start a memory session |
112
- | `pnpm mem:checkpoint --wu WU-XXX` | Save progress checkpoint |
113
- | `pnpm mem:recover --wu WU-XXX` | Generate recovery context (WU-1390) |
114
- | `pnpm mem:ready --wu WU-XXX` | Check pending nodes |
115
- | `pnpm mem:export --wu WU-XXX` | Export memory as markdown |
116
- | `pnpm mem:create "msg" --wu WU-XXX` | Create memory node (bug discovery) |
117
- | `pnpm mem:signal "msg" --wu WU-XXX` | Broadcast coordination signal |
118
- | `pnpm mem:inbox --wu WU-XXX` | Check coordination signals |
119
- | `pnpm mem:summarize --wu WU-XXX` | Summarize memory context |
120
- | `pnpm mem:triage --wu WU-XXX` | Triage discovered bugs |
121
- | `pnpm mem:context --wu WU-XXX` | Get context for current lane/WU |
122
- | `pnpm mem:context ... --lane <L>` | Filter context by lane (WU-1292) |
123
- | `pnpm mem:delete --id <node-id>` | Delete/archive a memory node |
124
- | `pnpm mem:cleanup` | Clean up stale memory data |
135
+ | Command | Description |
136
+ | ------------------------------------ | ------------------------------------------------------------------------ |
137
+ | `pnpm mem:init --wu WU-XXX` | Initialize memory for WU |
138
+ | `pnpm mem:start --wu WU-XXX` | Start a memory session (surfaces unread signals, INIT-015) |
139
+ | `pnpm mem:checkpoint --wu WU-XXX` | Save progress checkpoint (also created by auto-checkpoint hooks) |
140
+ | `pnpm mem:recover --wu WU-XXX` | Generate recovery context (WU-1390) |
141
+ | `pnpm mem:ready --wu WU-XXX` | Check pending nodes |
142
+ | `pnpm mem:export --wu WU-XXX` | Export memory as markdown |
143
+ | `pnpm mem:create "msg" --wu WU-XXX` | Create memory node (bug discovery) |
144
+ | `pnpm mem:signal "msg" --wu WU-XXX` | Broadcast coordination signal (append-only receipts, INIT-015) |
145
+ | `pnpm mem:inbox --wu WU-XXX` | Check coordination signals (receipt-aware read state, INIT-015) |
146
+ | `pnpm mem:inbox --no-mark` | Read signals without marking as read |
147
+ | `pnpm mem:summarize --wu WU-XXX` | Summarize memory context |
148
+ | `pnpm mem:triage --wu WU-XXX` | Triage discovered bugs |
149
+ | `pnpm mem:context --wu WU-XXX` | Get context for current lane/WU |
150
+ | `pnpm mem:context ... --lane <L>` | Filter context by lane (WU-1292) |
151
+ | `pnpm mem:delete --id <node-id>` | Delete/archive a memory node |
152
+ | `pnpm mem:cleanup` | Clean up stale memory data (respects `memory.decay` policy when enabled) |
153
+ | `pnpm mem:cleanup --decay` | Run decay-based archival (archive stale nodes below threshold) |
154
+ | `pnpm mem:cleanup --decay --dry-run` | Preview decay archival without changes |
155
+
156
+ ### Memory Enforcement (INIT-015)
157
+
158
+ Auto-checkpoint and decay enforcement are configured in `.lumenflow.config.yaml` under `memory.enforcement` and `memory.decay`. When enabled:
159
+
160
+ - **Auto-checkpoint hooks** create checkpoints automatically via PostToolUse (counter-based) and SubagentStop (always) events
161
+ - **wu:done checkpoint gate** warns or blocks if no checkpoints exist for the WU
162
+ - **Decay archival** prunes stale memory during wu:done when `memory.decay.enabled=true`
163
+
164
+ Generate enforcement hooks after configuration:
165
+
166
+ ```bash
167
+ pnpm lumenflow:integrate --client claude-code
168
+ ```
169
+
170
+ See [Configuration Reference](/reference/config) for all `memory.enforcement` and `memory.decay` keys.
125
171
 
126
172
  ---
127
173
 
128
174
  ## State Management
129
175
 
130
- | Command | Description |
131
- | ---------------------- | --------------------------- |
132
- | `pnpm state:doctor` | Diagnose state store issues |
133
- | `pnpm state:cleanup` | Clean up stale state data |
134
- | `pnpm signal:cleanup` | Clean up stale signals |
135
- | `pnpm state:bootstrap` | Bootstrap state store |
136
- | `pnpm backlog:prune` | Clean stale backlog entries |
176
+ | Command | Description |
177
+ | ----------------------------- | -------------------------------------- |
178
+ | `pnpm state:doctor` | Diagnose state store issues |
179
+ | `pnpm state:doctor --fix` | Auto-repair safe issues |
180
+ | `pnpm state:doctor --dry-run` | Preview repairs without making changes |
181
+ | `pnpm state:doctor --json` | Output as JSON |
182
+ | `pnpm state:cleanup` | Clean up stale state data |
183
+ | `pnpm signal:cleanup` | Clean up stale signals |
184
+ | `pnpm state:bootstrap` | Bootstrap state store |
185
+ | `pnpm backlog:prune` | Clean stale backlog entries |
186
+
187
+ ### state:doctor Issue Types (WU-1420)
188
+
189
+ The `state:doctor` command detects and can auto-fix these issues:
190
+
191
+ | Issue Type | Description | Auto-Fix Action |
192
+ | --------------- | ------------------------------------------------------ | ---------------------- |
193
+ | Orphaned WU | WU YAML status is 'done' but no stamp file exists | Creates stamp file |
194
+ | Dangling Signal | Signal references a WU that doesn't exist | Removes signal |
195
+ | Broken Event | Events exist for a WU that doesn't exist | Removes events |
196
+ | Status Mismatch | WU YAML status differs from state store derived status | Emits corrective event |
197
+
198
+ **Status Mismatch Detection (WU-1420):**
199
+
200
+ When WU YAML says 'ready' but the state store (derived from events) says 'in_progress',
201
+ `wu:claim` fails with 'already in_progress'. The `state:doctor --fix` command will emit
202
+ a `release` event to reconcile the state.
203
+
204
+ Supported mismatch fixes:
205
+
206
+ - YAML=ready, state=in_progress: Emits `release` event
207
+ - YAML=done, state=in_progress: Emits `complete` event
137
208
 
138
209
  ---
139
210
 
@@ -154,14 +225,32 @@ Plans are markdown documents that capture goals, scope, approach, and success cr
154
225
 
155
226
  Plans are stored in the repo at `docs/04-operations/plans/` by default (configurable via `directories.plansDir` in `.lumenflow.config.yaml`).
156
227
 
157
- | Command | Description |
158
- | ----------------------------------------------------- | ------------------------------------------- |
159
- | `pnpm initiative:plan --initiative INIT-XXX` | Link existing plan to initiative |
160
- | `pnpm initiative:plan --initiative INIT-XXX --create` | Create plan template and link to initiative |
228
+ If the plan exists only in conversation, use `--plan` on `wu:create` to generate a lightweight
229
+ stub in `$LUMENFLOW_HOME/plans/`, then summarize the conversation there and reference it via
230
+ `spec_refs`. Feature WUs require `spec_refs`; notes do not replace the plan link.
231
+
232
+ | Command | Description |
233
+ | ------------------------------------------------------------------------ | ------------------------------------------------------------- |
234
+ | `pnpm plan:create --id INIT-XXX --title "..."` | Create a repo-native plan file in `docs/04-operations/plans/` |
235
+ | `pnpm plan:edit --id INIT-XXX --section Goal --content "..."` | Edit a section in a plan file |
236
+ | `pnpm plan:link --id INIT-XXX --plan lumenflow://plans/INIT-XXX-plan.md` | Link plan URI to initiative or WU |
237
+ | `pnpm plan:promote --id INIT-XXX` | Promote plan status to approved |
238
+ | `pnpm initiative:plan --initiative INIT-XXX --plan <path>` | Legacy-compatible initiative linking command |
239
+ | `pnpm initiative:plan --initiative INIT-XXX --create` | Legacy-compatible create-and-link flow |
161
240
 
162
241
  ### Linking Plans
163
242
 
164
- **To an initiative:**
243
+ **To an initiative (canonical):**
244
+
245
+ ```bash
246
+ # Create a plan
247
+ pnpm plan:create --id INIT-001 --title "Auth System Rollout"
248
+
249
+ # Link plan URI to initiative
250
+ pnpm plan:link --id INIT-001 --plan lumenflow://plans/INIT-001-plan.md
251
+ ```
252
+
253
+ **Legacy-compatible initiative command:**
165
254
 
166
255
  ```bash
167
256
  # Create a new plan template
@@ -207,12 +296,12 @@ Plans use the `lumenflow://plans/` URI scheme for references:
207
296
 
208
297
  ## Orchestration
209
298
 
210
- | Command | Description |
211
- | -------------------------------------------- | -------------------------------- |
212
- | `pnpm orchestrate:initiative --id INIT-XXX` | Orchestrate initiative execution |
213
- | `pnpm orchestrate:init-status --id INIT-XXX` | Compact initiative progress view |
214
- | `pnpm orchestrate:monitor` | Monitor spawn/agent activity |
215
- | `pnpm spawn:list` | List active spawned agents |
299
+ | Command | Description |
300
+ | -------------------------------------------- | --------------------------------- |
301
+ | `pnpm orchestrate:initiative --id INIT-XXX` | Orchestrate initiative execution |
302
+ | `pnpm orchestrate:init-status --id INIT-XXX` | Compact initiative progress view |
303
+ | `pnpm orchestrate:monitor` | Monitor delegation/agent activity |
304
+ | `pnpm spawn:list` | List active delegation records |
216
305
 
217
306
  ---
218
307
 
@@ -255,9 +344,45 @@ Plans use the `lumenflow://plans/` URI scheme for references:
255
344
 
256
345
  ---
257
346
 
347
+ ## Worktree Bootstrap (Dependency-Closure Build)
348
+
349
+ Fresh worktrees don't have built `dist/` directories. Dist-backed CLI commands
350
+ (e.g., `lane:health`, `gates`, `wu:status`) require `@lumenflow/cli` and its
351
+ workspace dependencies to be built first.
352
+
353
+ **`pnpm bootstrap`** builds `@lumenflow/cli` plus its full dependency closure
354
+ (core, memory, metrics, initiatives, agent) in one command using turbo's
355
+ `--filter` with topological dependency resolution.
356
+
357
+ ```bash
358
+ # After wu:claim and cd into worktree:
359
+ pnpm bootstrap # Builds CLI + all workspace deps
360
+ pnpm lane:health # Now works
361
+ pnpm gates # Now works
362
+ ```
363
+
364
+ **When to use:**
365
+
366
+ - After `wu:claim` in a fresh worktree before running dist-backed commands
367
+ - After `pnpm install` if dist directories were cleaned
368
+ - As a lighter alternative to `pnpm build` (builds only CLI closure, not all packages)
369
+
370
+ **How it differs from other build commands:**
371
+
372
+ | Command | Scope | Use case |
373
+ | ---------------- | -------------------------------------- | ------------------ |
374
+ | `pnpm setup` | Install + build CLI + integrate hooks | First-time setup |
375
+ | `pnpm bootstrap` | Build CLI with dependency closure only | Worktree preflight |
376
+ | `pnpm build` | Build all packages | Full rebuild |
377
+
378
+ ---
379
+
258
380
  ## Workflow Sequence (Quick Reference)
259
381
 
260
382
  ```bash
383
+ # 0. Check available options (do this before first use of any command)
384
+ pnpm wu:create --help
385
+
261
386
  # 1. Create WU
262
387
  pnpm wu:create --id WU-XXX --lane "Framework: Core" --title "Add feature" \
263
388
  --description "Context: ... Problem: ... Solution: ..." \
@@ -271,6 +396,9 @@ pnpm wu:create --id WU-XXX --lane "Framework: Core" --title "Add feature" \
271
396
  pnpm wu:claim --id WU-XXX --lane "Framework: Core"
272
397
  cd worktrees/framework-core-wu-xxx
273
398
 
399
+ # 2b. Bootstrap (build CLI for dist-backed commands)
400
+ pnpm bootstrap
401
+
274
402
  # 3. Implement (TDD)
275
403
  # ... write tests first, then code ...
276
404
 
@@ -431,6 +559,47 @@ pnpm mem:inbox --since 30m # Check for signals (NOT TaskOutput)
431
559
  pnpm mem:create 'Bug: description' --type discovery --tags bug --wu WU-XXX
432
560
  ```
433
561
 
562
+ ### Cloud Lifecycle (Branch-PR Mode)
563
+
564
+ For cloud agents that cannot use local worktrees:
565
+
566
+ ```bash
567
+ # 1. Claim in cloud mode
568
+ pnpm wu:claim --id WU-XXX --lane "<Lane>" --cloud
569
+ # Or: LUMENFLOW_CLOUD=1 pnpm wu:claim --id WU-XXX --lane "<Lane>"
570
+
571
+ # 2. Work on lane branch, push commits
572
+
573
+ # 3. Prep (validates branch, runs gates in-place)
574
+ pnpm wu:prep --id WU-XXX
575
+
576
+ # 4. Complete (creates PR, does NOT merge to main)
577
+ pnpm wu:done --id WU-XXX
578
+
579
+ # 5. After PR is reviewed and merged, run cleanup
580
+ pnpm wu:cleanup --id WU-XXX
581
+ ```
582
+
583
+ **Post-merge cleanup (`wu:cleanup`):**
584
+
585
+ - Creates `.lumenflow/stamps/WU-XXX.done`
586
+ - Updates WU YAML to `status: done`
587
+ - Regenerates backlog.md and status.md
588
+ - Deletes the lane branch (local and remote)
589
+
590
+ **Cloud auto-detection (opt-in):**
591
+
592
+ ```yaml
593
+ # .lumenflow.config.yaml
594
+ cloud:
595
+ auto_detect: true # default: false
596
+ env_signals:
597
+ - name: CI
598
+ - name: CODEX
599
+ - name: GITHUB_ACTIONS
600
+ equals: 'true'
601
+ ```
602
+
434
603
  ### Enforcement Hooks (WU-1367)
435
604
 
436
605
  Configure hooks that enforce workflow compliance for Claude Code:
@@ -44,8 +44,8 @@ pnpm wu:create --lane "Experience: UI" --title "Add login form"
44
44
  For complex work, spawn sub-agents to work in parallel:
45
45
 
46
46
  ```bash
47
- # Generate spawn prompt for parallel agent
48
- pnpm wu:spawn --id WU-123 --client claude-code
47
+ # Generate handoff prompt for parallel agent
48
+ pnpm wu:brief --id WU-123 --client claude-code
49
49
  ```
50
50
 
51
51
  Sub-agents work on different aspects simultaneously:
@@ -6,6 +6,37 @@ This is the complete onboarding document for AI agents working with LumenFlow. R
6
6
 
7
7
  ---
8
8
 
9
+ ## Mandatory: Help-First CLI Usage
10
+
11
+ Before using any LumenFlow CLI command for the first time in a session, run `--help` first.
12
+
13
+ ```bash
14
+ pnpm wu:claim --help
15
+ pnpm wu:done --help
16
+ pnpm initiative:status --help
17
+ ```
18
+
19
+ Rules:
20
+
21
+ 1. Run `<command> --help` before first use of that command.
22
+ 2. Copy exact flags from help output; do not guess option names.
23
+ 3. If you hit an argument/flag error, rerun `--help` before retrying.
24
+
25
+ Optional Claude Code enforcement layer (recommended for teams):
26
+
27
+ ```bash
28
+ # .claude/hooks/pretooluse-help-first.sh (optional local hook)
29
+ cmd="$1"
30
+ if [[ "$cmd" =~ ^pnpm\ (wu:|initiative:|orchestrate:|mem:|state:) ]] && [[ "$cmd" != *"--help"* ]]; then
31
+ echo "Help-first rule: run '$cmd --help' before first use." >&2
32
+ exit 2
33
+ fi
34
+ ```
35
+
36
+ This hook is optional and client-specific. The primary enforcement is this onboarding workflow and quick-reference examples.
37
+
38
+ ---
39
+
9
40
  ## When Starting From Product Vision
10
41
 
11
42
  If you are starting a new project or feature from a product vision (e.g., "Build a task management app"), **do NOT create standalone WUs immediately**. Instead, follow the initiative-first workflow:
@@ -49,9 +80,18 @@ Only skip initiatives for:
49
80
 
50
81
  If work spans multiple WUs or multiple days, create an initiative first.
51
82
 
83
+ ### Lane-Fit Reasoning
84
+
85
+ When creating WUs or scoping initiatives, always evaluate whether the assigned lane fits the actual work:
86
+
87
+ - **Check code_paths alignment**: Compare the WU's `code_paths` against lane definitions in `.lumenflow.config.yaml`. If the majority of paths belong to a different lane, propose a lane change.
88
+ - **Use lane:suggest**: Run `pnpm lane:suggest --paths "src/file.ts"` to get a recommendation.
89
+ - **Propose changes proactively**: If scope expansion during implementation pushes a WU beyond its lane's boundaries, flag the mismatch to the user and suggest either a lane change or a WU split.
90
+ - **Initiative-level review**: When planning an initiative with multiple WUs, ensure each WU is assigned to the lane whose `code_paths` best cover the work. Systematic mismatches signal that lane taxonomy may need updating.
91
+
52
92
  ---
53
93
 
54
- ## Quick Start (Copy This)
94
+ ## Quick Start -- Local (Copy This)
55
95
 
56
96
  ```bash
57
97
  # 1. Check your assigned WU
@@ -63,6 +103,9 @@ pnpm wu:claim --id WU-XXXX --lane "Lane Name"
63
103
  # 3. IMMEDIATELY cd to worktree (CRITICAL!)
64
104
  cd worktrees/<lane>-wu-xxxx
65
105
 
106
+ # 3b. Bootstrap (builds CLI + deps for dist-backed commands)
107
+ pnpm bootstrap
108
+
66
109
  # 4. Do your work here (not in main!)
67
110
 
68
111
  # 5. Run gates before completion
@@ -74,6 +117,53 @@ cd /path/to/main/checkout
74
117
  pnpm wu:done --id WU-XXXX
75
118
  ```
76
119
 
120
+ ## Quick Start -- Cloud / Branch-PR (Copy This)
121
+
122
+ For cloud agents (Codex, Claude web, CI bots) that cannot create local worktrees:
123
+
124
+ ```bash
125
+ # 1. Check your assigned WU
126
+ cat docs/04-operations/tasks/wu/WU-XXXX.yaml
127
+
128
+ # 2. Claim in cloud mode (no worktree, sets claimed_mode: branch-pr)
129
+ pnpm wu:claim --id WU-XXXX --lane "Lane Name" --cloud
130
+ # Or: LUMENFLOW_CLOUD=1 pnpm wu:claim --id WU-XXXX --lane "Lane Name"
131
+
132
+ # 3. Work on the lane branch (lane/<lane>/wu-xxxx)
133
+
134
+ # 4. Run gates
135
+ pnpm wu:prep --id WU-XXXX
136
+
137
+ # 5. Complete (creates PR, does NOT merge to main)
138
+ pnpm wu:done --id WU-XXXX
139
+
140
+ # 6. After PR is merged, run cleanup
141
+ pnpm wu:cleanup --id WU-XXXX
142
+ ```
143
+
144
+ **Cloud activation methods (in precedence order):**
145
+
146
+ 1. `--cloud` flag on `wu:claim` (explicit, always wins)
147
+ 2. `LUMENFLOW_CLOUD=1` environment variable (explicit, always wins)
148
+ 3. Config-driven auto-detection when `cloud.auto_detect: true` in `.lumenflow.config.yaml`
149
+
150
+ **Auto-detection configuration:**
151
+
152
+ ```yaml
153
+ # .lumenflow.config.yaml
154
+ cloud:
155
+ auto_detect: true # default: false (opt-in)
156
+ env_signals: # checked only when auto_detect is true
157
+ - name: CI # presence check (any non-empty value)
158
+ - name: CODEX
159
+ - name: GITHUB_ACTIONS
160
+ equals: 'true' # exact match required
161
+ ```
162
+
163
+ When `auto_detect` is enabled, `wu:claim` checks the listed environment signals
164
+ and activates cloud mode if any match. No vendor-specific signals are hardcoded;
165
+ all signals are user-configured.
166
+
77
167
  ---
78
168
 
79
169
  ## Before Creating WUs
@@ -90,22 +180,26 @@ before running `wu:create`. `wu:claim` supports `--no-push` for local-only work.
90
180
 
91
181
  ## The 5 Rules You Must Follow
92
182
 
93
- ### Rule 1: ALWAYS Work in Worktrees
183
+ ### Rule 1: ALWAYS Work in Worktrees (or Branch-PR Mode)
94
184
 
95
- After `pnpm wu:claim`, you MUST immediately `cd` to the worktree. **Never edit files in the main checkout.**
185
+ After `pnpm wu:claim`, you MUST immediately `cd` to the worktree. **Never edit files in the main checkout** unless you are in branch-pr mode.
96
186
 
97
187
  ```bash
98
- # WRONG - editing in main
188
+ # WRONG - editing in main (worktree mode)
99
189
  pnpm wu:claim --id WU-123 --lane "Framework: CLI"
100
190
  vim packages/cli/src/index.ts # BLOCKED BY HOOKS!
101
191
 
102
- # RIGHT - editing in worktree
192
+ # RIGHT - editing in worktree (worktree mode)
103
193
  pnpm wu:claim --id WU-123 --lane "Framework: CLI"
104
194
  cd worktrees/framework-cli-wu-123 # IMMEDIATELY!
105
195
  vim packages/cli/src/index.ts # Safe here
196
+
197
+ # ALSO RIGHT - cloud/branch-pr mode (no worktree)
198
+ pnpm wu:claim --id WU-123 --lane "Framework: CLI" --cloud
199
+ # Work on lane branch directly (claimed_mode: branch-pr)
106
200
  ```
107
201
 
108
- **Why:** Worktrees isolate your changes. Main checkout is protected by git hooks.
202
+ **Why:** Worktrees isolate your changes. Main checkout is protected by git hooks. Branch-PR mode is the valid exception for cloud agents that cannot create local worktrees.
109
203
 
110
204
  ### Rule 2: ALWAYS Run wu:done
111
205
 
@@ -129,7 +223,7 @@ When writing or editing files, use paths relative to the worktree root.
129
223
 
130
224
  ```bash
131
225
  # WRONG - absolute paths
132
- Write to: /home/user/project/worktrees/cli-wu-123/src/index.ts
226
+ Write to: <repo-root>/worktrees/cli-wu-123/src/index.ts
133
227
 
134
228
  # RIGHT - relative paths
135
229
  Write to: src/index.ts
@@ -257,22 +351,25 @@ pnpm wu:done --id WU-XXX --skip-gates \
257
351
 
258
352
  ---
259
353
 
260
- ## Spawning Sub-Agents with wu:spawn
354
+ ## Delegating Sub-Agents with wu:brief / wu:delegate
261
355
 
262
- Use `wu:spawn` to create parallel sub-agents for complex WUs that require multiple agents working simultaneously on different aspects.
356
+ Use `wu:brief` to create parallel sub-agent handoff prompts for complex WUs. Use `wu:delegate` when you also need explicit lineage recording.
263
357
 
264
- ### When to Use wu:spawn
358
+ ### When to Use wu:brief
265
359
 
266
360
  - **Parallel work:** Multiple agents needed on the same WU simultaneously
267
361
  - **Specialized expertise:** Different agents for different domains (frontend, backend, docs)
268
362
  - **Context isolation:** Preventing context limit issues on large WUs
269
363
  - **Wave-based execution:** Coordinating multiple phases of work
270
364
 
271
- ### How to Use wu:spawn
365
+ ### How to Use wu:brief / wu:delegate
272
366
 
273
367
  ```bash
274
- # Spawn a sub-agent with client-specific context
275
- pnpm wu:spawn --id WU-XXXX --client <client-type>
368
+ # Generate a handoff prompt (no lineage side effect)
369
+ pnpm wu:brief --id WU-XXXX --client <client-type>
370
+
371
+ # Generate + record explicit delegation lineage
372
+ pnpm wu:delegate --id WU-XXXX --parent-wu WU-YYYY --client <client-type>
276
373
 
277
374
  # Valid client values:
278
375
  # - claude-code # Claude Code CLI
@@ -295,16 +392,19 @@ pnpm wu:spawn --id WU-XXXX --client <client-type>
295
392
 
296
393
  ## WU Lifecycle Commands
297
394
 
298
- | Command | Description | When to Use |
299
- | ----------------------------------------- | --------------------------------- | --------------------- |
300
- | `pnpm wu:status --id WU-XXX` | Show WU state and valid commands | Check current state |
301
- | `pnpm wu:claim --id WU-XXX --lane "Lane"` | Claim WU and create worktree | Start working |
302
- | `pnpm wu:edit --id WU-XXX --field value` | Edit WU spec fields | Update notes/desc |
303
- | `pnpm wu:spawn --id WU-XXX --client X` | Spawn sub-agent for parallel work | Complex WUs |
304
- | `pnpm gates` | Run quality gates | Before wu:done |
305
- | `pnpm gates --docs-only` | Run docs-only gates | For documentation WUs |
306
- | `pnpm wu:done --id WU-XXX` | Complete WU, merge, cleanup | After gates pass |
307
- | `pnpm wu:recover --id WU-XXX` | Fix inconsistent WU state | When state is broken |
395
+ | Command | Description | When to Use |
396
+ | ---------------------------------------------- | ---------------------------------------- | --------------------------- |
397
+ | `pnpm wu:status --id WU-XXX` | Show WU state and valid commands | Check current state |
398
+ | `pnpm wu:claim --id WU-XXX --lane "Lane"` | Claim WU and create worktree (default) | Start working (local) |
399
+ | `pnpm wu:claim --id WU-XXX --lane "L" --cloud` | Claim WU in branch-pr mode (no worktree) | Start working (cloud) |
400
+ | `pnpm wu:edit --id WU-XXX --field value` | Edit WU spec fields | Update notes/desc |
401
+ | `pnpm wu:brief --id WU-XXX --client X` | Generate sub-agent handoff prompt | Complex WUs |
402
+ | `pnpm wu:delegate --id WU-XXX --parent-wu P` | Generate prompt + record delegation | Auditable delegation flows |
403
+ | `pnpm gates` | Run quality gates | Before wu:done |
404
+ | `pnpm gates --docs-only` | Run docs-only gates | For documentation WUs |
405
+ | `pnpm wu:done --id WU-XXX` | Complete WU (merge or PR, cleanup) | After gates pass |
406
+ | `pnpm wu:cleanup --id WU-XXX` | Post-merge cleanup (branch-pr) | After PR merge (cloud only) |
407
+ | `pnpm wu:recover --id WU-XXX` | Fix inconsistent WU state | When state is broken |
308
408
 
309
409
  ---
310
410
 
@@ -465,7 +565,7 @@ rm -rf /tmp/nextjs-scaffold
465
565
 
466
566
  - [LUMENFLOW.md](../../../../../LUMENFLOW.md) - Main workflow documentation
467
567
  - [AGENTS.md](../../../../../AGENTS.md) - Universal agent entry point
468
- - [.lumenflow/constraints.md](../../../../../.lumenflow/constraints.md) - The 6 non-negotiable rules
568
+ - [.lumenflow/constraints.md](../../../../../.lumenflow/constraints.md) - The 8 non-negotiable rules
469
569
  - [troubleshooting-wu-done.md](troubleshooting-wu-done.md) - Why agents forget wu:done
470
570
  - [first-wu-mistakes.md](first-wu-mistakes.md) - Common mistakes to avoid
471
571
  - [quick-ref-commands.md](quick-ref-commands.md) - Command reference
@@ -112,6 +112,17 @@ cd worktrees/<lane>-wu-xxx
112
112
  pnpm wu:prep --id WU-XXX
113
113
  ```
114
114
 
115
+ ### "spec:linter failed"
116
+
117
+ `spec:linter` runs **scoped validation first** (current WU only), then **global validation**.
118
+
119
+ - If scoped validation fails, fix your WU spec.
120
+ - If global validation fails and the failures are **pre-existing on main**, `wu:prep` prints a
121
+ ready-to-copy `wu:done --skip-gates --fix-wu WU-XXXX` command.
122
+ - If global validation introduces **new failures**, you must fix them before proceeding.
123
+
124
+ Feature WUs **must** include `spec_refs` (use `pnpm wu:create --plan` if the plan exists only in conversation).
125
+
115
126
  ---
116
127
 
117
128
  ## Exposure Auto-Fill (WU-1041)