shipwright-cli 3.2.0 → 3.3.0

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 (279) hide show
  1. package/.claude/agents/code-reviewer.md +2 -0
  2. package/.claude/agents/devops-engineer.md +2 -0
  3. package/.claude/agents/doc-fleet-agent.md +2 -0
  4. package/.claude/agents/pipeline-agent.md +2 -0
  5. package/.claude/agents/shell-script-specialist.md +2 -0
  6. package/.claude/agents/test-specialist.md +2 -0
  7. package/.claude/hooks/agent-crash-capture.sh +32 -0
  8. package/.claude/hooks/post-tool-use.sh +3 -2
  9. package/.claude/hooks/pre-tool-use.sh +35 -3
  10. package/README.md +4 -4
  11. package/claude-code/hooks/config-change.sh +18 -0
  12. package/claude-code/hooks/instructions-reloaded.sh +7 -0
  13. package/claude-code/hooks/worktree-create.sh +25 -0
  14. package/claude-code/hooks/worktree-remove.sh +20 -0
  15. package/config/code-constitution.json +130 -0
  16. package/dashboard/middleware/auth.ts +134 -0
  17. package/dashboard/middleware/constants.ts +21 -0
  18. package/dashboard/public/index.html +2 -6
  19. package/dashboard/public/styles.css +100 -97
  20. package/dashboard/routes/auth.ts +38 -0
  21. package/dashboard/server.ts +66 -25
  22. package/dashboard/services/config.ts +26 -0
  23. package/dashboard/services/db.ts +118 -0
  24. package/dashboard/src/canvas/pixel-agent.ts +298 -0
  25. package/dashboard/src/canvas/pixel-sprites.ts +440 -0
  26. package/dashboard/src/canvas/shipyard-effects.ts +367 -0
  27. package/dashboard/src/canvas/shipyard-scene.ts +616 -0
  28. package/dashboard/src/canvas/submarine-layout.ts +267 -0
  29. package/dashboard/src/components/header.ts +8 -7
  30. package/dashboard/src/core/router.ts +1 -0
  31. package/dashboard/src/design/submarine-theme.ts +253 -0
  32. package/dashboard/src/main.ts +2 -0
  33. package/dashboard/src/types/api.ts +2 -1
  34. package/dashboard/src/views/activity.ts +2 -1
  35. package/dashboard/src/views/shipyard.ts +39 -0
  36. package/dashboard/types/index.ts +166 -0
  37. package/docs/plans/2026-02-28-compound-audit-and-shipyard-design.md +186 -0
  38. package/docs/plans/2026-02-28-skipper-shipwright-implementation-plan.md +1182 -0
  39. package/docs/plans/2026-02-28-skipper-shipwright-integration-design.md +531 -0
  40. package/docs/plans/2026-03-01-ai-powered-skill-injection-design.md +298 -0
  41. package/docs/plans/2026-03-01-ai-powered-skill-injection-plan.md +1109 -0
  42. package/docs/plans/2026-03-01-capabilities-cleanup-plan.md +658 -0
  43. package/docs/plans/2026-03-01-clean-architecture-plan.md +924 -0
  44. package/docs/plans/2026-03-01-compound-audit-cascade-design.md +191 -0
  45. package/docs/plans/2026-03-01-compound-audit-cascade-plan.md +921 -0
  46. package/docs/plans/2026-03-01-deep-integration-plan.md +851 -0
  47. package/docs/plans/2026-03-01-pipeline-audit-trail-design.md +145 -0
  48. package/docs/plans/2026-03-01-pipeline-audit-trail-plan.md +770 -0
  49. package/docs/plans/2026-03-01-refined-depths-brand-design.md +382 -0
  50. package/docs/plans/2026-03-01-refined-depths-implementation.md +599 -0
  51. package/docs/plans/2026-03-01-skipper-kernel-integration-design.md +203 -0
  52. package/docs/plans/2026-03-01-unified-platform-design.md +272 -0
  53. package/docs/plans/2026-03-07-claude-code-feature-integration-design.md +189 -0
  54. package/docs/plans/2026-03-07-claude-code-feature-integration-plan.md +1165 -0
  55. package/docs/research/BACKLOG_QUICK_REFERENCE.md +352 -0
  56. package/docs/research/CUTTING_EDGE_RESEARCH_2026.md +546 -0
  57. package/docs/research/RESEARCH_INDEX.md +439 -0
  58. package/docs/research/RESEARCH_SOURCES.md +440 -0
  59. package/docs/research/RESEARCH_SUMMARY.txt +275 -0
  60. package/docs/superpowers/specs/2026-03-10-pipeline-quality-revolution-design.md +341 -0
  61. package/package.json +2 -2
  62. package/scripts/lib/adaptive-model.sh +427 -0
  63. package/scripts/lib/adaptive-timeout.sh +316 -0
  64. package/scripts/lib/audit-trail.sh +309 -0
  65. package/scripts/lib/auto-recovery.sh +471 -0
  66. package/scripts/lib/bandit-selector.sh +431 -0
  67. package/scripts/lib/bootstrap.sh +104 -2
  68. package/scripts/lib/causal-graph.sh +455 -0
  69. package/scripts/lib/compat.sh +126 -0
  70. package/scripts/lib/compound-audit.sh +337 -0
  71. package/scripts/lib/constitutional.sh +454 -0
  72. package/scripts/lib/context-budget.sh +359 -0
  73. package/scripts/lib/convergence.sh +594 -0
  74. package/scripts/lib/cost-optimizer.sh +634 -0
  75. package/scripts/lib/daemon-adaptive.sh +10 -0
  76. package/scripts/lib/daemon-dispatch.sh +106 -17
  77. package/scripts/lib/daemon-failure.sh +34 -4
  78. package/scripts/lib/daemon-patrol.sh +23 -2
  79. package/scripts/lib/daemon-poll-github.sh +361 -0
  80. package/scripts/lib/daemon-poll-health.sh +299 -0
  81. package/scripts/lib/daemon-poll.sh +27 -611
  82. package/scripts/lib/daemon-state.sh +112 -66
  83. package/scripts/lib/daemon-triage.sh +10 -0
  84. package/scripts/lib/dod-scorecard.sh +442 -0
  85. package/scripts/lib/error-actionability.sh +300 -0
  86. package/scripts/lib/formal-spec.sh +461 -0
  87. package/scripts/lib/helpers.sh +177 -4
  88. package/scripts/lib/intent-analysis.sh +409 -0
  89. package/scripts/lib/loop-convergence.sh +350 -0
  90. package/scripts/lib/loop-iteration.sh +682 -0
  91. package/scripts/lib/loop-progress.sh +48 -0
  92. package/scripts/lib/loop-restart.sh +185 -0
  93. package/scripts/lib/memory-effectiveness.sh +506 -0
  94. package/scripts/lib/mutation-executor.sh +352 -0
  95. package/scripts/lib/outcome-feedback.sh +521 -0
  96. package/scripts/lib/pipeline-cli.sh +336 -0
  97. package/scripts/lib/pipeline-commands.sh +1216 -0
  98. package/scripts/lib/pipeline-detection.sh +100 -2
  99. package/scripts/lib/pipeline-execution.sh +897 -0
  100. package/scripts/lib/pipeline-github.sh +28 -3
  101. package/scripts/lib/pipeline-intelligence-compound.sh +431 -0
  102. package/scripts/lib/pipeline-intelligence-scoring.sh +407 -0
  103. package/scripts/lib/pipeline-intelligence-skip.sh +181 -0
  104. package/scripts/lib/pipeline-intelligence.sh +100 -1136
  105. package/scripts/lib/pipeline-quality-bash-compat.sh +182 -0
  106. package/scripts/lib/pipeline-quality-checks.sh +17 -715
  107. package/scripts/lib/pipeline-quality-gates.sh +563 -0
  108. package/scripts/lib/pipeline-stages-build.sh +730 -0
  109. package/scripts/lib/pipeline-stages-delivery.sh +965 -0
  110. package/scripts/lib/pipeline-stages-intake.sh +1133 -0
  111. package/scripts/lib/pipeline-stages-monitor.sh +407 -0
  112. package/scripts/lib/pipeline-stages-review.sh +1022 -0
  113. package/scripts/lib/pipeline-stages.sh +59 -2929
  114. package/scripts/lib/pipeline-state.sh +36 -5
  115. package/scripts/lib/pipeline-util.sh +487 -0
  116. package/scripts/lib/policy-learner.sh +438 -0
  117. package/scripts/lib/process-reward.sh +493 -0
  118. package/scripts/lib/project-detect.sh +649 -0
  119. package/scripts/lib/quality-profile.sh +334 -0
  120. package/scripts/lib/recruit-commands.sh +885 -0
  121. package/scripts/lib/recruit-learning.sh +739 -0
  122. package/scripts/lib/recruit-roles.sh +648 -0
  123. package/scripts/lib/reward-aggregator.sh +458 -0
  124. package/scripts/lib/rl-optimizer.sh +362 -0
  125. package/scripts/lib/root-cause.sh +427 -0
  126. package/scripts/lib/scope-enforcement.sh +445 -0
  127. package/scripts/lib/session-restart.sh +493 -0
  128. package/scripts/lib/skill-memory.sh +300 -0
  129. package/scripts/lib/skill-registry.sh +775 -0
  130. package/scripts/lib/spec-driven.sh +476 -0
  131. package/scripts/lib/test-helpers.sh +18 -7
  132. package/scripts/lib/test-holdout.sh +429 -0
  133. package/scripts/lib/test-optimizer.sh +511 -0
  134. package/scripts/shipwright-file-suggest.sh +45 -0
  135. package/scripts/skills/adversarial-quality.md +61 -0
  136. package/scripts/skills/api-design.md +44 -0
  137. package/scripts/skills/architecture-design.md +50 -0
  138. package/scripts/skills/brainstorming.md +43 -0
  139. package/scripts/skills/data-pipeline.md +44 -0
  140. package/scripts/skills/deploy-safety.md +64 -0
  141. package/scripts/skills/documentation.md +38 -0
  142. package/scripts/skills/frontend-design.md +45 -0
  143. package/scripts/skills/generated/.gitkeep +0 -0
  144. package/scripts/skills/generated/_refinements/.gitkeep +0 -0
  145. package/scripts/skills/generated/_refinements/adversarial-quality.patch.md +3 -0
  146. package/scripts/skills/generated/_refinements/architecture-design.patch.md +3 -0
  147. package/scripts/skills/generated/_refinements/brainstorming.patch.md +3 -0
  148. package/scripts/skills/generated/cli-version-management.md +29 -0
  149. package/scripts/skills/generated/collection-system-validation.md +99 -0
  150. package/scripts/skills/generated/large-scale-c-refactoring-coordination.md +97 -0
  151. package/scripts/skills/generated/pattern-matching-similarity-scoring.md +195 -0
  152. package/scripts/skills/generated/test-parallelization-detection.md +65 -0
  153. package/scripts/skills/observability.md +79 -0
  154. package/scripts/skills/performance.md +48 -0
  155. package/scripts/skills/pr-quality.md +49 -0
  156. package/scripts/skills/product-thinking.md +43 -0
  157. package/scripts/skills/security-audit.md +49 -0
  158. package/scripts/skills/systematic-debugging.md +40 -0
  159. package/scripts/skills/testing-strategy.md +47 -0
  160. package/scripts/skills/two-stage-review.md +52 -0
  161. package/scripts/skills/validation-thoroughness.md +55 -0
  162. package/scripts/sw +9 -3
  163. package/scripts/sw-activity.sh +9 -2
  164. package/scripts/sw-adaptive.sh +2 -1
  165. package/scripts/sw-adversarial.sh +2 -1
  166. package/scripts/sw-architecture-enforcer.sh +3 -1
  167. package/scripts/sw-auth.sh +12 -2
  168. package/scripts/sw-autonomous.sh +5 -1
  169. package/scripts/sw-changelog.sh +4 -1
  170. package/scripts/sw-checkpoint.sh +2 -1
  171. package/scripts/sw-ci.sh +5 -1
  172. package/scripts/sw-cleanup.sh +4 -26
  173. package/scripts/sw-code-review.sh +10 -4
  174. package/scripts/sw-connect.sh +2 -1
  175. package/scripts/sw-context.sh +2 -1
  176. package/scripts/sw-cost.sh +48 -3
  177. package/scripts/sw-daemon.sh +66 -9
  178. package/scripts/sw-dashboard.sh +3 -1
  179. package/scripts/sw-db.sh +59 -16
  180. package/scripts/sw-decide.sh +8 -2
  181. package/scripts/sw-decompose.sh +360 -17
  182. package/scripts/sw-deps.sh +4 -1
  183. package/scripts/sw-developer-simulation.sh +4 -1
  184. package/scripts/sw-discovery.sh +325 -2
  185. package/scripts/sw-doc-fleet.sh +4 -1
  186. package/scripts/sw-docs-agent.sh +3 -1
  187. package/scripts/sw-docs.sh +2 -1
  188. package/scripts/sw-doctor.sh +453 -2
  189. package/scripts/sw-dora.sh +4 -1
  190. package/scripts/sw-durable.sh +4 -3
  191. package/scripts/sw-e2e-orchestrator.sh +17 -16
  192. package/scripts/sw-eventbus.sh +7 -1
  193. package/scripts/sw-evidence.sh +364 -12
  194. package/scripts/sw-feedback.sh +550 -9
  195. package/scripts/sw-fix.sh +20 -1
  196. package/scripts/sw-fleet-discover.sh +6 -2
  197. package/scripts/sw-fleet-viz.sh +4 -1
  198. package/scripts/sw-fleet.sh +5 -1
  199. package/scripts/sw-github-app.sh +16 -3
  200. package/scripts/sw-github-checks.sh +3 -2
  201. package/scripts/sw-github-deploy.sh +3 -2
  202. package/scripts/sw-github-graphql.sh +18 -7
  203. package/scripts/sw-guild.sh +5 -1
  204. package/scripts/sw-heartbeat.sh +5 -30
  205. package/scripts/sw-hello.sh +67 -0
  206. package/scripts/sw-hygiene.sh +6 -1
  207. package/scripts/sw-incident.sh +265 -1
  208. package/scripts/sw-init.sh +18 -2
  209. package/scripts/sw-instrument.sh +10 -2
  210. package/scripts/sw-intelligence.sh +42 -6
  211. package/scripts/sw-jira.sh +5 -1
  212. package/scripts/sw-launchd.sh +2 -1
  213. package/scripts/sw-linear.sh +4 -1
  214. package/scripts/sw-logs.sh +4 -1
  215. package/scripts/sw-loop.sh +432 -1128
  216. package/scripts/sw-memory.sh +356 -2
  217. package/scripts/sw-mission-control.sh +6 -1
  218. package/scripts/sw-model-router.sh +481 -26
  219. package/scripts/sw-otel.sh +13 -4
  220. package/scripts/sw-oversight.sh +14 -5
  221. package/scripts/sw-patrol-meta.sh +334 -0
  222. package/scripts/sw-pipeline-composer.sh +5 -1
  223. package/scripts/sw-pipeline-vitals.sh +2 -1
  224. package/scripts/sw-pipeline.sh +53 -2664
  225. package/scripts/sw-pm.sh +12 -5
  226. package/scripts/sw-pr-lifecycle.sh +2 -1
  227. package/scripts/sw-predictive.sh +7 -1
  228. package/scripts/sw-prep.sh +185 -2
  229. package/scripts/sw-ps.sh +5 -25
  230. package/scripts/sw-public-dashboard.sh +15 -3
  231. package/scripts/sw-quality.sh +2 -1
  232. package/scripts/sw-reaper.sh +8 -25
  233. package/scripts/sw-recruit.sh +156 -2303
  234. package/scripts/sw-regression.sh +19 -12
  235. package/scripts/sw-release-manager.sh +3 -1
  236. package/scripts/sw-release.sh +4 -1
  237. package/scripts/sw-remote.sh +3 -1
  238. package/scripts/sw-replay.sh +7 -1
  239. package/scripts/sw-retro.sh +158 -1
  240. package/scripts/sw-review-rerun.sh +3 -1
  241. package/scripts/sw-scale.sh +10 -3
  242. package/scripts/sw-security-audit.sh +6 -1
  243. package/scripts/sw-self-optimize.sh +6 -3
  244. package/scripts/sw-session.sh +9 -3
  245. package/scripts/sw-setup.sh +3 -1
  246. package/scripts/sw-stall-detector.sh +406 -0
  247. package/scripts/sw-standup.sh +15 -7
  248. package/scripts/sw-status.sh +3 -1
  249. package/scripts/sw-strategic.sh +4 -1
  250. package/scripts/sw-stream.sh +7 -1
  251. package/scripts/sw-swarm.sh +18 -6
  252. package/scripts/sw-team-stages.sh +13 -6
  253. package/scripts/sw-templates.sh +5 -29
  254. package/scripts/sw-testgen.sh +7 -1
  255. package/scripts/sw-tmux-pipeline.sh +4 -1
  256. package/scripts/sw-tmux-role-color.sh +2 -0
  257. package/scripts/sw-tmux-status.sh +1 -1
  258. package/scripts/sw-tmux.sh +3 -1
  259. package/scripts/sw-trace.sh +3 -1
  260. package/scripts/sw-tracker-github.sh +3 -0
  261. package/scripts/sw-tracker-jira.sh +3 -0
  262. package/scripts/sw-tracker-linear.sh +3 -0
  263. package/scripts/sw-tracker.sh +3 -1
  264. package/scripts/sw-triage.sh +2 -1
  265. package/scripts/sw-upgrade.sh +3 -1
  266. package/scripts/sw-ux.sh +5 -2
  267. package/scripts/sw-webhook.sh +3 -1
  268. package/scripts/sw-widgets.sh +3 -1
  269. package/scripts/sw-worktree.sh +15 -3
  270. package/scripts/test-skill-injection.sh +1233 -0
  271. package/templates/pipelines/autonomous.json +27 -3
  272. package/templates/pipelines/cost-aware.json +34 -8
  273. package/templates/pipelines/deployed.json +12 -0
  274. package/templates/pipelines/enterprise.json +12 -0
  275. package/templates/pipelines/fast.json +6 -0
  276. package/templates/pipelines/full.json +27 -3
  277. package/templates/pipelines/hotfix.json +6 -0
  278. package/templates/pipelines/standard.json +12 -0
  279. package/templates/pipelines/tdd.json +12 -0
