@lumenflow/cli 2.2.2 → 2.3.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 (118) hide show
  1. package/README.md +147 -57
  2. package/dist/__tests__/agent-log-issue.test.js +56 -0
  3. package/dist/__tests__/cli-entry-point.test.js +66 -17
  4. package/dist/__tests__/cli-subprocess.test.js +25 -0
  5. package/dist/__tests__/init.test.js +298 -0
  6. package/dist/__tests__/initiative-plan.test.js +340 -0
  7. package/dist/__tests__/mem-cleanup-execution.test.js +19 -0
  8. package/dist/__tests__/merge-block.test.js +220 -0
  9. package/dist/__tests__/safe-git.test.js +191 -0
  10. package/dist/__tests__/state-doctor.test.js +274 -0
  11. package/dist/__tests__/wu-done.test.js +36 -0
  12. package/dist/__tests__/wu-edit.test.js +119 -0
  13. package/dist/__tests__/wu-prep.test.js +108 -0
  14. package/dist/agent-issues-query.js +4 -3
  15. package/dist/agent-log-issue.js +25 -4
  16. package/dist/backlog-prune.js +5 -4
  17. package/dist/cli-entry-point.js +11 -1
  18. package/dist/doctor.js +368 -0
  19. package/dist/flow-bottlenecks.js +6 -5
  20. package/dist/flow-report.js +4 -3
  21. package/dist/gates.js +356 -101
  22. package/dist/guard-locked.js +4 -3
  23. package/dist/guard-worktree-commit.js +4 -3
  24. package/dist/init.js +508 -86
  25. package/dist/initiative-add-wu.js +4 -3
  26. package/dist/initiative-bulk-assign-wus.js +8 -5
  27. package/dist/initiative-create.js +73 -37
  28. package/dist/initiative-edit.js +37 -21
  29. package/dist/initiative-list.js +4 -3
  30. package/dist/initiative-plan.js +337 -0
  31. package/dist/initiative-status.js +4 -3
  32. package/dist/lane-health.js +377 -0
  33. package/dist/lane-suggest.js +382 -0
  34. package/dist/mem-checkpoint.js +2 -2
  35. package/dist/mem-cleanup.js +2 -2
  36. package/dist/mem-context.js +306 -0
  37. package/dist/mem-create.js +2 -2
  38. package/dist/mem-delete.js +293 -0
  39. package/dist/mem-inbox.js +2 -2
  40. package/dist/mem-index.js +211 -0
  41. package/dist/mem-init.js +1 -1
  42. package/dist/mem-profile.js +207 -0
  43. package/dist/mem-promote.js +254 -0
  44. package/dist/mem-ready.js +2 -2
  45. package/dist/mem-signal.js +2 -2
  46. package/dist/mem-start.js +2 -2
  47. package/dist/mem-summarize.js +2 -2
  48. package/dist/mem-triage.js +2 -2
  49. package/dist/merge-block.js +222 -0
  50. package/dist/metrics-cli.js +7 -4
  51. package/dist/metrics-snapshot.js +4 -3
  52. package/dist/orchestrate-initiative.js +10 -4
  53. package/dist/orchestrate-monitor.js +379 -31
  54. package/dist/signal-cleanup.js +296 -0
  55. package/dist/spawn-list.js +6 -5
  56. package/dist/state-bootstrap.js +5 -4
  57. package/dist/state-cleanup.js +360 -0
  58. package/dist/state-doctor-fix.js +196 -0
  59. package/dist/state-doctor.js +501 -0
  60. package/dist/validate-agent-skills.js +4 -3
  61. package/dist/validate-agent-sync.js +4 -3
  62. package/dist/validate-backlog-sync.js +4 -3
  63. package/dist/validate-skills-spec.js +4 -3
  64. package/dist/validate.js +4 -3
  65. package/dist/wu-block.js +3 -3
  66. package/dist/wu-claim.js +208 -98
  67. package/dist/wu-cleanup.js +5 -4
  68. package/dist/wu-create.js +71 -46
  69. package/dist/wu-delete.js +88 -60
  70. package/dist/wu-deps.js +6 -5
  71. package/dist/wu-done-check.js +34 -0
  72. package/dist/wu-done.js +39 -12
  73. package/dist/wu-edit.js +63 -28
  74. package/dist/wu-infer-lane.js +7 -6
  75. package/dist/wu-preflight.js +23 -81
  76. package/dist/wu-prep.js +125 -0
  77. package/dist/wu-prune.js +4 -3
  78. package/dist/wu-recover.js +88 -22
  79. package/dist/wu-repair.js +7 -6
  80. package/dist/wu-spawn.js +226 -270
  81. package/dist/wu-status.js +4 -3
  82. package/dist/wu-unblock.js +5 -5
  83. package/dist/wu-unlock-lane.js +4 -3
  84. package/dist/wu-validate.js +5 -4
  85. package/package.json +16 -7
  86. package/templates/core/.lumenflow/constraints.md.template +192 -0
  87. package/templates/core/.lumenflow/rules/git-safety.md.template +27 -0
  88. package/templates/core/.lumenflow/rules/wu-workflow.md.template +48 -0
  89. package/templates/core/AGENTS.md.template +60 -0
  90. package/templates/core/LUMENFLOW.md.template +255 -0
  91. package/templates/core/UPGRADING.md.template +121 -0
  92. package/templates/core/ai/onboarding/agent-safety-card.md.template +106 -0
  93. package/templates/core/ai/onboarding/first-wu-mistakes.md.template +198 -0
  94. package/templates/core/ai/onboarding/quick-ref-commands.md.template +186 -0
  95. package/templates/core/ai/onboarding/release-process.md.template +362 -0
  96. package/templates/core/ai/onboarding/troubleshooting-wu-done.md.template +159 -0
  97. package/templates/core/ai/onboarding/wu-create-checklist.md.template +117 -0
  98. package/templates/vendors/aider/.aider.conf.yml.template +27 -0
  99. package/templates/vendors/claude/.claude/CLAUDE.md.template +52 -0
  100. package/templates/vendors/claude/.claude/settings.json.template +49 -0
  101. package/templates/vendors/claude/.claude/skills/bug-classification/SKILL.md.template +192 -0
  102. package/templates/vendors/claude/.claude/skills/code-quality/SKILL.md.template +152 -0
  103. package/templates/vendors/claude/.claude/skills/context-management/SKILL.md.template +155 -0
  104. package/templates/vendors/claude/.claude/skills/execution-memory/SKILL.md.template +304 -0
  105. package/templates/vendors/claude/.claude/skills/frontend-design/SKILL.md.template +131 -0
  106. package/templates/vendors/claude/.claude/skills/initiative-management/SKILL.md.template +164 -0
  107. package/templates/vendors/claude/.claude/skills/library-first/SKILL.md.template +98 -0
  108. package/templates/vendors/claude/.claude/skills/lumenflow-gates/SKILL.md.template +87 -0
  109. package/templates/vendors/claude/.claude/skills/multi-agent-coordination/SKILL.md.template +84 -0
  110. package/templates/vendors/claude/.claude/skills/ops-maintenance/SKILL.md.template +254 -0
  111. package/templates/vendors/claude/.claude/skills/orchestration/SKILL.md.template +189 -0
  112. package/templates/vendors/claude/.claude/skills/tdd-workflow/SKILL.md.template +139 -0
  113. package/templates/vendors/claude/.claude/skills/worktree-discipline/SKILL.md.template +138 -0
  114. package/templates/vendors/claude/.claude/skills/wu-lifecycle/SKILL.md.template +106 -0
  115. package/templates/vendors/cline/.clinerules.template +53 -0
  116. package/templates/vendors/cursor/.cursor/rules/lumenflow.md.template +34 -0
  117. package/templates/vendors/cursor/.cursor/rules.md.template +28 -0
  118. package/templates/vendors/windsurf/.windsurf/rules/lumenflow.md.template +34 -0
