specweave 0.26.2 → 0.26.4

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/CLAUDE.md +172 -1413
  2. package/dist/src/cli/commands/plan/plan-orchestrator.js +2 -2
  3. package/dist/src/cli/commands/plan/plan-orchestrator.js.map +1 -1
  4. package/dist/src/cli/helpers/issue-tracker/github-multi-repo.d.ts.map +1 -1
  5. package/dist/src/cli/helpers/issue-tracker/github-multi-repo.js +147 -55
  6. package/dist/src/cli/helpers/issue-tracker/github-multi-repo.js.map +1 -1
  7. package/dist/src/core/increment/completion-validator.d.ts +4 -0
  8. package/dist/src/core/increment/completion-validator.d.ts.map +1 -1
  9. package/dist/src/core/increment/completion-validator.js +36 -0
  10. package/dist/src/core/increment/completion-validator.js.map +1 -1
  11. package/dist/src/core/living-docs/living-docs-sync.d.ts.map +1 -1
  12. package/dist/src/core/living-docs/living-docs-sync.js +47 -13
  13. package/dist/src/core/living-docs/living-docs-sync.js.map +1 -1
  14. package/dist/src/core/us-sync-throttle.d.ts +113 -0
  15. package/dist/src/core/us-sync-throttle.d.ts.map +1 -0
  16. package/dist/src/core/us-sync-throttle.js +195 -0
  17. package/dist/src/core/us-sync-throttle.js.map +1 -0
  18. package/dist/src/utils/external-tool-drift-detector.d.ts +76 -0
  19. package/dist/src/utils/external-tool-drift-detector.d.ts.map +1 -0
  20. package/dist/src/utils/external-tool-drift-detector.js +235 -0
  21. package/dist/src/utils/external-tool-drift-detector.js.map +1 -0
  22. package/package.json +4 -4
  23. package/plugins/specweave/hooks/post-task-completion.sh +6 -6
  24. package/plugins/specweave/hooks/pre-increment-start.sh +6 -1
  25. package/plugins/specweave/lib/hooks/us-completion-orchestrator.js +62 -89
  26. package/plugins/specweave/lib/hooks/us-completion-orchestrator.ts +215 -0
  27. package/plugins/specweave-ado/lib/ado-multi-project-sync.js +0 -1
  28. package/plugins/specweave-jira/lib/enhanced-jira-sync.js +3 -3
  29. package/plugins/specweave-release/hooks/post-task-completion.sh +5 -1
  30. package/plugins/specweave/agents/pm/AGENT.md.bak +0 -1893
  31. package/plugins/specweave/hooks/docs-changed.sh.backup +0 -79
  32. package/plugins/specweave/hooks/human-input-required.sh.backup +0 -75
  33. package/plugins/specweave/hooks/lib/migrate-increment-work.sh.bak +0 -245
  34. package/plugins/specweave/hooks/lib/sync-spec-content.sh.bak +0 -149
  35. package/plugins/specweave/hooks/lib/validate-spec-status.sh.bak +0 -163
  36. package/plugins/specweave/hooks/post-first-increment.sh.backup +0 -61
  37. package/plugins/specweave/hooks/post-first-increment.sh.bak +0 -61
  38. package/plugins/specweave/hooks/post-increment-change.sh.backup +0 -98
  39. package/plugins/specweave/hooks/post-increment-completion.sh.backup +0 -231
  40. package/plugins/specweave/hooks/post-increment-planning.sh.backup +0 -1048
  41. package/plugins/specweave/hooks/post-increment-status-change.sh.backup +0 -147
  42. package/plugins/specweave/hooks/post-spec-update.sh.backup +0 -158
  43. package/plugins/specweave/hooks/post-spec-update.sh.bak +0 -158
  44. package/plugins/specweave/hooks/post-user-story-complete.sh.backup +0 -179
  45. package/plugins/specweave/hooks/post-user-story-complete.sh.bak +0 -179
  46. package/plugins/specweave/hooks/pre-command-deduplication.sh.backup +0 -83
  47. package/plugins/specweave/hooks/pre-command-deduplication.sh.bak +0 -83
  48. package/plugins/specweave/hooks/pre-implementation.sh.backup +0 -67
  49. package/plugins/specweave/hooks/pre-task-completion.sh.backup +0 -194
  50. package/plugins/specweave/hooks/pre-tool-use.sh.backup +0 -133
  51. package/plugins/specweave/hooks/user-prompt-submit.sh.backup +0 -386
  52. package/plugins/specweave/hooks/user-prompt-submit.sh.bak +0 -386
  53. package/plugins/specweave/lib/hooks/auto-transition.js.bak +0 -50
  54. package/plugins/specweave/lib/hooks/auto-transition.ts.bak +0 -84
  55. package/plugins/specweave/lib/hooks/git-diff-analyzer.d.js.bak +0 -0
  56. package/plugins/specweave/lib/hooks/git-diff-analyzer.d.ts.bak +0 -89
  57. package/plugins/specweave/lib/hooks/git-diff-analyzer.js.bak +0 -142
  58. package/plugins/specweave/lib/hooks/git-diff-analyzer.ts.bak +0 -269
  59. package/plugins/specweave/lib/hooks/invoke-translator-skill.d.js.bak +0 -0
  60. package/plugins/specweave/lib/hooks/invoke-translator-skill.d.ts.bak +0 -60
  61. package/plugins/specweave/lib/hooks/invoke-translator-skill.js.bak +0 -155
  62. package/plugins/specweave/lib/hooks/invoke-translator-skill.ts.bak +0 -264
  63. package/plugins/specweave/lib/hooks/prepare-reflection-context.d.js.bak +0 -0
  64. package/plugins/specweave/lib/hooks/prepare-reflection-context.d.ts.bak +0 -42
  65. package/plugins/specweave/lib/hooks/prepare-reflection-context.js.bak +0 -110
  66. package/plugins/specweave/lib/hooks/prepare-reflection-context.ts.bak +0 -178
  67. package/plugins/specweave/lib/hooks/reflection-config-loader.d.js.bak +0 -0
  68. package/plugins/specweave/lib/hooks/reflection-config-loader.d.ts.bak +0 -45
  69. package/plugins/specweave/lib/hooks/reflection-config-loader.js.bak +0 -92
  70. package/plugins/specweave/lib/hooks/reflection-config-loader.ts.bak +0 -156
  71. package/plugins/specweave/lib/hooks/reflection-parser.d.js.bak +0 -0
  72. package/plugins/specweave/lib/hooks/reflection-parser.d.ts.bak +0 -33
  73. package/plugins/specweave/lib/hooks/reflection-parser.js.bak +0 -301
  74. package/plugins/specweave/lib/hooks/reflection-parser.ts.bak +0 -484
  75. package/plugins/specweave/lib/hooks/reflection-prompt-builder.d.js.bak +0 -0
  76. package/plugins/specweave/lib/hooks/reflection-prompt-builder.d.ts.bak +0 -56
  77. package/plugins/specweave/lib/hooks/reflection-prompt-builder.js.bak +0 -182
  78. package/plugins/specweave/lib/hooks/reflection-prompt-builder.ts.bak +0 -306
  79. package/plugins/specweave/lib/hooks/reflection-storage.d.js.bak +0 -0
  80. package/plugins/specweave/lib/hooks/reflection-storage.d.ts.bak +0 -64
  81. package/plugins/specweave/lib/hooks/reflection-storage.js.bak +0 -231
  82. package/plugins/specweave/lib/hooks/reflection-storage.ts.bak +0 -369
  83. package/plugins/specweave/lib/hooks/run-self-reflection.d.js.bak +0 -0
  84. package/plugins/specweave/lib/hooks/run-self-reflection.d.ts.bak +0 -43
  85. package/plugins/specweave/lib/hooks/run-self-reflection.js.bak +0 -132
  86. package/plugins/specweave/lib/hooks/run-self-reflection.ts.bak +0 -258
  87. package/plugins/specweave/lib/hooks/sync-cache.js.bak +0 -294
  88. package/plugins/specweave/lib/hooks/sync-living-docs.d.js.bak +0 -1
  89. package/plugins/specweave/lib/hooks/sync-living-docs.d.ts.bak +0 -27
  90. package/plugins/specweave/lib/hooks/sync-living-docs.js.bak +0 -339
  91. package/plugins/specweave/lib/hooks/sync-us-tasks.js.bak +0 -476
  92. package/plugins/specweave/lib/hooks/translate-file.d.js.bak +0 -0
  93. package/plugins/specweave/lib/hooks/translate-file.d.ts.bak +0 -59
  94. package/plugins/specweave/lib/hooks/translate-file.js.bak +0 -289
  95. package/plugins/specweave/lib/hooks/translate-file.ts.bak +0 -428
  96. package/plugins/specweave/lib/hooks/translate-living-docs.d.js.bak +0 -0
  97. package/plugins/specweave/lib/hooks/translate-living-docs.d.ts.bak +0 -13
  98. package/plugins/specweave/lib/hooks/translate-living-docs.js.bak +0 -119
  99. package/plugins/specweave/lib/hooks/translate-living-docs.ts.bak +0 -224
  100. package/plugins/specweave/lib/hooks/update-ac-status.js.bak +0 -51
  101. package/plugins/specweave/lib/hooks/update-ac-status.ts.bak +0 -103
  102. package/plugins/specweave/lib/hooks/update-tasks-md.d.js.bak +0 -1
  103. package/plugins/specweave/lib/hooks/update-tasks-md.d.ts.bak +0 -29
  104. package/plugins/specweave/lib/hooks/update-tasks-md.js.bak +0 -296
  105. package/plugins/specweave/lib/hooks/update-tasks-md.ts.bak +0 -489
  106. package/plugins/specweave-ado/hooks/post-living-docs-update.sh.backup +0 -353
  107. package/plugins/specweave-ado/hooks/post-task-completion.sh.backup +0 -172
  108. package/plugins/specweave-ado/lib/enhanced-ado-sync.js +0 -170
  109. package/plugins/specweave-github/hooks/.specweave/logs/hooks-debug.log +0 -904
  110. package/plugins/specweave-github/hooks/post-task-completion.sh.backup +0 -258
  111. package/plugins/specweave-jira/hooks/post-task-completion.sh.backup +0 -172
  112. package/plugins/specweave-release/hooks/.specweave/logs/dora-tracking.log +0 -738
  113. package/plugins/specweave-release/hooks/post-task-completion.sh.backup +0 -110
package/CLAUDE.md CHANGED
@@ -14,540 +14,168 @@ For **contributors to SpecWeave itself** (not users).
14
14
 
15
15
  **NEVER run commands you know will fail.** Act on reasoning BEFORE execution.
16
16
 
17
- **Common patterns:**
18
- - Running code before compilation `npm run rebuild` FIRST
19
- - Database queries before migrations/setup
20
- - File ops before directory creation
21
-
22
- ```typescript
23
- // ❌ WRONG: Attempt → Fail → Fix
24
- node -e "require('./dist/file.js')" // You knew this would fail!
25
- npm run rebuild
26
-
27
- // ✅ CORRECT: Fix → Attempt
28
- npm run rebuild
29
- node -e "require('./dist/file.js')"
17
+ ```bash
18
+ # WRONG: node -e "require('./dist/file.js')" (before build)
19
+ # CORRECT: npm run rebuild && node -e "require('./dist/file.js')"
30
20
  ```
31
21
 
32
22
  ---
33
23
 
34
- ### 1. Local Development Setup
35
-
36
- **Standard Workflow** (Cross-platform):
24
+ ## 1. Development Setup
37
25
 
26
+ **Standard Workflow**:
38
27
  ```bash
39
- # Setup
40
28
  git clone https://github.com/YOUR_USERNAME/specweave.git
41
29
  cd specweave && npm install && npm run rebuild
42
30
 
43
31
  # Development Cycle
44
- vim src/core/task-parser.ts
45
32
  npm run rebuild && npm test
46
- git add . && git commit -m "feat: feature"
47
- git push origin develop
33
+ git add . && git commit -m "feat: feature" && git push origin develop
48
34
  # Wait 5-10s → Claude Code auto-updates marketplace
49
35
  ```
50
36
 
51
- **Testing Unpushed Changes:**
52
- - **Option 1**: Temp branch → push → test → delete
53
- - **Option 2**: Fork-based (`claude plugin marketplace add github:YOUR_USERNAME/specweave`)
37
+ **Testing Unpushed**: Temp branch → push → test → delete, OR `claude plugin marketplace add github:YOUR_USERNAME/specweave`
54
38
 
55
39
  ---
56
40
 
57
- ### 1a. Quick Marketplace Refresh (NEW! 🚀)
58
-
59
- **Problem**: After implementing new plugins locally, Claude Code needs to reload the marketplace.
60
-
61
- **Solution**: Use the automated refresh script!
41
+ ### 1a. Marketplace Refresh
62
42
 
63
43
  ```bash