@@ -0,0 +1,1165 @@
1
+ # Claude Code Feature Integration — Implementation Plan
2
+
3
+ > **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
4
+
5
+ **Goal:** Integrate all new Claude Code features (effort levels, fallback models, structured output, HTTP/prompt/agent hooks, lifecycle hooks, MCP config) into Shipwright's pipeline, daemon, and agent infrastructure.
6
+
7
+ **Architecture:** Four incremental PRs, each adding one feature category across all relevant scripts. Changes follow the existing pattern: flag parsing in CLI scripts, pass-through to `claude` CLI invocations, config generation in init/prep, validation in doctor.
8
+
9
+ **Tech Stack:** Bash 3.2, jq, JSON Schema, Claude CLI flags
10
+
11
+ ---
12
+
13
+ ## PR 1: CLI Flags Integration
14
+
15
+ ### Task 1: Add `--effort` and `--fallback-model` defaults to `sw-loop.sh`
16
+
17
+ **Files:**
18
+
19
+ - Modify: `scripts/sw-loop.sh:67-87` (defaults section)
20
+ - Modify: `scripts/sw-loop.sh:120-159` (help text)
21
+ - Modify: `scripts/sw-loop.sh:177-279` (argument parsing)
22
+
23
+ **Step 1: Add default variables after line 87**
24
+
25
+ ```bash
26
+ # After CONTEXT_BUDGET_CHARS line (~117)
27
+ EFFORT_LEVEL="${SW_EFFORT_LEVEL:-}"
28
+ FALLBACK_MODEL="${SW_FALLBACK_MODEL:-sonnet}"
29
+ ```
30
+
31
+ **Step 2: Add help text entries after the `--model` line (134)**
32
+
33
+ Add these lines in the OPTIONS section of `show_help()`:
34
+
35
+ ```bash
36
+ echo -e " ${CYAN}--effort${RESET} low|medium|high Effort level for Claude reasoning (default: auto per stage)"
37
+ echo -e " ${CYAN}--fallback-model${RESET} MODEL Fallback model on rate limits (default: sonnet)"
38
+ ```
39
+
40
+ **Step 3: Add argument parsing cases after `--model=*)` (line 207)**
41
+
42
+ ```bash
43
+ --effort)
44
+ EFFORT_LEVEL="${2:-}"
45
+ [[ -z "$EFFORT_LEVEL" ]] && { error "Missing value for --effort"; exit 1; }
46
+ shift 2
47
+ ;;
48
+ --effort=*) EFFORT_LEVEL="${1#--effort=}"; shift ;;
49
+ --fallback-model)
50
+ FALLBACK_MODEL="${2:-}"
51
+ [[ -z "$FALLBACK_MODEL" ]] && { error "Missing value for --fallback-model"; exit 1; }
52
+ shift 2
53
+ ;;
54
+ --fallback-model=*) FALLBACK_MODEL="${1#--fallback-model=}"; shift ;;
55
+ ```
56
+
57
+ **Step 4: Add validation after existing validation block (~line 325-335)**
58
+
59
+ ```bash
60
+ # Validate effort level
61
+ if [[ -n "$EFFORT_LEVEL" ]] && [[ "$EFFORT_LEVEL" != "low" && "$EFFORT_LEVEL" != "medium" && "$EFFORT_LEVEL" != "high" ]]; then
62
+ error "--effort must be low, medium, or high (got: $EFFORT_LEVEL)"
63
+ exit 1
64
+ fi
65
+ ```
66
+
67
+ **Step 5: Commit**
68
+
69
+ ```bash
70
+ git add scripts/sw-loop.sh
71
+ git commit -m "feat(loop): add --effort and --fallback-model flag parsing"
72
+ ```
73
+
74
+ ---
75
+
76
+ ### Task 2: Wire flags into `build_claude_flags()` in `lib/loop-iteration.sh`
77
+
78
+ **Files:**
79
+
80
+ - Modify: `scripts/lib/loop-iteration.sh:443-457` (build_claude_flags function)
81
+
82
+ **Step 1: Write failing test in `sw-loop-test.sh`**
83
+
84
+ Add after the existing `build_claude_flags` test (~line 218):
85
+
86
+ ```bash
87
+ echo -e "${DIM} effort level flag${RESET}"
88
+ if grep -q 'effort-level' "$SCRIPT_DIR/lib/loop-iteration.sh"; then
89
+ assert_pass "build_claude_flags supports --effort-level"
90
+ else
91
+ assert_fail "build_claude_flags supports --effort-level"
92
+ fi
93
+
94
+ echo -e "${DIM} fallback model flag${RESET}"
95
+ if grep -q 'fallback-model' "$SCRIPT_DIR/lib/loop-iteration.sh"; then
96
+ assert_pass "build_claude_flags supports --fallback-model"
97
+ else
98
+ assert_fail "build_claude_flags supports --fallback-model"
99
+ fi
100
+ ```
101
+
102
+ **Step 2: Run test to verify it fails**
103
+
104
+ Run: `bash scripts/sw-loop-test.sh 2>&1 | grep -A1 'effort-level\|fallback-model'`
105
+ Expected: FAIL lines
106
+
107
+ **Step 3: Add flags to `build_claude_flags()` in `lib/loop-iteration.sh:443-457`**
108
+
109
+ Replace the function body:
110
+
111
+ ```bash
112
+ build_claude_flags() {
113
+ local flags=()
114
+ flags+=("--model" "$MODEL")
115
+ flags+=("--output-format" "json")
116
+
117
+ if $SKIP_PERMISSIONS; then
118
+ flags+=("--dangerously-skip-permissions")
119
+ fi
120
+
121
+ if [[ -n "$MAX_TURNS" ]]; then
122
+ flags+=("--max-turns" "$MAX_TURNS")
123
+ fi
124
+
125
+ if [[ -n "${EFFORT_LEVEL:-}" ]]; then
126
+ flags+=("--effort-level" "$EFFORT_LEVEL")
127
+ fi
128
+
129
+ if [[ -n "${FALLBACK_MODEL:-}" ]]; then
130
+ flags+=("--fallback-model" "$FALLBACK_MODEL")
131
+ fi
132
+
133
+ echo "${flags[*]}"
134
+ }
135
+ ```
136
+
137
+ **Step 4: Run test to verify it passes**
138
+
139
+ Run: `bash scripts/sw-loop-test.sh 2>&1 | grep -A1 'effort-level\|fallback-model'`
140
+ Expected: PASS lines
141
+
142
+ **Step 5: Commit**
143
+
144
+ ```bash
145
+ git add scripts/lib/loop-iteration.sh scripts/sw-loop-test.sh
146
+ git commit -m "feat(loop): wire --effort-level and --fallback-model into claude flags"
147
+ ```
148
+
149
+ ---
150
+
151
+ ### Task 3: Add effort routing to pipeline stages
152
+
153
+ **Files:**
154
+
155
+ - Modify: `scripts/lib/pipeline-stages-intake.sh:374-385` (plan stage claude invocation)
156
+ - Modify: `scripts/lib/pipeline-stages-intake.sh:839-845` (design stage claude invocation)
157
+ - Modify: `scripts/lib/pipeline-stages-build.sh:361-374` (build stage loop args)
158
+ - Modify: `scripts/lib/pipeline-stages-review.sh` (review stage claude invocation)
159
+
160
+ **Step 1: Create helper function in `scripts/lib/pipeline-stages-build.sh`**
161
+
162
+ Add near the top (after sourcing, before first function):
163
+
164
+ ```bash
165
+ # Map pipeline stage to effort level (when no explicit --effort override)
166
+ _stage_effort_level() {
167
+ local stage="$1"
168
+ case "$stage" in
169
+ intake) echo "low" ;;
170
+ plan|design) echo "high" ;;
171
+ build) echo "medium" ;;
172
+ test) echo "medium" ;;
173
+ review|compound_quality) echo "high" ;;
174
+ pr|merge) echo "low" ;;
175
+ deploy|validate|monitor) echo "medium" ;;
176
+ *) echo "medium" ;;
177
+ esac
178
+ }
179
+
180
+ # Build common claude flags for pipeline stages
181
+ _pipeline_claude_flags() {
182
+ local stage="$1"
183
+ local model="$2"
184
+ local flags=("--model" "$model")
185
+
186
+ # Effort level: explicit override > per-stage default
187
+ local effort="${EFFORT_LEVEL_OVERRIDE:-$(_stage_effort_level "$stage")}"
188
+ flags+=("--effort-level" "$effort")
189
+
190
+ # Fallback model
191
+ if [[ -n "${FALLBACK_MODEL_OVERRIDE:-}" ]]; then
192
+ flags+=("--fallback-model" "$FALLBACK_MODEL_OVERRIDE")
193
+ elif [[ -n "${PIPELINE_FALLBACK_MODEL:-}" ]]; then
194
+ flags+=("--fallback-model" "$PIPELINE_FALLBACK_MODEL")
195
+ else
196
+ flags+=("--fallback-model" "sonnet")
197
+ fi
198
+
199
+ echo "${flags[*]}"
200
+ }
201
+ ```
202
+
203
+ **Step 2: Update plan stage in `pipeline-stages-intake.sh:384`**
204
+
205
+ Change:
206
+
207
+ ```bash
208
+ claude --print --model "$plan_model" --max-turns 25 --dangerously-skip-permissions \
209
+ ```
210
+
211
+ To:
212
+
213
+ ```bash
214
+ local _plan_flags
215
+ _plan_flags="$(_pipeline_claude_flags "plan" "$plan_model")"
216
+ # shellcheck disable=SC2086
217
+ claude --print $_plan_flags --max-turns 25 --dangerously-skip-permissions \
218
+ ```
219
+
220
+ **Step 3: Update design stage in `pipeline-stages-intake.sh:843`**
221
+
222
+ Same pattern — replace hardcoded `--model "$design_model"` with `$(_pipeline_claude_flags "design" "$design_model")`.
223
+
224
+ **Step 4: Pass `--effort` and `--fallback-model` through to loop in build stage**
225
+
226
+ In `pipeline-stages-build.sh`, after the `--max-restarts` line (~349), add:
227
+
228
+ ```bash
229
+ # Effort level and fallback model
230
+ [[ -n "${EFFORT_LEVEL_OVERRIDE:-}" ]] && loop_args+=(--effort "$EFFORT_LEVEL_OVERRIDE")
231
+ [[ -n "${FALLBACK_MODEL_OVERRIDE:-}" ]] && loop_args+=(--fallback-model "$FALLBACK_MODEL_OVERRIDE")
232
+ [[ -z "${FALLBACK_MODEL_OVERRIDE:-}" && -n "${PIPELINE_FALLBACK_MODEL:-}" ]] && loop_args+=(--fallback-model "$PIPELINE_FALLBACK_MODEL")
233
+ ```
234
+
235
+ **Step 5: Add `--effort` and `--fallback-model` parsing to `sw-pipeline.sh`**
236
+
237
+ Find the argument parsing section and add cases (same pattern as sw-loop.sh).
238
+
239
+ **Step 6: Commit**
240
+
241
+ ```bash
242
+ git add scripts/lib/pipeline-stages-intake.sh scripts/lib/pipeline-stages-build.sh scripts/lib/pipeline-stages-review.sh scripts/sw-pipeline.sh
243
+ git commit -m "feat(pipeline): per-stage effort routing and fallback model support"
244
+ ```
245
+
246
+ ---
247
+
248
+ ### Task 4: Add `--effort` and `--fallback-model` to `sw-fix.sh`
249
+
250
+ **Files:**
251
+
252
+ - Modify: `scripts/sw-fix.sh:53-74` (help text)
253
+ - Modify: `scripts/sw-fix.sh:79-109` (argument parsing)
254
+ - Modify: `scripts/sw-fix.sh:330-345` (command construction)
255
+
256
+ **Step 1: Add help text**
257
+
258
+ ```bash
259
+ echo -e " ${DIM}--effort level${RESET} Effort level: low, medium, high"
260
+ echo -e " ${DIM}--fallback-model model${RESET} Fallback model on rate limits (default: sonnet)"
261
+ ```
262
+
263
+ **Step 2: Add argument parsing**
264
+
265
+ ```bash
266
+ --effort)
267
+ EFFORT_LEVEL="$2"
268
+ shift 2
269
+ ;;
270
+ --fallback-model)
271
+ FALLBACK_MODEL="$2"
272
+ shift 2
273
+ ;;
274
+ ```
275
+
276
+ **Step 3: Add to command construction (~line 340)**
277
+
278
+ ```bash
279
+ [[ -n "${EFFORT_LEVEL:-}" ]] && cmd+=(--effort "$EFFORT_LEVEL")
280
+ [[ -n "${FALLBACK_MODEL:-}" ]] && cmd+=(--fallback-model "$FALLBACK_MODEL")
281
+ ```
282
+
283
+ **Step 4: Commit**
284
+
285
+ ```bash
286
+ git add scripts/sw-fix.sh
287
+ git commit -m "feat(fix): pass --effort and --fallback-model to pipelines"
288
+ ```
289
+
290
+ ---
291
+
292
+ ### Task 5: Add `fallback_model` and `effort_level` to daemon config
293
+
294
+ **Files:**
295
+
296
+ - Modify: `scripts/sw-daemon.sh` (config reading, spawn pipeline args)
297
+
298
+ **Step 1: Find where daemon reads config and spawns pipelines**
299
+
300
+ Search for where `daemon-config.json` fields are read and pipeline is spawned.
301
+
302
+ **Step 2: Add config reading**
303
+
304
+ ```bash
305
+ PIPELINE_FALLBACK_MODEL=$(_config_get "fallback_model" "sonnet" 2>/dev/null || echo "sonnet")
306
+ EFFORT_LEVEL_OVERRIDE=$(_config_get "effort_level" "" 2>/dev/null || echo "")
307
+ ```
308
+
309
+ **Step 3: Pass to spawned pipelines via env or args**
310
+
311
+ ```bash
312
+ export PIPELINE_FALLBACK_MODEL
313
+ [[ -n "$EFFORT_LEVEL_OVERRIDE" ]] && export EFFORT_LEVEL_OVERRIDE
314
+ ```
315
+
316
+ **Step 4: Commit**
317
+
318
+ ```bash
319
+ git add scripts/sw-daemon.sh
320
+ git commit -m "feat(daemon): read fallback_model and effort_level from config"
321
+ ```
322
+
323
+ ---
324
+
325
+ ### Task 6: Create JSON schemas for structured output
326
+
327
+ **Files:**
328
+
329
+ - Create: `schemas/iteration-result.json`
330
+ - Create: `schemas/audit-result.json`
331
+ - Create: `schemas/quality-gate.json`
332
+ - Create: `schemas/stage-handoff.json`
333
+
334
+ **Step 1: Create `schemas/iteration-result.json`**
335
+
336
+ ```json
337
+ {
338
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
339
+ "title": "Loop Iteration Result",
340
+ "type": "object",
341
+ "required": ["iteration", "status", "summary"],
342
+ "properties": {
343
+ "iteration": { "type": "integer" },
344
+ "status": { "enum": ["in_progress", "complete", "blocked", "failed"] },
345
+ "summary": { "type": "string", "maxLength": 500 },
346
+ "files_changed": { "type": "array", "items": { "type": "string" } },
347
+ "tests_passing": { "type": "boolean" },
348
+ "remaining_work": { "type": "array", "items": { "type": "string" } },
349
+ "blockers": { "type": "array", "items": { "type": "string" } }
350
+ }
351
+ }
352
+ ```
353
+
354
+ **Step 2: Create `schemas/audit-result.json`**
355
+
356
+ ```json
357
+ {
358
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
359
+ "title": "Audit Result",
360
+ "type": "object",
361
+ "required": ["passed", "findings"],
362
+ "properties": {
363
+ "passed": { "type": "boolean" },
364
+ "score": { "type": "integer", "minimum": 0, "maximum": 100 },
365
+ "findings": {
366
+ "type": "array",
367
+ "items": {
368
+ "type": "object",
369
+ "required": ["severity", "message"],
370
+ "properties": {
371
+ "severity": { "enum": ["critical", "warning", "info"] },
372
+ "message": { "type": "string" },
373
+ "file": { "type": "string" },
374
+ "line": { "type": "integer" }
375
+ }
376
+ }
377
+ }
378
+ }
379
+ }
380
+ ```
381
+
382
+ **Step 3: Create `schemas/quality-gate.json`**
383
+
384
+ ```json
385
+ {
386
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
387
+ "title": "Quality Gate Result",
388
+ "type": "object",
389
+ "required": ["gate", "passed", "reason"],
390
+ "properties": {
391
+ "gate": { "type": "string" },
392
+ "passed": { "type": "boolean" },
393
+ "reason": { "type": "string" },
394
+ "metrics": {
395
+ "type": "object",
396
+ "properties": {
397
+ "coverage": { "type": "number" },
398
+ "lint_errors": { "type": "integer" },
399
+ "test_failures": { "type": "integer" }
400
+ }
401
+ }
402
+ }
403
+ }
404
+ ```
405
+
406
+ **Step 4: Create `schemas/stage-handoff.json`**
407
+
408
+ ```json
409
+ {
410
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
411
+ "title": "Pipeline Stage Handoff",
412
+ "type": "object",
413
+ "required": ["from_stage", "to_stage", "summary"],
414
+ "properties": {
415
+ "from_stage": { "type": "string" },
416
+ "to_stage": { "type": "string" },
417
+ "summary": { "type": "string", "maxLength": 1000 },
418
+ "artifacts": { "type": "array", "items": { "type": "string" } },
419
+ "decisions": {
420
+ "type": "array",
421
+ "items": {
422
+ "type": "object",
423
+ "properties": {
424
+ "decision": { "type": "string" },
425
+ "rationale": { "type": "string" }
426
+ }
427
+ }
428
+ },
429
+ "risks": { "type": "array", "items": { "type": "string" } }
430
+ }
431
+ }
432
+ ```
433
+
434
+ **Step 5: Commit**
435
+
436
+ ```bash
437
+ git add schemas/
438
+ git commit -m "feat: add JSON schemas for structured agent output"
439
+ ```
440
+
441
+ ---
442
+
443
+ ### Task 7: Wire `--json-schema` into audit agent invocations
444
+
445
+ **Files:**
446
+
447
+ - Modify: `scripts/sw-loop.sh:1140-1170` (run_audit_agent function)
448
+ - Modify: `scripts/sw-loop.sh:1270-1300` (DoD evaluation)
449
+
450
+ **Step 1: Find the audit agent claude invocation (~line 1155-1161)**
451
+
452
+ Read the exact lines around the `claude -p "$audit_prompt"` call.
453
+
454
+ **Step 2: Add `--json-schema` flag**
455
+
456
+ ```bash
457
+ # Use structured output for machine-parseable audit results
458
+ local schema_file="${SCRIPT_DIR}/../schemas/audit-result.json"
459
+ if [[ -f "$schema_file" ]]; then
460
+ audit_flags+=("--json-schema" "$schema_file")
461
+ fi
462
+ ```
463
+
464
+ **Step 3: Update the result parsing to handle structured JSON**
465
+
466
+ After the `claude -p` call, parse the structured JSON instead of free-text:
467
+
468
+ ```bash
469
+ # Parse structured audit result
470
+ if [[ -f "$schema_file" ]] && command -v jq >/dev/null 2>&1; then
471
+ local audit_passed
472
+ audit_passed=$(jq -r '.passed // false' "$audit_log" 2>/dev/null || echo "false")
473
+ local audit_score
474
+ audit_score=$(jq -r '.score // 0' "$audit_log" 2>/dev/null || echo "0")
475
+ if [[ "$audit_passed" == "true" ]]; then
476
+ AUDIT_RESULT="pass"
477
+ else
478
+ AUDIT_RESULT="fail"
479
+ fi
480
+ fi
481
+ ```
482
+
483
+ **Step 4: Commit**
484
+
485
+ ```bash
486
+ git add scripts/sw-loop.sh
487
+ git commit -m "feat(loop): use --json-schema for structured audit output"
488
+ ```
489
+
490
+ ---
491
+
492
+ ## PR 2: Hook System Expansion
493
+
494
+ ### Task 8: Create WorktreeCreate hook
495
+
496
+ **Files:**
497
+
498
+ - Create: `claude-code/hooks/worktree-create.sh`
499
+
500
+ **Step 1: Create the hook script**
501
+
502
+ ```bash
503
+ #!/usr/bin/env bash
504
+ # Hook: WorktreeCreate — auto-setup worktree for pipeline agents
505
+ # Copies essential config into new worktrees so agents inherit settings
506
+ set -euo pipefail
507
+
508
+ # Read hook input from stdin (JSON with worktree path)
509
+ input=$(cat)
510
+ worktree_path=$(echo "$input" | jq -r '.worktree_path // empty' 2>/dev/null || true)
511
+
512
+ [[ -z "$worktree_path" ]] && exit 0
513
+
514
+ # Copy daemon config if it exists
515
+ src_config="$(git rev-parse --show-toplevel 2>/dev/null)/.claude/daemon-config.json"
516
+ if [[ -f "$src_config" ]]; then
517
+ mkdir -p "$worktree_path/.claude" 2>/dev/null || true
518
+ cp "$src_config" "$worktree_path/.claude/daemon-config.json" 2>/dev/null || true
519
+ fi
520
+
521
+ # Copy pipeline artifacts directory structure
522
+ src_artifacts="$(git rev-parse --show-toplevel 2>/dev/null)/.claude/pipeline-artifacts"
523
+ if [[ -d "$src_artifacts" ]]; then
524
+ mkdir -p "$worktree_path/.claude/pipeline-artifacts" 2>/dev/null || true
525
+ fi
526
+ ```
527
+
528
+ **Step 2: Make executable**
529
+
530
+ ```bash
531
+ chmod +x claude-code/hooks/worktree-create.sh
532
+ ```
533
+
534
+ **Step 3: Commit**
535
+
536
+ ```bash
537
+ git add claude-code/hooks/worktree-create.sh
538
+ git commit -m "feat(hooks): add WorktreeCreate hook for auto-setup"
539
+ ```
540
+
541
+ ---
542
+
543
+ ### Task 9: Create WorktreeRemove hook
544
+
545
+ **Files:**
546
+
547
+ - Create: `claude-code/hooks/worktree-remove.sh`
548
+
549
+ **Step 1: Create the hook script**
550
+
551
+ ```bash
552
+ #!/usr/bin/env bash
553
+ # Hook: WorktreeRemove — clean up state for removed worktree agents
554
+ set -euo pipefail
555
+
556
+ input=$(cat)
557
+ worktree_path=$(echo "$input" | jq -r '.worktree_path // empty' 2>/dev/null || true)
558
+
559
+ [[ -z "$worktree_path" ]] && exit 0
560
+
561
+ # Clean up heartbeat files associated with this worktree
562
+ heartbeat_dir="$HOME/.shipwright/heartbeats"
563
+ if [[ -d "$heartbeat_dir" ]]; then
564
+ # Find heartbeats referencing this worktree path
565
+ for hb in "$heartbeat_dir"/*.json; do
566
+ [[ -f "$hb" ]] || continue
567
+ hb_path=$(jq -r '.worktree // empty' "$hb" 2>/dev/null || true)
568
+ if [[ "$hb_path" == "$worktree_path" ]]; then
569
+ rm -f "$hb"
570
+ fi
571
+ done
572
+ fi
573
+ ```
574
+
575
+ **Step 2: Make executable and commit**
576
+
577
+ ```bash
578
+ chmod +x claude-code/hooks/worktree-remove.sh
579
+ git add claude-code/hooks/worktree-remove.sh
580
+ git commit -m "feat(hooks): add WorktreeRemove hook for cleanup"
581
+ ```
582
+
583
+ ---
584
+
585
+ ### Task 10: Create InstructionsLoaded hook (post-compaction reload)
586
+
587
+ **Files:**
588
+
589
+ - Create: `claude-code/hooks/instructions-reloaded.sh`
590
+
591
+ **Step 1: Create the hook script**
592
+
593
+ ```bash
594
+ #!/usr/bin/env bash
595
+ # Hook: InstructionsLoaded (matcher: "compact")
596
+ # After auto-compaction, ensure project conventions are re-injected
597
+ set -euo pipefail
598
+
599
+ # Log reload event for observability
600
+ mkdir -p "$HOME/.shipwright" 2>/dev/null || true
601
+ echo "{\"ts\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\",\"type\":\"instructions.reloaded\",\"trigger\":\"compaction\"}" >> "$HOME/.shipwright/events.jsonl" 2>/dev/null || true
602
+ ```
603
+
604
+ **Step 2: Commit**
605
+
606
+ ```bash
607
+ chmod +x claude-code/hooks/instructions-reloaded.sh
608
+ git add claude-code/hooks/instructions-reloaded.sh
609
+ git commit -m "feat(hooks): add InstructionsLoaded hook for post-compaction"
610
+ ```
611
+
612
+ ---
613
+
614
+ ### Task 11: Create ConfigChange hook for daemon
615
+
616
+ **Files:**
617
+
618
+ - Create: `claude-code/hooks/config-change.sh`
619
+
620
+ **Step 1: Create the hook script**
621
+
622
+ ```bash
623
+ #!/usr/bin/env bash
624
+ # Hook: ConfigChange — notify daemon of config updates
625
+ set -euo pipefail
626
+
627
+ input=$(cat)
628
+
629
+ # Log config change event
630
+ mkdir -p "$HOME/.shipwright" 2>/dev/null || true
631
+ echo "{\"ts\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\",\"type\":\"config.changed\",\"detail\":$(echo "$input" | jq -c '.' 2>/dev/null || echo '{}')}" >> "$HOME/.shipwright/events.jsonl" 2>/dev/null || true
632
+
633
+ # Signal running daemon to reload config (if PID file exists)
634
+ pid_file="$HOME/.shipwright/daemon.pid"
635
+ if [[ -f "$pid_file" ]]; then
636
+ daemon_pid=$(cat "$pid_file" 2>/dev/null || true)
637
+ if [[ -n "$daemon_pid" ]] && kill -0 "$daemon_pid" 2>/dev/null; then
638
+ kill -USR1 "$daemon_pid" 2>/dev/null || true
639
+ fi
640
+ fi
641
+ ```
642
+
643
+ **Step 2: Commit**
644
+
645
+ ```bash
646
+ chmod +x claude-code/hooks/config-change.sh
647
+ git add claude-code/hooks/config-change.sh
648
+ git commit -m "feat(hooks): add ConfigChange hook for daemon reload"
649
+ ```
650
+
651
+ ---
652
+
653
+ ### Task 12: Create PreToolUse hook for `--no-verify` prevention
654
+
655
+ **Files:**
656
+
657
+ - Modify: `.claude/hooks/pre-tool-use.sh` (add `--no-verify` check)
658
+
659
+ **Step 1: Read existing pre-tool-use.sh**
660
+
661
+ Read the full file to understand current structure.
662
+
663
+ **Step 2: Add `--no-verify` blocking**
664
+
665
+ After the existing bash 3.2 reminder logic, add:
666
+
667
+ ```bash
668
+ # Block git push --no-verify (exit code 2 = block the action)
669
+ if echo "$tool_input" | grep -qE 'git\s+push.*--no-verify'; then
670
+ echo '{"message":"Blocked: git push --no-verify bypasses safety checks. Remove --no-verify flag."}'
671
+ exit 2
672
+ fi
673
+ ```
674
+
675
+ **Step 3: Commit**
676
+
677
+ ```bash
678
+ git add .claude/hooks/pre-tool-use.sh
679
+ git commit -m "feat(hooks): block git push --no-verify via PreToolUse exit code 2"
680
+ ```
681
+
682
+ ---
683
+
684
+ ### Task 13: Register new hooks in settings.json and sw-init.sh
685
+
686
+ **Files:**
687
+
688
+ - Modify: `.claude/settings.json` (add new hook registrations)
689
+ - Modify: `scripts/sw-init.sh:558-610` (hook wiring section)
690
+
691
+ **Step 1: Add hook registrations to `.claude/settings.json`**
692
+
693
+ Add these entries to the `hooks` object:
694
+
695
+ ```json
696
+ "WorktreeCreate": [
697
+ {
698
+ "hooks": [
699
+ {
700
+ "type": "command",
701
+ "command": "~/.claude/hooks/worktree-create.sh",
702
+ "timeout": 15
703
+ }
704
+ ]
705
+ }
706
+ ],
707
+ "WorktreeRemove": [
708
+ {
709
+ "hooks": [
710
+ {
711
+ "type": "command",
712
+ "command": "~/.claude/hooks/worktree-remove.sh",
713
+ "timeout": 15
714
+ }
715
+ ]
716
+ }
717
+ ],
718
+ "InstructionsLoaded": [
719
+ {
720
+ "matcher": "compact",
721
+ "hooks": [
722
+ {
723
+ "type": "command",
724
+ "command": "~/.claude/hooks/instructions-reloaded.sh",
725
+ "timeout": 5
726
+ }
727
+ ]
728
+ }
729
+ ],
730
+ "ConfigChange": [
731
+ {
732
+ "hooks": [
733
+ {
734
+ "type": "command",
735
+ "command": "~/.claude/hooks/config-change.sh",
736
+ "timeout": 10
737
+ }
738
+ ]
739
+ }
740
+ ]
741
+ ```
742
+
743
+ **Step 2: Update sw-init.sh hook wiring to include new hooks**
744
+
745
+ The init script already iterates `claude-code/hooks/*.sh` and wires them. Verify the new hook filenames are being picked up by the existing loop. If the wiring maps hook filenames to event types, add the new mappings.
746
+
747
+ **Step 3: Commit**
748
+
749
+ ```bash
750
+ git add .claude/settings.json scripts/sw-init.sh
751
+ git commit -m "feat(hooks): register lifecycle hooks in settings.json"
752
+ ```
753
+
754
+ ---
755
+
756
+ ### Task 14: Add HTTP hook support to settings.json
757
+
758
+ **Files:**
759
+
760
+ - Modify: `.claude/settings.json`
761
+ - Modify: `scripts/sw-init.sh` (webhook URL configuration)
762
+
763
+ **Step 1: Add HTTP hook example for pipeline events**
764
+
765
+ In `settings.json`, add to the `PostToolUse` array (or create a new event like a stage completion hook):
766
+
767
+ ```json
768
+ "PostToolUse": [
769
+ {
770
+ "matcher": "Edit|Write",
771
+ "hooks": [
772
+ {
773
+ "type": "command",
774
+ "command": "jq -r '.tool_input.file_path' | xargs npx prettier --write 2>/dev/null || true"
775
+ }
776
+ ]
777
+ },
778
+ {
779
+ "matcher": "Bash",
780
+ "hooks": [
781
+ {
782
+ "type": "command",
783
+ "command": ".claude/hooks/post-tool-use.sh",
784
+ "timeout": 10
785
+ }
786
+ ]
787
+ }
788
+ ]
789
+ ```
790
+
791
+ **Step 2: Document webhook configuration in daemon-config.json**
792
+
793
+ Add to the daemon config template/documentation that users can add:
794
+
795
+ ```json
796
+ {
797
+ "webhooks": [
798
+ {
799
+ "url": "http://localhost:3000/api/events",
800
+ "events": ["pipeline.*", "build.*"],
801
+ "headers": {}
802
+ }
803
+ ]
804
+ }
805
+ ```
806
+
807
+ **Step 3: Update `sw-init.sh` to prompt for webhook URL during setup**
808
+
809
+ Add after the hook wiring section:
810
+
811
+ ```bash
812
+ # ─── Webhook Configuration ─────────────────────────────────────────────────
813
+ if [[ "${SHIPWRIGHT_WEBHOOK_URL:-}" != "" ]]; then
814
+ info "Webhook URL configured: $SHIPWRIGHT_WEBHOOK_URL"
815
+ fi
816
+ ```
817
+
818
+ **Step 4: Commit**
819
+
820
+ ```bash
821
+ git add .claude/settings.json scripts/sw-init.sh
822
+ git commit -m "feat(hooks): add HTTP hook support and webhook configuration"
823
+ ```
824
+
825
+ ---
826
+
827
+ ## PR 3: Environment & MCP Configuration
828
+
829
+ ### Task 15: Add new env vars to settings.json and init
830
+
831
+ **Files:**
832
+
833
+ - Modify: `.claude/settings.json:129-139` (env section)
834
+ - Modify: `scripts/sw-init.sh:519-528` (settings template)
835
+
836
+ **Step 1: Add env vars to `.claude/settings.json`**
837
+
838
+ Add to the `env` object:
839
+
840
+ ```json
841
+ "ENABLE_TOOL_SEARCH": "auto",
842
+ "MAX_MCP_OUTPUT_TOKENS": "50000"
843
+ ```
844
+
845
+ **Step 2: Add to sw-init.sh settings template**
846
+
847
+ In the fallback `cat > "$SETTINGS_FILE"` block (~line 519-528), add the new env vars:
848
+
849
+ ```bash
850
+ "ENABLE_TOOL_SEARCH": "auto",
851
+ "MAX_MCP_OUTPUT_TOKENS": "50000"
852
+ ```
853
+
854
+ **Step 3: Commit**
855
+
856
+ ```bash
857
+ git add .claude/settings.json scripts/sw-init.sh
858
+ git commit -m "feat(config): add ENABLE_TOOL_SEARCH and MAX_MCP_OUTPUT_TOKENS env vars"
859
+ ```
860
+
861
+ ---
862
+
863
+ ### Task 16: Generate managed-mcp.json template in sw-prep.sh
864
+
865
+ **Files:**
866
+
867
+ - Modify: `scripts/sw-prep.sh` (add new function after `prep_generate_settings`)
868
+ - Create: template content inline
869
+
870
+ **Step 1: Add function after `prep_generate_settings()` (~line 956)**
871
+
872
+ ```bash
873
+ # ─── prep_generate_managed_mcp ─────────────────────────────────────────────
874
+
875
+ prep_generate_managed_mcp() {
876
+ local filepath="$PROJECT_ROOT/.claude/managed-mcp.json"
877
+ if ! should_write "$filepath"; then return; fi
878
+
879
+ info "Generating .claude/managed-mcp.json..."
880
+
881
+ jq -n '{
882
+ "allowedMcpServers": ["*"],
883
+ "deniedMcpServers": [],
884
+ "note": "Configure MCP server access policies for pipeline agents"
885
+ }' > "$filepath"
886
+
887
+ track_file "$filepath"
888
+ success "Generated .claude/managed-mcp.json"
889
+ }
890
+ ```
891
+
892
+ **Step 2: Call the function from the main prep flow**
893
+
894
+ Find where `prep_generate_settings` is called and add `prep_generate_managed_mcp` after it.
895
+
896
+ **Step 3: Commit**
897
+
898
+ ```bash
899
+ git add scripts/sw-prep.sh
900
+ git commit -m "feat(prep): generate managed-mcp.json template"
901
+ ```
902
+
903
+ ---
904
+
905
+ ### Task 17: Create file suggestion script
906
+
907
+ **Files:**
908
+
909
+ - Create: `scripts/shipwright-file-suggest.sh`
910
+
911
+ **Step 1: Create the script**
912
+
913
+ ```bash
914
+ #!/usr/bin/env bash
915
+ # Custom file suggestion for Claude Code @ autocomplete
916
+ # Surfaces Shipwright-specific files for quick access
917
+ set -euo pipefail
918
+
919
+ PROJECT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || echo ".")
920
+
921
+ # Core config files
922
+ for f in \
923
+ ".claude/pipeline-state.md" \
924
+ ".claude/daemon-config.json" \
925
+ ".claude/fleet-config.json" \
926
+ ".claude/loop-state.md" \
927
+ ".claude/managed-mcp.json" \
928
+ ".claude/settings.json" \
929
+ ".claude/CLAUDE.md" \
930
+ "CLAUDE.md" \
931
+ "CHANGELOG.md"; do
932
+ [[ -f "$PROJECT_ROOT/$f" ]] && echo "$f"
933
+ done
934
+
935
+ # Agent definitions
936
+ for f in "$PROJECT_ROOT"/.claude/agents/*.md; do
937
+ [[ -f "$f" ]] && echo ".claude/agents/$(basename "$f")"
938
+ done
939
+
940
+ # Schemas
941
+ for f in "$PROJECT_ROOT"/schemas/*.json; do
942
+ [[ -f "$f" ]] && echo "schemas/$(basename "$f")"
943
+ done
944
+
945
+ # Pipeline artifacts (most recent)
946
+ if [[ -d "$PROJECT_ROOT/.claude/pipeline-artifacts" ]]; then
947
+ for f in plan.md design.md composed-pipeline.json; do
948
+ [[ -f "$PROJECT_ROOT/.claude/pipeline-artifacts/$f" ]] && echo ".claude/pipeline-artifacts/$f"
949
+ done
950
+ fi
951
+
952
+ # Loop logs (latest iteration)
953
+ if [[ -d "$PROJECT_ROOT/.claude/loop-logs" ]]; then
954
+ # shellcheck disable=SC2012
955
+ ls -t "$PROJECT_ROOT/.claude/loop-logs"/iteration-*.log 2>/dev/null | head -3 | while read -r f; do
956
+ echo ".claude/loop-logs/$(basename "$f")"
957
+ done
958
+ fi
959
+ ```
960
+
961
+ **Step 2: Make executable**
962
+
963
+ ```bash
964
+ chmod +x scripts/shipwright-file-suggest.sh
965
+ ```
966
+
967
+ **Step 3: Commit**
968
+
969
+ ```bash
970
+ git add scripts/shipwright-file-suggest.sh
971
+ git commit -m "feat: add file suggestion script for @ autocomplete"
972
+ ```
973
+
974
+ ---
975
+
976
+ ### Task 18: Add doctor checks for new settings
977
+
978
+ **Files:**
979
+
980
+ - Modify: `scripts/sw-doctor.sh` (add new validation section)
981
+
982
+ **Step 1: Find the last numbered check section in sw-doctor.sh**
983
+
984
+ Search for the pattern to identify where to add a new section.
985
+
986
+ **Step 2: Add validation section**
987
+
988
+ ```bash
989
+ # ─── Check N: Claude Code Feature Configuration ─────────────────────────────
990
+ echo ""
991
+ section_header "Claude Code Features"
992
+
993
+ # Check effort level if set
994
+ local _effort_val
995
+ _effort_val=$(jq -r '.env.CLAUDE_CODE_EFFORT_LEVEL // empty' "$SETTINGS_FILE" 2>/dev/null || true)
996
+ if [[ -n "$_effort_val" ]]; then
997
+ case "$_effort_val" in
998
+ low|medium|high) check_pass "Effort level: $_effort_val" ;;
999
+ *) check_fail "Invalid effort level: $_effort_val (must be low/medium/high)" ;;
1000
+ esac
1001
+ fi
1002
+
1003
+ # Check ENABLE_TOOL_SEARCH
1004
+ local _tool_search
1005
+ _tool_search=$(jq -r '.env.ENABLE_TOOL_SEARCH // empty' "$SETTINGS_FILE" 2>/dev/null || true)
1006
+ if [[ -n "$_tool_search" ]]; then
1007
+ check_pass "Tool search: $_tool_search"
1008
+ else
1009
+ check_warn "ENABLE_TOOL_SEARCH not set (recommend: auto)"
1010
+ fi
1011
+
1012
+ # Check MAX_MCP_OUTPUT_TOKENS
1013
+ local _mcp_tokens
1014
+ _mcp_tokens=$(jq -r '.env.MAX_MCP_OUTPUT_TOKENS // empty' "$SETTINGS_FILE" 2>/dev/null || true)
1015
+ if [[ -n "$_mcp_tokens" ]]; then
1016
+ check_pass "MCP output limit: $_mcp_tokens tokens"
1017
+ else
1018
+ check_warn "MAX_MCP_OUTPUT_TOKENS not set (recommend: 50000)"
1019
+ fi
1020
+
1021
+ # Check managed-mcp.json
1022
+ if [[ -f "$PROJECT_ROOT/.claude/managed-mcp.json" ]]; then
1023
+ if jq empty "$PROJECT_ROOT/.claude/managed-mcp.json" 2>/dev/null; then
1024
+ check_pass "managed-mcp.json exists and is valid JSON"
1025
+ else
1026
+ check_fail "managed-mcp.json has invalid JSON"
1027
+ fi
1028
+ fi
1029
+
1030
+ # Check schemas directory
1031
+ if [[ -d "$PROJECT_ROOT/schemas" ]]; then
1032
+ local schema_count
1033
+ schema_count=$(find "$PROJECT_ROOT/schemas" -name "*.json" 2>/dev/null | wc -l | xargs)
1034
+ check_pass "Schemas directory: ${schema_count} schema(s)"
1035
+ fi
1036
+ ```
1037
+
1038
+ **Step 3: Commit**
1039
+
1040
+ ```bash
1041
+ git add scripts/sw-doctor.sh
1042
+ git commit -m "feat(doctor): validate Claude Code feature configuration"
1043
+ ```
1044
+
1045
+ ---
1046
+
1047
+ ## PR 4: Documentation Updates
1048
+
1049
+ ### Task 19: Update .claude/CLAUDE.md with new features
1050
+
1051
+ **Files:**
1052
+
1053
+ - Modify: `.claude/CLAUDE.md` (multiple sections)
1054
+
1055
+ **Step 1: Add CLI Flags section after the "Pipeline Templates" table**
1056
+
1057
+ ````markdown
1058
+ ## CLI Flags
1059
+
1060
+ All `claude` CLI invocations in the pipeline support these flags:
1061
+
1062
+ | Flag | Default | Purpose |
1063
+ | ---------------------- | ---------------- | ------------------------------------------------------------------------------------ |
1064
+ | `--effort-level` | auto (per stage) | Reasoning depth: `low` (intake, PR), `medium` (build, test), `high` (design, review) |
1065
+ | `--fallback-model` | `sonnet` | Auto-fallback on rate limits — prevents pipeline failures |
1066
+ | `--json-schema <file>` | — | Structured output matching a schema (audit, quality gates) |
1067
+
1068
+ ### Effort Level Routing
1069
+
1070
+ | Stage | Default Effort | Rationale |
1071
+ | -------------------------------------- | -------------- | --------------------------- |
1072
+ | intake, pr, merge | low | Mechanical/formatting tasks |
1073
+ | build, test, deploy, validate, monitor | medium | Standard development work |
1074
+ | plan, design, review, compound_quality | high | Complex reasoning required |
1075
+
1076
+ Override globally: `--effort high` or via `daemon-config.json`:
1077
+
1078
+ ```json
1079
+ { "effort_level": "high", "fallback_model": "sonnet" }
1080
+ ```
1081
+ ````
1082
+
1083
+ ````
1084
+
1085
+ **Step 2: Expand Hooks section with new hook types**
1086
+
1087
+ Add subsections for HTTP hooks, prompt hooks, agent hooks, and lifecycle hooks. Document the new hooks in `claude-code/hooks/`.
1088
+
1089
+ **Step 3: Add Environment & MCP section**
1090
+
1091
+ Document `ENABLE_TOOL_SEARCH`, `MAX_MCP_OUTPUT_TOKENS`, `managed-mcp.json`, and `fileSuggestion`.
1092
+
1093
+ **Step 4: Update env vars table**
1094
+
1095
+ Add the new env vars to the existing table.
1096
+
1097
+ **Step 5: Commit**
1098
+
1099
+ ```bash
1100
+ git add .claude/CLAUDE.md
1101
+ git commit -m "docs: document CLI flags, hooks, and MCP configuration"
1102
+ ````
1103
+
1104
+ ---
1105
+
1106
+ ### Task 20: Update settings.json env section and add fileSuggestion
1107
+
1108
+ **Files:**
1109
+
1110
+ - Modify: `.claude/settings.json`
1111
+
1112
+ **Step 1: Add fileSuggestion to settings**
1113
+
1114
+ ```json
1115
+ {
1116
+ "fileSuggestion": "./scripts/shipwright-file-suggest.sh"
1117
+ }
1118
+ ```
1119
+
1120
+ **Step 2: Verify all env vars are present**
1121
+
1122
+ Ensure the `env` block has all documented vars.
1123
+
1124
+ **Step 3: Run doctor to validate**
1125
+
1126
+ ```bash
1127
+ shipwright doctor
1128
+ ```
1129
+
1130
+ **Step 4: Commit**
1131
+
1132
+ ```bash
1133
+ git add .claude/settings.json
1134
+ git commit -m "feat(config): add fileSuggestion and finalize env vars"
1135
+ ```
1136
+
1137
+ ---
1138
+
1139
+ ### Task 21: Final integration test
1140
+
1141
+ **Step 1: Run the full test suite**
1142
+
1143
+ ```bash
1144
+ npm test
1145
+ ```
1146
+
1147
+ **Step 2: Run doctor validation**
1148
+
1149
+ ```bash
1150
+ shipwright doctor
1151
+ ```
1152
+
1153
+ **Step 3: Verify help text shows new flags**
1154
+
1155
+ ```bash
1156
+ shipwright loop --help | grep -E 'effort|fallback'
1157
+ shipwright fix --help | grep -E 'effort|fallback'
1158
+ ```
1159
+
1160
+ **Step 4: Final commit and PR**
1161
+
1162
+ ```bash
1163
+ git add -A
1164
+ git commit -m "test: verify Claude Code feature integration"
1165
+ ```