@zigrivers/scaffold 2.38.1 → 2.44.3

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 (201) hide show
  1. package/README.md +10 -7
  2. package/dist/cli/commands/build.js +4 -4
  3. package/dist/cli/commands/build.js.map +1 -1
  4. package/dist/cli/commands/check.test.js +11 -8
  5. package/dist/cli/commands/check.test.js.map +1 -1
  6. package/dist/cli/commands/complete.d.ts.map +1 -1
  7. package/dist/cli/commands/complete.js +2 -1
  8. package/dist/cli/commands/complete.js.map +1 -1
  9. package/dist/cli/commands/complete.test.js +4 -1
  10. package/dist/cli/commands/complete.test.js.map +1 -1
  11. package/dist/cli/commands/dashboard.js +4 -4
  12. package/dist/cli/commands/dashboard.js.map +1 -1
  13. package/dist/cli/commands/knowledge.js +2 -2
  14. package/dist/cli/commands/knowledge.js.map +1 -1
  15. package/dist/cli/commands/knowledge.test.js +5 -12
  16. package/dist/cli/commands/knowledge.test.js.map +1 -1
  17. package/dist/cli/commands/list.d.ts +1 -1
  18. package/dist/cli/commands/list.d.ts.map +1 -1
  19. package/dist/cli/commands/list.js +84 -3
  20. package/dist/cli/commands/list.js.map +1 -1
  21. package/dist/cli/commands/list.test.js +82 -0
  22. package/dist/cli/commands/list.test.js.map +1 -1
  23. package/dist/cli/commands/next.test.js +4 -1
  24. package/dist/cli/commands/next.test.js.map +1 -1
  25. package/dist/cli/commands/reset.d.ts.map +1 -1
  26. package/dist/cli/commands/reset.js +5 -2
  27. package/dist/cli/commands/reset.js.map +1 -1
  28. package/dist/cli/commands/reset.test.js +4 -1
  29. package/dist/cli/commands/reset.test.js.map +1 -1
  30. package/dist/cli/commands/rework.d.ts.map +1 -1
  31. package/dist/cli/commands/rework.js +3 -2
  32. package/dist/cli/commands/rework.js.map +1 -1
  33. package/dist/cli/commands/run.d.ts.map +1 -1
  34. package/dist/cli/commands/run.js +28 -13
  35. package/dist/cli/commands/run.js.map +1 -1
  36. package/dist/cli/commands/run.test.js +1 -1
  37. package/dist/cli/commands/run.test.js.map +1 -1
  38. package/dist/cli/commands/skip.d.ts.map +1 -1
  39. package/dist/cli/commands/skip.js +2 -1
  40. package/dist/cli/commands/skip.js.map +1 -1
  41. package/dist/cli/commands/skip.test.js +4 -1
  42. package/dist/cli/commands/skip.test.js.map +1 -1
  43. package/dist/cli/commands/status.d.ts.map +1 -1
  44. package/dist/cli/commands/status.js +88 -4
  45. package/dist/cli/commands/status.js.map +1 -1
  46. package/dist/cli/commands/version.d.ts.map +1 -1
  47. package/dist/cli/commands/version.js +22 -3
  48. package/dist/cli/commands/version.js.map +1 -1
  49. package/dist/cli/commands/version.test.js +42 -0
  50. package/dist/cli/commands/version.test.js.map +1 -1
  51. package/dist/cli/output/context.test.js +14 -13
  52. package/dist/cli/output/context.test.js.map +1 -1
  53. package/dist/cli/output/interactive.js +4 -4
  54. package/dist/cli/output/json.d.ts +1 -0
  55. package/dist/cli/output/json.d.ts.map +1 -1
  56. package/dist/cli/output/json.js +14 -1
  57. package/dist/cli/output/json.js.map +1 -1
  58. package/dist/config/loader.d.ts.map +1 -1
  59. package/dist/config/loader.js +10 -3
  60. package/dist/config/loader.js.map +1 -1
  61. package/dist/config/loader.test.js +28 -0
  62. package/dist/config/loader.test.js.map +1 -1
  63. package/dist/core/assembly/engine.d.ts.map +1 -1
  64. package/dist/core/assembly/engine.js +6 -1
  65. package/dist/core/assembly/engine.js.map +1 -1
  66. package/dist/e2e/init.test.js +3 -0
  67. package/dist/e2e/init.test.js.map +1 -1
  68. package/dist/index.js +2 -1
  69. package/dist/index.js.map +1 -1
  70. package/dist/project/adopt.test.js +3 -0
  71. package/dist/project/adopt.test.js.map +1 -1
  72. package/dist/project/claude-md.d.ts.map +1 -1
  73. package/dist/project/claude-md.js +2 -1
  74. package/dist/project/claude-md.js.map +1 -1
  75. package/dist/project/detector.js +3 -3
  76. package/dist/project/detector.js.map +1 -1
  77. package/dist/project/signals.d.ts +1 -0
  78. package/dist/project/signals.d.ts.map +1 -1
  79. package/dist/state/decision-logger.d.ts.map +1 -1
  80. package/dist/state/decision-logger.js +7 -4
  81. package/dist/state/decision-logger.js.map +1 -1
  82. package/dist/state/lock-manager.js +1 -1
  83. package/dist/state/lock-manager.js.map +1 -1
  84. package/dist/state/lock-manager.test.js +27 -3
  85. package/dist/state/lock-manager.test.js.map +1 -1
  86. package/dist/state/state-manager.d.ts.map +1 -1
  87. package/dist/state/state-manager.js +6 -0
  88. package/dist/state/state-manager.js.map +1 -1
  89. package/dist/state/state-manager.test.js +7 -0
  90. package/dist/state/state-manager.test.js.map +1 -1
  91. package/dist/types/assembly.d.ts +2 -0
  92. package/dist/types/assembly.d.ts.map +1 -1
  93. package/dist/utils/eligible.d.ts +8 -0
  94. package/dist/utils/eligible.d.ts.map +1 -0
  95. package/dist/utils/eligible.js +36 -0
  96. package/dist/utils/eligible.js.map +1 -0
  97. package/dist/validation/config-validator.test.js +15 -13
  98. package/dist/validation/config-validator.test.js.map +1 -1
  99. package/dist/validation/index.test.js +1 -1
  100. package/dist/wizard/wizard.d.ts.map +1 -1
  101. package/dist/wizard/wizard.js +1 -0
  102. package/dist/wizard/wizard.js.map +1 -1
  103. package/dist/wizard/wizard.test.js +2 -0
  104. package/dist/wizard/wizard.test.js.map +1 -1
  105. package/knowledge/core/automated-review-tooling.md +4 -4
  106. package/knowledge/core/eval-craft.md +44 -0
  107. package/knowledge/core/multi-model-review-dispatch.md +8 -0
  108. package/knowledge/core/system-architecture.md +39 -0
  109. package/knowledge/core/task-decomposition.md +53 -0
  110. package/knowledge/core/testing-strategy.md +160 -0
  111. package/knowledge/finalization/implementation-playbook.md +24 -7
  112. package/knowledge/product/prd-craft.md +41 -0
  113. package/knowledge/review/review-adr.md +1 -1
  114. package/knowledge/review/review-api-design.md +1 -1
  115. package/knowledge/review/review-database-design.md +1 -1
  116. package/knowledge/review/review-domain-modeling.md +1 -1
  117. package/knowledge/review/review-implementation-tasks.md +1 -1
  118. package/knowledge/review/review-methodology.md +1 -1
  119. package/knowledge/review/review-operations.md +1 -1
  120. package/knowledge/review/review-prd.md +1 -1
  121. package/knowledge/review/review-security.md +1 -1
  122. package/knowledge/review/review-system-architecture.md +1 -1
  123. package/knowledge/review/review-testing-strategy.md +1 -1
  124. package/knowledge/review/review-user-stories.md +1 -1
  125. package/knowledge/review/review-ux-specification.md +1 -1
  126. package/knowledge/review/review-vision.md +1 -1
  127. package/knowledge/tools/post-implementation-review-methodology.md +107 -0
  128. package/knowledge/validation/critical-path-analysis.md +13 -0
  129. package/knowledge/validation/implementability-review.md +14 -0
  130. package/package.json +2 -1
  131. package/pipeline/architecture/review-architecture.md +8 -5
  132. package/pipeline/architecture/system-architecture.md +9 -3
  133. package/pipeline/build/multi-agent-resume.md +21 -7
  134. package/pipeline/build/multi-agent-start.md +22 -7
  135. package/pipeline/build/new-enhancement.md +20 -12
  136. package/pipeline/build/quick-task.md +18 -11
  137. package/pipeline/build/single-agent-resume.md +20 -6
  138. package/pipeline/build/single-agent-start.md +24 -8
  139. package/pipeline/consolidation/claude-md-optimization.md +8 -4
  140. package/pipeline/consolidation/workflow-audit.md +9 -5
  141. package/pipeline/decisions/adrs.md +7 -3
  142. package/pipeline/decisions/review-adrs.md +8 -5
  143. package/pipeline/environment/ai-memory-setup.md +6 -2
  144. package/pipeline/environment/automated-pr-review.md +79 -12
  145. package/pipeline/environment/design-system.md +9 -6
  146. package/pipeline/environment/dev-env-setup.md +8 -5
  147. package/pipeline/environment/git-workflow.md +16 -13
  148. package/pipeline/finalization/apply-fixes-and-freeze.md +10 -5
  149. package/pipeline/finalization/developer-onboarding-guide.md +10 -3
  150. package/pipeline/finalization/implementation-playbook.md +13 -4
  151. package/pipeline/foundation/beads.md +8 -5
  152. package/pipeline/foundation/coding-standards.md +13 -10
  153. package/pipeline/foundation/project-structure.md +16 -13
  154. package/pipeline/foundation/tdd.md +9 -4
  155. package/pipeline/foundation/tech-stack.md +7 -5
  156. package/pipeline/integration/add-e2e-testing.md +12 -8
  157. package/pipeline/modeling/domain-modeling.md +9 -7
  158. package/pipeline/modeling/review-domain-modeling.md +8 -6
  159. package/pipeline/parity/platform-parity-review.md +9 -6
  160. package/pipeline/planning/implementation-plan-review.md +10 -7
  161. package/pipeline/planning/implementation-plan.md +41 -9
  162. package/pipeline/pre/create-prd.md +7 -4
  163. package/pipeline/pre/innovate-prd.md +12 -8
  164. package/pipeline/pre/innovate-user-stories.md +10 -7
  165. package/pipeline/pre/review-prd.md +12 -10
  166. package/pipeline/pre/review-user-stories.md +12 -9
  167. package/pipeline/pre/user-stories.md +7 -4
  168. package/pipeline/quality/create-evals.md +6 -3
  169. package/pipeline/quality/operations.md +7 -3
  170. package/pipeline/quality/review-operations.md +12 -5
  171. package/pipeline/quality/review-security.md +11 -6
  172. package/pipeline/quality/review-testing.md +11 -6
  173. package/pipeline/quality/security.md +6 -2
  174. package/pipeline/quality/story-tests.md +14 -9
  175. package/pipeline/specification/api-contracts.md +9 -3
  176. package/pipeline/specification/database-schema.md +8 -2
  177. package/pipeline/specification/review-api.md +10 -4
  178. package/pipeline/specification/review-database.md +8 -3
  179. package/pipeline/specification/review-ux.md +9 -3
  180. package/pipeline/specification/ux-spec.md +9 -4
  181. package/pipeline/validation/critical-path-walkthrough.md +10 -5
  182. package/pipeline/validation/cross-phase-consistency.md +9 -4
  183. package/pipeline/validation/decision-completeness.md +8 -3
  184. package/pipeline/validation/dependency-graph-validation.md +8 -3
  185. package/pipeline/validation/implementability-dry-run.md +9 -5
  186. package/pipeline/validation/scope-creep-check.md +11 -6
  187. package/pipeline/validation/traceability-matrix.md +10 -5
  188. package/pipeline/vision/create-vision.md +7 -4
  189. package/pipeline/vision/innovate-vision.md +11 -8
  190. package/pipeline/vision/review-vision.md +15 -12
  191. package/skills/multi-model-dispatch/SKILL.md +6 -5
  192. package/skills/scaffold-runner/SKILL.md +47 -3
  193. package/tools/dashboard.md +53 -0
  194. package/tools/post-implementation-review.md +655 -0
  195. package/tools/prompt-pipeline.md +160 -0
  196. package/tools/release.md +440 -0
  197. package/tools/review-pr.md +229 -0
  198. package/tools/session-analyzer.md +299 -0
  199. package/tools/update.md +113 -0
  200. package/tools/version-bump.md +290 -0
  201. package/tools/version.md +82 -0