64
- # FROM GITHUB (default, recommended) - Pulls latest from GitHub
65
- bash scripts/refresh-marketplace.sh
66
-
67
- # LOCAL DEVELOPMENT - Uses your local changes (ONLY for active development!)
68
- bash scripts/refresh-marketplace.sh --local
69
- ```
70
-
71
- **🚨 CRITICAL: Always Use GitHub Mode Unless Actively Developing!**
72
-
73
- **Why GitHub mode is mandatory:**
74
- - ✅ **Separate Installation**: Creates proper copy at `~/.claude/plugins/marketplaces/specweave/`
75
- - ✅ **Stable Source**: Pulls from committed GitHub code, not unstable local changes
76
- - ✅ **No Path Coupling**: Clear separation between source and runtime
77
- - ✅ **Production-Ready**: What end users will experience
78
-
79
- **Why local mode is dangerous:**
80
- - ❌ **Filesystem Coupling**: `installLocation` = source directory (no separate copy!)
81
- - ❌ **Stale Hook Risk**: Any git operations, file deletions, or uncommitted changes affect "installed" plugins
82
- - ❌ **Path Confusion**: Claude Code expects hooks at `~/.claude/plugins/marketplaces/` but they're in your working directory
83
- - ❌ **Instability**: Leads to "hook not found" errors like you just experienced
84
-
85
- **Rule of thumb:**
86
- - **Development workflow**: Commit → Push → `bash scripts/refresh-marketplace.sh` (GitHub mode) → Test
87
- - **Emergency local testing**: Use `--local` ONLY when you need to test uncommitted changes, then immediately switch back to GitHub mode
88
-
89
- **What it does**:
90
- 1. ✅ Removes existing marketplace
91
- 2. ✅ Clears all plugin caches
92
- 3. ✅ Re-adds marketplace (local or GitHub)
93
- 4. ✅ Installs ALL plugins automatically
94
- 5. ✅ Shows success/failure summary
95
-
96
- **Output Example**:
97
- ```
98
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
99
- SpecWeave Marketplace Refresh (github mode)
100
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
101
-
102
- 📦 Step 1: Removing existing marketplace...
103
- ✓ Marketplace removed
104
-
105
- 🧹 Step 2: Clearing plugin caches...
106
- ✓ Installed plugins cache backed up
107
-
108
- 📥 Step 3: Adding marketplace...
109
- Pulling latest from GitHub: anton-abyzov/specweave
110
- Cloning via SSH: git@github.com:anton-abyzov/specweave.git
111
- ✓ GitHub marketplace added
112
-
113
- 📋 Step 4: Reading plugin list...
114
- ✓ Found 27 plugins
115
-
116
- ⚙️ Step 5: Installing all plugins...
117
- Installing specweave...
118
- ✓ specweave installed
119
-
120
- [... all 19 plugins ...]
121
-
122
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
123
- Installation Summary
124
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
125
-
126
- Total plugins: 19
127
- Successful: 19
128
- Failed: 0
129
-
130
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
131
- ✓ ALL PLUGINS INSTALLED SUCCESSFULLY!
132
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
133
-
134
- Next steps:
135
- 1. Restart Claude Code for changes to take effect
136
- 2. Run /plugin to verify all plugins loaded
137
- 3. Check ~/.claude/plugins/installed_plugins.json
44
+ bash scripts/refresh-marketplace.sh # GitHub (default, ALWAYS use)
45
+ bash scripts/refresh-marketplace.sh --local # Local dev only (filesystem coupling risks)
138
46
  ```
139
47
 
140
- **When to use**:
141
- - After pushing changes to GitHub (GitHub mode - default)
142
- - ✅ After pulling latest from GitHub (GitHub mode)
143
- - ✅ When plugins aren't loading correctly (GitHub mode)
144
- - ✅ After adding new plugins (commit → push → refresh with GitHub mode)
145
- - ⚠️ To test uncommitted local changes (local mode - use sparingly!)
146
-
147
- **Time**: ~30 seconds (vs 5-10 minutes manual)
48
+ **Use GitHub mode**: Proper install path, stable source, no hook coupling (~30s)
49
+ **Verify**: `jq -r '.specweave.source' ~/.claude/plugins/known_marketplaces.json` should be `"github"`
148
50
 
149
- **Verification after refresh**:
150
- ```bash
151
- # Check marketplace source (should be "github")
152
- cat ~/.claude/plugins/known_marketplaces.json | jq -r '.specweave.source'
153
-
154
- # Should output: {"source": "github", "repo": "anton-abyzov/specweave"}
155
- # NOT: {"source": "directory", "path": "/Users/..."}
156
- ```
157
-
158
- **Requirements**: `jq` installed (`brew install jq`)
51
+ **Note**: GitHub mode shows "AC test validator not available" warning because `dist/` is gitignored. Use `--local` mode when developing hooks/validators to test with built artifacts. Regular users with `npm install specweave` won't see this (validator found in `node_modules/`).
159
52
 
160
53
  ---
161
54
 
162
- ### 1b. NPM Release Workflow (NEW! 🚀)
163
-
164
- **Two release modes**: Default (GitHub Actions) and Direct (`--only` flag)
165
-
166
- #### Default Mode (Recommended)
167
-
168
- ```bash
169
- # Push to GitHub → GitHub Actions publishes to npm
170
- /specweave-release:npm
171
- ```
172
-
173
- **What happens**:
174
- 1. ✅ Bumps patch version (e.g., 0.24.11 → 0.24.12)
175
- 2. ✅ Creates git commit + tag
176
- 3. ✅ Pushes to GitHub
177
- 4. ✅ Triggers GitHub Actions workflow
178
- 5. ✅ GitHub Actions publishes to npm (1-2 min)
179
-
180
- **Use when**: Regular releases, want CI validation
181
-
182
- #### Direct Mode (`--only` flag)
55
+ ### 1b. NPM Release
183
56
 
184
57
  ```bash
185
- # Publish directly to npm (bypasses GitHub Actions)
186
- /specweave-release:npm --only
58
+ /specweave-release:npm # GitHub Actions (2-3 min, recommended)
59
+ /specweave-release:npm --only # Direct publish (30s, emergencies)
187
60
  ```
188
61
 
189
- **What happens**:
190
- 1. ✅ Bumps patch version
191
- 2. ✅ Creates git commit + tag
192
- 3. ✅ Builds package (`npm run rebuild`)
193
- 4. ✅ **Publishes to npm immediately**
194
- 5. ✅ Pushes git changes to GitHub (optional)
195
-
196
- **Use when**:
197
- - 🔥 Emergency releases (hotfix needed NOW)
198
- - ⚡ Want immediate feedback (no CI wait)
199
- - 🧪 Testing release process locally
200
- - 💻 GitHub Actions unavailable
201
-
202
- **Example output**:
203
- ```
204
- ✅ Published directly to npm!
205
-
206
- 📦 Version: v0.24.12
207
- 🔗 NPM: https://www.npmjs.com/package/specweave
208
- 🏷️ Git Tag: v0.24.12 (created locally)
209
-
210
- What happened:
211
- - ✅ Version bumped and committed
212
- - ✅ Git tag created locally
213
- - ✅ Package built (npm run rebuild)
214
- - ✅ Published to npm directly
215
- - ✅ Git changes pushed to GitHub
216
-
217
- Note: Published via direct push (bypassed GitHub Actions)
218
- ```
219
-
220
- **Safety**:
221
- - ✅ Both modes do pre-flight checks (branch, uncommitted changes)
222
- - ✅ Both create proper git commits/tags
223
- - ✅ Direct mode rebuilds before publishing
224
- - ✅ Default mode is preferred for regular releases
225
-
226
- **Time comparison**:
227
- - Default mode: 2-3 minutes (includes CI)
228
- - Direct mode (`--only`): 30 seconds
229
-
230
62
  ---
231
63
 
232
- ### 2. Increment Folder Structure
64
+ ## 2. Folder Structure Rules
233
65
 
234
- **CRITICAL RULES**:
235
-
236
- **At `.specweave/increments/` root - ONLY 3 things allowed**:
237
- 1. Numbered increment folders: `####-increment-name/` (e.g., `0053-safe-feature-deletion/`)
238
- 2. Archive folder: `_archive/`
239
- 3. README.md (optional documentation)
240
-
241
- **❌ NOT ALLOWED at root**: `_working/`, `reports/`, `logs/`, `scripts/`, or ANY other folders/files
242
-
243
- **Inside each increment folder - ONLY 4 files at root**: `spec.md`, `plan.md`, `tasks.md`, `metadata.json`
66
+ **At `.specweave/increments/` root - ONLY**:
67
+ 1. `####-increment-name/` folders
68
+ 2. `_archive/` folder
69
+ 3. `README.md` (optional)
244
70
 
71
+ **Inside increment folders - ONLY at root**: `spec.md`, `plan.md`, `tasks.md`, `metadata.json`
245
72
  **Everything else → subfolders**: `reports/`, `scripts/`, `logs/`
246
73
 
247
74
  ```bash
248
- # WRONG: .specweave/increments/_working/fix/
249
- # ❌ WRONG: .specweave/increments/reports/
250
- # ❌ WRONG: .specweave/increments/0046/analysis-report.md
251
- # ✅ CORRECT: .specweave/increments/0046/reports/analysis-report.md
252
- ```
253
-
254
- **Validation**:
255
- ```bash
256
- # Check for violations at root (should output NOTHING)
75
+ # Validation (should output NOTHING):
257
76
  ls -1 .specweave/increments/ | grep -v "^[0-9]" | grep -v "^_archive" | grep -v "^README.md"
258
77
  ```
259
78
 
260
- **See**: `.specweave/docs/internal/governance/increment-folder-structure.md` (complete standard)
261
-
262
79
  ---
263
80
 
264
- ### 3. Protected Directories
81
+ ## 3. Protected Directories
265
82
 
266
83
  **Never delete**: `.specweave/docs/`, `.specweave/increments/`
267
-
268
- **Pre-commit hook blocks**: Deletion of 50+ files, `rm -rf` on protected dirs
269
-
84
+ **Pre-commit hook blocks**: 50+ file deletions, `rm -rf` on protected dirs
270
85
  **Recovery**: `git restore .specweave/`
271
86
 
272
87
  ---
273
88
 
274
- ### 4. Test Cleanup Safety
275
-
276
- **REQUIRED before `rm -rf`**:
277
- 1. Verify `pwd` (MUST be project root)
278
- 2. Dry-run with `-print` (NO deletion)
279
- 3. Count files to delete
280
- 4. Manual confirmation
281
- 5. Execute → Verify → Run tests
282
-
283
- ---
284
-
285
- ### 5. NEVER Use `specweave init . --force`
89
+ ## 4-6. Safety Rules
286
90
 
287
- **Danger**: Deletes ALL increments/docs without backup
288
-
289
- **Use**: `specweave init .` (interactive, safe)
91
+ **4. Test Cleanup**: `pwd` check dry-run → count → confirm → execute
92
+ **5. NEVER**: `specweave init . --force` (deletes all without backup)
93
+ **6. Completion**: `/specweave:done 0043` (validates), NEVER manual `metadata.json` edit
290
94
 
291
95
  ---
292
96
 
293
- ### 6. Increment Completion
294
-
295
- **Always use**: `/specweave:done 0043` (validates ACs, tasks, tests, coverage)
97
+ ## 7. Source of Truth: tasks.md + spec.md (CRITICAL!)
296
98
 
297
- **Never**: Manual `metadata.json` edit (blocked by pre-commit hook)
298
-
299
- ---
99
+ **Internal TODO is ephemeral. tasks.md + spec.md are SOURCE OF TRUTH.**
300
100
 
