clitrigger 0.1.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 (201) hide show
  1. package/.env.example +9 -0
  2. package/LICENSE +21 -0
  3. package/README.md +186 -0
  4. package/bin/clitrigger.js +106 -0
  5. package/dist/client/assets/index-BkOCv65b.css +1 -0
  6. package/dist/client/assets/index-Fbf16Lh1.js +129 -0
  7. package/dist/client/index.html +24 -0
  8. package/dist/server/db/connection.d.ts +4 -0
  9. package/dist/server/db/connection.d.ts.map +1 -0
  10. package/dist/server/db/connection.js +24 -0
  11. package/dist/server/db/connection.js.map +1 -0
  12. package/dist/server/db/queries.d.ts +265 -0
  13. package/dist/server/db/queries.d.ts.map +1 -0
  14. package/dist/server/db/queries.js +836 -0
  15. package/dist/server/db/queries.js.map +1 -0
  16. package/dist/server/db/schema.d.ts +3 -0
  17. package/dist/server/db/schema.d.ts.map +1 -0
  18. package/dist/server/db/schema.js +325 -0
  19. package/dist/server/db/schema.js.map +1 -0
  20. package/dist/server/index.d.ts +5 -0
  21. package/dist/server/index.d.ts.map +1 -0
  22. package/dist/server/index.js +207 -0
  23. package/dist/server/index.js.map +1 -0
  24. package/dist/server/middleware/auth.d.ts +5 -0
  25. package/dist/server/middleware/auth.d.ts.map +1 -0
  26. package/dist/server/middleware/auth.js +45 -0
  27. package/dist/server/middleware/auth.js.map +1 -0
  28. package/dist/server/plugins/github/index.d.ts +3 -0
  29. package/dist/server/plugins/github/index.d.ts.map +1 -0
  30. package/dist/server/plugins/github/index.js +18 -0
  31. package/dist/server/plugins/github/index.js.map +1 -0
  32. package/dist/server/plugins/github/router.d.ts +4 -0
  33. package/dist/server/plugins/github/router.d.ts.map +1 -0
  34. package/dist/server/plugins/github/router.js +250 -0
  35. package/dist/server/plugins/github/router.js.map +1 -0
  36. package/dist/server/plugins/gstack/index.d.ts +3 -0
  37. package/dist/server/plugins/gstack/index.d.ts.map +1 -0
  38. package/dist/server/plugins/gstack/index.js +36 -0
  39. package/dist/server/plugins/gstack/index.js.map +1 -0
  40. package/dist/server/plugins/jira/index.d.ts +3 -0
  41. package/dist/server/plugins/jira/index.d.ts.map +1 -0
  42. package/dist/server/plugins/jira/index.js +19 -0
  43. package/dist/server/plugins/jira/index.js.map +1 -0
  44. package/dist/server/plugins/jira/router.d.ts +4 -0
  45. package/dist/server/plugins/jira/router.d.ts.map +1 -0
  46. package/dist/server/plugins/jira/router.js +332 -0
  47. package/dist/server/plugins/jira/router.js.map +1 -0
  48. package/dist/server/plugins/notion/index.d.ts +3 -0
  49. package/dist/server/plugins/notion/index.d.ts.map +1 -0
  50. package/dist/server/plugins/notion/index.js +17 -0
  51. package/dist/server/plugins/notion/index.js.map +1 -0
  52. package/dist/server/plugins/notion/router.d.ts +4 -0
  53. package/dist/server/plugins/notion/router.d.ts.map +1 -0
  54. package/dist/server/plugins/notion/router.js +313 -0
  55. package/dist/server/plugins/notion/router.js.map +1 -0
  56. package/dist/server/plugins/registry.d.ts +8 -0
  57. package/dist/server/plugins/registry.d.ts.map +1 -0
  58. package/dist/server/plugins/registry.js +31 -0
  59. package/dist/server/plugins/registry.js.map +1 -0
  60. package/dist/server/plugins/types.d.ts +32 -0
  61. package/dist/server/plugins/types.d.ts.map +1 -0
  62. package/dist/server/plugins/types.js +2 -0
  63. package/dist/server/plugins/types.js.map +1 -0
  64. package/dist/server/resources/gstack-skills/LICENSE +21 -0
  65. package/dist/server/resources/gstack-skills/benchmark/SKILL.md +528 -0
  66. package/dist/server/resources/gstack-skills/careful/SKILL.md +59 -0
  67. package/dist/server/resources/gstack-skills/cso/SKILL.md +898 -0
  68. package/dist/server/resources/gstack-skills/investigate/SKILL.md +474 -0
  69. package/dist/server/resources/gstack-skills/qa/SKILL.md +1055 -0
  70. package/dist/server/resources/gstack-skills/qa-only/SKILL.md +672 -0
  71. package/dist/server/resources/gstack-skills/review/SKILL.md +1044 -0
  72. package/dist/server/resources/gstack-skills/skills-manifest.d.ts +9 -0
  73. package/dist/server/resources/gstack-skills/skills-manifest.d.ts.map +1 -0
  74. package/dist/server/resources/gstack-skills/skills-manifest.js +52 -0
  75. package/dist/server/resources/gstack-skills/skills-manifest.js.map +1 -0
  76. package/dist/server/resources/gstack-skills/skills-manifest.ts +59 -0
  77. package/dist/server/routes/auth.d.ts +3 -0
  78. package/dist/server/routes/auth.d.ts.map +1 -0
  79. package/dist/server/routes/auth.js +70 -0
  80. package/dist/server/routes/auth.js.map +1 -0
  81. package/dist/server/routes/debug-logs.d.ts +3 -0
  82. package/dist/server/routes/debug-logs.d.ts.map +1 -0
  83. package/dist/server/routes/debug-logs.js +43 -0
  84. package/dist/server/routes/debug-logs.js.map +1 -0
  85. package/dist/server/routes/discussions.d.ts +3 -0
  86. package/dist/server/routes/discussions.d.ts.map +1 -0
  87. package/dist/server/routes/discussions.js +544 -0
  88. package/dist/server/routes/discussions.js.map +1 -0
  89. package/dist/server/routes/execution.d.ts +3 -0
  90. package/dist/server/routes/execution.d.ts.map +1 -0
  91. package/dist/server/routes/execution.js +339 -0
  92. package/dist/server/routes/execution.js.map +1 -0
  93. package/dist/server/routes/github.d.ts +3 -0
  94. package/dist/server/routes/github.d.ts.map +1 -0
  95. package/dist/server/routes/github.js +251 -0
  96. package/dist/server/routes/github.js.map +1 -0
  97. package/dist/server/routes/images.d.ts +17 -0
  98. package/dist/server/routes/images.d.ts.map +1 -0
  99. package/dist/server/routes/images.js +152 -0
  100. package/dist/server/routes/images.js.map +1 -0
  101. package/dist/server/routes/jira.d.ts +3 -0
  102. package/dist/server/routes/jira.d.ts.map +1 -0
  103. package/dist/server/routes/jira.js +333 -0
  104. package/dist/server/routes/jira.js.map +1 -0
  105. package/dist/server/routes/logs.d.ts +3 -0
  106. package/dist/server/routes/logs.d.ts.map +1 -0
  107. package/dist/server/routes/logs.js +156 -0
  108. package/dist/server/routes/logs.js.map +1 -0
  109. package/dist/server/routes/models.d.ts +3 -0
  110. package/dist/server/routes/models.d.ts.map +1 -0
  111. package/dist/server/routes/models.js +65 -0
  112. package/dist/server/routes/models.js.map +1 -0
  113. package/dist/server/routes/notion.d.ts +3 -0
  114. package/dist/server/routes/notion.d.ts.map +1 -0
  115. package/dist/server/routes/notion.js +312 -0
  116. package/dist/server/routes/notion.js.map +1 -0
  117. package/dist/server/routes/pipelines.d.ts +3 -0
  118. package/dist/server/routes/pipelines.d.ts.map +1 -0
  119. package/dist/server/routes/pipelines.js +315 -0
  120. package/dist/server/routes/pipelines.js.map +1 -0
  121. package/dist/server/routes/plugins.d.ts +3 -0
  122. package/dist/server/routes/plugins.d.ts.map +1 -0
  123. package/dist/server/routes/plugins.js +71 -0
  124. package/dist/server/routes/plugins.js.map +1 -0
  125. package/dist/server/routes/projects.d.ts +3 -0
  126. package/dist/server/routes/projects.d.ts.map +1 -0
  127. package/dist/server/routes/projects.js +557 -0
  128. package/dist/server/routes/projects.js.map +1 -0
  129. package/dist/server/routes/schedules.d.ts +3 -0
  130. package/dist/server/routes/schedules.d.ts.map +1 -0
  131. package/dist/server/routes/schedules.js +247 -0
  132. package/dist/server/routes/schedules.js.map +1 -0
  133. package/dist/server/routes/todos.d.ts +3 -0
  134. package/dist/server/routes/todos.d.ts.map +1 -0
  135. package/dist/server/routes/todos.js +103 -0
  136. package/dist/server/routes/todos.js.map +1 -0
  137. package/dist/server/routes/tunnel.d.ts +3 -0
  138. package/dist/server/routes/tunnel.d.ts.map +1 -0
  139. package/dist/server/routes/tunnel.js +44 -0
  140. package/dist/server/routes/tunnel.js.map +1 -0
  141. package/dist/server/services/claude-manager.d.ts +42 -0
  142. package/dist/server/services/claude-manager.d.ts.map +1 -0
  143. package/dist/server/services/claude-manager.js +275 -0
  144. package/dist/server/services/claude-manager.js.map +1 -0
  145. package/dist/server/services/cli-adapters.d.ts +35 -0
  146. package/dist/server/services/cli-adapters.d.ts.map +1 -0
  147. package/dist/server/services/cli-adapters.js +139 -0
  148. package/dist/server/services/cli-adapters.js.map +1 -0
  149. package/dist/server/services/debug-logger.d.ts +35 -0
  150. package/dist/server/services/debug-logger.d.ts.map +1 -0
  151. package/dist/server/services/debug-logger.js +168 -0
  152. package/dist/server/services/debug-logger.js.map +1 -0
  153. package/dist/server/services/discussion-orchestrator.d.ts +47 -0
  154. package/dist/server/services/discussion-orchestrator.d.ts.map +1 -0
  155. package/dist/server/services/discussion-orchestrator.js +599 -0
  156. package/dist/server/services/discussion-orchestrator.js.map +1 -0
  157. package/dist/server/services/log-streamer.d.ts +45 -0
  158. package/dist/server/services/log-streamer.d.ts.map +1 -0
  159. package/dist/server/services/log-streamer.js +348 -0
  160. package/dist/server/services/log-streamer.js.map +1 -0
  161. package/dist/server/services/orchestrator.d.ts +69 -0
  162. package/dist/server/services/orchestrator.d.ts.map +1 -0
  163. package/dist/server/services/orchestrator.js +642 -0
  164. package/dist/server/services/orchestrator.js.map +1 -0
  165. package/dist/server/services/pipeline-orchestrator.d.ts +43 -0
  166. package/dist/server/services/pipeline-orchestrator.d.ts.map +1 -0
  167. package/dist/server/services/pipeline-orchestrator.js +503 -0
  168. package/dist/server/services/pipeline-orchestrator.js.map +1 -0
  169. package/dist/server/services/prompt-guard.d.ts +19 -0
  170. package/dist/server/services/prompt-guard.d.ts.map +1 -0
  171. package/dist/server/services/prompt-guard.js +43 -0
  172. package/dist/server/services/prompt-guard.js.map +1 -0
  173. package/dist/server/services/scheduler.d.ts +43 -0
  174. package/dist/server/services/scheduler.d.ts.map +1 -0
  175. package/dist/server/services/scheduler.js +199 -0
  176. package/dist/server/services/scheduler.js.map +1 -0
  177. package/dist/server/services/skill-injector.d.ts +17 -0
  178. package/dist/server/services/skill-injector.d.ts.map +1 -0
  179. package/dist/server/services/skill-injector.js +60 -0
  180. package/dist/server/services/skill-injector.js.map +1 -0
  181. package/dist/server/services/tunnel-manager.d.ts +42 -0
  182. package/dist/server/services/tunnel-manager.d.ts.map +1 -0
  183. package/dist/server/services/tunnel-manager.js +265 -0
  184. package/dist/server/services/tunnel-manager.js.map +1 -0
  185. package/dist/server/services/worktree-manager.d.ts +117 -0
  186. package/dist/server/services/worktree-manager.d.ts.map +1 -0
  187. package/dist/server/services/worktree-manager.js +400 -0
  188. package/dist/server/services/worktree-manager.js.map +1 -0
  189. package/dist/server/websocket/broadcaster.d.ts +12 -0
  190. package/dist/server/websocket/broadcaster.d.ts.map +1 -0
  191. package/dist/server/websocket/broadcaster.js +23 -0
  192. package/dist/server/websocket/broadcaster.js.map +1 -0
  193. package/dist/server/websocket/events.d.ts +94 -0
  194. package/dist/server/websocket/events.d.ts.map +1 -0
  195. package/dist/server/websocket/events.js +2 -0
  196. package/dist/server/websocket/events.js.map +1 -0
  197. package/dist/server/websocket/index.d.ts +3 -0
  198. package/dist/server/websocket/index.d.ts.map +1 -0
  199. package/dist/server/websocket/index.js +82 -0
  200. package/dist/server/websocket/index.js.map +1 -0
  201. package/package.json +68 -0
