gru-ai 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 (143) hide show
  1. package/.claude/skills/brainstorm/SKILL.md +340 -0
  2. package/.claude/skills/code-review-excellence/SKILL.md +198 -0
  3. package/.claude/skills/directive/SKILL.md +121 -0
  4. package/.claude/skills/directive/docs/pipeline/00-delegation-and-triage.md +181 -0
  5. package/.claude/skills/directive/docs/pipeline/01-checkpoint.md +34 -0
  6. package/.claude/skills/directive/docs/pipeline/02-read-directive.md +38 -0
  7. package/.claude/skills/directive/docs/pipeline/03-read-context.md +15 -0
  8. package/.claude/skills/directive/docs/pipeline/04-challenge.md +38 -0
  9. package/.claude/skills/directive/docs/pipeline/05-planning.md +64 -0
  10. package/.claude/skills/directive/docs/pipeline/06-technical-audit.md +88 -0
  11. package/.claude/skills/directive/docs/pipeline/07-plan-approval.md +145 -0
  12. package/.claude/skills/directive/docs/pipeline/07b-project-brainstorm.md +85 -0
  13. package/.claude/skills/directive/docs/pipeline/08-worktree-and-state.md +50 -0
  14. package/.claude/skills/directive/docs/pipeline/09-execute-projects.md +709 -0
  15. package/.claude/skills/directive/docs/pipeline/10-wrapup.md +242 -0
  16. package/.claude/skills/directive/docs/pipeline/11-completion-gate.md +75 -0
  17. package/.claude/skills/directive/docs/reference/rules/casting-rules.md +78 -0
  18. package/.claude/skills/directive/docs/reference/rules/failure-handling.md +20 -0
  19. package/.claude/skills/directive/docs/reference/rules/phase-definitions.md +42 -0
  20. package/.claude/skills/directive/docs/reference/rules/scope-and-dod.md +30 -0
  21. package/.claude/skills/directive/docs/reference/schemas/audit-output.md +44 -0
  22. package/.claude/skills/directive/docs/reference/schemas/brainstorm-output.md +52 -0
  23. package/.claude/skills/directive/docs/reference/schemas/challenger-output.md +13 -0
  24. package/.claude/skills/directive/docs/reference/schemas/checkpoint.md +18 -0
  25. package/.claude/skills/directive/docs/reference/schemas/current-json.md +5 -0
  26. package/.claude/skills/directive/docs/reference/schemas/directive-json.md +143 -0
  27. package/.claude/skills/directive/docs/reference/schemas/investigation-output.md +37 -0
  28. package/.claude/skills/directive/docs/reference/schemas/plan-schema.md +103 -0
  29. package/.claude/skills/directive/docs/reference/templates/architect-prompt.md +66 -0
  30. package/.claude/skills/directive/docs/reference/templates/auditor-prompt.md +53 -0
  31. package/.claude/skills/directive/docs/reference/templates/brainstorm-prompt.md +68 -0
  32. package/.claude/skills/directive/docs/reference/templates/challenger-prompt.md +35 -0
  33. package/.claude/skills/directive/docs/reference/templates/digest.md +134 -0
  34. package/.claude/skills/directive/docs/reference/templates/investigator-prompt.md +51 -0
  35. package/.claude/skills/directive/docs/reference/templates/planner-prompt.md +130 -0
  36. package/.claude/skills/frontend-design/SKILL.md +42 -0
  37. package/.claude/skills/gruai-agents/SKILL.md +161 -0
  38. package/.claude/skills/gruai-config/SKILL.md +61 -0
  39. package/.claude/skills/healthcheck/SKILL.md +216 -0
  40. package/.claude/skills/report/SKILL.md +380 -0
  41. package/.claude/skills/scout/SKILL.md +452 -0
  42. package/.claude/skills/seo-audit/SKILL.md +107 -0
  43. package/.claude/skills/walkthrough/SKILL.md +274 -0
  44. package/.claude/skills/webapp-testing/SKILL.md +96 -0
  45. package/LICENSE +21 -0
  46. package/README.md +206 -0
  47. package/cli/templates/CLAUDE.md.template +57 -0
  48. package/cli/templates/agent-roles/backend.md +47 -0
  49. package/cli/templates/agent-roles/cmo.md +52 -0
  50. package/cli/templates/agent-roles/content.md +48 -0
  51. package/cli/templates/agent-roles/coo.md +66 -0
  52. package/cli/templates/agent-roles/cpo.md +52 -0
  53. package/cli/templates/agent-roles/cto.md +63 -0
  54. package/cli/templates/agent-roles/data.md +46 -0
  55. package/cli/templates/agent-roles/design.md +46 -0
  56. package/cli/templates/agent-roles/frontend.md +47 -0
  57. package/cli/templates/agent-roles/fullstack.md +47 -0
  58. package/cli/templates/agent-roles/qa.md +46 -0
  59. package/cli/templates/backlog.json.template +3 -0
  60. package/cli/templates/directive.json.template +9 -0
  61. package/cli/templates/directive.md.template +23 -0
  62. package/cli/templates/goals-index.md +21 -0
  63. package/cli/templates/gruai.config.json.template +12 -0
  64. package/cli/templates/lessons.md +16 -0
  65. package/cli/templates/vision.md +35 -0
  66. package/cli/templates/welcome-directive/directive.json +9 -0
  67. package/cli/templates/welcome-directive/directive.md +53 -0
  68. package/dist/assets/GamePage-C5XQQOQH.js +49 -0
  69. package/dist/assets/README.md +17 -0
  70. package/dist/assets/characters/char_0.png +0 -0
  71. package/dist/assets/characters/char_1.png +0 -0
  72. package/dist/assets/characters/char_10.png +0 -0
  73. package/dist/assets/characters/char_11.png +0 -0
  74. package/dist/assets/characters/char_2.png +0 -0
  75. package/dist/assets/characters/char_3.png +0 -0
  76. package/dist/assets/characters/char_4.png +0 -0
  77. package/dist/assets/characters/char_5.png +0 -0
  78. package/dist/assets/characters/char_6.png +0 -0
  79. package/dist/assets/characters/char_7.png +0 -0
  80. package/dist/assets/characters/char_8.png +0 -0
  81. package/dist/assets/characters/char_9.png +0 -0
  82. package/dist/assets/index-CnTPDqpP.js +12 -0
  83. package/dist/assets/index-gR5q7ikB.css +1 -0
  84. package/dist/assets/office/furniture.png +0 -0
  85. package/dist/assets/office/room-builder.png +0 -0
  86. package/dist/index.html +16 -0
  87. package/dist-server/scripts/intelligence-trends.d.ts +100 -0
  88. package/dist-server/scripts/intelligence-trends.js +365 -0
  89. package/dist-server/server/actions/cleanup.d.ts +4 -0
  90. package/dist-server/server/actions/cleanup.js +30 -0
  91. package/dist-server/server/actions/send-input.d.ts +6 -0
  92. package/dist-server/server/actions/send-input.js +147 -0
  93. package/dist-server/server/actions/terminal.d.ts +4 -0
  94. package/dist-server/server/actions/terminal.js +427 -0
  95. package/dist-server/server/config.d.ts +9 -0
  96. package/dist-server/server/config.js +217 -0
  97. package/dist-server/server/db.d.ts +7 -0
  98. package/dist-server/server/db.js +79 -0
  99. package/dist-server/server/hooks/event-receiver.d.ts +11 -0
  100. package/dist-server/server/hooks/event-receiver.js +36 -0
  101. package/dist-server/server/index.d.ts +1 -0
  102. package/dist-server/server/index.js +552 -0
  103. package/dist-server/server/notifications/macos.d.ts +5 -0
  104. package/dist-server/server/notifications/macos.js +22 -0
  105. package/dist-server/server/notifications/notifier.d.ts +17 -0
  106. package/dist-server/server/notifications/notifier.js +110 -0
  107. package/dist-server/server/parsers/process-discovery.d.ts +39 -0
  108. package/dist-server/server/parsers/process-discovery.js +776 -0
  109. package/dist-server/server/parsers/session-scanner.d.ts +56 -0
  110. package/dist-server/server/parsers/session-scanner.js +390 -0
  111. package/dist-server/server/parsers/session-state.d.ts +68 -0
  112. package/dist-server/server/parsers/session-state.js +696 -0
  113. package/dist-server/server/parsers/session-state.test.d.ts +1 -0
  114. package/dist-server/server/parsers/session-state.test.js +950 -0
  115. package/dist-server/server/parsers/task-parser.d.ts +10 -0
  116. package/dist-server/server/parsers/task-parser.js +97 -0
  117. package/dist-server/server/parsers/team-parser.d.ts +3 -0
  118. package/dist-server/server/parsers/team-parser.js +67 -0
  119. package/dist-server/server/platform/__tests__/claude-code.test.d.ts +1 -0
  120. package/dist-server/server/platform/__tests__/claude-code.test.js +311 -0
  121. package/dist-server/server/platform/claude-code.d.ts +34 -0
  122. package/dist-server/server/platform/claude-code.js +94 -0
  123. package/dist-server/server/platform/index.d.ts +5 -0
  124. package/dist-server/server/platform/index.js +1 -0
  125. package/dist-server/server/platform/types.d.ts +190 -0
  126. package/dist-server/server/platform/types.js +9 -0
  127. package/dist-server/server/state/aggregator.d.ts +42 -0
  128. package/dist-server/server/state/aggregator.js +1080 -0
  129. package/dist-server/server/state/work-item-types.d.ts +555 -0
  130. package/dist-server/server/state/work-item-types.js +168 -0
  131. package/dist-server/server/types.d.ts +237 -0
  132. package/dist-server/server/types.js +1 -0
  133. package/dist-server/server/watchers/claude-watcher.d.ts +17 -0
  134. package/dist-server/server/watchers/claude-watcher.js +130 -0
  135. package/dist-server/server/watchers/context-watcher.d.ts +22 -0
  136. package/dist-server/server/watchers/context-watcher.js +125 -0
  137. package/dist-server/server/watchers/directive-watcher.d.ts +46 -0
  138. package/dist-server/server/watchers/directive-watcher.js +497 -0
  139. package/dist-server/server/watchers/session-watcher.d.ts +18 -0
  140. package/dist-server/server/watchers/session-watcher.js +126 -0
  141. package/dist-server/server/watchers/state-watcher.d.ts +36 -0
  142. package/dist-server/server/watchers/state-watcher.js +369 -0
  143. package/package.json +68 -0