301
- ### 7. Source of Truth: tasks.md + spec.md (CRITICAL!)
302
-
303
- **THE MOST CRITICAL RULE**: Internal TODO is ephemeral. **tasks.md + spec.md are SOURCE OF TRUTH.**
304
-
305
- **MANDATORY workflow:**
101
+ **MANDATORY workflow**:
306
102
  ```typescript
307
- // 1. Complete work
308
- await createIntegrationTest();
309
-
310
- // 2. Update internal TODO
103
+ // 1. Complete work → 2. TodoWrite → 3. IMMEDIATELY Edit tasks.md → 4. IMMEDIATELY Edit spec.md
104
+ await work();
311
105
  TodoWrite([{task: "T-013", status: "completed"}]);
312
-
313
- // 3. IMMEDIATELY update tasks.md (NEVER skip!)
314
106
  Edit("tasks.md", "**Status**: [ ] pending", "**Status**: [x] completed");
315
-
316
- // 4. IMMEDIATELY update spec.md ACs
317
107
  Edit("spec.md", "- [ ] **AC-US1-01**", "- [x] **AC-US1-01**");
318
108
  ```
319
109
 
320
- **Status Line Sync (Automatic):**
321
- - TodoWrite `post-task-completion.sh` hook status line cache updates
322
- - **NEVER** edit tasks.md without TodoWrite (hook won't fire → desync)
323
- - Validation: `/specweave:validate-status`
110
+ **Status Line Sync**: TodoWrite → `post-task-completion.sh` → cache updates
111
+ **GitHub Duplicates**: Use `DuplicateDetector.createWithProtection()`, NEVER `--limit 1` in gh searches
112
+ **Validation**: `/specweave:validate-status`
324
113
 
325
- **GitHub Duplicate Prevention:**
326
- - **ALWAYS** use `DuplicateDetector.createWithProtection()` for GitHub issues
327
- - 3-phase: Detection → Verification → Reflection (auto-close duplicates)
328
- - **NEVER** use `--limit 1` in gh searches (hides duplicates, use `--limit 50`)
329
- - Cleanup: `bash scripts/cleanup-duplicate-github-issues.sh --dry-run`
330
-
331
- **Pre-closure validation:**
114
+ **Pre-closure check**:
332
115
  ```bash
333
- grep "^\*\*Status\*\*:" tasks.md | grep -c "\[x\] completed" # Must equal total_tasks
116
+ grep "^\*\*Status\*\*:" tasks.md | grep -c "\[x\] completed" # Must equal total
334
117
  grep -c "^- \[x\] \*\*AC-" spec.md # Must equal total ACs
335
- /specweave:done 0044
336
118
  ```
337
119
 
338
- **Incidents**:
339
- - 2025-11-19 (0044): Internal TODO "completed" while tasks.md showed `[ ] pending`
340
- - 2025-11-20: Status line 10% desync (tasks marked without TodoWrite)
341
- - 2025-11-20: 10+ duplicate GitHub issues (race conditions, --limit 1 bug)
342
-
343
120
  ---
344
121
 
345
- ### 7a. AC Presence in spec.md (MANDATORY - v0.24.0+) ⚠️
122
+ ### 7a. AC Presence in spec.md (MANDATORY)
346
123
 
347
- **CRITICAL RULE**: spec.md MUST contain inline Acceptance Criteria, even when using `structure: user-stories` with external living docs.
348
-
349
- **Why**: The AC sync hook (`post-task-completion.sh`) requires ACs in spec.md to function. Without inline ACs, you get 0% AC completion and broken status line.
350
-
351
- **Architecture** (ADR-0064):
352
- ```
353
- spec.md = SOURCE OF TRUTH for ACs
354
- living docs = DOCUMENTATION LAYER (optional, provides rich context)
355
- ```
356
-
357
- **Validation Gates**:
358
- 1. `/specweave:do` (pre-start hook) - **BLOCKS** if ACs missing
359
- 2. `/specweave:validate` - **ERRORS** if ACs missing
360
- 3. `/specweave:increment` - **AUTO-EMBEDS** ACs during creation
124
+ **spec.md MUST contain inline ACs** even with external living docs. AC sync hook requires them.
361
125
 
362
126
  **Required Format**:
363
127
  ```markdown
364
128
  ## Acceptance Criteria
365
-
366
129
  <!-- Auto-synced from living docs -->
367
-
368
- ### US-001: User Story Title
369
-
370
- - [ ] **AC-US1-01**: Criterion description
371
- - [ ] **AC-US1-02**: Criterion description
372
- ```
373
-
374
- **If ACs are missing**:
375
- ```bash
376
- # Manual fix: Auto-embed ACs from living docs
377
- /specweave:embed-acs 0050
378
-
379
- # Or add ACs manually to spec.md
380
- Edit("spec.md", "...", "...\n\n## Acceptance Criteria\n\n...")
130
+ ### US-001: Title
131
+ - [ ] **AC-US1-01**: Description
381
132
  ```
382
133
 
383
- **Common mistake**: Generating "pointer-only" spec.md that just references living docs without embedding ACs.
384
-
385
- **Incident** (2025-11-22, Increment 0050):
386
- - spec.md had 0 inline ACs (only references to living docs)
387
- - tasks.md referenced 39 ACs (AC-US1-01, AC-US4-01, etc.)
388
- - AC sync hook failed: 38 warnings, 0% completion
389
- - Fix: `/specweave:embed-acs 0050` → auto-embedded 39 ACs → 100% completion
390
-
391
- **Prevention**:
392
- - Pre-start hook validates AC presence before allowing work to start
393
- - Spec generators auto-embed ACs when `structure: user-stories` is used
394
- - Validation command checks AC count matches metadata.json
395
-
396
- **See**: ADR-0064, `src/utils/ac-embedder.ts`, `src/core/validators/ac-presence-validator.ts`
134
+ **If missing**: `/specweave:embed-acs 0050` (auto-embeds from living docs)
135
+ **Validation**: `/specweave:do` blocks if ACs missing
397
136
 
398
137
  ---
399
138
 
400
- ### 7b. AC Sync Parser - Task Status Format (CRITICAL - v0.25.2+) 🔥
401
-
402
- **CRITICAL BUG FIXED 2025-11-24**: AC sync hook was only detecting list format checkboxes, missing field format entirely!
139
+ ### 7b. AC Sync Parser (v0.25.2)
403
140
 
404
- **The Bug**: Parser in `ac-status-manager.ts` only looked for `- [x]` list items, completely missing `**Status**: [x] completed` field format introduced in v0.23.0. This caused ALL 70 ACs in increment 0053 to show false "0% tasks complete" even though tasks.md showed 37/37 completed!
405
-
406
- **Impact**:
407
- - ❌ Data integrity violation (metadata.json polluted with false conflicts)
408
- - ❌ Violated Source of Truth principle (tasks.md said "done", hook said "0%")
409
- - ❌ Potential for closing increments with incomplete work (hook gave false positives)
410
-
411
- **Root Cause** (before fix):
412
- ```typescript
413
- // ac-status-manager.ts:137 (BROKEN - only detected list format!)
414
- if (currentTaskId && line.includes('- [')) { // ❌ MISSED FIELD FORMAT!
415
- if (line.includes('- [ ]')) {
416
- hasUncheckedBoxes = true;
417
- } else if (line.includes('- [x]')) {
418
- hasCheckedBoxes = true;
419
- }
420
- }
421
- ```
422
-
423
- **The Fix** (v0.25.2):
424
- ```typescript
425
- // Now supports BOTH formats!
426
- if (currentTaskId) {
427
- // 1. List format: - [x] or - [ ]
428
- if (line.includes('- [')) {
429
- if (line.includes('- [ ]')) {
430
- hasUncheckedBoxes = true;
431
- } else if (line.includes('- [x]')) {
432
- hasCheckedBoxes = true;
433
- }
434
- }
435
- // 2. Field format: **Status**: [x] completed (NEW!)
436
- else if (line.match(/\*\*Status\*\*:\s*\[x\]/i)) {
437
- hasCheckedBoxes = true;
438
- }
439
- // 3. Field format: **Status**: [ ] pending (NEW!)
440
- else if (line.match(/\*\*Status\*\*:\s*\[\s\]/i)) {
441
- hasUncheckedBoxes = true;
442
- }
443
- }
444
- ```
445
-
446
- **Supported Task Formats** (both work now):
447
-
448
- **Format 1: List items** (legacy, still supported):
449
- ```markdown
450
- ### T-001: Task Title
451
- **Satisfies ACs**: AC-US1-01
452
- - [x] Completed
453
- - [x] Done
454
- ```
455
-
456
- **Format 2: Field format** (v0.23.0+, NOW WORKS!):
457
- ```markdown
458
- ### T-001: Task Title
459
- **User Story**: US-001
460
- **Satisfies ACs**: AC-US1-01
461
- **Priority**: P1
462
- **Status**: [x] completed ← THIS NOW WORKS!
463
- ```
464
-
465
- **Validation** (ensure fix is present):
466
- ```bash
467
- # Check parser supports field format
468
- grep -A 5 "Check for field format" src/core/increment/ac-status-manager.ts
469
-
470
- # Should see: line.match(/\*\*Status\*\*:\s*\[x\]/i)
471
- ```
472
-
473
- **Regression Tests** (5 new tests added):
474
- ```bash
475
- npm test -- ac-status-manager.test.ts -t "Task status field format"
476
-
477
- # Tests:
478
- # 1. Field format detection (completed)
479
- # 2. Field format detection (incomplete)
480
- # 3. Mixed format support (field + list)
481
- # 4. Case-insensitive matching
482
- # 5. Real-world increment 0053 format
483
- ```
484
-
485
- **Incident** (2025-11-24, Increment 0053):
486
- - All 70 ACs showed "AC-USXX-YY: [x] but only 0/1 tasks complete (0%)"
487
- - tasks.md clearly showed 37/37 tasks with `**Status**: [x] completed`
488
- - Hook logged 280 conflict messages (4 acSyncEvents × 70 conflicts each)
489
- - Fix: Updated parser → rebuilt → verified 0 conflicts
490
-
491
- **Prevention**:
492
- - ✅ 5 comprehensive regression tests (tests/unit/ac-status-manager.test.ts:855-1051)
493
- - ✅ Tests include real-world increment 0053 format
494
- - ✅ CI/CD runs all 43 AC status manager tests on every commit
495
- - ✅ Emergency recovery guide: `.specweave/docs/internal/emergency-procedures/AC-SYNC-CONFLICT-FIX-2025-11-24.md`
496
-
497
- **CRITICAL**: When introducing new task formats, ALWAYS update ALL parsers and add regression tests!
498
-
499
- **See**: Emergency fix report (AC-SYNC-CONFLICT-FIX-2025-11-24.md), increment 0053 metadata.json (acSyncEvents)
141
+ **Both formats supported**: `- [x] Done` (legacy list) OR `**Status**: [x] completed` (field format)
500
142
 
501
143
  ---
502
144
 
503
- ### 8. Logger Abstraction (NEVER `console.*`)
145
+ ## 8. Logger Abstraction
504
146
 
505
- **Rule**: ALL `src/` code uses logger injection, NEVER `console.log/error/warn`
147
+ **Rule**: ALL `src/` code uses logger injection, NEVER `console.*`
506
148
 
507
149
  ```typescript
508
150
  import { Logger, consoleLogger } from '../../utils/logger.js';
509
-
510
- export class MyClass {
511
- constructor(options: { logger?: Logger } = {}) {
512
- this.logger = options.logger ?? consoleLogger;
513
- }
151
+ constructor(options: { logger?: Logger } = {}) {
152
+ this.logger = options.logger ?? consoleLogger;
514
153
  }
515
- // In tests: new MyClass({ logger: silentLogger });
516
154
  ```
517
155
 
518
- **Exception - CLI Commands**: `src/cli/commands/*.ts` may use `console.*` with comment:
519
- ```typescript
520
- // NOTE: This CLI command is primarily user-facing output (console.log/console.error).
521
- // All console.* calls are legitimate user-facing exceptions as defined in CONTRIBUTING.md.
522
- ```
156
+ **Exception**: `src/cli/commands/*.ts` may use `console.*` with comment explaining it's user-facing output
523
157
 
524
158
  ---
525
159
 
526
- ### 8a. Native fs (NEVER `fs-extra`)
160
+ ### 8a. Native fs
527
161
 
528
- **Rule**: Use native Node.js `fs`, NEVER `fs-extra`
162
+ **Use native Node.js `fs`, NEVER `fs-extra`**
529
163
 
530
164
  ```typescript
531
- // ✅ CORRECT - Native fs
165
+ // ✅ CORRECT
532
166
  import { existsSync, readFileSync } from 'fs';
533
167
  import { promises as fs } from 'fs';
534
168
  import { mkdirpSync, writeJsonSync } from '../utils/fs-native.js';
535
-
536
- // ❌ WRONG: import fs from 'fs-extra';
537
169
  ```
538
170
 
539
- **Migration**: `fs.existsSync → existsSync`, `fs.ensureDir → fs.mkdir(dir, {recursive: true})`, `fs.removeSync → removeSync`
540
-
541
- **Prevention**: Pre-commit hook blocks fs-extra imports (bypass: `// legacy fs-extra`)
542
-
543
171
  ---
544
172
 
545
- ### 9. Coding Standards
173
+ ## 9. Coding Standards
546
174
 
547
175
  **Critical rules (enforced)**:
548
- 1. NEVER `console.*` (use logger)
549
- 2. ALWAYS `.js` extensions in imports
550
- 3. Test files: `.test.ts` (NEVER `.spec.ts`)
176
+ 1. NEVER `console.*` (use logger)
177
+ 2. ALWAYS `.js` extensions in imports
178
+ 3. Test files: `.test.ts` (NEVER `.spec.ts`)
551
179
  4. Avoid `any` type
552
180
  5. Functions < 100 lines
553
181
  6. Custom error types
@@ -560,149 +188,44 @@ import { mkdirpSync, writeJsonSync } from '../utils/fs-native.js';
560
188
 
561
189
  ---
562
190
 
563
- ### 10. GitHub Issue Format (v0.24.0+)
564
-
565
- **CRITICAL**: GitHub issues are ONLY created for User Stories, NEVER for Features!
191
+ ## 10. GitHub Issue Format
566
192
 
567
193
  **ONLY Correct Format**: `[FS-XXX][US-YYY] User Story Title`
568
194
 
569
- **PROHIBITED Formats** (Pre-commit hook blocks these):
570
- ```
571
- ❌ [SP-US-XXX] ... (Deprecated SP- prefix, removed v0.24.0)
572
- ❌ [SP-FS-XXX] ... (Deprecated SP- prefix, removed v0.24.0)
573
- ❌ [SP-FS-XXX-specweave] ... (SP prefix + project suffix, DEPRECATED!)
574
- ❌ [FS-048] ... (Feature-only - USE MILESTONE, NOT ISSUE!)
575
- ❌ [FS-048-specweave] ... (Project suffix - README.md ONLY, NOT GitHub!)
576
- ❌ [undefined][US-XXX] ... (Missing Feature ID - validation error!)
577
- ```
578
-
579
- **ONLY CORRECT Examples**:
580
- ```
581
- ✅ [FS-048][US-001] Smart Pagination During Init
582
- ✅ [FS-048][US-002] CLI-First Defaults
583
- ✅ [FS-033][US-015] Task Completion Tracking
584
- ```
585
-
586
- **Architecture** (ADR-0032 Universal Hierarchy Mapping):
587
- ```
588
- Feature FS-048 → GitHub Milestone "FS-048: Feature Title"
589
- ├─ User Story US-001 → Issue #XXX: [FS-048][US-001] US Title
590
- ├─ User Story US-002 → Issue #YYY: [FS-048][US-002] US Title
591
- └─ User Story US-003 → Issue #ZZZ: [FS-048][US-003] US Title
592
- ```
593
-
594
- **Create issues**:
595
- ```bash
596
- # ✅ CORRECT: Creates User Story issues
597
- /specweave-github:sync FS-048
598
-
599
- # ❌ WRONG: /specweave:increment does NOT create GitHub issues
600
- ```
601
-
602
- **Enforcement**:
603
- - **Pre-commit hook**: Blocks code commits with prohibited formats
604
- - **UserStoryIssueBuilder**: Runtime validation throws error if featureId invalid
605
- - **Pattern matching**: Final safety check before issue creation
606
- - **Manual review**: Close any wrong-format issues immediately
195
+ **PROHIBITED**: `[SP-*]`, `[FS-XXX]` alone, `[undefined][US-XXX]`, project suffixes
607
196
 
608
- **If you see wrong-format issues** (e.g., `[SP-US-XXX]`, `[SP-FS-XXX]`, or `[FS-XXX]` alone):
609
- 1. **Close immediately** with comment: "WRONG FORMAT: Violates ADR-0032. Use [FS-XXX][US-YYY] format."
610
- 2. Delete any duplicate Feature folders (e.g., FS-050 when FS-048 exists)
611
- 3. Use `/specweave-github:sync FS-XXX` to create correct User Story issues
612
- 4. **REPORT THE BUG** - this should never happen with validation!
197
+ **Architecture**: Feature Milestone, User Stories Issues
613
198
 
614
- **See**:
615
- - `.specweave/increments/0047-us-task-linkage/reports/FEATURE-LEVEL-GITHUB-SYNC-REMOVAL-PLAN.md`
616
- - `.specweave/increments/0050-*/reports/GITHUB-ISSUE-BUG-ANALYSIS-2025-11-22.md`
617
- - `.specweave/increments/0050-*/reports/SP-PREFIX-BUG-ROOT-CAUSE-2025-11-22.md`
618
-
619
- ---
620
-
621
- ### 10a. NO Increment-to-Increment References (ADR-0061) ⛔
622
-
623
- **CRITICAL ARCHITECTURAL RULE**: Increments NEVER reference other increments!
624
-
625
- **The Only Allowed Flow**:
626
- ```
627
- INCREMENT (metadata.json: feature_id) → FEATURE → USER STORIES
628
- ```
199
+ **Create**: `/specweave-github:sync FS-048`
629
200
 
630
- **❌ FORBIDDEN**:
631
- ```yaml
632
- # In user story frontmatter
633
- ---
634
- id: US-001
635
- feature: FS-048
636
- increments: [0050-external-tool-import] # ❌ NEVER DO THIS!
637
- ---
638
- ```
639
-
640
- ```markdown
641
- # In user story content
642
- Implemented in increment 0050-external-tool-import ❌ NEVER DO THIS!
643
- ```
644
-
645
- **✅ CORRECT**:
646
- ```yaml
647
- # Increment metadata.json
648
- {
649
- "feature_id": "FS-048" ✅ Forward reference only
650
- }
651
-
652
- # User story frontmatter
653
- ---
654
- id: US-001
655
- feature: FS-048 ✅ No increment reference needed!
656
201
  ---
657
- ```
658
-
659
- **Why This Matters**:
660
-
661
- 1. **Hooks Break Without This**: The GitHub sync hook reads increment metadata → finds feature_id → finds all user stories for that feature → creates GitHub issues. If user stories required increment references, this creates circular dependencies and hooks detect 0 specs.
662
-
663
- 2. **Clean Separation**: Living docs (user stories) are permanent. Increments are temporary implementations. User stories should never know about increments.
664
202
 
665
- 3. **Multi-Increment Support**: Multiple increments can implement the same feature (Phase 1a, 1b, 1c). Each auto-syncs ALL user stories without duplication.
203
+ ### 10a. NO Increment-to-Increment References (ADR-0061)
666
204
 
667
- **Enforcement**:
668
- - Pre-commit hook validates NO increment references in living docs
669
- - Spec-detector ignores reverse references (defensive)
670
- - **See**: ADR-0061 for complete architectural rationale
205
+ **FORBIDDEN**: User stories referencing increments (`increments: [0050-...]`)
206
+ **ONLY ALLOWED**: `INCREMENT FEATURE USER STORIES` (forward reference only)
671
207
 
672
- **Incident**: 2025-11-22 - Hooks appeared broken (0 specs detected, 0 GitHub issues created) due to old spec-detector logic requiring reverse references. Fixed in v0.24.0+.
208
+ **Why**: Hooks break, circular dependencies, multi-increment support broken
673
209
 
674
210
  ---
675
211
 
676
- ### 11. Task Format with US Linkage (v0.23.0+)
212
+ ## 11. Task Format with US Linkage
677
213
 
678
- **Required fields**:
679
214
  ```markdown
680
215
  ### T-001: Task Title
681
- **User Story**: US-001 ← MANDATORY
682
- **Satisfies ACs**: AC-US1-01, AC-US1-02 ← MANDATORY
216
+ **User Story**: US-001 ← MANDATORY
217
+ **Satisfies ACs**: AC-US1-01 ← MANDATORY
683
218
  **Status**: [x] completed
684
219
  ```
685
220
 
686
- **Why**: Traceability (Task ↔ User Story ↔ AC ↔ Feature), Living docs auto-sync, AC coverage validation
687
-
688
- **Validation**: Tasks without linkage → warnings, orphan tasks → `/specweave:done` blocks closure
689
-
690
221
  ---
691
222
 
692
- ### 12. ADR Naming Convention
693
-
694
- **Correct format**: `XXXX-decision-title.md` (4-digit, kebab-case, NO `adr-` prefix)
223
+ ## 12. ADR Naming
695
224
 
225
+ **Format**: `XXXX-decision-title.md` (4-digit, kebab-case, NO `adr-` prefix)
696
226
  **Header**: `# ADR-XXXX: Decision Title`
697
-
698
227
  **Location**: `.specweave/docs/internal/architecture/adr/`
699
228
 
700
- ```
701
- ✅ Filename: 0007-github-first-task-sync.md, Header: # ADR-0007: ...
702
- ❌ adr-0007-github-first-task-sync.md (redundant adr- prefix)
703
- ❌ 007-github-first-task-sync.md (3-digit)
704
- ```
705
-
706
229
  **Auto-numbering**:
707
230
  ```bash
708
231
  ls .specweave/docs/internal/architecture/adr/*.md | grep -E '/[0-9]{4}-' | \
@@ -712,513 +235,93 @@ ls .specweave/docs/internal/architecture/adr/*.md | grep -E '/[0-9]{4}-' | \
712
235
 
713
236
  ---
714
237
 
715
- ### 13. Structured Data Matching
238
+ ## 13. Structured Data Matching
716
239
 
717
240
  **NEVER use string search for frontmatter/IDs**:
718
241
 
719
242
  ```typescript
720
- // ❌ WRONG: Matches ANYWHERE (false positives!)
721
- content.includes('FS-039') // Matches "See FS-039" in docs!
722
-
723
- // ✅ CORRECT: Parse frontmatter explicitly
724
- const match = content.match(/^feature_id:\s*["']?([^"'\n]+)["']?$/m);
725
- if (match && match[1].trim() === 'FS-039') { /* ... */ }
726
-
727
- // ❌ WRONG: Substring matching
728
- archivedList.some(item => item.includes(searchId))
729
-
730
- // ✅ CORRECT: Exact equality
731
- archivedList.some(item => item === searchId)
243
+ // ❌ WRONG: content.includes('FS-039') // Matches "See FS-039"!
244
+ // ✅ CORRECT: const match = content.match(/^feature_id:\s*["']?([^"'\n]+)["']?$/m);
732
245
  ```
733
246
 
734
- **Incident**: 2025-11-20 - 11 features incorrectly archived (string search false positives)
735
-
736
247
  ---
737
248
 
738
- ### 14. Marketplace Plugin Completeness
739
-
740
- **NEVER add incomplete plugins to marketplace.json**
249
+ ## 14. Marketplace Plugin Completeness
741
250
 
742
251
  **Complete plugin requires**: `agents/`, `commands/`, OR `lib/` (not just `.claude-plugin/` + `skills/`)
743
252
 
744
- **MANDATORY validation**:
745
- ```bash
746
- bash scripts/validate-marketplace-plugins.sh # Must see "✅ VALIDATION PASSED!"
747
- ```
748
-
749
- **Adding new plugin**:
750
- 1. Create with agents/commands/lib (NOT empty dirs!)
751
- 2. Add to marketplace.json
752
- 3. **VALIDATE** (critical!)
753
- 4. Update `bin/fix-marketplace-errors.sh`
754
- 5. Test: `npm pack && npm i -g ./specweave-*.tgz`
755
-
756
- **Incident**: 2025-11-20 - 8 incomplete plugins failed loading on global install
253
+ **MANDATORY**: `bash scripts/validate-marketplace-plugins.sh`
757
254
 
758
255
  ---
759
256
 
760
- ### 15. Skills vs Agents
761
-
762
- **Key Differences**:
257
+ ## 15. Skills vs Agents
763
258
 
764
259
  | Aspect | Skills | Agents |
765
260
  |--------|--------|--------|
766
261
  | **Location** | `plugins/*/skills/name/SKILL.md` | `plugins/*/agents/name/AGENT.md` |
767
262
  | **Invocation** | `Skill()` or `/command` | `Task()` with `subagent_type` |
768
- | **Activation** | Automatic (keywords) | Explicit call |
769
- | **File** | `SKILL.md` (YAML frontmatter) | `AGENT.md` |
263
+ | **Activation** | Automatic (keywords) | Explicit |
770
264
 
771
265
  **Agent naming**: `{plugin}:{directory}:{yaml-name}`
772
266
 
773
- ```typescript
774
- // ✅ CORRECT: Skill
775
- Skill({ skill: "increment-quality-judge-v2" }); // or /specweave:qa
776
-
777
- // ✅ CORRECT: Agent
778
- Task({ subagent_type: "specweave:qa-lead:qa-lead", prompt: "..." });
779
-
780
- // ❌ WRONG: Skill as agent
781
- Task({ subagent_type: "specweave:increment-quality-judge-v2" }); // ERROR!
782
- ```
783
-
784
- **Validation**: `bash scripts/validate-plugin-directories.sh --fix`
785
-
786
- **Incident**: 2025-11-20 - Empty agent directory caused "Agent not found" error
787
-
788
267
  ---
789
268
 
790
- ### 16. YAML Frontmatter Validation
269
+ ## 16. YAML Frontmatter
791
270
 
792
- **Required format**:
271
+ **Required**:
793
272
  ```yaml
794
273
  ---
795
274
  increment: 0001-feature-name # REQUIRED: 4-digit + kebab-case
796
- title: Feature Title # OPTIONAL
797
275
  feature_id: FS-001 # OPTIONAL
798
276
  ---
799
277
  ```
800
278
 
801
- **Common mistakes**: Unclosed brackets/quotes, invalid objects, missing `increment`, uppercase in ID
802
-
803
- **Validation layers**:
804
- 1. Pre-commit hook: `scripts/pre-commit-yaml-validation.sh`
805
- 2. Spec parser (uses `js-yaml`, provides line numbers)
806
- 3. `/specweave:validate 0001`
807
-
808
- **Manual test**:
809
- ```bash
810
- node -e "const yaml = require('js-yaml'); const fs = require('fs'); \
811
- const content = fs.readFileSync('.specweave/increments/0001-test/spec.md', 'utf-8'); \
812
- const fm = content.match(/^---\n([\s\S]*?)\n---/); \
813
- console.log('✅ Valid:', JSON.stringify(yaml.load(fm[1]), null, 2));"
814
- ```
279
+ **Validation**: Pre-commit hook, spec parser, `/specweave:validate 0001`
815
280
 
816
281
  ---
817
282
 
818
- ## 17. Git Provider Abstraction (v0.24.0+)
819
-
820
- **Architecture**: Interface-driven multi-platform support with registry pattern
821
-
822
- **Key files**:
823
- - `src/core/repo-structure/git-provider.ts` - Interface definition
824
- - `src/core/repo-structure/platform-registry.ts` - Singleton registry
825
- - `src/core/repo-structure/providers/` - Platform implementations
283
+ ## 17. Git Provider Abstraction
826
284
 
827
- **Provider Interface**:
828
- ```typescript
829
- export interface GitProvider {
830
- readonly config: GitProviderConfig;
831
-
832
- validateRepository(owner: string, repo: string, token?: string): Promise<ValidationResult>;
833
- validateOwner(owner: string, token?: string): Promise<OwnerValidationResult>;
834
- createRepository(params: CreateRepoParams, token: string): Promise<string>;
835
- isOrganization(owner: string, token?: string): Promise<boolean>;
285
+ **Interface-driven multi-platform support**:
286
+ - GitHub, GitLab, Bitbucket, Azure DevOps, Local Git
836
287
 
837
- getRemoteUrl(owner: string, repo: string, urlType: 'ssh' | 'https'): string;
838
- getTokenUrl(): string;
839
- getRequiredScopes(isOrg: boolean): string[];
840
- }
841
- ```
842
-
843
- **Usage pattern**:
288
+ **Usage**:
844
289
  ```typescript
845
- import { initializeProviders } from './providers/index.js';
846
290
  import { getPlatformRegistry } from './platform-registry.js';
847
-
848
- // Initialize providers (call once during startup)
849
- initializeProviders();
850
-
851
- // Get provider for user-selected platform
852
- const registry = getPlatformRegistry();
853
- const provider = registry.getProvider('github'); // or 'gitlab', 'bitbucket'
854
-
855
- // Use provider methods (platform-agnostic code)
291
+ const provider = registry.getProvider('github');
856
292
  const result = await provider.validateRepository('owner', 'repo', token);
857
- const url = provider.getRemoteUrl('owner', 'repo', 'ssh');
858
- await provider.createRepository({ owner, name, description, visibility }, token);
859
- ```
860
-
861
- **Platform Support**:
862
- - ✅ GitHub (fully supported): `github-provider.ts`
863
- - ✅ GitLab (fully supported): `gitlab-provider.ts`
864
- - ✅ Bitbucket (fully supported): `bitbucket-provider.ts`
865
- - ✅ Azure DevOps (fully supported): `azure-devops-provider.ts`
866
- - ✅ Local Git (fully supported): `local-provider.ts`
867
-
868
- **Adding new platform**:
869
- 1. Create `src/core/repo-structure/providers/{platform}-provider.ts`
870
- 2. Implement `GitProvider` interface
871
- 3. Register in `providers/index.ts`: `registry.registerProvider('platform', provider)`
872
- 4. Update platform registry metadata: `registry.registerPlatform({ type, name, description, supported })`
873
-
874
- **NEVER**:
875
- - ❌ Hardcode platform names (use `provider.config.name`)
876
- - ❌ Hardcode API endpoints (use `provider.config.apiBaseUrl`)
877
- - ❌ Hardcode Git hosts (use `provider.config.host`)
878
- - ❌ Use GitHub-specific methods (use provider interface)
879
-
880
- **See**: ADR-0069 (Git Provider Abstraction Layer)
881
-
882
- ---
883
-
884
- ## Project Structure
885
-
886
- ```
887
- src/ # TypeScript (compiled to dist/)
888
- plugins/ # Skills, agents, commands, hooks
889
- ├── specweave/ # Core plugin
890
- └── specweave-*/ # Optional plugins
891
- .specweave/ # Increments, docs, logs
892
- ```
893
-
894
- **Rules**: `src/` = TS only, ALL components = `plugins/`, NEVER mix `.ts` + `SKILL.md`, NEVER root files
895
-
896
- ---
897
-
898
- ## Plugin Hook Registration
899
-
900
- **Valid hook events** (10 total): `PostToolUse`, `PreToolUse`, `PermissionRequest`, `Notification`, `UserPromptSubmit`, `Stop`, `SubagentStop`, `PreCompact`, `SessionStart`, `SessionEnd`
901
-
902
- **Format** (`plugins/*/.claude-plugin/plugin.json`):
903
- ```json
904
- {
905
- "hooks": {
906
- "PostToolUse": [
907
- {
908
- "matcher": "TodoWrite",
909
- "hooks": [{
910
- "type": "command",
911
- "command": "${CLAUDE_PLUGIN_ROOT}/hooks/post-task-completion.sh",
912
- "timeout": 10
913
- }]
914
- }
915
- ]
916
- }
917
- }
918
293
  ```
919
294
 
920
- **❌ WRONG**: `"TodoWrite": {...}` (invalid event)
921
- **✅ CORRECT**: `"PostToolUse"` with `"matcher": "TodoWrite"`
295
+ **NEVER**: Hardcode platform names, API endpoints, Git hosts
922
296
 
923
297
  ---
924
298
 
925
- ## 9a. Hook Performance & Safety (CRITICAL - v0.25.0)
299
+ ### 17a. GitHub Multi-Repo Init Flow (v0.26.3 - ADR-0132)
926
300
 
927
- **Critical incidents**:
928
- - 2025-11-22 - Multiple Claude Code crashes due to hook overhead
929
- - 2025-11-23 - Hook process storm (6 hooks per Edit/Write → 300 processes/min)
930
- - 2025-11-24 (AM) - PROJECT_ROOT order bug (recursion guard at wrong path → crashes)
931
- - **2025-11-24 (PM) - TodoWrite crash: US sync triggers unguarded external tool cascade → infinite recursion** ⚠️
932
-
933
- **Root cause**:
934
- - **Original**: Process exhaustion from spawning 6 bash processes per Edit/Write operation
935
- - **NEW (v0.25.1)**: US completion orchestrator triggers `livingDocsSync.syncIncrement()` which calls `syncToExternalTools()` without checking `SKIP_GITHUB_SYNC` → Edit/Write operations → new hook chains → infinite recursion → crash
936
-
937
- **LONG-TERM FIX (v0.25.0)**: Hook Consolidation
938
- - **Reduced from 6 → 4 hooks per Edit/Write** (33% reduction)
939
- - **Consolidated hooks**:
940
- - `pre-edit-write-consolidated.sh` (replaces pre-edit-spec + pre-write-spec)
941
- - `post-edit-write-consolidated.sh` (replaces post-edit-spec + post-write-spec)
942
- - `post-metadata-change.sh` (enhanced with ultra-fast early exit)
943
- - **Performance**: 50% reduction in hook overhead
944
- - **See**: ADR-0070 (Hook Consolidation)
945
-
946
- **Emergency fixes implemented (v0.24.3)**:
947
-
948
- ### 1. Emergency Kill Switch
949
- ```bash
950
- # INSTANT disable of ALL hooks
951
- export SPECWEAVE_DISABLE_HOOKS=1
952
- ```
953
-
954
- ### 2. Circuit Breaker (Auto-Protection)
955
- - **Threshold**: 3 consecutive failures → auto-disable hooks
956
- - **File**: `.specweave/state/.hook-circuit-breaker`
957
- - **Recovery**: `rm .specweave/state/.hook-circuit-breaker`
958
-
959
- ### 3. File Locking (Prevents Concurrent Execution)
960
- - **Max instances**: 1 per hook type
961
- - **Timeout**: 5-10 seconds with stale lock cleanup
962
- - **Mechanism**: Directory-based mutex
963
-
964
- ### 4. Aggressive Debouncing
965
- - **Window**: 5 seconds (increased from 1s)
966
- - **Effect**: Batches rapid operations
967
- - **Trade-off**: 5s staleness acceptable for UX
968
-
969
- ### 5. Complete Error Isolation
970
- ```bash
971
- set +e # NEVER use set -e in hooks
972
- exit 0 # ALWAYS exit 0, never block workflow
973
- ```
974
-
975
- ### 6. Consolidated Background Work
976
- - **Before**: 6+ Node.js spawns per task (exhaustion!)
977
- - **After**: 1 consolidated background job
978
- - **Reduction**: 85% fewer processes
979
-
980
- ### Hook Safety Checklist (MANDATORY)
981
-
982
- **✅ EVERY hook MUST have**:
983
- 1. `PROJECT_ROOT` defined BEFORE any path variables (CRITICAL - v0.26.1)
984
- 2. Kill switch check (`SPECWEAVE_DISABLE_HOOKS`)
985
- 3. Circuit breaker check (3 failure threshold)
986
- 4. File locking (prevent concurrent runs)
987
- 5. Debouncing (5s minimum)
988
- 6. Error isolation (`set +e`, `exit 0`)
989
- 7. Background work wrapped in subshell
990
- 8. Circuit breaker updates on success/failure
991
-
992
- **❌ NEVER in hooks**:
993
- - `set -e` (causes crashes)
994
- - Synchronous Node.js spawns
995
- - Multiple separate background jobs
996
- - Error propagation to Claude Code
997
- - Missing `exit 0` at end
998
-
999
- ### Performance Targets
1000
-
1001
- | Metric | Target | Warning | Critical |
1002
- |--------|--------|---------|----------|
1003
- | Hook execution | <100ms | 100-500ms | >500ms |
1004
- | Background processes | 0-2 | 3-5 | 6+ |
1005
- | Circuit breaker count | 0 | 1-2 | 3 (open) |
1006
-
1007
- ### Emergency Recovery
1008
-
1009
- **If Claude Code crashes**:
1010
- ```bash
1011
- # 1. Immediate kill switch
1012
- export SPECWEAVE_DISABLE_HOOKS=1
301
+ **Rule**: NEVER early returns in routing code. Use mapping.
1013
302
 
1014
- # 2. Reset circuit breaker
1015
- rm -f .specweave/state/.hook-circuit-breaker
1016
-
1017
- # 3. Clear locks
1018
- rm -rf .specweave/state/.hook-*.lock
1019
-
1020
- # 4. Rebuild
1021
- npm run rebuild
1022
- ```
1023
-
1024
- **See**:
1025
- - `.specweave/docs/internal/emergency-procedures/HOOK-CRASH-RECOVERY.md` (Complete recovery guide)
1026
- - ADR-0060 (Three-tier optimization architecture)
1027
- - `.specweave/increments/0050-*/reports/hook-crash-analysis.md` (Incident analysis)
1028
-
1029
- ### Active Increment Filtering (v0.24.4 - ARCHITECTURAL FIX)
1030
-
1031
- **Critical architectural change**: Hooks now **ONLY** process active increments.
1032
-
1033
- **Problem**: The old logic used `ls -td` (time-based) which:
1034
- - Processed 50+ increments on every TodoWrite
1035
- - Could pick completed increments if recently modified
1036
- - Caused infinite loops when hitting bad AC data
1037
- - Wasted 90%+ of hook overhead on completed work
1038
-
1039
- **Solution**: State-based filtering (`.specweave/state/active-increment.json`)
1040
-
1041
- ```bash
1042
- # NEW: Read active increments from state file
1043
- mapfile -t ACTIVE_INCREMENTS < <(jq -r '.ids[]' "$ACTIVE_STATE_FILE")
1044
-
1045
- # Process ONLY active increments
1046
- for CURRENT_INCREMENT in "${ACTIVE_INCREMENTS[@]}"; do
1047
- # Safety: Skip if completed/abandoned/archived
1048
- if [[ "$STATUS" == "completed" ]] || [[ "$STATUS" == "abandoned" ]]; then
1049
- continue
1050
- fi
1051
-
1052
- # Process (tasks.md, AC sync, living docs, etc.)
1053
- done
1054
- ```
1055
-
1056
- **Impact**:
1057
- - ✅ 95% reduction in hook overhead (50+ → 1-2 increments)
1058
- - ✅ Zero risk of infinite loops (completed increments never touched)
1059
- - ✅ Clean architecture (source of truth: state file)
1060
- - ✅ Multi-increment support (processes array)
1061
-
1062
- **Fail-safe defaults**:
1063
- - No state file → skip all work
1064
- - Empty array → skip all work (normal when no active increments)
1065
- - Missing directory → skip increment
1066
- - Archived → skip increment
1067
- - Completed/abandoned status → skip increment
1068
-
1069
- **See**: `.specweave/increments/0050-*/reports/ARCHITECTURAL-FIX-ACTIVE-INCREMENT-FILTERING.md`
1070
-
1071
- ### Hook Variable Initialization Order (v0.26.1 - CRITICAL FIX)
1072
-
1073
- **CRITICAL BUG PATTERN**: Variables used in path construction MUST be defined BEFORE they're used!
1074
-
1075
- **Incident** (2025-11-24): Claude Code crashed 3x due to `PROJECT_ROOT` being used before definition in `post-task-completion.sh`.
1076
-
1077
- **The Bug**:
1078
- ```bash
1079
- # ❌ WRONG: Uses $PROJECT_ROOT before it's defined
1080
- RECURSION_GUARD_FILE="$PROJECT_ROOT/.specweave/state/.hook-recursion-guard" # Line 71
1081
- # ... 40 lines later ...
1082
- PROJECT_ROOT="$(find_project_root ...)" # Line 112 - TOO LATE!
1083
-
1084
- # Result: Guard file created at wrong path (/.specweave/state/...)
1085
- ```
1086
-
1087
- **What Happened**:
1088
- 1. Guard file created at **invalid path** (`/.specweave/state/.hook-recursion-guard`)
1089
- 2. Other hooks check guard at **correct path** (`/full/project/path/.specweave/state/...`)
1090
- 3. Guard not found → hooks don't exit early → **INFINITE RECURSION**
1091
- 4. PreToolUse hook fired 3x → Claude Code crashed
1092
-
1093
- **✅ CORRECT Pattern**:
1094
- ```bash
1095
- # 1. Define find_project_root() function FIRST (line 40)
1096
- find_project_root() { ... }
1097
-
1098
- # 2. Set PROJECT_ROOT IMMEDIATELY (line 50)
1099
- PROJECT_ROOT="$(find_project_root ...)"
1100
-
1101
- # 3. NOW use PROJECT_ROOT in paths (line 60+)
1102
- RECURSION_GUARD_FILE="$PROJECT_ROOT/.specweave/state/.hook-recursion-guard"
1103
- ```
1104
-
1105
- **Validation** (automated script):
1106
- ```bash
1107
- # Run the validation script (validates all hooks automatically)
1108
- bash scripts/validate-hook-variable-order.sh
1109
-
1110
- # Expected output: ✅ ALL HOOKS VALIDATED SUCCESSFULLY
1111
- # If fails: Script shows exactly which hooks have wrong variable order
1112
- ```
1113
-
1114
- **Enforcement** (✅ DONE - v0.26.1):
1115
- - ✅ Pre-commit hook added: runs `validate-hook-variable-order.sh` on every commit
1116
- - ✅ Regression tests added: `tests/unit/hooks/recursion-guard.test.ts` (29 tests)
1117
- - ✅ Validates all hooks with RECURSION_GUARD_FILE have correct variable order
1118
- - ✅ Blocks commits where `PROJECT_ROOT` is defined after `RECURSION_GUARD_FILE`
1119
-
1120
- **Manual validation**:
1121
- ```bash
1122
- # Check specific hook manually
1123
- hook="plugins/specweave/hooks/post-task-completion.sh"
1124
- guard_line=$(grep -n "^RECURSION_GUARD_FILE=" "$hook" | cut -d: -f1)
1125
- root_line=$(grep -n "^PROJECT_ROOT=" "$hook" | cut -d: -f1)
1126
- echo "PROJECT_ROOT: line $root_line"
1127
- echo "RECURSION_GUARD_FILE: line $guard_line"
1128
- # root_line MUST be < guard_line
303
+ ```typescript
304
+ // if (option === 'advanced') return { type: 'basic' };
305
+ // ✅ let mapped = undefined; if (option === 'advanced') mapped = 'enhanced';
1129
306
  ```
1130
307
 
1131
- **See**:
1132
- - `.specweave/increments/0051-*/reports/PROJECT-ROOT-ORDER-BUG-2025-11-24.md`
1133
- - `scripts/validate-hook-variable-order.sh` (validation script)
1134
- - `tests/unit/hooks/recursion-guard.test.ts` (regression tests)
1135
-
1136
308
  ---
1137
309
 
1138
- ### TodoWrite Crash (v0.25.1 - EMERGENCY FIX) ⚠️
1139
-
1140
- **CRITICAL BUG**: Marking tasks complete via TodoWrite crashes Claude Code due to unguarded external tool sync cascade.
1141
-
1142
- **Incident** (2025-11-24 PM): User reported Claude Code crash when marking tasks complete in increment 0053-safe-feature-deletion.
1143
-
1144
- **Root Cause**:
1145
- 1. US completion orchestrator (`us-completion-orchestrator.js`) detects all 6 USs as "newly complete" (perfect storm when last task marked)
1146
- 2. Calls `livingDocsSync.syncIncrement()` without checking `SKIP_US_SYNC` flag
1147
- 3. Living docs sync calls `syncToExternalTools()` without checking `SKIP_GITHUB_SYNC` flag
1148
- 4. External tool sync creates/updates GitHub issues (Edit/Write operations)
1149
- 5. Edit/Write hooks trigger NEW hook chains (recursion guard doesn't protect Edit/Write events)
1150
- 6. **Infinite recursion** → Process exhaustion → Claude Code crash
1151
-
1152
- **Crash Flow**:
1153
- ```
1154
- TodoWrite → post-task-completion.sh
1155
- → consolidated-sync.js (operation 5/6)
1156
- → us-completion-orchestrator.js
1157
- → livingDocsSync.syncIncrement()
1158
- → syncToExternalTools() ← NO GUARD!
1159
- → syncToGitHub()
1160
- → Edit/Write operations
1161
- → NEW HOOK CHAIN
1162
- → INFINITE RECURSION
1163
- → 💥 CRASH
1164
- ```
1165
-
1166
- **Emergency Hotfix** (v0.25.1 - ✅ DEPLOYED):
1167
- ```bash
1168
- # File: plugins/specweave/hooks/post-task-completion.sh (line 463)
1169
- export SKIP_US_SYNC=true
1170
- ```
1171
-
1172
- **Impact**:
1173
- - ✅ **NO MORE CRASHES**: TodoWrite is now safe
1174
- - ⚠️ **Manual sync required**: Must run `/specweave:sync-progress` after completing tasks
1175
- - ✅ **Living docs still work**: AC sync, tasks.md updates, status line all function
1176
-
1177
- **Verification**:
1178
- ```bash
1179
- # 1. Check hotfix applied
1180
- grep "SKIP_US_SYNC=true" plugins/specweave/hooks/post-task-completion.sh
1181
-
1182
- # 2. Test task completion
1183
- TodoWrite([{ content: "T-001", status: "completed" }])
1184
-
1185
- # 3. Verify no crash
1186
- tail -50 .specweave/logs/hooks-debug.log | grep "SKIP_US_SYNC"
1187
- # Expected: ℹ️ User story sync skipped (SKIP_US_SYNC=true)
1188
-
1189
- # 4. Manual sync when ready
1190
- /specweave:sync-progress 0053
1191
- ```
1192
-
1193
- **Long-Term Fix** (v0.26.0 - PLANNED):
1194
- - **Tier 1**: Add `SKIP_EXTERNAL_SYNC` check in `LivingDocsSync.syncIncrement()`
1195
- - **Tier 2**: Universal recursion guard (ALL hooks check same guard file)
1196
- - **Tier 3**: Smart throttling (60-second window for US sync)
1197
- - **Result**: Restore automatic US sync (now safe with guard rails!)
1198
-
1199
- **Recovery** (If crash occurs):
1200
- ```bash
1201
- # 1. Kill stuck processes
1202
- ps aux | grep -E "consolidated-sync|us-completion" | awk '{print $2}' | xargs kill -9
1203
-
1204
- # 2. Disable hooks
1205
- export SPECWEAVE_DISABLE_HOOKS=1
310
+ ## Hook Performance & Safety
1206
311
 
1207
- # 3. Clean locks
1208
- rm -rf .specweave/state/.hook-*.lock
1209
- rm -f .specweave/state/.hook-recursion-guard
312
+ **Emergency**: `export SPECWEAVE_DISABLE_HOOKS=1` → `rm -f .specweave/state/.hook-*` `npm run rebuild`
1210
313
 
1211
- # 4. Apply hotfix (see above)
1212
-
1213
- # 5. Re-enable hooks
1214
- unset SPECWEAVE_DISABLE_HOOKS
1215
- ```
314
+ **Mandatory Checklist**: PROJECT_ROOT first, kill switch, circuit breaker, file lock, debounce (5s), `set +e`, `exit 0`, active-only filtering
315
+ **Never**: `set -e`, sync spawns, error propagation
316
+ **Targets**: <100ms, 0-2 processes, 0 breaker trips
1216
317
 
1217
- **See**:
1218
- - `.specweave/increments/0053-safe-feature-deletion/reports/EXECUTIVE-SUMMARY-CRASH-FIX-2025-11-24.md` (Executive summary)
1219
- - `.specweave/increments/0053-safe-feature-deletion/reports/ROOT-CAUSE-ANALYSIS-TODOWRITE-CRASH-2025-11-24.md` (Detailed analysis)
1220
- - `.specweave/docs/internal/emergency-procedures/TODOWRITE-CRASH-RECOVERY.md` (Recovery guide)
1221
- - `.specweave/docs/internal/architecture/adr/0129-us-sync-guard-rails.md` (ADR-0129)
318
+ **Critical Fixes**:
319
+ - v0.26.1: **Automatic US sync restored!** `SKIP_US_SYNC` removed → Smart throttle (60s window) → fs.writeFile() validated safe
320
+ - v0.25.2: `SKIP_EXTERNAL_SYNC` guard at LivingDocsSync layer → prevents recursion cascade
321
+ - v0.25.1: TodoWrite crash → emergency `SKIP_US_SYNC=true` → manual `/specweave:sync-progress` (temporary fix)
322
+ - v0.25.0: 6→4 hooks (33% reduction)
323
+ - v0.24.4: State-based filtering (95% overhead reduction)
324
+ - v0.26.1: PROJECT_ROOT before RECURSION_GUARD_FILE (order bug fix)
1222
325
 
1223
326
  ---
1224
327
 
@@ -1233,470 +336,113 @@ unset SPECWEAVE_DISABLE_HOOKS
1233
336
  /specweave:done 0002 # Close (validates)
1234
337
  /specweave:validate 0001 # Validate
1235
338
  /specweave:qa 0001 # Quality check
1236
- /specweave:pause/resume/abandon # State management
1237
339
 
1238
340
  # Feature deletion
1239
- specweave delete-feature FS-042 --dry-run # Preview deletion
1240
- specweave delete-feature FS-042 # Safe deletion (requires confirmation)
1241
- specweave delete-feature FS-042 --force # Force delete (orphans active increments)
1242
- specweave delete-feature FS-042 --no-git # Skip git operations
1243
- specweave delete-feature FS-042 --no-github # Skip GitHub issue cleanup
1244
- specweave delete-feature FS-042 --yes # Skip confirmations (except elevated)
1245
- ```
1246
-
1247
- **Local setup**:
1248
- ```bash
1249
- git clone https://github.com/YOUR_USERNAME/specweave.git
1250
- cd specweave && npm install && npm run rebuild
1251
- bash scripts/install-git-hooks.sh
1252
-
1253
- # Push changes to GitHub → Claude Code auto-updates marketplace (5-10s)
1254
- # For fork-based testing: claude plugin marketplace add github:YOUR_USERNAME/specweave
341
+ specweave delete-feature FS-042 --dry-run # Preview
342
+ specweave delete-feature FS-042 # Safe delete (requires confirmation)
343
+ specweave delete-feature FS-042 --force # Force (orphans active increments)
1255
344
  ```
1256
345
 
1257
346
  ---
1258
347
 
1259
348
  ## Build & Test
1260
349
 
1261
- **Build**:
1262
- ```bash
1263
- npm run rebuild # Clean + build (development)
1264
- npm run build # Compile TS + copy deps
1265
- ```
1266
-
1267
- **Architecture**: `tsc` → `dist/src/`, esbuild → plugin hooks, copy deps → `plugins/*/lib/vendor/`
1268
-
1269
- **CRITICAL**: Always `.js` extensions (`import { foo } from './bar.js'`)
350
+ **Build**: `npm run rebuild` (clean + build), `npm run build`
351
+ **Architecture**: `tsc` → `dist/src/`, esbuild → hooks, copy deps → `plugins/*/lib/vendor/`
352
+ **CRITICAL**: Always `.js` extensions in imports
1270
353
 
1271
354
  **Test**:
1272
355
  ```bash
1273
- npm test # Smoke
1274
- npm run test:unit # Unit
1275
- npm run test:integration # Integration
1276
- npm run test:all # All
1277
- npm run test:coverage # Coverage (80%+ required)
356
+ npm test # Smoke
357
+ npm run test:unit # Unit
358
+ npm run test:integration # Integration
359
+ npm run test:all # All
360
+ npm run test:coverage # Coverage (80%+ required)
1278
361
  ```
1279
362
 
1280
- **Test rules**:
1281
- - Use `vi.fn()` (NOT `jest.fn()`)
1282
- - Use `os.tmpdir()` (NOT `process.cwd()`)
1283
- - ALL tests = `.test.ts` (NEVER `.spec.ts`)
1284
- - Use `createIsolatedTestDir()` helper
363
+ **Test rules**: `vi.fn()` (NOT `jest.fn()`), `os.tmpdir()` (NOT `process.cwd()`), `.test.ts` (NOT `.spec.ts`)
1285
364
 
1286
365
  ---
1287
366
 
1288
- ## Configuration Management (v0.24.0+)
367
+ ## Configuration Management
1289
368
 
1290
369
  **Secrets** (.env, gitignored) vs **Config** (.specweave/config.json, committed)
1291
370
 
1292
- ```typescript
1293
- import { getConfigManager } from '../core/config/index.js';
1294
-
1295
- const configManager = getConfigManager(projectRoot);
1296
- const config = await configManager.read();
1297
- await configManager.update({ issueTracker: { provider: 'jira', domain: 'example.atlassian.net' }});
1298
- ```
1299
-
1300
- **What goes where**:
1301
-
1302
- | Type | Location | Example | Committed? |
1303
- |------|----------|---------|------------|
1304
- | Tokens/Emails | `.env` | `JIRA_API_TOKEN=xyz` | ❌ |
1305
- | Domains/Strategies | `config.json` | `"domain": "example.atlassian.net"` | ✅ |
1306
-
1307
- **Migration**: `node -e "require('./dist/src/cli/commands/migrate-config.js').migrateConfig({ dryRun: true })"`
1308
-
1309
- **See**: ADR-0050, `src/core/config/config-manager.ts`
371
+ | Type | Location | Committed? |
372
+ |------|----------|------------|
373
+ | Tokens/Emails | `.env` | ❌ |
374
+ | Domains/Strategies | `config.json` | ✅ |
1310
375
 
1311
376
  ---
1312
377
 
1313
- ## Cache Management (v0.24.0+)
378
+ ## Cache Management
1314
379
 
1315
- **Smart Caching with 24-Hour TTL**: Reduces API calls by 90% during init and sync operations.
380
+ **Location**: `.specweave/cache/`, **TTL**: 24 hours
1316
381
 
1317
- ### Cache Architecture
382
+ **Cached**: JIRA projects, ADO config, boards, components (NOT tokens/PATs)
1318
383
 
1319
- **Location**: `.specweave/cache/`
1320
- **TTL**: 24 hours (configurable)
1321
- **Format**: JSON with timestamps
1322
-
1323
- ### Cached Data
1324
-
1325
- | Cache Key | Data | Use Case |
1326
- |-----------|------|----------|
1327
- | `jira-projects-{domain}` | Project list | JIRA init (auto-discovery) |
1328
- | `ado-config` | Org/project/teams | ADO init (manual entry) |
1329
- | `jira-{PROJECT}-deps` | Boards, components, versions | On-demand dependency loading |
1330
- | `ado-{PROJECT}-deps` | Area paths, teams | ADO dependency loading |
1331
-
1332
- ### Cache Operations
1333
-
1334
- **Automatic caching** (during init):
1335
- - JIRA: `promptJiraCredentials()` caches selected projects
1336
- - ADO: `promptAzureDevOpsCredentials()` caches org/project config
1337
-
1338
- **Manual cache management**:
1339
- ```bash
1340
- # Refresh cache (bypass TTL)
1341
- /specweave-jira:refresh-cache --all
1342
- /specweave-ado:refresh-cache --all
1343
-
1344
- # Clean old caches
1345
- /specweave:cleanup-cache --older-than 7d
1346
-
1347
- # View cache statistics
1348
- /specweave:cache-stats
1349
- ```
1350
-
1351
- ### Cache Security
1352
-
1353
- **Never cached**: API tokens, PATs, passwords (secrets stay in `.env`)
1354
- **Always cached**: Non-sensitive config (domains, project keys, org names)
1355
- **Atomic writes**: Temp file → rename pattern prevents corruption
1356
- **Auto-recovery**: Corrupted cache auto-deleted, fallback to API
1357
-
1358
- ### Integration
1359
-
1360
- **CLI Helpers**:
1361
- - `src/cli/helpers/issue-tracker/jira.ts`: JIRA project caching
1362
- - `src/cli/helpers/issue-tracker/ado.ts`: ADO config caching
1363
-
1364
- **Core Module**:
1365
- - `src/core/cache/cache-manager.ts`: TTL validation, atomic writes, corruption handling
1366
-
1367
- **Tests**:
1368
- - `tests/integration/cli/helpers/cache-integration.test.ts`: 85%+ coverage
1369
-
1370
- **See**: ADR-0051 (Smart Caching with TTL), `src/core/cache/rate-limit-checker.ts`
1371
-
1372
- ---
1373
-
1374
- ## Troubleshooting
1375
-
1376
- - **Skills not activating**: Check YAML frontmatter, restart Claude Code
1377
- - **Commands not working**: Verify plugin installed, restart
1378
- - **Tests failing**: `npm run rebuild`
1379
- - **Root polluted**: Move to `.specweave/increments/####/reports/`
1380
- - **Hooks failing**: Push to GitHub (auto-updates 5-10s)
384
+ **Manual**: `/specweave-jira:refresh-cache --all`, `/specweave:cleanup-cache --older-than 7d`
1381
385
 
1382
386
  ---
1383
387
 
1384
- ## Comprehensive Progress Sync (v0.25.0+)
1385
-
1386
- **Command**: `/specweave:sync-progress`
1387
-
1388
- **Purpose**: Single-button multi-system synchronization. Orchestrates complete flow from task completion → living docs → external tools (GitHub/JIRA/ADO).
1389
-
1390
- ### What It Does
1391
-
1392
- **Comprehensive Sync Flow**:
1393
- ```
1394
- tasks.md (source of truth)
1395
-
1396
- spec.md ACs (marked complete)
1397
-
1398
- Living docs (user stories updated)
1399
-
1400
- External tools (GitHub/JIRA/ADO synced)
1401
-
1402
- Status line cache (updated display)
1403
- ```
1404
-
1405
- **One command replaces 4 manual steps**:
1406
- ```bash
1407
- # OLD: Manual multi-step sync (error-prone)
1408
- /specweave:sync-acs 0053
1409
- /specweave:sync-specs 0053
1410
- /specweave-github:sync 0053
1411
- /specweave:update-status
1412
-
1413
- # NEW: Single comprehensive sync ✅
1414
- /specweave:sync-progress 0053
1415
- ```
1416
-
1417
- ### Usage
1418
-
1419
- ```bash
1420
- # Auto-detect active increment
1421
- /specweave:sync-progress
1422
-
1423
- # Explicit increment ID
1424
- /specweave:sync-progress 0053
1425
-
1426
- # Dry-run mode (preview without executing)
1427
- /specweave:sync-progress 0053 --dry-run
1428
-
1429
- # Skip external tools (local-only sync)
1430
- /specweave:sync-progress 0053 --no-github --no-jira --no-ado
1431
- ```
1432
-
1433
- ### When to Use
1434
-
1435
- **✅ Use /specweave:sync-progress when**:
1436
- 1. After completing tasks in tasks.md
1437
- 2. Before closing increment (`/specweave:done`)
1438
- 3. Want to update status line with latest progress
1439
- 4. Need to sync to external tools (GitHub/JIRA/ADO)
1440
- 5. After bulk task completion
1441
-
1442
- **❌ Don't use when**:
1443
- 1. Only need to sync ACs → Use `/specweave:sync-acs`
1444
- 2. Only need to sync docs → Use `/specweave:sync-specs`
1445
- 3. Only need to sync GitHub → Use `/specweave-github:sync`
1446
-
1447
- ### Multi-Phase Orchestration
1448
-
1449
- **Phase 1: Tasks → ACs (spec.md)**
1450
- - Reads completed tasks from tasks.md
1451
- - Finds linked ACs via `**Satisfies ACs**` field
1452
- - Marks ACs as complete: `[ ]` → `[x]`
1453
- - Updates metadata.json with AC count
1454
-
1455
- **Phase 2: Spec → Living Docs**
1456
- - Syncs spec.md to living docs structure
1457
- - Updates user story completion status
1458
- - Generates/updates feature ID if needed
1459
-
1460
- **Phase 3: Living Docs → External Tools**
1461
- - **GitHub**: Closes completed user story issues, updates epic checklist
1462
- - **JIRA**: Updates story status, transitions workflow
1463
- - **Azure DevOps**: Updates work item state, adds comments
1464
-
1465
- **Phase 4: Status Line Cache**
1466
- - Updates status line with latest completion %
1467
-
1468
- ### Flags
1469
-
1470
- | Flag | Purpose | Example |
1471
- |------|---------|---------|
1472
- | `--dry-run` | Preview without executing | `--dry-run` |
1473
- | `--no-github` | Skip GitHub sync | `--no-github` |
1474
- | `--no-jira` | Skip JIRA sync | `--no-jira` |
1475
- | `--no-ado` | Skip Azure DevOps sync | `--no-ado` |
1476
- | `--force` | Force sync even if validation fails | `--force` |
1477
-
1478
- ### Error Handling
1479
-
1480
- **Graceful Degradation**:
1481
- - **Critical errors** (AC sync, docs sync): Abort entire sync
1482
- - **Non-critical errors** (GitHub, JIRA, ADO): Log warning, continue
1483
-
1484
- **Philosophy**: Core sync (tasks → docs) must succeed. External tool sync is best-effort.
1485
-
1486
- ### Example Workflow
1487
-
1488
- **Typical increment workflow with progress sync**:
1489
-
1490
- ```bash
1491
- # 1. Plan increment
1492
- /specweave:increment "Safe feature deletion"
1493
-
1494
- # 2. Execute tasks
1495
- /specweave:do
1496
-
1497
- # [Complete 5 tasks...]
1498
-
1499
- # 3. Sync progress after batch
1500
- /specweave:sync-progress
1501
-
1502
- # [Complete remaining 32 tasks...]
1503
-
1504
- # 4. Final sync before closure
1505
- /specweave:sync-progress 0053
1506
-
1507
- # 5. Validate quality
1508
- /specweave:validate 0053 --quality
1509
-
1510
- # 6. Close increment
1511
- /specweave:done 0053
1512
- ```
1513
-
1514
- ### External Tool Auto-Detection
1515
-
1516
- **Automatic detection** from `.specweave/config.json`:
1517
- - GitHub: `"provider": "github"`
1518
- - JIRA: `"provider": "jira"`
1519
- - Azure DevOps: `"provider": "azure-devops"`
1520
-
1521
- **Only configured tools are synced**:
1522
- ```
1523
- ✅ GitHub integration detected → Will sync
1524
- ℹ️ No JIRA integration → Skip
1525
- ℹ️ No ADO integration → Skip
1526
- ```
1527
-
1528
- ### Troubleshooting
388
+ ## Comprehensive Progress Sync
1529
389
 
1530
- **"No active increment found"**:
1531
- ```bash
1532
- # Provide increment ID explicitly
1533
- /specweave:sync-progress 0053
1534
- ```
390
+ **Command**: `/specweave:sync-progress [increment]`
1535
391
 
1536
- **"AC sync had warnings: 5 ACs not found"**:
1537
- ```bash
1538
- # Embed ACs from living docs into spec.md
1539
- /specweave:embed-acs 0053
392
+ **Flow**: tasks.md spec.md ACs living docs → external tools (GitHub/JIRA/ADO) → status line
1540
393
 
1541
- # Then retry sync
1542
- /specweave:sync-progress 0053
1543
- ```
394
+ **Replaces 4 commands**: `/specweave:sync-acs` + `/specweave:sync-specs` + `/specweave-github:sync` + `/specweave:update-status`
1544
395
 
1545
- **"GitHub rate limit exceeded"** (non-critical):
1546
- - Docs are synced successfully
1547
- - Retry GitHub sync later when rate limit resets:
1548
- ```bash
1549
- /specweave-github:sync 0053
1550
- ```
396
+ **Flags**: `--dry-run`, `--no-github`, `--no-jira`, `--no-ado`, `--force`
1551
397
 
1552
- **See**:
1553
- - Skill: `progress-sync` (comprehensive guide)
1554
- - Increment 0053 (added in this increment)
398
+ **When to use**: After completing tasks, before closing increment, bulk completion
1555
399
 
1556
400
  ---
1557
401
 
1558
- ## Safe Feature Deletion (v0.25.0+)
402
+ ## Safe Feature Deletion
1559
403
 
1560
404
  **Command**: `specweave delete-feature <feature-id>`
1561
405
 
1562
- Safe deletion of features with multi-gate validation, automatic cleanup, and audit logging.
406
+ **4-Tier Validation**: Feature detection active increment check git status → GitHub scan
407
+ **3-Phase Commit**: Validation → staging (reversible) → commit (irreversible)
408
+ **Multi-Gate Confirmation**: Primary (y/N) → elevated (type "delete" in force mode) → GitHub (separate)
1563
409
 
1564
- ### Usage
410
+ **Deletes**: Living docs FEATURE.md, user stories, README, GitHub issues
411
+ **NOT deleted**: Increments (metadata.json updated if orphaned)
1565
412
 
1566
- ```bash
1567
- # Preview deletion (recommended first step)
1568
- specweave delete-feature FS-042 --dry-run
1569
-
1570
- # Safe deletion (requires confirmation)
1571
- specweave delete-feature FS-042
413
+ **Modes**: Safe (default, blocks active increments), Force (`--force`, orphans increments), Dry-run (`--dry-run`, preview)
1572
414
 
1573
- # Force deletion (bypasses active increment validation)
1574
- specweave delete-feature FS-042 --force
415
+ **Audit**: `.specweave/logs/feature-deletions.log` (JSON Lines, includes commit SHA)
1575
416
 
1576
- # Skip git operations
1577
- specweave delete-feature FS-042 --no-git
417
+ ---
1578
418
 
1579
- # Skip GitHub issue cleanup
1580
- specweave delete-feature FS-042 --no-github
419
+ ## Project Structure
1581
420
 
1582
- # Skip confirmations (except elevated confirmation in force mode)
1583
- specweave delete-feature FS-042 --yes
421
+ ```
422
+ src/ # TypeScript dist/
423
+ plugins/ # Skills, agents, commands, hooks
424
+ ├── specweave/ # Core
425
+ └── specweave-*/ # Optional
426
+ .specweave/ # Increments, docs, logs
1584
427
  ```
1585
428
 
1586
- ### Safety Features
1587
-
1588
- **4-Tier Validation**:
1589
- 1. **Feature Detection**: Scans living docs and user stories
1590
- 2. **Active Increment Check**: Blocks deletion if active increments reference feature (safe mode)
1591
- 3. **Git Status Check**: Ensures clean working directory
1592
- 4. **GitHub Issue Scan**: Finds related issues for cleanup
1593
-
1594
- **3-Phase Commit Pattern**:
1595
- 1. **Validation Phase**: All safety checks
1596
- 2. **Staging Phase**: Reversible (file backup, git staging)
1597
- 3. **Commit Phase**: Irreversible (git commit, GitHub cleanup, audit log)
1598
-
1599
- **Multi-Gate Confirmation**:
1600
- - Primary Confirmation: y/N prompt for all deletions
1601
- - Elevated Confirmation: Type "delete" for force mode (orphans active increments)
1602
- - GitHub Confirmation: Separate prompt for closing GitHub issues
1603
-
1604
- ### What Gets Deleted
1605
-
1606
- ✅ Living docs: `.specweave/docs/internal/specs/_features/FS-XXX/FEATURE.md`
1607
- ✅ User stories: `.specweave/docs/internal/specs/{project}/FS-XXX/us-*.md`
1608
- ✅ README files: `.specweave/docs/internal/specs/{project}/FS-XXX/README.md`
1609
- ✅ GitHub issues: Issues matching `[FS-XXX][US-YYY]` pattern (optional)
1610
-
1611
- ❌ NOT deleted: Increments (only metadata.json updated if orphaned)
1612
-
1613
- ### Modes
1614
-
1615
- **Safe Mode (default)**:
1616
- - Blocks deletion if active increments reference feature
1617
- - Requires clean git working directory
1618
- - Requires explicit confirmation
1619
-
1620
- **Force Mode (`--force`)**:
1621
- - Allows deletion with active increments
1622
- - Updates orphaned increment metadata.json (removes feature_id)
1623
- - Requires elevated confirmation (type "delete")
1624
-
1625
- **Dry-Run Mode (`--dry-run`)**:
1626
- - Preview deletion without executing
1627
- - Shows all files to be deleted
1628
- - Shows git operations
1629
- - Shows GitHub issues to be closed
429
+ ---
1630
430
 
1631
- ### Audit Logging
431
+ ## Plugin Hook Registration
1632
432
 
1633
- All deletions logged to `.specweave/logs/feature-deletions.log` (JSON Lines format):
433
+ **Valid events** (10): PostToolUse, PreToolUse, PermissionRequest, Notification, UserPromptSubmit, Stop, SubagentStop, PreCompact, SessionStart, SessionEnd
1634
434
 
1635
435
  ```json
1636
436
  {
1637
- "featureId": "FS-042",
1638
- "timestamp": "2025-11-24T01:45:00.000Z",
1639
- "user": "john-doe",
1640
- "mode": "safe",
1641
- "filesDeleted": 6,
1642
- "commitSha": "abc123def",
1643
- "githubIssuesClosed": 3,
1644
- "orphanedIncrements": [],
1645
- "status": "success"
437
+ "hooks": {
438
+ "PostToolUse": [{
439
+ "matcher": "TodoWrite",
440
+ "hooks": [{ "type": "command", "command": "${CLAUDE_PLUGIN_ROOT}/hooks/post-task-completion.sh", "timeout": 10 }]
441
+ }]
442
+ }
1646
443
  }
1647
444
  ```
1648
445
 
1649
- **Log rotation**: Automatically rotates at 10MB threshold.
1650
-
1651
- ### Error Handling
1652
-
1653
- **Non-blocking errors** (logged as warnings):
1654
- - GitHub API rate limits (exponential backoff retry)
1655
- - GitHub issue cleanup failures
1656
- - Audit log write failures
1657
-
1658
- **Blocking errors** (prevent deletion):
1659
- - Feature not found
1660
- - Active increments in safe mode
1661
- - Git working directory not clean (without `--no-git`)
1662
- - Invalid feature ID format (must be FS-XXX)
1663
-
1664
- ### Examples
1665
-
1666
- ```bash
1667
- # Recommended workflow
1668
- specweave delete-feature FS-042 --dry-run # Preview
1669
- specweave delete-feature FS-042 # Execute (with confirmation)
1670
-
1671
- # Force delete feature with active increment 0050
1672
- specweave delete-feature FS-042 --force # Requires typing "delete"
1673
-
1674
- # Delete without git commit (manual git workflow)
1675
- specweave delete-feature FS-042 --no-git
1676
-
1677
- # Delete with auto-yes (CI/CD pipelines)
1678
- specweave delete-feature FS-042 --yes --dry-run # Still shows preview
1679
- ```
1680
-
1681
- ### Important Notes
1682
-
1683
- **GitHub Integration**:
1684
- - Owner/repo auto-detected from `git remote get-url origin`
1685
- - If no GitHub remote → GitHub cleanup silently skipped (non-blocking)
1686
- - Pattern detection: `https://github.com/owner/repo.git` or `git@github.com:owner/repo.git`
1687
-
1688
- **No Undo**:
1689
- - Deletion is permanent (files deleted from filesystem)
1690
- - Recovery: `git log --all --full-history -- path/to/deleted/file` → `git checkout <commit> -- path`
1691
- - Audit log: `.specweave/logs/feature-deletions.log` (includes commit SHA)
1692
-
1693
- **Force Mode Risk**:
1694
- - Orphaned increments lose `feature_id` in metadata.json
1695
- - Breaking change: `/specweave:sync-specs` won't sync orphaned increments
1696
- - Recovery: Manually restore `feature_id` in metadata.json
1697
-
1698
- **See**: Increment 0053-safe-feature-deletion for implementation details.
1699
-
1700
446
  ---
1701
447
 
1702
448
  ## Quick Reference
@@ -1708,11 +454,24 @@ specweave delete-feature FS-042 --yes --dry-run # Still shows preview
1708
454
  **Structure**: `src/` (TS), `plugins/` (components), `.specweave/` (data), `tests/` (tests)
1709
455
 
1710
456
  **Remember**:
1711
- 1. Push → GitHub → Claude Code auto-updates (5-10s)
1712
- 2. Keep root clean
457
+ 1. Push → GitHub → auto-updates (5-10s)
458
+ 2. Keep root clean (reports in increment subfolders)
1713
459
  3. Test before commit
1714
460
  4. NEVER delete `.specweave/`
1715
461
  5. Use `/specweave:done` (not manual edits)
462
+ 6. ALWAYS use GitHub mode for marketplace refresh (unless actively developing uncommitted changes)
463
+ 7. tasks.md + spec.md are SOURCE OF TRUTH (not internal TODO)
1716
464
 
1717
465
  **See**: `.github/CONTRIBUTING.md`, https://spec-weave.com
1718
466
 
467
+ ---
468
+
469
+ ## References
470
+
471
+ **ADRs**: 0032 (GitHub Hierarchy), 0050 (Config Management), 0051 (Caching), 0060 (Hook Optimization), 0061 (No Increment References), 0064 (AC Presence), 0069 (Git Provider Abstraction), 0070 (Hook Consolidation), 0129 (US Sync Guard Rails), 0132 (No Early Returns)
472
+
473
+ **Emergency Procedures**: `.specweave/docs/internal/emergency-procedures/HOOK-CRASH-RECOVERY.md`, `TODOWRITE-CRASH-RECOVERY.md`, `AC-SYNC-CONFLICT-FIX-2025-11-24.md`
474
+
475
+ **Incident Reports**: See increment 0044 (TODO desync), 0047 (GitHub sync removal), 0050 (Hook crashes, AC presence, GitHub issues), 0051 (PROJECT_ROOT order), 0053 (Safe deletion, TodoWrite crash, AC parser, GitHub multi-repo)
476
+
477
+ **Validation Scripts**: `validate-marketplace-plugins.sh`, `validate-plugin-directories.sh`, `validate-hook-variable-order.sh`, `cleanup-duplicate-github-issues.sh`