@@ -0,0 +1,474 @@
1
+ ---
2
+ name: investigate
3
+ preamble-tier: 2
4
+ version: 1.0.0
5
+ description: |
6
+ Systematic debugging with root cause investigation. Four phases: investigate,
7
+ analyze, hypothesize, implement. Iron Law: no fixes without root cause.
8
+ Use when asked to "debug this", "fix this bug", "why is this broken",
9
+ "investigate this error", or "root cause analysis".
10
+ Proactively suggest when the user reports errors, unexpected behavior, or
11
+ is troubleshooting why something stopped working.
12
+ allowed-tools:
13
+ - Bash
14
+ - Read
15
+ - Write
16
+ - Edit
17
+ - Grep
18
+ - Glob
19
+ - AskUserQuestion
20
+ - WebSearch
21
+ hooks:
22
+ PreToolUse:
23
+ - matcher: "Edit"
24
+ hooks:
25
+ - type: command
26
+ command: "bash ${CLAUDE_SKILL_DIR}/../freeze/bin/check-freeze.sh"
27
+ statusMessage: "Checking debug scope boundary..."
28
+ - matcher: "Write"
29
+ hooks:
30
+ - type: command
31
+ command: "bash ${CLAUDE_SKILL_DIR}/../freeze/bin/check-freeze.sh"
32
+ statusMessage: "Checking debug scope boundary..."
33
+ ---
34
+ <!-- AUTO-GENERATED from SKILL.md.tmpl — do not edit directly -->
35
+ <!-- Regenerate: bun run gen:skill-docs -->
36
+
37
+ ## Preamble (run first)
38
+
39
+ ```bash
40
+ _UPD=$(~/.claude/skills/gstack/bin/gstack-update-check 2>/dev/null || .claude/skills/gstack/bin/gstack-update-check 2>/dev/null || true)
41
+ [ -n "$_UPD" ] && echo "$_UPD" || true
42
+ mkdir -p ~/.gstack/sessions
43
+ touch ~/.gstack/sessions/"$PPID"
44
+ _SESSIONS=$(find ~/.gstack/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ')
45
+ find ~/.gstack/sessions -mmin +120 -type f -delete 2>/dev/null || true
46
+ _CONTRIB=$(~/.claude/skills/gstack/bin/gstack-config get gstack_contributor 2>/dev/null || true)
47
+ _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null || echo "true")
48
+ _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown")
49
+ echo "BRANCH: $_BRANCH"
50
+ echo "PROACTIVE: $_PROACTIVE"
51
+ source <(~/.claude/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true
52
+ REPO_MODE=${REPO_MODE:-unknown}
53
+ echo "REPO_MODE: $REPO_MODE"
54
+ _LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no")
55
+ echo "LAKE_INTRO: $_LAKE_SEEN"
56
+ _TEL=$(~/.claude/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true)
57
+ _TEL_PROMPTED=$([ -f ~/.gstack/.telemetry-prompted ] && echo "yes" || echo "no")
58
+ _TEL_START=$(date +%s)
59
+ _SESSION_ID="$$-$(date +%s)"
60
+ echo "TELEMETRY: ${_TEL:-off}"
61
+ echo "TEL_PROMPTED: $_TEL_PROMPTED"
62
+ mkdir -p ~/.gstack/analytics
63
+ echo '{"skill":"investigate","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true
64
+ # zsh-compatible: use find instead of glob to avoid NOMATCH error
65
+ for _PF in $(find ~/.gstack/analytics -maxdepth 1 -name '.pending-*' 2>/dev/null); do [ -f "$_PF" ] && ~/.claude/skills/gstack/bin/gstack-telemetry-log --event-type skill_run --skill _pending_finalize --outcome unknown --session-id "$_SESSION_ID" 2>/dev/null || true; break; done
66
+ ```
67
+
68
+ If `PROACTIVE` is `"false"`, do not proactively suggest gstack skills — only invoke
69
+ them when the user explicitly asks. The user opted out of proactive suggestions.
70
+
71
+ If output shows `UPGRADE_AVAILABLE <old> <new>`: read `~/.claude/skills/gstack/gstack-upgrade/SKILL.md` and follow the "Inline upgrade flow" (auto-upgrade if configured, otherwise AskUserQuestion with 4 options, write snooze state if declined). If `JUST_UPGRADED <from> <to>`: tell user "Running gstack v{to} (just updated!)" and continue.
72
+
73
+ If `LAKE_INTRO` is `no`: Before continuing, introduce the Completeness Principle.
74
+ Tell the user: "gstack follows the **Boil the Lake** principle — always do the complete
75
+ thing when AI makes the marginal cost near-zero. Read more: https://garryslist.org/posts/boil-the-ocean"
76
+ Then offer to open the essay in their default browser:
77
+
78
+ ```bash
79
+ open https://garryslist.org/posts/boil-the-ocean
80
+ touch ~/.gstack/.completeness-intro-seen
81
+ ```
82
+
83
+ Only run `open` if the user says yes. Always run `touch` to mark as seen. This only happens once.
84
+
85
+ If `TEL_PROMPTED` is `no` AND `LAKE_INTRO` is `yes`: After the lake intro is handled,
86
+ ask the user about telemetry. Use AskUserQuestion:
87
+
88
+ > Help gstack get better! Community mode shares usage data (which skills you use, how long
89
+ > they take, crash info) with a stable device ID so we can track trends and fix bugs faster.
90
+ > No code, file paths, or repo names are ever sent.
91
+ > Change anytime with `gstack-config set telemetry off`.
92
+
93
+ Options:
94
+ - A) Help gstack get better! (recommended)
95
+ - B) No thanks
96
+
97
+ If A: run `~/.claude/skills/gstack/bin/gstack-config set telemetry community`
98
+
99
+ If B: ask a follow-up AskUserQuestion:
100
+
101
+ > How about anonymous mode? We just learn that *someone* used gstack — no unique ID,
102
+ > no way to connect sessions. Just a counter that helps us know if anyone's out there.
103
+
104
+ Options:
105
+ - A) Sure, anonymous is fine
106
+ - B) No thanks, fully off
107
+
108
+ If B→A: run `~/.claude/skills/gstack/bin/gstack-config set telemetry anonymous`
109
+ If B→B: run `~/.claude/skills/gstack/bin/gstack-config set telemetry off`
110
+
111
+ Always run:
112
+ ```bash
113
+ touch ~/.gstack/.telemetry-prompted
114
+ ```
115
+
116
+ This only happens once. If `TEL_PROMPTED` is `yes`, skip this entirely.
117
+
118
+ ## AskUserQuestion Format
119
+
120
+ **ALWAYS follow this structure for every AskUserQuestion call:**
121
+ 1. **Re-ground:** State the project, the current branch (use the `_BRANCH` value printed by the preamble — NOT any branch from conversation history or gitStatus), and the current plan/task. (1-2 sentences)
122
+ 2. **Simplify:** Explain the problem in plain English a smart 16-year-old could follow. No raw function names, no internal jargon, no implementation details. Use concrete examples and analogies. Say what it DOES, not what it's called.
123
+ 3. **Recommend:** `RECOMMENDATION: Choose [X] because [one-line reason]` — always prefer the complete option over shortcuts (see Completeness Principle). Include `Completeness: X/10` for each option. Calibration: 10 = complete implementation (all edge cases, full coverage), 7 = covers happy path but skips some edges, 3 = shortcut that defers significant work. If both options are 8+, pick the higher; if one is ≤5, flag it.
124
+ 4. **Options:** Lettered options: `A) ... B) ... C) ...` — when an option involves effort, show both scales: `(human: ~X / CC: ~Y)`
125
+ 5. **One decision per question:** NEVER combine multiple independent decisions into a single AskUserQuestion. Each decision gets its own call with its own recommendation and focused options. Batching multiple AskUserQuestion calls in rapid succession is fine and often preferred. Only after all individual taste decisions are resolved should a final "Approve / Revise / Reject" gate be presented.
126
+
127
+ Assume the user hasn't looked at this window in 20 minutes and doesn't have the code open. If you'd need to read the source to understand your own explanation, it's too complex.
128
+
129
+ Per-skill instructions may add additional formatting rules on top of this baseline.
130
+
131
+ ## Completeness Principle — Boil the Lake
132
+
133
+ AI-assisted coding makes the marginal cost of completeness near-zero. When you present options:
134
+
135
+ - If Option A is the complete implementation (full parity, all edge cases, 100% coverage) and Option B is a shortcut that saves modest effort — **always recommend A**. The delta between 80 lines and 150 lines is meaningless with CC+gstack. "Good enough" is the wrong instinct when "complete" costs minutes more.
136
+ - **Lake vs. ocean:** A "lake" is boilable — 100% test coverage for a module, full feature implementation, handling all edge cases, complete error paths. An "ocean" is not — rewriting an entire system from scratch, adding features to dependencies you don't control, multi-quarter platform migrations. Recommend boiling lakes. Flag oceans as out of scope.
137
+ - **When estimating effort**, always show both scales: human team time and CC+gstack time. The compression ratio varies by task type — use this reference:
138
+
139
+ | Task type | Human team | CC+gstack | Compression |
140
+ |-----------|-----------|-----------|-------------|
141
+ | Boilerplate / scaffolding | 2 days | 15 min | ~100x |
142
+ | Test writing | 1 day | 15 min | ~50x |
143
+ | Feature implementation | 1 week | 30 min | ~30x |
144
+ | Bug fix + regression test | 4 hours | 15 min | ~20x |
145
+ | Architecture / design | 2 days | 4 hours | ~5x |
146
+ | Research / exploration | 1 day | 3 hours | ~3x |
147
+
148
+ - This principle applies to test coverage, error handling, documentation, edge cases, and feature completeness. Don't skip the last 10% to "save time" — with AI, that 10% costs seconds.
149
+
150
+ **Anti-patterns — DON'T do this:**
151
+ - BAD: "Choose B — it covers 90% of the value with less code." (If A is only 70 lines more, choose A.)
152
+ - BAD: "We can skip edge case handling to save time." (Edge case handling costs minutes with CC.)
153
+ - BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.)
154
+ - BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.")
155
+
156
+ ## Repo Ownership Mode — See Something, Say Something
157
+
158
+ `REPO_MODE` from the preamble tells you who owns issues in this repo:
159
+
160
+ - **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action.
161
+ - **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing.
162
+ - **`unknown`** — Treat as collaborative (safer default — ask before fixing).
163
+
164
+ **See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on.
165
+
166
+ Never let a noticed issue silently pass. The whole point is proactive communication.
167
+
168
+ ## Search Before Building
169
+
170
+ Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.claude/skills/gstack/ETHOS.md` for the full philosophy.
171
+
172
+ **Three layers of knowledge:**
173
+ - **Layer 1** (tried and true — in distribution). Don't reinvent the wheel. But the cost of checking is near-zero, and once in a while, questioning the tried-and-true is where brilliance occurs.
174
+ - **Layer 2** (new and popular — search for these). But scrutinize: humans are subject to mania. Search results are inputs to your thinking, not answers.
175
+ - **Layer 3** (first principles — prize these above all). Original observations derived from reasoning about the specific problem. The most valuable of all.
176
+
177
+ **Eureka moment:** When first-principles reasoning reveals conventional wisdom is wrong, name it:
178
+ "EUREKA: Everyone does X because [assumption]. But [evidence] shows this is wrong. Y is better because [reasoning]."
179
+
180
+ Log eureka moments:
181
+ ```bash
182
+ jq -n --arg ts "$(date -u +%Y-%m-%dT%H:%M:%SZ)" --arg skill "SKILL_NAME" --arg branch "$(git branch --show-current 2>/dev/null)" --arg insight "ONE_LINE_SUMMARY" '{ts:$ts,skill:$skill,branch:$branch,insight:$insight}' >> ~/.gstack/analytics/eureka.jsonl 2>/dev/null || true
183
+ ```
184
+ Replace SKILL_NAME and ONE_LINE_SUMMARY. Runs inline — don't stop the workflow.
185
+
186
+ **WebSearch fallback:** If WebSearch is unavailable, skip the search step and note: "Search unavailable — proceeding with in-distribution knowledge only."
187
+
188
+ ## Contributor Mode
189
+
190
+ If `_CONTRIB` is `true`: you are in **contributor mode**. You're a gstack user who also helps make it better.
191
+
192
+ **At the end of each major workflow step** (not after every single command), reflect on the gstack tooling you used. Rate your experience 0 to 10. If it wasn't a 10, think about why. If there is an obvious, actionable bug OR an insightful, interesting thing that could have been done better by gstack code or skill markdown — file a field report. Maybe our contributor will help make us better!
193
+
194
+ **Calibration — this is the bar:** For example, `$B js "await fetch(...)"` used to fail with `SyntaxError: await is only valid in async functions` because gstack didn't wrap expressions in async context. Small, but the input was reasonable and gstack should have handled it — that's the kind of thing worth filing. Things less consequential than this, ignore.
195
+
196
+ **NOT worth filing:** user's app bugs, network errors to user's URL, auth failures on user's site, user's own JS logic bugs.
197
+
198
+ **To file:** write `~/.gstack/contributor-logs/{slug}.md` with **all sections below** (do not truncate — include every section through the Date/Version footer):
199
+
200
+ ```
201
+ # {Title}
202
+
203
+ Hey gstack team — ran into this while using /{skill-name}:
204
+
205
+ **What I was trying to do:** {what the user/agent was attempting}
206
+ **What happened instead:** {what actually happened}
207
+ **My rating:** {0-10} — {one sentence on why it wasn't a 10}
208
+
209
+ ## Steps to reproduce
210
+ 1. {step}
211
+
212
+ ## Raw output
213
+ ```
214
+ {paste the actual error or unexpected output here}
215
+ ```
216
+
217
+ ## What would make this a 10
218
+ {one sentence: what gstack should have done differently}
219
+
220
+ **Date:** {YYYY-MM-DD} | **Version:** {gstack version} | **Skill:** /{skill}
221
+ ```
222
+
223
+ Slug: lowercase, hyphens, max 60 chars (e.g. `browse-js-no-await`). Skip if file already exists. Max 3 reports per session. File inline and continue — don't stop the workflow. Tell user: "Filed gstack field report: {title}"
224
+
225
+ ## Completion Status Protocol
226
+
227
+ When completing a skill workflow, report status using one of:
228
+ - **DONE** — All steps completed successfully. Evidence provided for each claim.
229
+ - **DONE_WITH_CONCERNS** — Completed, but with issues the user should know about. List each concern.
230
+ - **BLOCKED** — Cannot proceed. State what is blocking and what was tried.
231
+ - **NEEDS_CONTEXT** — Missing information required to continue. State exactly what you need.
232
+
233
+ ### Escalation
234
+
235
+ It is always OK to stop and say "this is too hard for me" or "I'm not confident in this result."
236
+
237
+ Bad work is worse than no work. You will not be penalized for escalating.
238
+ - If you have attempted a task 3 times without success, STOP and escalate.
239
+ - If you are uncertain about a security-sensitive change, STOP and escalate.
240
+ - If the scope of work exceeds what you can verify, STOP and escalate.
241
+
242
+ Escalation format:
243
+ ```
244
+ STATUS: BLOCKED | NEEDS_CONTEXT
245
+ REASON: [1-2 sentences]
246
+ ATTEMPTED: [what you tried]
247
+ RECOMMENDATION: [what the user should do next]
248
+ ```
249
+
250
+ ## Telemetry (run last)
251
+
252
+ After the skill workflow completes (success, error, or abort), log the telemetry event.
253
+ Determine the skill name from the `name:` field in this file's YAML frontmatter.
254
+ Determine the outcome from the workflow result (success if completed normally, error
255
+ if it failed, abort if the user interrupted).
256
+
257
+ **PLAN MODE EXCEPTION — ALWAYS RUN:** This command writes telemetry to
258
+ `~/.gstack/analytics/` (user config directory, not project files). The skill
259
+ preamble already writes to the same directory — this is the same pattern.
260
+ Skipping this command loses session duration and outcome data.
261
+
262
+ Run this bash:
263
+
264
+ ```bash
265
+ _TEL_END=$(date +%s)
266
+ _TEL_DUR=$(( _TEL_END - _TEL_START ))
267
+ rm -f ~/.gstack/analytics/.pending-"$_SESSION_ID" 2>/dev/null || true
268
+ ~/.claude/skills/gstack/bin/gstack-telemetry-log \
269
+ --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \
270
+ --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null &
271
+ ```
272
+
273
+ Replace `SKILL_NAME` with the actual skill name from frontmatter, `OUTCOME` with
274
+ success/error/abort, and `USED_BROWSE` with true/false based on whether `$B` was used.
275
+ If you cannot determine the outcome, use "unknown". This runs in the background and
276
+ never blocks the user.
277
+
278
+ ## Plan Status Footer
279
+
280
+ When you are in plan mode and about to call ExitPlanMode:
281
+
282
+ 1. Check if the plan file already has a `## GSTACK REVIEW REPORT` section.
283
+ 2. If it DOES — skip (a review skill already wrote a richer report).
284
+ 3. If it does NOT — run this command:
285
+
286
+ \`\`\`bash
287
+ ~/.claude/skills/gstack/bin/gstack-review-read
288
+ \`\`\`
289
+
290
+ Then write a `## GSTACK REVIEW REPORT` section to the end of the plan file:
291
+
292
+ - If the output contains review entries (JSONL lines before `---CONFIG---`): format the
293
+ standard report table with runs/status/findings per skill, same format as the review
294
+ skills use.
295
+ - If the output is `NO_REVIEWS` or empty: write this placeholder table:
296
+
297
+ \`\`\`markdown
298
+ ## GSTACK REVIEW REPORT
299
+
300
+ | Review | Trigger | Why | Runs | Status | Findings |
301
+ |--------|---------|-----|------|--------|----------|
302
+ | CEO Review | \`/plan-ceo-review\` | Scope & strategy | 0 | — | — |
303
+ | Codex Review | \`/codex review\` | Independent 2nd opinion | 0 | — | — |
304
+ | Eng Review | \`/plan-eng-review\` | Architecture & tests (required) | 0 | — | — |
305
+ | Design Review | \`/plan-design-review\` | UI/UX gaps | 0 | — | — |
306
+
307
+ **VERDICT:** NO REVIEWS YET — run \`/autoplan\` for full review pipeline, or individual reviews above.
308
+ \`\`\`
309
+
310
+ **PLAN MODE EXCEPTION — ALWAYS RUN:** This writes to the plan file, which is the one
311
+ file you are allowed to edit in plan mode. The plan file review report is part of the
312
+ plan's living status.
313
+
314
+ # Systematic Debugging
315
+
316
+ ## Iron Law
317
+
318
+ **NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST.**
319
+
320
+ Fixing symptoms creates whack-a-mole debugging. Every fix that doesn't address root cause makes the next bug harder to find. Find the root cause, then fix it.
321
+
322
+ ---
323
+
324
+ ## Phase 1: Root Cause Investigation
325
+
326
+ Gather context before forming any hypothesis.
327
+
328
+ 1. **Collect symptoms:** Read the error messages, stack traces, and reproduction steps. If the user hasn't provided enough context, ask ONE question at a time via AskUserQuestion.
329
+
330
+ 2. **Read the code:** Trace the code path from the symptom back to potential causes. Use Grep to find all references, Read to understand the logic.
331
+
332
+ 3. **Check recent changes:**
333
+ ```bash
334
+ git log --oneline -20 -- <affected-files>
335
+ ```
336
+ Was this working before? What changed? A regression means the root cause is in the diff.
337
+
338
+ 4. **Reproduce:** Can you trigger the bug deterministically? If not, gather more evidence before proceeding.
339
+
340
+ Output: **"Root cause hypothesis: ..."** — a specific, testable claim about what is wrong and why.
341
+
342
+ ---
343
+
344
+ ## Scope Lock
345
+
346
+ After forming your root cause hypothesis, lock edits to the affected module to prevent scope creep.
347
+
348
+ ```bash
349
+ [ -x "${CLAUDE_SKILL_DIR}/../freeze/bin/check-freeze.sh" ] && echo "FREEZE_AVAILABLE" || echo "FREEZE_UNAVAILABLE"
350
+ ```
351
+
352
+ **If FREEZE_AVAILABLE:** Identify the narrowest directory containing the affected files. Write it to the freeze state file:
353
+
354
+ ```bash
355
+ STATE_DIR="${CLAUDE_PLUGIN_DATA:-$HOME/.gstack}"
356
+ mkdir -p "$STATE_DIR"
357
+ echo "<detected-directory>/" > "$STATE_DIR/freeze-dir.txt"
358
+ echo "Debug scope locked to: <detected-directory>/"
359
+ ```
360
+
361
+ Substitute `<detected-directory>` with the actual directory path (e.g., `src/auth/`). Tell the user: "Edits restricted to `<dir>/` for this debug session. This prevents changes to unrelated code. Run `/unfreeze` to remove the restriction."
362
+
363
+ If the bug spans the entire repo or the scope is genuinely unclear, skip the lock and note why.
364
+
365
+ **If FREEZE_UNAVAILABLE:** Skip scope lock. Edits are unrestricted.
366
+
367
+ ---
368
+
369
+ ## Phase 2: Pattern Analysis
370
+
371
+ Check if this bug matches a known pattern:
372
+
373
+ | Pattern | Signature | Where to look |
374
+ |---------|-----------|---------------|
375
+ | Race condition | Intermittent, timing-dependent | Concurrent access to shared state |
376
+ | Nil/null propagation | NoMethodError, TypeError | Missing guards on optional values |
377
+ | State corruption | Inconsistent data, partial updates | Transactions, callbacks, hooks |
378
+ | Integration failure | Timeout, unexpected response | External API calls, service boundaries |
379
+ | Configuration drift | Works locally, fails in staging/prod | Env vars, feature flags, DB state |
380
+ | Stale cache | Shows old data, fixes on cache clear | Redis, CDN, browser cache, Turbo |
381
+
382
+ Also check:
383
+ - `TODOS.md` for related known issues
384
+ - `git log` for prior fixes in the same area — **recurring bugs in the same files are an architectural smell**, not a coincidence
385
+
386
+ **External pattern search:** If the bug doesn't match a known pattern above, WebSearch for:
387
+ - "{framework} {generic error type}" — **sanitize first:** strip hostnames, IPs, file paths, SQL, customer data. Search the error category, not the raw message.
388
+ - "{library} {component} known issues"
389
+
390
+ If WebSearch is unavailable, skip this search and proceed with hypothesis testing. If a documented solution or known dependency bug surfaces, present it as a candidate hypothesis in Phase 3.
391
+
392
+ ---
393
+
394
+ ## Phase 3: Hypothesis Testing
395
+
396
+ Before writing ANY fix, verify your hypothesis.
397
+
398
+ 1. **Confirm the hypothesis:** Add a temporary log statement, assertion, or debug output at the suspected root cause. Run the reproduction. Does the evidence match?
399
+
400
+ 2. **If the hypothesis is wrong:** Before forming the next hypothesis, consider searching for the error. **Sanitize first** — strip hostnames, IPs, file paths, SQL fragments, customer identifiers, and any internal/proprietary data from the error message. Search only the generic error type and framework context: "{component} {sanitized error type} {framework version}". If the error message is too specific to sanitize safely, skip the search. If WebSearch is unavailable, skip and proceed. Then return to Phase 1. Gather more evidence. Do not guess.
401
+
402
+ 3. **3-strike rule:** If 3 hypotheses fail, **STOP**. Use AskUserQuestion:
403
+ ```
404
+ 3 hypotheses tested, none match. This may be an architectural issue
405
+ rather than a simple bug.
406
+
407
+ A) Continue investigating — I have a new hypothesis: [describe]
408
+ B) Escalate for human review — this needs someone who knows the system
409
+ C) Add logging and wait — instrument the area and catch it next time
410
+ ```
411
+
412
+ **Red flags** — if you see any of these, slow down:
413
+ - "Quick fix for now" — there is no "for now." Fix it right or escalate.
414
+ - Proposing a fix before tracing data flow — you're guessing.
415
+ - Each fix reveals a new problem elsewhere — wrong layer, not wrong code.
416
+
417
+ ---
418
+
419
+ ## Phase 4: Implementation
420
+
421
+ Once root cause is confirmed:
422
+
423
+ 1. **Fix the root cause, not the symptom.** The smallest change that eliminates the actual problem.
424
+
425
+ 2. **Minimal diff:** Fewest files touched, fewest lines changed. Resist the urge to refactor adjacent code.
426
+
427
+ 3. **Write a regression test** that:
428
+ - **Fails** without the fix (proves the test is meaningful)
429
+ - **Passes** with the fix (proves the fix works)
430
+
431
+ 4. **Run the full test suite.** Paste the output. No regressions allowed.
432
+
433
+ 5. **If the fix touches >5 files:** Use AskUserQuestion to flag the blast radius:
434
+ ```
435
+ This fix touches N files. That's a large blast radius for a bug fix.
436
+ A) Proceed — the root cause genuinely spans these files
437
+ B) Split — fix the critical path now, defer the rest
438
+ C) Rethink — maybe there's a more targeted approach
439
+ ```
440
+
441
+ ---
442
+
443
+ ## Phase 5: Verification & Report
444
+
445
+ **Fresh verification:** Reproduce the original bug scenario and confirm it's fixed. This is not optional.
446
+
447
+ Run the test suite and paste the output.
448
+
449
+ Output a structured debug report:
450
+ ```
451
+ DEBUG REPORT
452
+ ════════════════════════════════════════
453
+ Symptom: [what the user observed]
454
+ Root cause: [what was actually wrong]
455
+ Fix: [what was changed, with file:line references]
456
+ Evidence: [test output, reproduction attempt showing fix works]
457
+ Regression test: [file:line of the new test]
458
+ Related: [TODOS.md items, prior bugs in same area, architectural notes]
459
+ Status: DONE | DONE_WITH_CONCERNS | BLOCKED
460
+ ════════════════════════════════════════
461
+ ```
462
+
463
+ ---
464
+
465
+ ## Important Rules
466
+
467
+ - **3+ failed fix attempts → STOP and question the architecture.** Wrong architecture, not failed hypothesis.
468
+ - **Never apply a fix you cannot verify.** If you can't reproduce and confirm, don't ship it.
469
+ - **Never say "this should fix it."** Verify and prove it. Run the tests.
470
+ - **If fix touches >5 files → AskUserQuestion** about blast radius before proceeding.
471
+ - **Completion status:**
472
+ - DONE — root cause found, fix applied, regression test written, all tests pass
473
+ - DONE_WITH_CONCERNS — fixed but cannot fully verify (e.g., intermittent bug, requires staging)
474
+ - BLOCKED — root cause unclear after investigation, escalated