@@ -0,0 +1,229 @@
1
+ ---
2
+ name: review-pr
3
+ description: Run all configured code review channels on a PR (Codex CLI, Gemini CLI, Superpowers code-reviewer)
4
+ phase: null
5
+ order: null
6
+ dependencies: []
7
+ outputs: []
8
+ conditional: null
9
+ stateless: true
10
+ category: tool
11
+ knowledge-base: [multi-model-review-dispatch, automated-review-tooling]
12
+ argument-hint: "<PR number or blank for current branch>"
13
+ ---
14
+
15
+ ## Purpose
16
+
17
+ Run all three code review channels on a pull request and reconcile findings.
18
+ This is the single entry point for PR code review — agents call this once instead
19
+ of remembering three separate review invocations.
20
+
21
+ The three channels are:
22
+ 1. **Codex CLI** — OpenAI's code analysis (implementation correctness, security, API contracts)
23
+ 2. **Gemini CLI** — Google's design reasoning (architectural patterns, broad context)
24
+ 3. **Superpowers code-reviewer** — Claude subagent review (plan alignment, code quality, testing)
25
+
26
+ ## Inputs
27
+
28
+ - $ARGUMENTS — PR number (optional; auto-detected from current branch if omitted)
29
+ - docs/review-standards.md (optional) — severity definitions and review criteria
30
+ - docs/coding-standards.md (required) — coding conventions for review context
31
+ - docs/tdd-standards.md (optional) — test coverage expectations
32
+ - AGENTS.md (optional) — reviewer instructions with project-specific rules
33
+
34
+ ## Expected Outputs
35
+
36
+ - All three review channels executed (or fallback documented)
37
+ - P0/P1/P2 findings fixed before proceeding
38
+ - Review summary with per-channel results and reconciliation
39
+
40
+ ## Instructions
41
+
42
+ ### Step 1: Identify the PR
43
+
44
+ ```bash
45
+ # Use argument if provided, otherwise detect from current branch
46
+ PR_NUMBER="${ARGUMENTS:-$(gh pr view --json number -q .number 2>/dev/null)}"
47
+ ```
48
+
49
+ If no PR is found, stop and tell the user to create a PR first.
50
+
51
+ ### Step 2: Gather Review Context
52
+
53
+ Collect the PR diff and project standards for review prompts:
54
+
55
+ ```bash
56
+ PR_DIFF=$(gh pr diff "$PR_NUMBER")
57
+ ```
58
+
59
+ Read these files for review context (skip any that don't exist):
60
+ - `docs/coding-standards.md`
61
+ - `docs/tdd-standards.md`
62
+ - `docs/review-standards.md`
63
+ - `AGENTS.md`
64
+
65
+ ### Step 3: Run All Three Review Channels
66
+
67
+ Run all three channels. Track which ones complete successfully.
68
+
69
+ #### Channel 1: Codex CLI
70
+
71
+ **Auth check first** (auth tokens expire — always re-verify):
72
+
73
+ ```bash
74
+ codex login status 2>/dev/null && echo "codex authenticated" || echo "codex NOT authenticated"
75
+ ```
76
+
77
+ If Codex is not installed, skip this channel and note it in the summary.
78
+ If auth fails, tell the user: "Codex auth expired. Run: `! codex login`" — do NOT
79
+ silently fall back. After the user re-authenticates, retry.
80
+
81
+ **Run the review:**
82
+
83
+ ```bash
84
+ codex exec --skip-git-repo-check -s read-only --ephemeral "REVIEW_PROMPT" 2>/dev/null
85
+ ```
86
+
87
+ The review prompt must include:
88
+ - The PR diff
89
+ - Coding standards from docs/coding-standards.md
90
+ - Review standards from docs/review-standards.md (if exists)
91
+ - Instruction to report P0/P1/P2 findings as JSON with severity, location (file:line), description, and suggestion
92
+
93
+ #### Channel 2: Gemini CLI
94
+
95
+ **Auth check first:**
96
+
97
+ ```bash
98
+ GEMINI_AUTH_CHECK=$(NO_BROWSER=true gemini -p "respond with ok" -o json 2>&1)
99
+ GEMINI_EXIT=$?
100
+ if [ "$GEMINI_EXIT" -eq 0 ]; then
101
+ echo "gemini authenticated"
102
+ elif [ "$GEMINI_EXIT" -eq 41 ]; then
103
+ echo "gemini NOT authenticated (exit 41: auth error)"
104
+ fi
105
+ ```
106
+
107
+ If Gemini is not installed, skip this channel and note it in the summary.
108
+ If auth fails (exit 41), tell the user: "Gemini auth expired. Run: `! gemini -p \"hello\"`" — do NOT silently fall back. After the user re-authenticates, retry.
109
+
110
+ **Run the review:**
111
+
112
+ ```bash
113
+ NO_BROWSER=true gemini -p "REVIEW_PROMPT" --output-format json --approval-mode yolo 2>/dev/null
114
+ ```
115
+
116
+ Same review prompt content as Codex. Do NOT share one model's output with the other —
117
+ each reviews independently.
118
+
119
+ #### Channel 3: Superpowers Code-Reviewer Subagent
120
+
121
+ Dispatch the `superpowers:code-reviewer` subagent. This channel always runs (it uses
122
+ Claude, which is always available).
123
+
124
+ ```bash
125
+ BASE_SHA=$(gh pr view "$PR_NUMBER" --json baseRefOid -q .baseRefOid)
126
+ HEAD_SHA=$(gh pr view "$PR_NUMBER" --json headRefOid -q .headRefOid)
127
+ ```
128
+
129
+ Dispatch with the Agent tool using `superpowers:code-reviewer` as the subagent type,
130
+ providing:
131
+ - `WHAT_WAS_IMPLEMENTED` — PR title and description
132
+ - `PLAN_OR_REQUIREMENTS` — coding standards and review standards
133
+ - `BASE_SHA` — base commit
134
+ - `HEAD_SHA` — head commit
135
+ - `DESCRIPTION` — PR summary
136
+
137
+ ### Step 4: Reconcile Findings
138
+
139
+ After all channels complete, reconcile findings:
140
+
141
+ | Scenario | Confidence | Action |
142
+ |----------|-----------|--------|
143
+ | Multiple channels flag same issue | **High** | Fix immediately |
144
+ | All channels approve (no findings) | **High** | Proceed to merge |
145
+ | One channel flags P0, others approve | **High** | Fix it — P0 is critical from any source |
146
+ | One channel flags P1, others approve | **Medium** | Fix it — P1 findings are mandatory regardless of source count |
147
+ | Channels contradict each other | **Low** | Present to user for adjudication |
148
+
149
+ ### Step 5: Report Results
150
+
151
+ Output a review summary in this format:
152
+
153
+ ```
154
+ ## Code Review Summary — PR #[number]
155
+
156
+ ### Channels Executed
157
+ - [ ] Codex CLI — [completed / skipped (not installed) / skipped (auth failed) / error]
158
+ - [ ] Gemini CLI — [completed / skipped (not installed) / skipped (auth failed) / error]
159
+ - [ ] Superpowers code-reviewer — [completed / error]
160
+
161
+ ### Consensus Findings (High Confidence)
162
+ [Findings flagged by 2+ channels]
163
+
164
+ ### Single-Source Findings
165
+ [Findings from only one channel, with attribution]
166
+
167
+ ### Disagreements
168
+ [Contradictions between channels]
169
+
170
+ ### Verdict
171
+ [All channels approve / Fix required (list P0/P1/P2 items) / User adjudication needed]
172
+ ```
173
+
174
+ ### Step 6: Fix P0/P1/P2 Findings
175
+
176
+ If any P0, P1, or P2 findings exist:
177
+ 1. Fix them in the code
178
+ 2. Push the fixes: `git push`
179
+ 3. Re-run the channels that produced findings to verify fixes
180
+ 4. After 3 fix rounds with unresolved P0/P1/P2 findings, stop and ask the user for direction — do NOT merge automatically. Document remaining findings and let the user decide whether to continue fixing, create follow-up issues, or override.
181
+
182
+ ### Step 7: Confirm Completion
183
+
184
+ After all findings are resolved (or 3 rounds complete), output:
185
+
186
+ ```
187
+ Code review complete. All 3 channels executed. PR #[number] is ready for merge.
188
+ ```
189
+
190
+ Do NOT proceed to the next task or merge until this confirmation is output.
191
+
192
+ ## Fallback Behavior
193
+
194
+ | Situation | Action |
195
+ |-----------|--------|
196
+ | Neither Codex nor Gemini installed | Run Superpowers code-reviewer only; document as "single-channel review" |
197
+ | One CLI installed, one not | Run available CLI + Superpowers; document missing channel |
198
+ | CLI auth expired | Surface to user with recovery command; do NOT silently skip |
199
+ | Superpowers plugin not installed | Run both CLIs; warn user to install superpowers plugin |
200
+ | All external channels unavailable | Superpowers code-reviewer only; warn user that review coverage is reduced |
201
+
202
+ ## Process Rules
203
+
204
+ 1. **All three channels are mandatory** — skip only when the tool is genuinely unavailable (not installed), never by choice.
205
+ 2. **Auth failures are not silent** — always surface to the user with recovery instructions.
206
+ 3. **Independence** — never share one channel's output with another. Each reviews the diff independently.
207
+ 4. **Fix before proceeding** — P0/P1/P2 findings must be resolved before moving to the next task.
208
+ 5. **Document everything** — the review summary must show which channels ran and which were skipped, with reasons.
209
+
210
+ ---
211
+
212
+ ## After This Step
213
+
214
+ When code review is complete, tell the user:
215
+
216
+ ---
217
+ **Code review complete** — All channels executed for PR #[number].
218
+
219
+ **Results:**
220
+ - Channels run: [list which of the 3 ran]
221
+ - Findings fixed: [count]
222
+ - Remaining: [none / list]
223
+
224
+ **Next:** Return to the task execution loop — mark the task complete and pick up
225
+ the next unblocked task with `/scaffold:single-agent-start`.
226
+
227
+ **Pipeline reference:** `/scaffold:prompt-pipeline`
228
+
229
+ ---
@@ -0,0 +1,299 @@
1
+ ---
2
+ name: session-analyzer
3
+ description: Analyze session history to find automation opportunities
4
+ phase: null
5
+ order: null
6
+ dependencies: []
7
+ outputs: []
8
+ conditional: null
9
+ stateless: true
10
+ category: tool
11
+ knowledge-base: [session-analysis]
12
+ ---
13
+
14
+ ## Purpose
15
+
16
+ Analyze all Claude Code sessions on this computer and identify repeated tasks,
17
+ workflows, decisions, and patterns across every project — then recommend what
18
+ to automate as skills, plugins, agents, and claude.md rules.
19
+
20
+ ## Inputs
21
+
22
+ | Flag | Description |
23
+ |------|-------------|
24
+ | `--project <name>` | Focus deep analysis on one project (match against `~/.claude/projects/` directory names) |
25
+ | `--depth shallow` | Use only `history.jsonl` and `stats-cache.json` — fast, skips session sampling |
26
+ | `--depth deep` | Sample session transcripts from all active projects (default when omitted) |
27
+ | `--output <path>` | Save the report as a markdown file at the specified path |
28
+
29
+ ## Expected Outputs
30
+
31
+ A structured recommendations report containing:
32
+ - Summary statistics (sessions, projects, date range, prompt count)
33
+ - Top 10 skills to build
34
+ - Top 5 plugins/tools to build
35
+ - Top 5 agents to build
36
+ - Most important missing claude.md sections
37
+ - Build-first recommendation with scoring
38
+ - Ranked build-order backlog (top 15 items)
39
+
40
+ ## Instructions
41
+
42
+ ### Phase 1: Data Collection
43
+
44
+ Use **parallel subagents** to read the data sources below simultaneously. Each subagent handles one or two sources and returns a structured summary — not raw content.
45
+
46
+ #### 1.1 Prompt History Index
47
+
48
+ Read `~/.claude/history.jsonl` fully. Each line is a JSON object:
49
+ ```json
50
+ { "display": "<the prompt text>", "timestamp": 1234567890, "project": "/path/to/project" }
51
+ ```
52
+
53
+ Extract:
54
+ - Total prompt count and date range
55
+ - All unique project paths and their prompt counts
56
+ - All prompt text (store as an array for clustering in Phase 2)
57
+ - The 5 most active projects by prompt count
58
+
59
+ #### 1.2 Activity Statistics
60
+
61
+ Read `~/.claude/stats-cache.json`. Extract:
62
+ - Daily message counts and session counts
63
+ - Most active days/weeks
64
+ - Overall usage volume
65
+
66
+ #### 1.3 Project Discovery
67
+
68
+ List all directories under `~/.claude/projects/`. For each project directory:
69
+ - Count the number of `.jsonl` session files
70
+ - Note the most recently modified session file date
71
+ - Identify if a CLAUDE.md-style file exists in that project's working directory
72
+
73
+ #### 1.4 Session Transcript Sampling
74
+
75
+ Skip this step if `--depth shallow` was passed.
76
+
77
+ For the **5 most active projects** identified in step 1.1:
78
+ - Find the 5 most recently modified `.jsonl` session files in `~/.claude/projects/<project-slug>/`
79
+ - Read the first 80 lines of each session file
80
+ - From each line, extract only entries where `type == "user"` (user messages only, skip assistant and tool responses)
81
+ - Summarize the user messages from each session — do not reproduce raw content
82
+
83
+ #### 1.5 Plan Title Clustering
84
+
85
+ List all files in `~/.claude/plans/`. For each `.md` file:
86
+ - Read only the first 3 lines (title + brief context)
87
+ - Note the filename slug (e.g., `calm-fixing-storm.md` — likely a bug-fix plan)
88
+ - Identify recurring themes across plan titles
89
+
90
+ #### 1.6 Cross-Project CLAUDE.md Patterns
91
+
92
+ For the 5 most active projects identified in step 1.1:
93
+ - Locate the project's working directory from the path-encoded slug in `~/.claude/projects/`
94
+ - Read its `CLAUDE.md` if it exists
95
+ - Extract: key rules, repeated commands, tool preferences, workflow constraints
96
+ - Note rules that appear in 2+ project CLAUDE.md files (these are likely global preferences)
97
+
98
+ ---
99
+
100
+ ### Phase 2: Pattern Recognition
101
+
102
+ Using the data collected in Phase 1, identify patterns by category. Focus on **recurrence** — one-off requests are not patterns.
103
+
104
+ #### 2.1 Prompt Clustering
105
+
106
+ Group the prompt history by semantic similarity. Look for:
107
+ - Prompts that follow the same template structure (e.g., "Create a PRD for X", "Write tests for Y")
108
+ - Prompts that reference the same type of task across different projects
109
+ - Prompts that start with the same verbs or follow the same format
110
+
111
+ Flag any prompt pattern that appears **3 or more times** as a candidate for automation.
112
+
113
+ #### 2.2 Repeated Workflow Sequences
114
+
115
+ Look for multi-step patterns — sequences of prompts in the same session or across sessions that follow the same order:
116
+
117
+ Examples to detect:
118
+ - Always: plan then implement then test then commit
119
+ - Always: read file then understand then refactor then verify
120
+ - Always: create task then write code then write tests then PR
121
+
122
+ #### 2.3 Correction and Preference Patterns
123
+
124
+ Scan for patterns that indicate stated preferences or corrections:
125
+ - Phrases like "always", "never", "don't", "remember to", "make sure to"
126
+ - Corrections where the user had to re-prompt because the previous response didn't follow a preference
127
+ - Project-agnostic preferences that appear in multiple projects
128
+
129
+ #### 2.4 Tool and Integration Requests
130
+
131
+ Look for prompts asking Claude to:
132
+ - Access external services (GitHub, Jira, Slack, Notion, Linear, etc.)
133
+ - Search for information online
134
+ - Read/write files outside the project directory
135
+ - Run scripts or CLI tools in specific ways
136
+ - Transform data between formats (JSON to CSV, screenshot to code, etc.)
137
+
138
+ #### 2.5 Autonomy and Orchestration Requests
139
+
140
+ Look for prompts that describe **multi-step workflows** needing minimal supervision:
141
+ - "Do X, then Y, then Z"
142
+ - "Every time I do X, also do Y"
143
+ - "Check Z before you do X"
144
+ - "Run until all tasks are done"
145
+ - Any request for a loop, pipeline, or sequence with conditional steps
146
+
147
+ ---
148
+
149
+ ### Phase 3: Categorization
150
+
151
+ Sort each identified pattern into exactly one of these 4 buckets. Use the decision criteria below.
152
+
153
+ #### Bucket A: Skills
154
+ **Definition:** A repeatable thinking or writing task that can be captured as a reusable structured prompt. The output is predictable and follows a consistent format.
155
+
156
+ **Decision criteria:** Use this bucket if:
157
+ - The same prompt structure was used 3+ times
158
+ - The task produces a document, analysis, or structured artifact
159
+ - The task requires thinking/judgment but follows a known process
160
+ - No external system access required
161
+
162
+ **Examples:** Code review checklist, PRD creation, git commit message generation, explaining a codebase to a new dev, writing test plans.
163
+
164
+ #### Bucket B: Plugins / Tools
165
+ **Definition:** A task that requires access to external systems, APIs, web content, databases, or file integrations. The bottleneck is data access, not reasoning.
166
+
167
+ **Decision criteria:** Use this bucket if:
168
+ - The task requires reading from or writing to an external service
169
+ - The task requires searching the web or scraping data
170
+ - The task requires transforming data between systems
171
+ - The task would be trivially easy if Claude had the data, but currently requires the user to copy-paste
172
+
173
+ **Examples:** GitHub PR status fetcher, Jira ticket creator, Slack message summarizer, browser automation, CSV data analysis.
174
+
175
+ #### Bucket C: Agents
176
+ **Definition:** A multi-step autonomous workflow that requires decision-making, orchestration, or running until a condition is met. The value is in the automation of a sequence, not just a single step.
177
+
178
+ **Decision criteria:** Use this bucket if:
179
+ - The task involves 5+ sequential steps that are always done together
180
+ - The task requires branching logic or conditional decisions
181
+ - The task runs until a condition is met (e.g., "keep trying until tests pass")
182
+ - The task coordinates multiple tools or sessions
183
+
184
+ **Examples:** End-to-end feature implementation loop, automated code review and fix cycle, CI failure diagnosis and fix agent, multi-file refactor with test verification.
185
+
186
+ #### Bucket D: claude.md Rules
187
+ **Definition:** A rule, preference, standard, or project context that is currently being stated ad-hoc in prompts instead of being captured once in CLAUDE.md (or a per-project config).
188
+
189
+ **Decision criteria:** Use this bucket if:
190
+ - The user has stated the same rule 2+ times across sessions
191
+ - The rule could be written once and would apply to all future sessions
192
+ - The rule is about tone, format, process, or project context (not task-specific logic)
193
+
194
+ **Examples:** "Always use TypeScript strict mode", "Never commit without running tests", "Use kebab-case for file names", "This project uses Postgres not MySQL".
195
+
196
+ ---
197
+
198
+ ### Phase 4: Detailed Analysis
199
+
200
+ For **every item** identified in Phase 3, produce a structured entry:
201
+
202
+ ```
203
+ ### [Bucket] Item Name
204
+
205
+ **What I keep doing:** [1-2 sentences describing the repeated pattern]
206
+
207
+ **Why this bucket:** [1 sentence justifying the categorization]
208
+
209
+ **Frequency:** [Exact count from history, or estimate with reasoning]
210
+
211
+ **Time saved per use:** [Estimated minutes saved each time this is automated]
212
+
213
+ **Suggested implementation:**
214
+ [2-4 sentences describing what building this would look like. For skills: describe the prompt structure. For plugins: name the API or integration needed. For agents: describe the steps and decision points. For claude.md: quote the exact rule.]
215
+
216
+ **Priority:** [High / Medium / Low]
217
+ [Justify: High = frequent + high time savings + easy to build. Low = rare or hard to build.]
218
+ ```
219
+
220
+ ---
221
+
222
+ ### Phase 5: Recommendations Report
223
+
224
+ After completing Phase 4, produce the final report with these sections in order:
225
+
226
+ #### Summary Stats
227
+
228
+ ```
229
+ Sessions analyzed: [N]
230
+ Projects analyzed: [N]
231
+ Date range: [earliest] to [latest]
232
+ Total prompts reviewed: [N]
233
+ Patterns identified: [N] (Skills: N, Plugins: N, Agents: N, claude.md: N)
234
+ ```
235
+
236
+ #### Top 10 Skills to Build
237
+
238
+ Ranked by: frequency x time-saved / implementation effort.
239
+
240
+ For each, include: name, one-line description, estimated weekly time saved, priority.
241
+
242
+ #### Top 5 Plugins / Tools to Build
243
+
244
+ Ranked by: how often the user is blocked or doing manual copy-paste that a tool would eliminate.
245
+
246
+ For each, include: name, what external system it connects to, the core capability needed, priority.
247
+
248
+ #### Top 5 Agents to Build
249
+
250
+ Ranked by: how many sequential steps it automates, how often the workflow runs.
251
+
252
+ For each, include: name, the workflow it automates, estimated steps saved per run, priority.
253
+
254
+ #### Most Important Missing claude.md Sections
255
+
256
+ List the top rules/preferences that appeared repeatedly in prompts but are not yet captured in a claude.md. For each:
257
+ - The rule itself (suggested wording)
258
+ - How often it was re-stated in prompts
259
+ - Which projects it applies to (all / specific project)
260
+
261
+ #### Build-First Recommendation
262
+
263
+ Recommend the single best thing to build first. Score each item using:
264
+
265
+ ```
266
+ Score = (Impact x 3) + (Frequency x 2) + (Ease x 1)
267
+ ```
268
+
269
+ Where each dimension is rated 1-5:
270
+ - **Impact**: How much friction or time does this eliminate per use?
271
+ - **Frequency**: How often does the pattern occur per week?
272
+ - **Ease**: How quick is it to implement? (5 = under 30 min, 1 = requires significant infrastructure)
273
+
274
+ Present the top 3 scored items and explain the winner.
275
+
276
+ #### Recommended Build Order
277
+
278
+ A ranked backlog of the top 15 items across all 4 buckets, ordered by score. Format as a table:
279
+
280
+ | Rank | Type | Name | Score | Reason |
281
+ |------|------|------|-------|--------|
282
+ | 1 | Skill | ... | 22 | High frequency, easy to build |
283
+ | 2 | claude.md | ... | 20 | Stated 8x, zero effort to capture |
284
+ | ... | | | | |
285
+
286
+ ---
287
+
288
+ ## Process Rules
289
+
290
+ 1. **Read-only** — never write, modify, or delete any files in `~/.claude/`
291
+ 2. **Privacy-aware** — summarize patterns only; do not reproduce raw conversation content, API keys, passwords, or sensitive data
292
+ 3. **Subagents for data collection** — use parallel subagents in Phase 1 to read multiple data sources simultaneously; this keeps the main context from filling with raw session data
293
+ 4. **Subagents return summaries** — each subagent should return structured summaries, not raw file contents
294
+ 5. **Handle sparse data gracefully** — if `history.jsonl` has fewer than 50 entries, note this and proceed with what's available; don't fabricate patterns
295
+ 6. **Depth flag controls scope** — `--depth shallow` skips steps 1.4 and 1.6 (no session transcript sampling, no cross-project CLAUDE.md reading)
296
+ 7. **Project flag focuses analysis** — if `--project <name>` is passed, steps 1.4 and 1.6 read from that project only; steps 1.1-1.3 still cover all projects for context
297
+ 8. **No output file by default** — present the report inline; if `--output <path>` is passed, also save to that path as markdown
298
+ 9. **Minimum 3 examples** — don't put an item in Bucket A (Skills) unless you found at least 3 concrete examples; note the exact prompts that support the pattern
299
+ 10. **Frequency beats recency** — a pattern that appeared 10 times last year beats one that appeared 3 times this week
@@ -0,0 +1,113 @@
1
+ ---
2
+ name: update
3
+ description: Check for and apply scaffold updates
4
+ phase: null
5
+ order: null
6
+ dependencies: []
7
+ outputs: []
8
+ conditional: null
9
+ stateless: true
10
+ category: tool
11
+ knowledge-base: []
12
+ ---
13
+
14
+ ## Purpose
15
+
16
+ Check for and apply updates to the scaffold prompt pipeline. Detects the
17
+ installation method, fetches the latest version, shows what changed, and
18
+ applies the update.
19
+
20
+ ## Instructions
21
+
22
+ ### Step 1 — Detect Installation Method
23
+
24
+ Check which installation method is in use:
25
+
26
+ 1. Run `ls ~/.claude/commands/.scaffold-version 2>/dev/null` to check for the user-command version marker.
27
+ 2. Check if this command was invoked as `/scaffold:update` (plugin install) or `/user:update` (user command install).
28
+
29
+ Report the detected method to the user.
30
+
31
+ ### Step 2 — Fetch Latest Version
32
+
33
+ Clone or pull the latest scaffold repo:
34
+
35
+ ```bash
36
+ CACHE_DIR="$HOME/.cache/scaffold"
37
+ if [ -d "$CACHE_DIR/.git" ]; then
38
+ cd "$CACHE_DIR" && git pull origin main
39
+ else
40
+ mkdir -p "$(dirname "$CACHE_DIR")"
41
+ git clone https://github.com/zigrivers/scaffold.git "$CACHE_DIR"
42
+ fi
43
+ ```
44
+
45
+ ### Step 3 — Show What Changed
46
+
47
+ Read `~/.cache/scaffold/CHANGELOG.md` and display the entries to the user so they can see what's new.
48
+
49
+ If `~/.claude/commands/.scaffold-version` exists, read it to determine the currently installed version and highlight only the newer entries.
50
+
51
+ ### Step 4 — Apply Update
52
+
53
+ **For user command installs** (files in `~/.claude/commands/`):
54
+
55
+ Run the install script from the fetched repo to update all command files:
56
+
57
+ ```bash
58
+ bash ~/.cache/scaffold/scripts/install.sh -f
59
+ ```
60
+
61
+ Report the result to the user.
62
+
63
+ **For plugin installs** (`/scaffold:` prefix):
64
+
65
+ Update the plugin in-place by pulling the latest code into the marketplace clone:
66
+
67
+ 1. Locate the marketplace clone directory:
68
+ ```bash
69
+ PLUGIN_DIR="$HOME/.claude/plugins/marketplaces/zigrivers-scaffold"
70
+ ```
71
+
72
+ 2. Verify it exists and is a git repo. If the directory doesn't exist or has no `.git`, fall back to telling the user to run `/plugin marketplace update zigrivers-scaffold` and stop here.
73
+
74
+ 3. Record the current state before updating:
75
+ ```bash
76
+ cd "$PLUGIN_DIR" && git rev-parse --short HEAD
77
+ ```
78
+
79
+ 4. Pull the latest changes:
80
+ ```bash
81
+ cd "$PLUGIN_DIR" && git pull origin main
82
+ ```
83
+
84
+ 5. Read the new version from the plugin manifest:
85
+ ```bash
86
+ cat "$PLUGIN_DIR/.claude-plugin/plugin.json"
87
+ ```
88
+ Extract the `version` field from the JSON.
89
+
90
+ 6. **Best-effort metadata sync** — Update `~/.claude/plugins/installed_plugins.json` to keep Claude Code's metadata in sync. Read the file, find the entry for `scaffold@zigrivers-scaffold`, and update its `version`, `commitSha` (from `git rev-parse HEAD`), and `lastUpdated` (current ISO timestamp) fields. Write the updated JSON back. **Wrap this in error handling** — if reading/writing fails, skip it silently. The update still worked because commands are served directly from the clone.
91
+
92
+ 7. **Best-effort timestamp sync** — Update the `lastUpdated` field for `zigrivers-scaffold` in `~/.claude/plugins/known_marketplaces.json`. Same error handling approach — skip silently on failure.
93
+
94
+ 8. Report the result: old SHA to new SHA, old version to new version.
95
+
96
+ ### Step 5 — Confirm
97
+
98
+ After updating, tell the user:
99
+
100
+ ---
101
+ **Scaffold updated.** Run `/scaffold:prompt-pipeline` (or `/user:prompt-pipeline`) to verify the commands are working.
102
+
103
+ Check the changelog above for what's new. If any prompts you've already run were changed, you may want to re-run them.
104
+
105
+ **Note:** For plugin installs, updated commands take effect immediately for new invocations. If anything seems stale, start a fresh Claude Code session.
106
+
107
+ ---
108
+
109
+ ## Process Rules
110
+
111
+ 1. Run each step in order.
112
+ 2. Do NOT skip the changelog display — users need to see what changed.
113
+ 3. If any step fails, report the error clearly and suggest running `./scripts/update.sh` from the scaffold repo directory as a fallback.