@@ -0,0 +1,255 @@
1
+ # LumenFlow Workflow Guide
2
+
3
+ **Last updated:** {{DATE}}
4
+
5
+ LumenFlow is a vendor-agnostic workflow framework for AI-native software development.
6
+
7
+ > **Context Safety**: When approaching context limits (80% usage, 50+ tool calls), spawn a fresh agent instead of continuing after compaction. See [wu-sizing-guide.md](docs/04-operations/_frameworks/lumenflow/wu-sizing-guide.md).
8
+
9
+ ---
10
+
11
+ ## Critical Rule: ALWAYS Run wu:done
12
+
13
+ **After completing work on a WU, you MUST run `pnpm wu:done --id WU-XXXX` from the main checkout.**
14
+
15
+ This is the single most forgotten step. Do NOT:
16
+
17
+ - Write "To Complete: pnpm wu:done" and stop
18
+ - Ask if you should run wu:done
19
+ - Forget to run wu:done
20
+
21
+ **DO**: Run `pnpm wu:done --id WU-XXXX` immediately after gates pass.
22
+
23
+ See: [docs/04-operations/\_frameworks/lumenflow/agent/onboarding/troubleshooting-wu-done.md](docs/04-operations/_frameworks/lumenflow/agent/onboarding/troubleshooting-wu-done.md)
24
+
25
+ ---
26
+
27
+ ## Quick Start
28
+
29
+ ```bash
30
+ # 1. Setup (first time only)
31
+ pnpm setup
32
+
33
+ # 2. Create a WU (default: creates spec/wu-xxxx branch, never writes to main)
34
+ pnpm wu:create --id WU-XXXX --lane <Lane> --title "Title" \
35
+ --description "..." --acceptance "..." --code-paths "..." \
36
+ --test-paths-unit "..." --exposure backend-only \
37
+ --spec-refs "lumenflow://plans/WU-XXXX-plan.md"
38
+
39
+ # 3. Claim (auto-merges spec branch to main if needed)
40
+ pnpm wu:claim --id WU-XXXX --lane <Lane>
41
+ cd worktrees/<lane>-wu-xxxx
42
+
43
+ # 4. Implement in worktree
44
+
45
+ # 5. Run gates
46
+ pnpm gates --docs-only # for docs changes
47
+ pnpm gates # for code changes
48
+
49
+ # 6. Complete (from main checkout)
50
+ cd /path/to/main
51
+ pnpm wu:done --id WU-XXXX
52
+ ```
53
+
54
+ ---
55
+
56
+ ## Core Principles
57
+
58
+ 1. **TDD**: Failing test -> implementation -> passing test (>=90% coverage on new code)
59
+ 2. **Library-First**: Search existing libraries before custom code
60
+ 3. **DRY/SOLID/KISS/YAGNI**: No magic numbers, no hardcoded strings
61
+ 4. **Worktree Discipline**: After `wu:claim`, work ONLY in the worktree
62
+ 5. **Branch Safety**: NEVER edit files on main branch. Run `git branch --show-current` before edits.
63
+ 6. **Gates Before Done**: All gates must pass before `wu:done`
64
+ 7. **Do Not Bypass Hooks**: No `--no-verify`, fix issues properly
65
+ 8. **Always wu:done**: Complete every WU by running `pnpm wu:done`
66
+
67
+ ---
68
+
69
+ ## Global State
70
+
71
+ Canonical global state is defined by:
72
+
73
+ - `origin/main` (WU YAML + status.md + backlog.md + state store)
74
+ - Remote lane branches (e.g., `origin/lane/<lane>/wu-<id>`)
75
+
76
+ `wu:claim` updates canonical claim state on `origin/main` using a push-only micro-worktree, then
77
+ creates the lane branch and pushes it by default for global visibility. Use `--no-push` only for
78
+ air-gapped/offline work; it creates a local-only claim and warns explicitly.
79
+
80
+ ---
81
+
82
+ ## Documentation Structure
83
+
84
+ ### Core (Vendor-Agnostic)
85
+
86
+ - **LUMENFLOW.md** - This file, main entry point
87
+ - **.lumenflow/constraints.md** - Non-negotiable workflow constraints
88
+ - **.lumenflow/rules/** - Workflow rules (git-safety.md, wu-workflow.md, etc.)
89
+ - **docs/04-operations/\_frameworks/lumenflow/agent/onboarding/** - Agent onboarding documentation
90
+
91
+ ### Vendor Integrations
92
+
93
+ - **.claude/** - Claude Code (settings.json, hooks, .claude/CLAUDE.md)
94
+ - **.cursor/** - Cursor (rules, settings)
95
+ - **.aider.conf.yml** - Aider configuration
96
+ - **.continue/** - Continue configuration
97
+
98
+ ---
99
+
100
+ ## Worktree Discipline (IMMUTABLE LAW)
101
+
102
+ After claiming a WU, you MUST work in its worktree:
103
+
104
+ ```bash
105
+ # 1. Claim creates worktree
106
+ pnpm wu:claim --id WU-XXX --lane <lane>
107
+
108
+ # 2. IMMEDIATELY cd to worktree
109
+ cd worktrees/<lane>-wu-xxx
110
+
111
+ # 3. ALL work happens here (edits, git add/commit/push, tests, gates)
112
+
113
+ # 4. Return to main ONLY to complete
114
+ cd /path/to/main
115
+ pnpm wu:done --id WU-XXX
116
+ ```
117
+
118
+ Main checkout becomes read-only after claim. Hooks will block WU commits from main.
119
+
120
+ ---
121
+
122
+ ## Definition of Done
123
+
124
+ - Acceptance criteria satisfied
125
+ - Gates green (`pnpm gates` or `pnpm gates --docs-only`)
126
+ - WU YAML status = `done`
127
+ - `.lumenflow/stamps/WU-<id>.done` exists
128
+ - **wu:done has been run** (not just documented as "to do")
129
+
130
+ ---
131
+
132
+ ## Core Commands
133
+
134
+ > **Complete CLI reference (60+ commands):** See [quick-ref-commands.md](ai/onboarding/quick-ref-commands.md)
135
+
136
+ | Command | Description |
137
+ | ------------------------------- | ------------------------------------------------------ |
138
+ | `pnpm wu:create` | Create new WU spec |
139
+ | `pnpm wu:claim` | Claim WU, update canonical state, create worktree |
140
+ | `pnpm wu:done` | Complete WU (merge, stamp, cleanup) |
141
+ | `pnpm wu:block` | Block WU (transitions to blocked, frees lane) |
142
+ | `pnpm wu:unblock` | Unblock WU (transitions to in_progress) |
143
+ | `pnpm wu:release` | Release orphaned WU (in_progress to ready for reclaim) |
144
+ | `pnpm wu:status` | Show WU status, location, and valid commands |
145
+ | `pnpm wu:recover` | Analyze and fix WU state inconsistencies |
146
+ | `pnpm gates` | Run quality gates |
147
+ | `pnpm mem:checkpoint` | Save memory checkpoint |
148
+ | `pnpm exec lumenflow docs:sync` | Sync agent docs after upgrading LumenFlow packages |
149
+
150
+ ### Context-Aware Validation (WU-1090)
151
+
152
+ WU lifecycle commands include context-aware validation that automatically checks:
153
+
154
+ - **Location**: Whether you are in main checkout or a worktree
155
+ - **WU Status**: Whether the WU is in the correct state for the command
156
+ - **Git State**: Uncommitted changes, commits ahead/behind
157
+
158
+ When validation fails, commands provide copy-paste ready fix commands:
159
+
160
+ ```
161
+ ERROR: WRONG_LOCATION - wu:done must be run from main checkout
162
+
163
+ FIX: Run this command:
164
+ cd {{PROJECT_ROOT}} && pnpm wu:done --id WU-1090
165
+ ```
166
+
167
+ Configure validation behavior in `.lumenflow.config.yaml`:
168
+
169
+ ```yaml
170
+ experimental:
171
+ context_validation: true # Enable/disable validation
172
+ validation_mode: 'warn' # 'off' | 'warn' | 'error'
173
+ show_next_steps: true # Show guidance after command success
174
+ ```
175
+
176
+ ### Recovery Commands
177
+
178
+ If WU state becomes inconsistent (e.g., worktree exists but status is 'ready'), use recovery:
179
+
180
+ ```bash
181
+ # Analyze issues
182
+ pnpm wu:recover --id WU-XXX
183
+
184
+ # Apply suggested fix
185
+ pnpm wu:recover --id WU-XXX --action resume # Reconcile state, preserve work
186
+ pnpm wu:recover --id WU-XXX --action reset # Reset to ready, discard worktree
187
+ pnpm wu:recover --id WU-XXX --action cleanup # Remove leftover worktree
188
+ ```
189
+
190
+ ---
191
+
192
+ ## Constraints
193
+
194
+ See [.lumenflow/constraints.md](.lumenflow/constraints.md) for the 6 non-negotiable rules:
195
+
196
+ 1. Worktree discipline and git safety
197
+ 2. WUs are specs, not code
198
+ 3. Docs-only vs code WUs
199
+ 4. LLM-first, zero-fallback inference
200
+ 5. Gates and skip-gates
201
+ 6. Safety and governance
202
+
203
+ ---
204
+
205
+ ## Agent Onboarding
206
+
207
+ If you're an AI agent, read the onboarding docs:
208
+
209
+ 1. [docs/04-operations/\_frameworks/lumenflow/agent/onboarding/troubleshooting-wu-done.md](docs/04-operations/_frameworks/lumenflow/agent/onboarding/troubleshooting-wu-done.md) - Most common mistake
210
+ 2. [docs/04-operations/\_frameworks/lumenflow/agent/onboarding/first-wu-mistakes.md](docs/04-operations/_frameworks/lumenflow/agent/onboarding/first-wu-mistakes.md) - First WU pitfalls
211
+ 3. [docs/04-operations/\_frameworks/lumenflow/agent/onboarding/agent-safety-card.md](docs/04-operations/_frameworks/lumenflow/agent/onboarding/agent-safety-card.md) - Safety guardrails
212
+ 4. [docs/04-operations/\_frameworks/lumenflow/agent/onboarding/quick-ref-commands.md](docs/04-operations/_frameworks/lumenflow/agent/onboarding/quick-ref-commands.md) - Command reference
213
+
214
+ ---
215
+
216
+ ## Skills & Agents
217
+
218
+ LumenFlow provides modular skills and agent definitions for AI assistants.
219
+
220
+ ### Skills
221
+
222
+ Skills are knowledge bundles in `.claude/skills/` (Claude Code) or `.lumenflow/skills/` (vendor-agnostic):
223
+
224
+ | Skill | Purpose |
225
+ | --------------------- | ------------------------------------------- |
226
+ | `wu-lifecycle` | WU claim/block/done automation |
227
+ | `worktree-discipline` | Prevent absolute path trap |
228
+ | `tdd-workflow` | RED-GREEN-REFACTOR, test-driven development |
229
+ | `lumenflow-gates` | Gate troubleshooting |
230
+ | `bug-classification` | P0-P3 triage, fix-in-place decisions |
231
+
232
+ Load skills in Claude Code: `/skill wu-lifecycle`
233
+
234
+ ### Agents
235
+
236
+ Pre-configured agent definitions in `.claude/agents/`:
237
+
238
+ | Agent | Purpose |
239
+ | ----------------- | -------------------------- |
240
+ | `general-purpose` | Standard WU implementation |
241
+ | `lumenflow-pm` | Backlog & lifecycle |
242
+ | `test-engineer` | TDD, coverage |
243
+ | `code-reviewer` | Quality checks |
244
+ | `bug-triage` | Bug classification |
245
+
246
+ Generate spawn prompts: `pnpm wu:spawn --id WU-XXX --client claude-code`
247
+
248
+ ---
249
+
250
+ ## References
251
+
252
+ - [LumenFlow Complete Guide](docs/04-operations/_frameworks/lumenflow/lumenflow-complete.md)
253
+ - [WU Sizing Guide](docs/04-operations/_frameworks/lumenflow/wu-sizing-guide.md)
254
+ - [Skills Index](.claude/skills/INDEX.md)
255
+ - [Agents README](.claude/agents/README.md)
@@ -0,0 +1,121 @@
1
+ # Upgrading LumenFlow
2
+
3
+ This guide covers upgrading LumenFlow packages in your project.
4
+
5
+ ## Quick Upgrade
6
+
7
+ ```bash
8
+ # Check for available updates
9
+ pnpm outdated @lumenflow/*
10
+
11
+ # Update all LumenFlow packages
12
+ pnpm update @lumenflow/cli @lumenflow/core @lumenflow/memory @lumenflow/agent @lumenflow/initiatives
13
+
14
+ # Sync documentation and templates
15
+ pnpm exec lumenflow docs:sync
16
+ ```
17
+
18
+ ## Version Compatibility
19
+
20
+ LumenFlow follows semantic versioning:
21
+
22
+ - **Major versions** (e.g., 1.x to 2.x): Breaking changes, require migration steps
23
+ - **Minor versions** (e.g., 1.1 to 1.2): New features, backwards compatible
24
+ - **Patch versions** (e.g., 1.1.0 to 1.1.1): Bug fixes, backwards compatible
25
+
26
+ All `@lumenflow/*` packages are versioned together. Always upgrade them as a group.
27
+
28
+ ## Step-by-Step Upgrade Process
29
+
30
+ ### 1. Check Current Versions
31
+
32
+ ```bash
33
+ pnpm list @lumenflow/*
34
+ ```
35
+
36
+ ### 2. Review Changelog
37
+
38
+ Before upgrading, review the changelog for breaking changes:
39
+
40
+ - [GitHub Releases](https://github.com/hellmai/os/releases)
41
+ - [lumenflow.dev/changelog](https://lumenflow.dev/changelog)
42
+
43
+ ### 3. Update Packages
44
+
45
+ ```bash
46
+ # Update to latest versions
47
+ pnpm update @lumenflow/cli @lumenflow/core @lumenflow/memory @lumenflow/agent @lumenflow/initiatives
48
+
49
+ # Or update to a specific version
50
+ pnpm add @lumenflow/cli@^1.2.0 @lumenflow/core@^1.2.0
51
+ ```
52
+
53
+ ### 4. Sync Documentation
54
+
55
+ After upgrading, sync agent onboarding documentation:
56
+
57
+ ```bash
58
+ pnpm exec lumenflow docs:sync
59
+ ```
60
+
61
+ This updates:
62
+
63
+ - `.lumenflow/` - Workflow rules and constraints
64
+ - `.claude/` - Claude Code skills and settings (if used)
65
+ - `.cursor/` - Cursor rules (if used)
66
+ - Agent onboarding documentation
67
+
68
+ ### 5. Verify Installation
69
+
70
+ ```bash
71
+ # Run gates to verify everything works
72
+ pnpm gates
73
+
74
+ # Check CLI version
75
+ pnpm exec lumenflow --version
76
+ ```
77
+
78
+ ## Troubleshooting
79
+
80
+ ### Package Resolution Errors
81
+
82
+ If you encounter dependency resolution errors:
83
+
84
+ ```bash
85
+ # Clear pnpm cache and reinstall
86
+ pnpm store prune
87
+ rm -rf node_modules pnpm-lock.yaml
88
+ pnpm install
89
+ ```
90
+
91
+ ### CLI Not Found
92
+
93
+ If `lumenflow` command is not found after upgrade:
94
+
95
+ ```bash
96
+ # Rebuild CLI
97
+ pnpm --filter @lumenflow/cli build
98
+
99
+ # Or reinstall
100
+ pnpm install
101
+ ```
102
+
103
+ ### Template Conflicts
104
+
105
+ If `docs:sync` reports conflicts:
106
+
107
+ 1. Review the diff for each conflicting file
108
+ 2. Merge manually or accept incoming changes
109
+ 3. Run `pnpm gates` to verify
110
+
111
+ ## Migration Guides
112
+
113
+ For major version upgrades, see version-specific migration guides:
114
+
115
+ - [Migrating to v2.0](https://lumenflow.dev/migration/v2)
116
+ - [Migrating to v1.0](https://lumenflow.dev/migration/v1)
117
+
118
+ ## Getting Help
119
+
120
+ - [GitHub Issues](https://github.com/hellmai/os/issues)
121
+ - [lumenflow.dev/docs](https://lumenflow.dev/docs)
@@ -0,0 +1,106 @@
1
+ # Agent Safety Card
2
+
3
+ **Last updated:** {{DATE}}
4
+
5
+ Quick reference for AI agents working in LumenFlow projects.
6
+
7
+ ---
8
+
9
+ ## Stop and Ask When
10
+
11
+ - Same error repeats 3 times
12
+ - Auth or permissions changes needed
13
+ - PII/PHI/secrets involved
14
+ - Cloud spend decisions
15
+ - Policy changes required
16
+ - Anything feels irreversible
17
+
18
+ ---
19
+
20
+ ## Never Do
21
+
22
+ | Action | Why |
23
+ | ------------------------ | ---------------- |
24
+ | `git reset --hard` | Data loss |
25
+ | `git push --force` | History rewrite |
26
+ | `--no-verify` | Bypasses safety |
27
+ | `git stash` (on main) | Hides work |
28
+ | `git clean -fd` | Deletes files |
29
+ | Work in main after claim | Breaks isolation |
30
+ | Skip wu:done | Incomplete WU |
31
+
32
+ ---
33
+
34
+ ## Always Do
35
+
36
+ | Action | Why |
37
+ | -------------------------- | ---------------- |
38
+ | Read WU spec first | Understand scope |
39
+ | cd to worktree after claim | Isolation |
40
+ | Write tests before code | TDD |
41
+ | Run gates before wu:done | Quality |
42
+ | Run wu:done | Complete WU |
43
+ | Stay within code_paths | Scope discipline |
44
+
45
+ ---
46
+
47
+ ## Error Handling
48
+
49
+ ### Max 3 Attempts
50
+
51
+ If same error happens 3 times:
52
+
53
+ 1. Stop trying
54
+ 2. Document what happened
55
+ 3. Ask for help
56
+
57
+ ### Gate Failures
58
+
59
+ 1. Read the error message
60
+ 2. Fix the underlying issue
61
+ 3. Re-run gates
62
+ 4. Never use `--skip-gates` for new failures
63
+
64
+ ---
65
+
66
+ ## Quick Commands
67
+
68
+ ```bash
69
+ # Check lane availability
70
+ cat docs/04-operations/tasks/status.md
71
+
72
+ # Claim a WU
73
+ pnpm wu:claim --id WU-XXX --lane <Lane>
74
+
75
+ # Work in worktree
76
+ cd worktrees/<lane>-wu-xxx
77
+
78
+ # Run gates
79
+ pnpm gates # Code changes
80
+ pnpm gates --docs-only # Docs changes
81
+
82
+ # Complete WU
83
+ cd /path/to/main
84
+ pnpm wu:done --id WU-XXX
85
+ ```
86
+
87
+ ---
88
+
89
+ ## Completion Checklist
90
+
91
+ - [ ] Gates pass
92
+ - [ ] cd to main
93
+ - [ ] Run wu:done
94
+ - [ ] Verify success output
95
+ - [ ] Report completion
96
+
97
+ ---
98
+
99
+ ## When Uncertain
100
+
101
+ Choose the safer path:
102
+
103
+ - Don't modify files outside code_paths
104
+ - Don't bypass hooks
105
+ - Don't skip gates
106
+ - Ask rather than assume
@@ -0,0 +1,198 @@
1
+ # First WU Mistakes
2
+
3
+ **Last updated:** {{DATE}}
4
+
5
+ Common mistakes agents make on their first WU, and how to avoid them.
6
+
7
+ ---
8
+
9
+ ## Mistake 1: Not Using Worktrees
10
+
11
+ ### Wrong
12
+
13
+ ```bash
14
+ # Working directly in main
15
+ vim src/feature.ts
16
+ git commit -m "feat: add feature"
17
+ git push origin main
18
+ ```
19
+
20
+ ### Right
21
+
22
+ ```bash
23
+ # Claim first, then work in worktree
24
+ pnpm wu:claim --id WU-123 --lane Core
25
+ cd worktrees/core-wu-123
26
+ vim src/feature.ts
27
+ git commit -m "feat: add feature"
28
+ git push origin lane/core/wu-123
29
+ cd /path/to/main
30
+ pnpm wu:done --id WU-123
31
+ ```
32
+
33
+ ---
34
+
35
+ ## Mistake 2: Forgetting to Run wu:done
36
+
37
+ See [troubleshooting-wu-done.md](troubleshooting-wu-done.md) for the full explanation.
38
+
39
+ **TL;DR:** After gates pass, ALWAYS run `pnpm wu:done --id WU-XXX`.
40
+
41
+ ---
42
+
43
+ ## Mistake 3: Working Outside code_paths
44
+
45
+ ### Wrong
46
+
47
+ The WU says `code_paths: [src/api/**]` but you edit `src/ui/component.ts`.
48
+
49
+ ### Right
50
+
51
+ Only edit files within the specified `code_paths`. If you need to edit other files, that's a different WU.
52
+
53
+ ---
54
+
55
+ ## Mistake 4: Skipping TDD
56
+
57
+ ### Wrong
58
+
59
+ ```
60
+ 1. Write the feature
61
+ 2. Maybe write tests later
62
+ 3. Tests are hard, skip them
63
+ ```
64
+
65
+ ### Right
66
+
67
+ ```
68
+ 1. Write failing test
69
+ 2. Run test (confirm RED)
70
+ 3. Write minimum code
71
+ 4. Run test (confirm GREEN)
72
+ 5. Refactor if needed
73
+ ```
74
+
75
+ ---
76
+
77
+ ## Mistake 5: Using Forbidden Git Commands
78
+
79
+ ### Wrong
80
+
81
+ ```bash
82
+ git reset --hard HEAD
83
+ git push --force
84
+ git commit --no-verify
85
+ ```
86
+
87
+ ### Right
88
+
89
+ ```bash
90
+ git add .
91
+ git commit -m "feat: description"
92
+ git push origin lane/core/wu-123
93
+ ```
94
+
95
+ ---
96
+
97
+ ## Mistake 6: Working After Hours on Same WU
98
+
99
+ If you need to pause:
100
+
101
+ ```bash
102
+ # Commit your work
103
+ git add .
104
+ git commit -m "wip: partial progress"
105
+ git push origin lane/core/wu-123
106
+ ```
107
+
108
+ Do NOT leave uncommitted changes in the worktree.
109
+
110
+ ---
111
+
112
+ ## Mistake 7: Ignoring Gate Failures
113
+
114
+ ### Wrong
115
+
116
+ ```
117
+ Gates failed but I think the code is fine.
118
+ Let me use --skip-gates.
119
+ ```
120
+
121
+ ### Right
122
+
123
+ ```
124
+ Gates failed. Let me read the error:
125
+ - TypeScript error in src/api/handler.ts
126
+ - Missing return type
127
+
128
+ Fix: Add the return type.
129
+ Re-run: pnpm gates
130
+ ```
131
+
132
+ ---
133
+
134
+ ## Mistake 8: Scope Creep
135
+
136
+ ### Wrong
137
+
138
+ The WU says "Add user profile endpoint" but you also:
139
+
140
+ - Refactor the database schema
141
+ - Add email notifications
142
+ - Redesign the UI
143
+
144
+ ### Right
145
+
146
+ Implement exactly what the acceptance criteria specify. If you discover other needed changes, create new WUs for them.
147
+
148
+ ---
149
+
150
+ ## Mistake 9: Not Reading the WU Spec
151
+
152
+ ### Wrong
153
+
154
+ Start coding immediately based on the title.
155
+
156
+ ### Right
157
+
158
+ 1. Read the full WU YAML
159
+ 2. Understand acceptance criteria
160
+ 3. Review code_paths
161
+ 4. Check dependencies
162
+ 5. Then start
163
+
164
+ ---
165
+
166
+ ## Mistake 10: Editing Main After Claim
167
+
168
+ ### Wrong
169
+
170
+ ```bash
171
+ pnpm wu:claim --id WU-123 --lane Core
172
+ # Still in main directory
173
+ vim src/feature.ts # WRONG!
174
+ ```
175
+
176
+ ### Right
177
+
178
+ ```bash
179
+ pnpm wu:claim --id WU-123 --lane Core
180
+ cd worktrees/core-wu-123 # IMMEDIATELY
181
+ vim src/feature.ts # Now it's safe
182
+ ```
183
+
184
+ ---
185
+
186
+ ## Quick Checklist
187
+
188
+ Before starting any WU:
189
+
190
+ - [ ] Read the full WU spec
191
+ - [ ] Understand acceptance criteria
192
+ - [ ] Claim the WU with `pnpm wu:claim`
193
+ - [ ] cd to the worktree IMMEDIATELY
194
+ - [ ] Work only in the worktree
195
+ - [ ] Stay within code_paths
196
+ - [ ] Follow TDD
197
+ - [ ] Run gates before wu:done
198
+ - [ ] ALWAYS run wu:done