@@ -0,0 +1,340 @@
1
+ ---
2
+ name: "brainstorm"
3
+ description: "Structured brainstorm — from quick Socratic refinement to full C-suite strategy sessions. The missing step before /directive: figure out WHAT to do before telling agents to DO it. Takes a question or topic as argument."
4
+ ---
5
+
6
+ # Brainstorm — Structured Strategic Thinking
7
+
8
+ ## Role Resolution
9
+
10
+ Read `.claude/agent-registry.json` to map roles to agent names. Use each agent's `id` as the `subagent_type` when spawning. The COO = operations/orchestration, the CTO = architecture/technical, the CPO = product/UX, the CMO = growth/marketing.
11
+
12
+ ---
13
+
14
+ The CEO has a question: $ARGUMENTS
15
+
16
+ ## Step 0: Triage
17
+
18
+ Read the question. Classify it before doing anything else.
19
+
20
+ **Lightweight** — single agent, Socratic dialogue, no external research:
21
+ - Focused design question ("how should I structure this component?")
22
+ - Single-domain topic (just architecture, or just UX, or just process)
23
+ - Answer can be reached in one conversation
24
+ - No cross-cutting impact (doesn't change multiple systems)
25
+
26
+ **Heavyweight** — multi-agent parallel research, synthesis, options:
27
+ - Strategic question affecting multiple systems ("how should goal tracking work?")
28
+ - Crosses domains (architecture + UX + operations)
29
+ - Needs external research (how do others solve this?)
30
+ - Decision has lasting consequences (data models, project structure, user flows)
31
+
32
+ State the classification:
33
+ ```
34
+ Classification: {lightweight | heavyweight}
35
+ Reasoning: {one sentence}
36
+ ```
37
+
38
+ ---
39
+
40
+ ## Lightweight Path — Socratic Refinement
41
+
42
+ For focused questions. One agent, interactive dialogue. Think 5-minute whiteboard chat.
43
+
44
+ **Pick the right agent** based on the question domain:
45
+ - Architecture / data model → the CTO
46
+ - User experience / product → the CPO
47
+ - Process / operations → the COO
48
+ - Growth / positioning → the CMO
49
+
50
+ Spawn the agent (using the registry's `id` as `subagent_type`) with:
51
+ - Their personality file (auto-loaded via `subagent_type`)
52
+ - The CEO's question
53
+ - `.context/vision.md` and `.context/preferences.md`
54
+ - Relevant files the question touches
55
+
56
+ ```
57
+ You are {Name}, {Title}. The CEO wants to think through a design question with you.
58
+
59
+ QUESTION: {question}
60
+
61
+ Your job: Socratic refinement. Don't jump to an answer. Instead:
62
+
63
+ 1. CLARIFY — Ask 2-3 sharpening questions to make sure you understand what the CEO really needs. What are the constraints? What matters most? What have they already considered?
64
+
65
+ 2. EXPLORE — Once you understand, propose 2 options with clear trade-offs. Be opinionated. "I'd go with A because..." not "both have merit."
66
+
67
+ 3. DETAIL — After the CEO picks a direction, flesh it out: what changes, what the structure looks like, what to watch out for.
68
+
69
+ Keep it conversational. Short responses. This is a dialogue, not a report.
70
+
71
+ CRITICAL OUTPUT FORMAT: JSON only. First character `{`, last `}`.
72
+
73
+ {
74
+ "agent": "{name}",
75
+ "clarifying_questions": ["question 1", "question 2", "question 3"],
76
+ "initial_instinct": "Your gut reaction to the question in 1-2 sentences"
77
+ }
78
+ ```
79
+
80
+ **After the agent asks questions**, present them to the CEO via AskUserQuestion or as text. Let the CEO answer. Then re-spawn the agent (or resume) with the answers to get the options.
81
+
82
+ **Final output:** Write a brief design note to `.context/directives/{relevant-directive}/brainstorm.md` capturing the decision. Keep it short — this is a lightweight brainstorm, not a design doc.
83
+
84
+ **If the question turns out to be bigger than expected** (agent's questions reveal cross-cutting complexity), upgrade to heavyweight. Tell the CEO: "This is bigger than it looked — upgrading to full brainstorm."
85
+
86
+ ---
87
+
88
+ ## Heavyweight Path — Multi-Agent Strategy Session
89
+
90
+ For strategic questions. Full C-suite, parallel research, synthesis, options.
91
+
92
+ **The pattern:** Diverge (independent perspectives) → Converge (synthesize options) → Decide (CEO picks) → Capture (design doc).
93
+
94
+ ## Step 1: Frame the Question
95
+
96
+ Read the CEO's question. If it's vague, clarify it with AskUserQuestion before proceeding.
97
+
98
+ Read context:
99
+ - `.context/vision.md` — current north star
100
+ - `.context/preferences.md` — CEO preferences
101
+ - `.context/goals/*/goal.json` — current goal structure
102
+ - `.context/lessons/scenarios.md` — standing user scenarios (if relevant)
103
+
104
+ Frame the question as a clear design challenge:
105
+ - **What we're deciding**: one sentence
106
+ - **Why it matters**: what breaks if we get this wrong
107
+ - **Constraints**: non-negotiables from vision.md or preferences.md
108
+ - **Current state**: how things work today (brief)
109
+
110
+ Show the framing to the CEO before spawning agents. This prevents wasted work on a misunderstood question.
111
+
112
+ ## Step 2: Diverge — Independent Perspectives
113
+
114
+ Spawn 2-3 C-suite agents **in parallel**. Pick the most relevant agents for the question domain:
115
+
116
+ - **Architecture / data model / system design** → the CTO
117
+ - **User experience / product design / workflows** → the CPO
118
+ - **Operations / process / project structure** → the COO
119
+ - **Growth / positioning / external patterns** → the CMO
120
+
121
+ **Always include the COO** (they synthesize in Step 3). Pick 1-2 others based on the question.
122
+
123
+ Each agent receives:
124
+ - Their personality from `.claude/agents/{name}.md`
125
+ - The framed question from Step 1
126
+ - `.context/vision.md` and `.context/preferences.md`
127
+ - Relevant context files (goal structure, current system docs, etc.)
128
+ - These instructions:
129
+
130
+ ```
131
+ You are {Name}, {Title}. The CEO is brainstorming a strategic question and wants your independent perspective.
132
+
133
+ QUESTION: {framed question}
134
+ CURRENT STATE: {how it works today}
135
+ CONSTRAINTS: {non-negotiables}
136
+
137
+ Your job:
138
+ 1. RESEARCH first — use WebSearch if external patterns would help (how do other tools/frameworks handle this?). Use Read/Grep/Glob if you need to understand the current system.
139
+ 2. THINK from your domain expertise — what matters most from your perspective?
140
+ 3. PROPOSE — give 1-2 concrete options with trade-offs. Don't hedge. Have an opinion.
141
+
142
+ Structure your response:
143
+
144
+ {
145
+ "agent": "{name}",
146
+ "perspective": "Your 2-3 sentence framing of the problem from your domain",
147
+ "research": [
148
+ {
149
+ "finding": "What you found externally or internally",
150
+ "source": "URL or file path",
151
+ "relevance": "Why it matters to this question"
152
+ }
153
+ ],
154
+ "proposals": [
155
+ {
156
+ "name": "short-name",
157
+ "summary": "One paragraph describing the approach",
158
+ "pros": ["advantage 1", "advantage 2"],
159
+ "cons": ["disadvantage 1", "disadvantage 2"],
160
+ "effort": "quick (hours) | medium (days) | large (weeks)",
161
+ "opinion": "Why you'd pick this one (or not)"
162
+ }
163
+ ],
164
+ "non_negotiables": ["Things that MUST be true regardless of which option we pick"],
165
+ "watch_outs": ["Risks or gotchas the CEO should know about"]
166
+ }
167
+
168
+ CRITICAL: First character `{`, last character `}`. JSON only. Have a STRONG opinion — the CEO wants perspectives, not waffling.
169
+ ```
170
+
171
+ All agents: `subagent_type: "general-purpose"`, `model: "opus"`.
172
+
173
+ ## Step 3: Converge — COO Synthesizes
174
+
175
+ After all agents return, spawn the COO with a synthesis task.
176
+
177
+ The COO receives:
178
+ - Their personality
179
+ - All agent outputs from Step 2
180
+ - The original framed question
181
+ - Vision + preferences
182
+
183
+ ```
184
+ You are the COO. The team has brainstormed independently. Your job: synthesize their perspectives into 2-3 clear OPTIONS for the CEO to choose from.
185
+
186
+ AGENT PERSPECTIVES:
187
+ {all agent outputs}
188
+
189
+ SYNTHESIS RULES:
190
+ 1. Find the OVERLAPS — where do agents agree? This is the foundation.
191
+ 2. Find the CONFLICTS — where do they disagree? These are the real decision points.
192
+ 3. Design 2-3 OPTIONS that represent genuinely different approaches (not just variations).
193
+ 4. For each option, be honest about trade-offs. Don't create a strawman "bad option" to make one look good.
194
+ 5. Include a "COO'S PICK" — your recommendation with reasoning.
195
+ 6. Include the NON-NEGOTIABLES that all agents agreed on (these apply regardless of option).
196
+
197
+ {
198
+ "agreements": ["Things all agents agreed on — the foundation"],
199
+ "tensions": [
200
+ {
201
+ "topic": "What they disagree about",
202
+ "positions": {"sarah": "her view", "marcus": "his view"},
203
+ "why_it_matters": "What depends on this decision"
204
+ }
205
+ ],
206
+ "options": [
207
+ {
208
+ "name": "Option A: descriptive name",
209
+ "summary": "2-3 sentence description",
210
+ "inspired_by": ["which agent roles/perspectives contributed"],
211
+ "pros": ["advantages"],
212
+ "cons": ["disadvantages"],
213
+ "effort": "quick | medium | large",
214
+ "best_when": "This option is best if the CEO values X over Y"
215
+ }
216
+ ],
217
+ "non_negotiables": ["Must be true regardless of option chosen"],
218
+ "coo_pick": {
219
+ "option": "Option name",
220
+ "reasoning": "Why — in 2-3 sentences"
221
+ }
222
+ }
223
+
224
+ CRITICAL: First character `{`, last character `}`. JSON only.
225
+ ```
226
+
227
+ ## Step 4: Present to CEO
228
+
229
+ Present the synthesized options in a readable format:
230
+
231
+ ```
232
+ # Brainstorm: {question title}
233
+
234
+ ## The Team Agrees On
235
+ {non-negotiables — things that are true regardless of direction}
236
+
237
+ ## The Key Tensions
238
+ {where agents disagreed — these are the real decisions}
239
+
240
+ ## Options
241
+
242
+ ### Option A: {name}
243
+ {summary}
244
+ **Pros:** {list}
245
+ **Cons:** {list}
246
+ **Effort:** {estimate}
247
+ **Best if:** {when to pick this}
248
+
249
+ ### Option B: {name}
250
+ ...
251
+
252
+ ### Option C: {name} (if applicable)
253
+ ...
254
+
255
+ ## COO's Recommendation
256
+ {COO's pick and reasoning}
257
+
258
+ ## Research Highlights
259
+ {Most interesting external findings from agents — URLs included}
260
+ ```
261
+
262
+ Ask the CEO using AskUserQuestion:
263
+ - Option A / Option B / Option C / "Hybrid — let me explain"
264
+
265
+ ## Step 5: Capture Decision
266
+
267
+ After the CEO decides:
268
+
269
+ 1. **Write a design doc** to `.context/directives/{relevant-directive}/brainstorm.md`:
270
+ ```markdown
271
+ # {Question Title}
272
+ Date: {date}
273
+ Decision: {chosen option}
274
+ Participants: {agents involved}
275
+
276
+ ## Context
277
+ {framed question + why it matters}
278
+
279
+ ## Options Considered
280
+ {brief summary of each option}
281
+
282
+ ## Decision
283
+ {which option + CEO's reasoning}
284
+
285
+ ## Non-Negotiables
286
+ {agreed constraints}
287
+
288
+ ## Next Steps
289
+ {what needs to happen to implement this — becomes /directive input}
290
+ ```
291
+
292
+ 2. **If the decision requires implementation**, ask the CEO:
293
+ - "Create directive" — write a directive to directives/ based on the decision
294
+ - "Add to backlog" — write to the relevant goal's backlog
295
+ - "Design doc only" — just capture the decision, implement later
296
+
297
+ ## Failure Handling
298
+
299
+ | Situation | Action |
300
+ |-----------|--------|
301
+ | Agent output doesn't parse | Log error, continue with others. 2/3 perspectives is fine. |
302
+ | Agents all agree | Great — present the consensus as the recommendation. Still offer 2 options (the consensus + a contrarian alternative). |
303
+ | CEO wants to explore further | Spawn additional research on the specific area. Don't re-run the whole brainstorm. |
304
+ | Question is too broad | Break it into sub-questions. Brainstorm the most foundational one first. |
305
+
306
+ ## How Brainstorm Fits the Conductor Flow
307
+
308
+ **Normal path (auto-triggered):** Strategic directives trigger a brainstorm automatically inside the /directive pipeline. The CEO never needs to invoke /brainstorm separately — the team detects when strategic thinking is needed and handles it.
309
+
310
+ ```
311
+ CEO gives direction → /directive → triage as "strategic" → C-suite brainstorms → COO plans → execute
312
+ ```
313
+
314
+ **Standalone path (CEO-invoked):** The CEO can still invoke /brainstorm directly for questions that don't need a directive — strategy decisions, process design, framework choices, or "I want to think through X with the team" moments.
315
+
316
+ ```
317
+ CEO invokes /brainstorm → triage → lightweight or heavyweight brainstorm → design doc
318
+ ```
319
+
320
+ **Not every directive needs a brainstorm** (simple fixes don't). But strategic work — new data models, workflow changes, architectural shifts — benefits from the team exploring approaches before the COO plans execution.
321
+
322
+ ## Rules
323
+
324
+ ### NEVER
325
+ - Skip triage (Step 0) — always classify before spawning
326
+ - Use heavyweight for a focused question (wastes tokens and CEO time)
327
+ - Use lightweight for a strategic question (misses perspectives)
328
+ - Start heavyweight agents without framing the question first (Step 1)
329
+ - Let heavyweight agents see each other's output during Step 2 (independent thinking prevents groupthink)
330
+ - Present more than 3 options (decision paralysis)
331
+ - Skip the COO's synthesis in heavyweight (raw perspectives without synthesis is a data dump)
332
+
333
+ ### ALWAYS
334
+ - Triage first — lightweight or heavyweight
335
+ - Capture the decision to a discussion file (reasoning dies in context windows)
336
+ - Upgrade lightweight → heavyweight if clarifying questions reveal cross-cutting complexity
337
+ - Include at least the COO + one other agent for heavyweight
338
+ - Have the COO state a recommendation for heavyweight (no "it depends" cop-outs)
339
+ - Include external research in heavyweight (agents should WebSearch, not just opine)
340
+ - Frame the question before spawning heavyweight agents (prevents wasted work)
@@ -0,0 +1,198 @@
1
+ ---
2
+ name: code-review-excellence
3
+ description: |
4
+ Provides comprehensive code review guidance for React 19, Vue 3, Rust, TypeScript, Java, Python, and C/C++.
5
+ Helps catch bugs, improve code quality, and give constructive feedback.
6
+ Use when: reviewing pull requests, conducting PR reviews, code review, reviewing code changes,
7
+ establishing review standards, mentoring developers, architecture reviews, security audits,
8
+ checking code quality, finding bugs, giving feedback on code.
9
+ allowed-tools:
10
+ - Read
11
+ - Grep
12
+ - Glob
13
+ - Bash # 运行 lint/test/build 命令验证代码质量
14
+ - WebFetch # 查阅最新文档和最佳实践
15
+ ---
16
+
17
+ # Code Review Excellence
18
+
19
+ Transform code reviews from gatekeeping to knowledge sharing through constructive feedback, systematic analysis, and collaborative improvement.
20
+
21
+ ## When to Use This Skill
22
+
23
+ - Reviewing pull requests and code changes
24
+ - Establishing code review standards for teams
25
+ - Mentoring junior developers through reviews
26
+ - Conducting architecture reviews
27
+ - Creating review checklists and guidelines
28
+ - Improving team collaboration
29
+ - Reducing code review cycle time
30
+ - Maintaining code quality standards
31
+
32
+ ## Core Principles
33
+
34
+ ### 1. The Review Mindset
35
+
36
+ **Goals of Code Review:**
37
+ - Catch bugs and edge cases
38
+ - Ensure code maintainability
39
+ - Share knowledge across team
40
+ - Enforce coding standards
41
+ - Improve design and architecture
42
+ - Build team culture
43
+
44
+ **Not the Goals:**
45
+ - Show off knowledge
46
+ - Nitpick formatting (use linters)
47
+ - Block progress unnecessarily
48
+ - Rewrite to your preference
49
+
50
+ ### 2. Effective Feedback
51
+
52
+ **Good Feedback is:**
53
+ - Specific and actionable
54
+ - Educational, not judgmental
55
+ - Focused on the code, not the person
56
+ - Balanced (praise good work too)
57
+ - Prioritized (critical vs nice-to-have)
58
+
59
+ ```markdown
60
+ ❌ Bad: "This is wrong."
61
+ ✅ Good: "This could cause a race condition when multiple users
62
+ access simultaneously. Consider using a mutex here."
63
+
64
+ ❌ Bad: "Why didn't you use X pattern?"
65
+ ✅ Good: "Have you considered the Repository pattern? It would
66
+ make this easier to test. Here's an example: [link]"
67
+
68
+ ❌ Bad: "Rename this variable."
69
+ ✅ Good: "[nit] Consider `userCount` instead of `uc` for
70
+ clarity. Not blocking if you prefer to keep it."
71
+ ```
72
+
73
+ ### 3. Review Scope
74
+
75
+ **What to Review:**
76
+ - Logic correctness and edge cases
77
+ - Security vulnerabilities
78
+ - Performance implications
79
+ - Test coverage and quality
80
+ - Error handling
81
+ - Documentation and comments
82
+ - API design and naming
83
+ - Architectural fit
84
+
85
+ **What Not to Review Manually:**
86
+ - Code formatting (use Prettier, Black, etc.)
87
+ - Import organization
88
+ - Linting violations
89
+ - Simple typos
90
+
91
+ ## Review Process
92
+
93
+ ### Phase 1: Context Gathering (2-3 minutes)
94
+
95
+ Before diving into code, understand:
96
+ 1. Read PR description and linked issue
97
+ 2. Check PR size (>400 lines? Ask to split)
98
+ 3. Review CI/CD status (tests passing?)
99
+ 4. Understand the business requirement
100
+ 5. Note any relevant architectural decisions
101
+
102
+ ### Phase 2: High-Level Review (5-10 minutes)
103
+
104
+ 1. **Architecture & Design** - Does the solution fit the problem?
105
+ - For significant changes, consult [Architecture Review Guide](reference/architecture-review-guide.md)
106
+ - Check: SOLID principles, coupling/cohesion, anti-patterns
107
+ 2. **Performance Assessment** - Are there performance concerns?
108
+ - For performance-critical code, consult [Performance Review Guide](reference/performance-review-guide.md)
109
+ - Check: Algorithm complexity, N+1 queries, memory usage
110
+ 3. **File Organization** - Are new files in the right places?
111
+ 4. **Testing Strategy** - Are there tests covering edge cases?
112
+
113
+ ### Phase 3: Line-by-Line Review (10-20 minutes)
114
+
115
+ For each file, check:
116
+ - **Logic & Correctness** - Edge cases, off-by-one, null checks, race conditions
117
+ - **Security** - Input validation, injection risks, XSS, sensitive data
118
+ - **Performance** - N+1 queries, unnecessary loops, memory leaks
119
+ - **Maintainability** - Clear names, single responsibility, comments
120
+
121
+ ### Phase 4: Summary & Decision (2-3 minutes)
122
+
123
+ 1. Summarize key concerns
124
+ 2. Highlight what you liked
125
+ 3. Make clear decision:
126
+ - ✅ Approve
127
+ - 💬 Comment (minor suggestions)
128
+ - 🔄 Request Changes (must address)
129
+ 4. Offer to pair if complex
130
+
131
+ ## Review Techniques
132
+
133
+ ### Technique 1: The Checklist Method
134
+
135
+ Use checklists for consistent reviews. See [Security Review Guide](reference/security-review-guide.md) for comprehensive security checklist.
136
+
137
+ ### Technique 2: The Question Approach
138
+
139
+ Instead of stating problems, ask questions:
140
+
141
+ ```markdown
142
+ ❌ "This will fail if the list is empty."
143
+ ✅ "What happens if `items` is an empty array?"
144
+
145
+ ❌ "You need error handling here."
146
+ ✅ "How should this behave if the API call fails?"
147
+ ```
148
+
149
+ ### Technique 3: Suggest, Don't Command
150
+
151
+ Use collaborative language:
152
+
153
+ ```markdown
154
+ ❌ "You must change this to use async/await"
155
+ ✅ "Suggestion: async/await might make this more readable. What do you think?"
156
+
157
+ ❌ "Extract this into a function"
158
+ ✅ "This logic appears in 3 places. Would it make sense to extract it?"
159
+ ```
160
+
161
+ ### Technique 4: Differentiate Severity
162
+
163
+ Use labels to indicate priority:
164
+
165
+ - 🔴 `[blocking]` - Must fix before merge
166
+ - 🟡 `[important]` - Should fix, discuss if disagree
167
+ - 🟢 `[nit]` - Nice to have, not blocking
168
+ - 💡 `[suggestion]` - Alternative approach to consider
169
+ - 📚 `[learning]` - Educational comment, no action needed
170
+ - 🎉 `[praise]` - Good work, keep it up!
171
+
172
+ ## Language-Specific Guides
173
+
174
+ 根据审查的代码语言,查阅对应的详细指南:
175
+
176
+ | Language/Framework | Reference File | Key Topics |
177
+ |-------------------|----------------|------------|
178
+ | **React** | [React Guide](reference/react.md) | Hooks, useEffect, React 19 Actions, RSC, Suspense, TanStack Query v5 |
179
+ | **Vue 3** | [Vue Guide](reference/vue.md) | Composition API, 响应性系统, Props/Emits, Watchers, Composables |
180
+ | **Rust** | [Rust Guide](reference/rust.md) | 所有权/借用, Unsafe 审查, 异步代码, 错误处理 |
181
+ | **TypeScript** | [TypeScript Guide](reference/typescript.md) | 类型安全, async/await, 不可变性 |
182
+ | **Python** | [Python Guide](reference/python.md) | 可变默认参数, 异常处理, 类属性 |
183
+ | **Java** | [Java Guide](reference/java.md) | Java 17/21 新特性, Spring Boot 3, 虚拟线程, Stream/Optional |
184
+ | **Go** | [Go Guide](reference/go.md) | 错误处理, goroutine/channel, context, 接口设计 |
185
+ | **C** | [C Guide](reference/c.md) | 指针/缓冲区, 内存安全, UB, 错误处理 |
186
+ | **C++** | [C++ Guide](reference/cpp.md) | RAII, 生命周期, Rule of 0/3/5, 异常安全 |
187
+ | **CSS/Less/Sass** | [CSS Guide](reference/css-less-sass.md) | 变量规范, !important, 性能优化, 响应式, 兼容性 |
188
+ | **Qt** | [Qt Guide](reference/qt.md) | 对象模型, 信号/槽, 内存管理, 线程安全, 性能 |
189
+
190
+ ## Additional Resources
191
+
192
+ - [Architecture Review Guide](reference/architecture-review-guide.md) - 架构设计审查指南(SOLID、反模式、耦合度)
193
+ - [Performance Review Guide](reference/performance-review-guide.md) - 性能审查指南(Web Vitals、N+1、复杂度)
194
+ - [Common Bugs Checklist](reference/common-bugs-checklist.md) - 按语言分类的常见错误清单
195
+ - [Security Review Guide](reference/security-review-guide.md) - 安全审查指南
196
+ - [Code Review Best Practices](reference/code-review-best-practices.md) - 代码审查最佳实践
197
+ - [PR Review Template](assets/pr-review-template.md) - PR 审查评论模板
198
+ - [Review Checklist](assets/review-checklist.md) - 快速参考清单
@@ -0,0 +1,121 @@
1
+ ---
2
+ name: "directive"
3
+ description: "Execute work through the directive pipeline — evaluate, plan, cast agents, build, review, and report. Takes a directive name (matching .context/directives/), a project path, or an ad-hoc CEO request.\n\nTRIGGER: Use this skill whenever the user requests non-trivial work that goes beyond a one-liner fix. This includes: building features, running projects with project.json, executing multiple tasks, multi-file changes, or any work with defined DOD/reviewers. Route through this pipeline so reviews and verification steps fire. Do NOT spawn builder agents directly.\n\nFor heavyweight/strategic work, create a directive file in .context/directives/ first. For medium work with an existing project.json, pass the project path. For quick multi-step tasks, pass an ad-hoc description — no directive file needed."
4
+ ---
5
+
6
+ # Execute Directive
7
+
8
+ Execute the CEO directive: $ARGUMENTS
9
+
10
+ ## Role Resolution — Read First
11
+
12
+ Before executing, read `.claude/agent-registry.json` to map roles to agent names. The pipeline uses role-based language throughout. Resolve roles to concrete agent names using the registry:
13
+
14
+ - **COO** = the agent with `"title": "COO"` (plans projects, orchestrates execution)
15
+ - **CTO** = the agent with `"title": "CTO"` (architecture, audits, reviews, technical decomposition)
16
+ - **CPO** = the agent with `"title": "CPO"` (product strategy, UX review, user perspective)
17
+ - **CMO** = the agent with `"title": "CMO"` (growth, SEO, content strategy)
18
+ - **Frontend Developer** = the agent with `"title": "FE"` (React, Tailwind, components)
19
+ - **Backend Developer** = the agent with `"title": "BE"` (server, API, infrastructure)
20
+ - **Full-Stack Engineer** = the agent with `"title": "FS"` (cross-domain work)
21
+ - **Data Engineer** = the agent with `"title": "DE"` (pipelines, parsers, indexing)
22
+ - **Content Builder** = the agent with `"title": "CB"` (MDX, documentation, copywriting)
23
+ - **QA Engineer** = the agent with `"title": "QA"` (testing, investigation, validation)
24
+ - **UI/UX Designer** = the agent with `"title": "UX"` (design review, wireframes, visual quality)
25
+
26
+ Use each agent's `id` field as the `subagent_type` value when spawning. Use the `agentFile` field to locate personality files. The registry is the single source of truth for who fills each role.
27
+
28
+ ---
29
+
30
+ ## MANDATORY: Start with Triage — DO NOT SKIP
31
+
32
+ **YOU MUST read and execute [00-delegation-and-triage.md](docs/pipeline/00-delegation-and-triage.md) BEFORE doing anything else.**
33
+
34
+ DO NOT read source code. DO NOT edit files. DO NOT start solving the problem. The pipeline exists to ensure quality — every shortcut you take skips a review, a gate, or a verification step.
35
+
36
+ Your FIRST action must be: Read the triage doc, classify the directive weight, output the triage block, and create directive.json. Only then proceed to the next pipeline step.
37
+
38
+ If you catch yourself wanting to "just fix it quickly" — STOP. That impulse is exactly what the pipeline prevents. Even lightweight directives have a defined process (triage → context → plan → audit → build → review → digest → completion). The COO plans for ALL weights.
39
+
40
+ ---
41
+
42
+ ## How to Use This Routing Map
43
+
44
+ This file is a routing table. Each row points to a modular doc containing full instructions for that step. **Read only the docs you need for the current step** — don't load everything at once.
45
+
46
+ ### Pipeline Progress Protocol
47
+
48
+ **After completing each pipeline step**, update `.context/directives/{id}/directive.json`:
49
+ 1. Set `pipeline.{stepId}.status` to `"completed"` with:
50
+ - `agent`: who performed this step (e.g. "CEO", "COO", "CTO, full-stack engineer")
51
+ - `output`: REQUIRED object with at least a `summary` string (1-2 sentences of what happened/decided). Add other keys as relevant (e.g. `decision`, `weight`, `projects`).
52
+ - `artifacts`: array of file paths produced (if any)
53
+ 2. Set `current_step` to the next step's ID
54
+ 3. Set `updated_at` to the current ISO timestamp
55
+ 4. Use the Write tool to overwrite the full directive.json
56
+
57
+ **When starting a step**, set `pipeline.{stepId}.status` to `"active"`.
58
+
59
+ > **Why output is mandatory:** The dashboard renders pipeline step details directly from directive.json. Without `output.summary`, the UI shows empty steps — the CEO can't see what happened. Every step must leave a trace.
60
+
61
+ The server's directive-watcher reads `directive.json` directly (NOT `current.json`) and pushes pipeline state to the dashboard via WebSocket. Keeping `pipeline` updated is what makes the stepper UI show real-time progress.
62
+
63
+ ### Pipeline Steps
64
+
65
+ | # | Step ID | Doc | Purpose | Depends On |
66
+ |---|---------|-----|---------|------------|
67
+ | 1 | triage | [00-delegation-and-triage.md](docs/pipeline/00-delegation-and-triage.md) | Triage directive weight + select process | — |
68
+ | 2 | checkpoint | [01-checkpoint.md](docs/pipeline/01-checkpoint.md) | Check for existing checkpoint, resume if found | — |
69
+ | 3 | read | [02-read-directive.md](docs/pipeline/02-read-directive.md) | Read directive file + create directive.json | triage |
70
+ | 4 | context | [03-read-context.md](docs/pipeline/03-read-context.md) | Read all context files before planning | read |
71
+ | 5 | challenge | [04-challenge.md](docs/pipeline/04-challenge.md) | C-suite challenge (heavyweight only) | context |
72
+ | 6 | plan | [05-planning.md](docs/pipeline/05-planning.md) | COO strategic planning | context |
73
+ | 7 | audit | [06-technical-audit.md](docs/pipeline/06-technical-audit.md) | Technical codebase audit | plan |
74
+ | 8 | approve | [07-plan-approval.md](docs/pipeline/07-plan-approval.md) | Present plan to CEO for approval | audit |
75
+ | 9 | project-brainstorm | [07b-project-brainstorm.md](docs/pipeline/07b-project-brainstorm.md) | CTO + builder decompose projects into tasks with DOD | approve |
76
+ | 10 | setup | [08-worktree-and-state.md](docs/pipeline/08-worktree-and-state.md) | Worktree isolation + directive state init | project-brainstorm |
77
+ | 11 | execute | [09-execute-projects.md](docs/pipeline/09-execute-projects.md) | Execute all tasks (phases, agents, UX) | setup |
78
+ | 12 | review-gate | [09-execute-projects.md](docs/pipeline/09-execute-projects.md) | Review verification gate (end of doc) | execute |
79
+ | 13 | wrapup | [10-wrapup.md](docs/pipeline/10-wrapup.md) | OKRs, follow-ups, stale doc detection, digest, lessons, report | review-gate |
80
+ | 14 | completion | [11-completion-gate.md](docs/pipeline/11-completion-gate.md) | CEO completion gate -- approve or reopen | wrapup |
81
+
82
+ ### Reference Docs — Schemas
83
+
84
+ | Doc | Content |
85
+ |-----|---------|
86
+ | [plan-schema.md](docs/reference/schemas/plan-schema.md) | COO plan output JSON schema |
87
+ | [audit-output.md](docs/reference/schemas/audit-output.md) | Architect output JSON schema (design recommendations — second phase of two-agent audit) |
88
+ | [investigation-output.md](docs/reference/schemas/investigation-output.md) | QA Engineer's investigation output JSON schema (pure data — first phase of two-agent audit) |
89
+ | [checkpoint.md](docs/reference/schemas/checkpoint.md) | Checkpoint JSON schema (includes dod_verification field) |
90
+ | [directive-json.md](docs/reference/schemas/directive-json.md) | Directive JSON schema (THE source of truth — includes pipeline progress for dashboard) |
91
+ | [challenger-output.md](docs/reference/schemas/challenger-output.md) | Challenger output JSON schema |
92
+ | [brainstorm-output.md](docs/reference/schemas/brainstorm-output.md) | Brainstorm output JSON schema (proposals + rebuttals) |
93
+
94
+ ### Reference Docs — Templates
95
+
96
+ | Doc | Content |
97
+ |-----|---------|
98
+ | [planner-prompt.md](docs/reference/templates/planner-prompt.md) | Full COO planning prompt |
99
+ | [investigator-prompt.md](docs/reference/templates/investigator-prompt.md) | Investigation prompt template for the QA Engineer (pure data gathering — first phase of audit) |
100
+ | [architect-prompt.md](docs/reference/templates/architect-prompt.md) | Architect prompt template (design recommendations — second phase of audit) |
101
+ | [auditor-prompt.md](docs/reference/templates/auditor-prompt.md) | Combined audit prompt for the CTO (single-agent path for simple tasks) |
102
+ | [challenger-prompt.md](docs/reference/templates/challenger-prompt.md) | Challenger prompt template |
103
+ | [brainstorm-prompt.md](docs/reference/templates/brainstorm-prompt.md) | Brainstorm agent prompt template (Phase 1 proposals + Phase 2 deliberation) |
104
+ | [digest.md](docs/reference/templates/digest.md) | Digest report template |
105
+
106
+ ### Reference Docs — Rules
107
+
108
+ | Doc | Content |
109
+ |-----|---------|
110
+ | [casting-rules.md](docs/reference/rules/casting-rules.md) | Agent casting: delegation, auditing, reviewing, specialists |
111
+ | [phase-definitions.md](docs/reference/rules/phase-definitions.md) | Phase building blocks + common patterns |
112
+ | [scope-and-dod.md](docs/reference/rules/scope-and-dod.md) | Scope format + Definition of Done rules |
113
+ | [failure-handling.md](docs/reference/rules/failure-handling.md) | Failure handling table |
114
+
115
+ ### Validation Scripts
116
+
117
+ | Script | Content |
118
+ |--------|---------|
119
+ | [validate-cast.sh](../../hooks/validate-cast.sh) | Mechanical casting validation — checks auditor present, builder != reviewer, complex has C-suite reviewer |
120
+ | [validate-project-json.sh](../../hooks/validate-project-json.sh) | Pre-execution gate — blocks execute step if project.json missing or incomplete (no tasks, no DOD, no scope) |
121
+ | [detect-stale-docs.sh](../../hooks/detect-stale-docs.sh) | Post-directive — scans docs for references to modified files, flags potentially stale docs |