sinapse-ai 7.1.0 → 7.2.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 (64) hide show
  1. package/.sinapse-ai/data/entity-registry.yaml +749 -757
  2. package/.sinapse-ai/install-manifest.yaml +4 -4
  3. package/bin/cli.js +116 -75
  4. package/package.json +2 -1
  5. package/squads/claude-code-mastery/CHANGELOG.md +22 -0
  6. package/squads/claude-code-mastery/README.md +146 -0
  7. package/squads/claude-code-mastery/agents/claude-mastery-chief.md +554 -0
  8. package/squads/claude-code-mastery/agents/config-engineer.md +865 -0
  9. package/squads/claude-code-mastery/agents/hooks-architect.md +1013 -0
  10. package/squads/claude-code-mastery/agents/mcp-integrator.md +791 -0
  11. package/squads/claude-code-mastery/agents/project-integrator.md +1196 -0
  12. package/squads/claude-code-mastery/agents/roadmap-sentinel.md +931 -0
  13. package/squads/claude-code-mastery/agents/skill-craftsman.md +1250 -0
  14. package/squads/claude-code-mastery/agents/swarm-orqx.md +1008 -0
  15. package/squads/claude-code-mastery/checklists/agent-team-readiness-checklist.md +88 -0
  16. package/squads/claude-code-mastery/checklists/brownfield-readiness-checklist.md +91 -0
  17. package/squads/claude-code-mastery/checklists/change-checklist.md +75 -0
  18. package/squads/claude-code-mastery/checklists/context-rot-checklist.md +114 -0
  19. package/squads/claude-code-mastery/checklists/integration-audit-checklist.md +104 -0
  20. package/squads/claude-code-mastery/checklists/multi-agent-review-checklist.md +77 -0
  21. package/squads/claude-code-mastery/checklists/pre-push-checklist.md +79 -0
  22. package/squads/claude-code-mastery/data/ci-cd-patterns.yaml +412 -0
  23. package/squads/claude-code-mastery/data/claude-code-quick-ref.yaml +314 -0
  24. package/squads/claude-code-mastery/data/hook-patterns.yaml +512 -0
  25. package/squads/claude-code-mastery/data/mcp-integration-catalog.yaml +323 -0
  26. package/squads/claude-code-mastery/data/project-type-signatures.yaml +335 -0
  27. package/squads/claude-code-mastery/scripts/validate-setup.js +163 -0
  28. package/squads/claude-code-mastery/squad.yaml +205 -0
  29. package/squads/claude-code-mastery/tasks/audit-integration.md +219 -0
  30. package/squads/claude-code-mastery/tasks/audit-settings.md +206 -0
  31. package/squads/claude-code-mastery/tasks/audit-setup.md +225 -0
  32. package/squads/claude-code-mastery/tasks/brownfield-setup.md +322 -0
  33. package/squads/claude-code-mastery/tasks/ci-cd-setup.md +335 -0
  34. package/squads/claude-code-mastery/tasks/claude-md-engineer.md +334 -0
  35. package/squads/claude-code-mastery/tasks/configure-claude-code.md +215 -0
  36. package/squads/claude-code-mastery/tasks/context-rot-audit.md +329 -0
  37. package/squads/claude-code-mastery/tasks/create-agent-definition.md +278 -0
  38. package/squads/claude-code-mastery/tasks/create-rules.md +206 -0
  39. package/squads/claude-code-mastery/tasks/create-team-topology.md +258 -0
  40. package/squads/claude-code-mastery/tasks/diagnose.md +166 -0
  41. package/squads/claude-code-mastery/tasks/enterprise-config.md +346 -0
  42. package/squads/claude-code-mastery/tasks/hook-designer.md +272 -0
  43. package/squads/claude-code-mastery/tasks/integrate-project.md +304 -0
  44. package/squads/claude-code-mastery/tasks/mcp-integration-plan.md +229 -0
  45. package/squads/claude-code-mastery/tasks/mcp-workflow.md +285 -0
  46. package/squads/claude-code-mastery/tasks/multi-project-setup.md +228 -0
  47. package/squads/claude-code-mastery/tasks/optimize-context.md +217 -0
  48. package/squads/claude-code-mastery/tasks/optimize-workflow.md +226 -0
  49. package/squads/claude-code-mastery/tasks/parallel-decomposition.md +293 -0
  50. package/squads/claude-code-mastery/tasks/permission-strategy.md +266 -0
  51. package/squads/claude-code-mastery/tasks/sandbox-setup.md +279 -0
  52. package/squads/claude-code-mastery/tasks/setup-repository.md +230 -0
  53. package/squads/claude-code-mastery/tasks/setup-wizard.md +236 -0
  54. package/squads/claude-code-mastery/tasks/worktree-strategy.md +320 -0
  55. package/squads/claude-code-mastery/templates/claude-md-fullstack.md +147 -0
  56. package/squads/claude-code-mastery/templates/claude-md-library.md +175 -0
  57. package/squads/claude-code-mastery/templates/claude-md-microservices.md +186 -0
  58. package/squads/claude-code-mastery/templates/claude-md-mobile.md +198 -0
  59. package/squads/claude-code-mastery/templates/claude-md-monorepo.md +139 -0
  60. package/squads/claude-code-mastery/templates/github-actions-claude-ci.yml +348 -0
  61. package/squads/claude-code-mastery/templates/github-actions-claude-review.yml +179 -0
  62. package/squads/claude-code-mastery/workflows/wf-audit-complete.yaml +140 -0
  63. package/squads/claude-code-mastery/workflows/wf-knowledge-update.yaml +165 -0
  64. package/squads/claude-code-mastery/workflows/wf-project-setup.yaml +192 -0
@@ -0,0 +1,206 @@
1
+ # Task: Create Conditional Rules
2
+
3
+ **Task ID:** CCM-CONFIG-003
4
+ **Version:** 1.0.0
5
+ **Command:** `*create-rules`
6
+ **Orchestrator:** Sigil (config-engineer)
7
+ **Purpose:** Create conditional rules in `.claude/rules/` with proper `paths:` YAML frontmatter for context-efficient loading, ensuring rules only activate when relevant files are being worked on.
8
+
9
+ ---
10
+
11
+ ## Overview
12
+
13
+ ```
14
+ +------------------+ +------------------+ +------------------+
15
+ | 1. Identify | --> | 2. Create Rule | --> | 3. Write Rule |
16
+ | Rule Need | | File with | | Content |
17
+ +------------------+ | Frontmatter | +------------------+
18
+ +------------------+ |
19
+ v
20
+ +------------------+ +------------------+
21
+ | 5. Test Rule | <-- | 4. Validate |
22
+ | Activation | | Rule Loading |
23
+ +------------------+ +------------------+
24
+ ```
25
+
26
+ ---
27
+
28
+ ## Inputs
29
+
30
+ | Field | Type | Source | Required | Validation |
31
+ |-------|------|--------|----------|------------|
32
+ | rule_name | string | User parameter | Yes | Kebab-case filename (e.g., `api-conventions`) |
33
+ | rule_type | string | User parameter | No | `conditional` (default) or `always-on` |
34
+ | target_paths | array | User parameter or auto-detected | No | Glob patterns for conditional loading |
35
+ | description | string | User parameter | No | Purpose of the rule |
36
+
37
+ ---
38
+
39
+ ## Preconditions
40
+
41
+ - .claude/ directory exists (or will be created)
42
+ - Understanding of which directories/files the rule should apply to
43
+ - No existing rule file with the same name (or user confirms overwrite)
44
+
45
+ ---
46
+
47
+ ## Execution Phases
48
+
49
+ ### Phase 1: Identify Rule Need
50
+
51
+ Determine what kind of rule to create:
52
+
53
+ 1. Ask the user what behavior they want to enforce or what context they want to inject
54
+ 2. Categorize the rule:
55
+
56
+ | Category | Example Rules | Typical Paths |
57
+ |----------|---------------|---------------|
58
+ | API conventions | Endpoint patterns, error handling, validation | `src/api/**`, `server/**` |
59
+ | Component patterns | React patterns, styling, props conventions | `src/components/**/*.tsx` |
60
+ | Test conventions | Testing patterns, mock strategies, coverage | `tests/**`, `**/*.test.*` |
61
+ | Database rules | Migration patterns, query conventions, RLS | `migrations/**`, `supabase/**` |
62
+ | Documentation | Doc formatting, README structure, changelog | `docs/**`, `*.md` |
63
+ | Security | Input validation, auth patterns, OWASP | `src/auth/**`, `src/middleware/**` |
64
+ | Configuration | Config file conventions, env var patterns | `*.config.*`, `.env.*` |
65
+ | Always-on | Project-wide conventions (no paths: needed) | (none -- loads always) |
66
+
67
+ 3. If the user is unsure: scan the project structure and suggest rules based on detected directories
68
+
69
+ ### Phase 2: Create Rule File with Frontmatter
70
+
71
+ 1. Determine the file path: `.claude/rules/{rule_name}.md`
72
+ 2. For **conditional rules**, generate the `paths:` YAML frontmatter:
73
+
74
+ ```markdown
75
+ ---
76
+ paths:
77
+ - "src/api/**/*.ts"
78
+ - "src/api/**/*.tsx"
79
+ - "server/**/*.ts"
80
+ ---
81
+ ```
82
+
83
+ **Glob pattern reference:**
84
+ - `*` matches any single path segment
85
+ - `**` matches zero or more path segments (recursive)
86
+ - `*.ts` matches TypeScript files in current directory
87
+ - `**/*.ts` matches TypeScript files recursively
88
+ - `src/{api,server}/**` matches multiple directories
89
+ - `**/*.{ts,tsx}` matches multiple extensions using brace expansion
90
+
91
+ 3. For **always-on rules**, omit the frontmatter entirely (no `---` blocks)
92
+ 4. Create subdirectories if organizing by domain: `.claude/rules/frontend/`, `.claude/rules/backend/`
93
+
94
+ ### Phase 3: Write Rule Content
95
+
96
+ Write the rule body following these guidelines:
97
+
98
+ 1. **Start with a clear header** explaining the rule's purpose
99
+ 2. **Use imperative instructions** -- tell Claude what to do, not what to consider
100
+ 3. **Be specific and verifiable** -- include code examples when relevant
101
+ 4. **Keep rules concise** -- target 20-60 lines per rule file
102
+ 5. **Use bullet points** for individual rules
103
+
104
+ **Rule template:**
105
+
106
+ ```markdown
107
+ ---
108
+ paths:
109
+ - "{glob-patterns}"
110
+ ---
111
+ # {Rule Title}
112
+
113
+ ## Conventions
114
+
115
+ - {Specific, actionable instruction}
116
+ - {Another instruction with example}
117
+
118
+ ## Patterns
119
+
120
+ When creating {X}, follow this pattern:
121
+
122
+ ```{language}
123
+ {code example}
124
+ ```
125
+
126
+ ## Anti-patterns
127
+
128
+ - Do NOT {specific thing to avoid}
129
+ - Do NOT {another thing to avoid}
130
+ ```
131
+
132
+ ### Phase 4: Validate Rule Loading
133
+
134
+ 1. Verify the frontmatter YAML is valid:
135
+ - Proper `---` delimiters (opening and closing)
136
+ - `paths:` is a YAML array (each item starts with `- `)
137
+ - Glob patterns are quoted strings
138
+ - No trailing whitespace or tab characters in frontmatter
139
+ 2. Verify the file is saved in `.claude/rules/` (or a subdirectory)
140
+ 3. Check that the glob patterns match actual files in the project:
141
+ - Run a glob match test against the project structure
142
+ - Warn if patterns match zero files (possibly incorrect)
143
+ - Warn if patterns match too many files (overly broad)
144
+
145
+ ### Phase 5: Test Rule Activation
146
+
147
+ 1. Explain to the user how to verify the rule loads:
148
+ - Open a file matching one of the glob patterns
149
+ - The rule should appear in Claude's context for that interaction
150
+ - Rules without paths: frontmatter load on every interaction
151
+ 2. Suggest a test prompt that would trigger the rule's instructions
152
+ 3. If the rule conflicts with CLAUDE.md content, flag the conflict:
153
+ - Rules and CLAUDE.md instructions should complement, not contradict
154
+ - If contradiction exists: recommend removing the instruction from CLAUDE.md (the rule file is more targeted)
155
+
156
+ ---
157
+
158
+ ## Output Format
159
+
160
+ ```markdown
161
+ ## Rule Created
162
+
163
+ **File:** .claude/rules/{rule_name}.md
164
+ **Type:** {conditional | always-on}
165
+ **Lines:** {N}
166
+
167
+ ### Loading Behavior
168
+
169
+ {For conditional:}
170
+ This rule loads when Claude reads files matching:
171
+ - `{pattern-1}` -- matches {N} files
172
+ - `{pattern-2}` -- matches {N} files
173
+
174
+ {For always-on:}
175
+ This rule loads on every interaction.
176
+
177
+ ### Content Summary
178
+
179
+ {1-2 sentence summary of what the rule enforces}
180
+
181
+ ### Verification
182
+
183
+ Open any file matching the paths above and ask Claude to follow the
184
+ conventions. The rule will be active in that context.
185
+ ```
186
+
187
+ ---
188
+
189
+ ## Veto Conditions
190
+
191
+ - **NEVER** create a rule that contradicts instructions in CLAUDE.md without flagging the conflict and recommending resolution.
192
+ - **NEVER** create a conditional rule without testing that its glob patterns match at least one existing file. Warn if zero matches.
193
+ - **NEVER** write a rule file over 100 lines. Split into multiple focused rules instead.
194
+ - **NEVER** include secrets, API keys, or credentials in rule files (they are committed to git).
195
+ - **NEVER** create an always-on rule for content that should be conditional. Large always-on rules waste context budget on every interaction.
196
+
197
+ ---
198
+
199
+ ## Completion Criteria
200
+
201
+ - [ ] Rule need identified and categorized
202
+ - [ ] File created in .claude/rules/ with correct path
203
+ - [ ] Frontmatter YAML validated (for conditional rules)
204
+ - [ ] Rule content follows the template with specific, actionable instructions
205
+ - [ ] Glob patterns tested against project structure
206
+ - [ ] No conflicts with existing CLAUDE.md instructions
@@ -0,0 +1,258 @@
1
+ # Task: Design Agent Team Configuration
2
+
3
+ **Task ID:** create-team-topology
4
+ **Version:** 1.0
5
+ **Purpose:** Design and configure a multi-agent team with defined topology, roles, and communication patterns
6
+ **Orchestrator:** @swarm-orqx (Nexus)
7
+ **Mode:** Interactive (elicit: true)
8
+ **Quality Standard:** Team topology tested with dry-run, all agents load successfully
9
+
10
+ ---
11
+
12
+ ## Overview
13
+
14
+ This task designs an Agent Team configuration where multiple subagents collaborate on a workload. It covers topology selection, role definition, communication patterns, and isolation strategies.
15
+
16
+ ```
17
+ INPUT (workload_description + team_size + isolation_needs)
18
+ |
19
+ [PHASE 1: WORKLOAD DECOMPOSITION]
20
+ -> Analyze the workload for parallelizable units
21
+ -> Identify shared state requirements
22
+ -> Determine coordination needs
23
+ |
24
+ [PHASE 2: ROLE DEFINITION]
25
+ -> Define each agent's responsibility
26
+ -> Assign models per role
27
+ -> Set tool permissions per agent
28
+ |
29
+ [PHASE 3: AGENT FILE CREATION]
30
+ -> Create .claude/agents/{name}.md for each member
31
+ -> Configure frontmatter (name, model, tools)
32
+ -> Write role-specific instructions
33
+ |
34
+ [PHASE 4: TOPOLOGY DESIGN]
35
+ -> Select topology pattern
36
+ -> Define communication flow
37
+ -> Set max_turns per agent
38
+ |
39
+ [PHASE 5: COMMUNICATION PATTERNS]
40
+ -> Define handoff protocol between agents
41
+ -> Set up shared context (files, directories)
42
+ -> Configure completion criteria
43
+ |
44
+ [PHASE 6: COMPLETION CRITERIA]
45
+ -> Define what "done" means for each agent
46
+ -> Define what "done" means for the team
47
+ -> Plan output aggregation
48
+ |
49
+ OUTPUT: Agent team files + topology diagram + communication spec
50
+ ```
51
+
52
+ ---
53
+
54
+ ## Inputs
55
+
56
+ | Field | Type | Source | Required | Validation |
57
+ |-------|------|--------|----------|------------|
58
+ | workload_description | string | User | yes | Clear description of the full task |
59
+ | team_size | number | User or auto | no | Suggested number of agents (default: auto-detect) |
60
+ | isolation_mode | enum | User | no | shared (default) / worktree / none |
61
+ | topology_preference | enum | User | no | hub-spoke / pipeline / peer / auto |
62
+ | max_budget | string | User | no | Cost constraint (e.g., "keep it cheap") |
63
+
64
+ ---
65
+
66
+ ## Preconditions
67
+
68
+ 1. `.claude/agents/` directory exists
69
+ 2. Workload is clearly defined and scoped
70
+ 3. At least 2 distinct subtasks identified in the workload
71
+
72
+ ---
73
+
74
+ ## Phase 1: Workload Decomposition
75
+
76
+ **Goal:** Break the workload into agent-sized units.
77
+
78
+ ### Steps
79
+
80
+ 1.1. Analyze the workload description for distinct, separable concerns.
81
+ 1.2. Identify which subtasks can run in parallel vs sequentially.
82
+ 1.3. Map shared resources (files, databases, APIs) across subtasks.
83
+ 1.4. Determine minimum team size based on distinct concerns.
84
+
85
+ ### Decomposition Checklist
86
+
87
+ - [ ] Each subtask has a single clear responsibility
88
+ - [ ] Dependencies between subtasks are identified
89
+ - [ ] Shared state conflicts are documented
90
+ - [ ] Parallelization opportunities are marked
91
+
92
+ ---
93
+
94
+ ## Phase 2: Role Definition
95
+
96
+ **Goal:** Assign clear roles to each agent.
97
+
98
+ ### Steps
99
+
100
+ 2.1. For each subtask, define an agent role:
101
+
102
+ ```yaml
103
+ roles:
104
+ - name: "{role-name}"
105
+ responsibility: "{what this agent does}"
106
+ inputs: "{what it receives}"
107
+ outputs: "{what it produces}"
108
+ model: "{opus|sonnet|haiku}"
109
+ tools: ["{tool1}", "{tool2}"]
110
+ ```
111
+
112
+ 2.2. Assign models based on task complexity:
113
+ - Coordinator/orchestrator: sonnet (needs judgment, not deep analysis)
114
+ - Complex analysis: opus (architecture, security review)
115
+ - Code generation: sonnet (standard implementation)
116
+ - Simple tasks: haiku (formatting, data extraction)
117
+
118
+ 2.3. Verify no two agents have overlapping responsibilities.
119
+
120
+ ---
121
+
122
+ ## Phase 3: Agent File Creation
123
+
124
+ **Goal:** Create the agent definition files.
125
+
126
+ ### Steps
127
+
128
+ 3.1. For each role from Phase 2, create `.claude/agents/{role-name}.md`.
129
+ 3.2. Use the create-agent-definition task format for each file.
130
+ 3.3. Include team-specific instructions in each agent:
131
+ - What other agents exist on the team
132
+ - Where to write outputs (shared directory)
133
+ - How to signal completion
134
+
135
+ ---
136
+
137
+ ## Phase 4: Topology Design
138
+
139
+ **Goal:** Select the right topology for agent interaction.
140
+
141
+ ### Topology Comparison
142
+
143
+ | Topology | Structure | Best For | Coordination Cost |
144
+ |----------|-----------|----------|-------------------|
145
+ | **Hub-and-Spoke** | One coordinator dispatches to specialists | Mixed tasks, varied complexity | Medium |
146
+ | **Pipeline** | Agent A output feeds Agent B input | Sequential processing, data transformation | Low |
147
+ | **Peer** | All agents work independently, merge at end | Embarrassingly parallel tasks | Low |
148
+ | **Hierarchical** | Multi-level coordinators with sub-teams | Large complex projects | High |
149
+
150
+ ### Selection Decision
151
+
152
+ ```
153
+ Are subtasks independent with no shared state?
154
+ YES -> Peer topology
155
+ NO -> Do subtasks form a sequential chain?
156
+ YES -> Pipeline topology
157
+ NO -> Is there one "brain" coordinating specialists?
158
+ YES -> Hub-and-Spoke topology
159
+ NO -> Hierarchical topology
160
+ ```
161
+
162
+ 4.1. Select topology based on decomposition analysis.
163
+ 4.2. Document the topology with an ASCII diagram.
164
+ 4.3. Set `max_turns` guidance per agent:
165
+ - Simple tasks: 5-10 turns
166
+ - Standard tasks: 15-25 turns
167
+ - Complex tasks: 30-50 turns
168
+
169
+ ---
170
+
171
+ ## Phase 5: Communication Patterns
172
+
173
+ **Goal:** Define how agents share information.
174
+
175
+ ### Communication Strategies
176
+
177
+ | Strategy | Mechanism | Isolation Level |
178
+ |----------|-----------|----------------|
179
+ | **File-based** | Agents write to shared directory | Low (same repo) |
180
+ | **Worktree** | Each agent has its own git worktree | High (separate working trees) |
181
+ | **Branch** | Agents work on separate branches | Medium (same repo, different branches) |
182
+
183
+ ### Steps
184
+
185
+ 5.1. Define a shared output directory (e.g., `.claude/team-output/{task-id}/`).
186
+ 5.2. Define handoff format (how one agent signals completion):
187
+ - Write a `{agent-name}-done.md` file with summary and outputs
188
+ - Or write to a shared `progress.yaml` file
189
+ 5.3. Define conflict resolution if agents might modify the same files:
190
+ - Use worktree isolation for high-risk scenarios
191
+ - Use file-level ownership for medium-risk
192
+ - Use merge-at-end for low-risk
193
+
194
+ ---
195
+
196
+ ## Phase 6: Completion Criteria
197
+
198
+ **Goal:** Define what "done" means.
199
+
200
+ ### Steps
201
+
202
+ 6.1. For each agent, define completion as:
203
+ - Output files written
204
+ - Quality check passed (lint, test, etc.)
205
+ - Completion signal sent
206
+
207
+ 6.2. For the team, define completion as:
208
+ - All agents report done
209
+ - Outputs aggregated
210
+ - Integration test passed (if applicable)
211
+
212
+ 6.3. Define failure handling:
213
+ - Agent fails -> retry once, then escalate to coordinator
214
+ - Coordinator fails -> escalate to human
215
+ - Timeout -> kill agent, report partial results
216
+
217
+ ---
218
+
219
+ ## Output Format
220
+
221
+ ```yaml
222
+ team_topology_result:
223
+ topology: "{hub-spoke|pipeline|peer|hierarchical}"
224
+ agents:
225
+ - name: "{agent-1}"
226
+ file: ".claude/agents/{agent-1}.md"
227
+ model: "sonnet-4"
228
+ role: "{responsibility}"
229
+ - name: "{agent-2}"
230
+ file: ".claude/agents/{agent-2}.md"
231
+ model: "haiku-4"
232
+ role: "{responsibility}"
233
+ communication:
234
+ strategy: "{file-based|worktree|branch}"
235
+ shared_dir: ".claude/team-output/{task-id}/"
236
+ handoff_format: "completion-file"
237
+ completion:
238
+ all_agents_done: true
239
+ outputs_aggregated: true
240
+ diagram: |
241
+ [Coordinator]
242
+ |
243
+ +---+---+
244
+ | |
245
+ [A1] [A2]
246
+ ```
247
+
248
+ ---
249
+
250
+ ## Veto Conditions
251
+
252
+ | Condition | Action |
253
+ |-----------|--------|
254
+ | Workload cannot be decomposed into 2+ distinct subtasks | HALT -- single agent is sufficient |
255
+ | Team size exceeds 6 agents | HALT -- decompose into sub-teams first |
256
+ | All agents need write access to the same files | HALT -- redesign with file ownership or worktree isolation |
257
+ | No clear completion criteria defined | HALT -- define "done" before creating team |
258
+ | Model costs exceed stated budget constraint | HALT -- downgrade models or reduce team size |
@@ -0,0 +1,166 @@
1
+ # Task: Diagnose Claude Code Question
2
+
3
+ **Task ID:** CCM-CHIEF-001
4
+ **Version:** 1.0.0
5
+ **Command:** `*diagnose`
6
+ **Orchestrator:** Orion (claude-mastery-chief)
7
+ **Purpose:** Triage Claude Code questions and problems, provide a quick answer, and route to the appropriate specialist agent when domain-specific expertise is needed.
8
+
9
+ ---
10
+
11
+ ## Overview
12
+
13
+ ```
14
+ User Question
15
+ |
16
+ v
17
+ +------------------+
18
+ | 1. Parse Request |
19
+ | Extract keywords|
20
+ +------------------+
21
+ |
22
+ v
23
+ +------------------+
24
+ | 2. Match Routing |
25
+ | Matrix |
26
+ +------------------+
27
+ |
28
+ +-------+-------+
29
+ | |
30
+ v v
31
+ Cross-cutting Domain-specific
32
+ | |
33
+ v v
34
+ +----------+ +------------------+
35
+ | 3a. Answer| | 3b. Quick Answer |
36
+ | Directly | | + Route to |
37
+ +----------+ | Specialist |
38
+ | +------------------+
39
+ v |
40
+ +------------------+ |
41
+ | 4. Output Report | <+
42
+ +------------------+
43
+ ```
44
+
45
+ ---
46
+
47
+ ## Inputs
48
+
49
+ | Field | Type | Source | Required | Validation |
50
+ |-------|------|--------|----------|------------|
51
+ | question | string | User prompt | Yes | Non-empty natural language question or problem description |
52
+ | context | object | Session state | No | Active story, branch, recent errors if available |
53
+
54
+ ---
55
+
56
+ ## Preconditions
57
+
58
+ - Claude Code Mastery squad is active with Orion as the entry agent
59
+ - Routing matrix is loaded from the agent definition (triage.routing_matrix)
60
+ - All 7 specialist agents are registered in config.yaml
61
+
62
+ ---
63
+
64
+ ## Execution Phases
65
+
66
+ ### Phase 1: Analyze Request (Keyword Extraction)
67
+
68
+ 1. Parse the user's question or problem description
69
+ 2. Extract primary keywords and intent signals
70
+ 3. Identify the request category:
71
+ - Is it a "how to" question?
72
+ - Is it a debugging/troubleshooting problem?
73
+ - Is it a setup/configuration request?
74
+ - Is it a conceptual/comparison question?
75
+ 4. Note any secondary domains that may be relevant
76
+
77
+ ### Phase 2: Match Against Routing Matrix
78
+
79
+ Apply keyword matching against the 7 specialist domains:
80
+
81
+ | Domain | Keywords | Route To | Persona |
82
+ |--------|----------|----------|---------|
83
+ | hooks | hook, pre_tool_use, post_tool_use, lifecycle, intercept, block, exit code, automation pipeline, pre_compact, notification, damage control | hooks-architect | Latch |
84
+ | mcp | mcp, server, tool search, stdio, sse, http streamable, mcp__, context7, exa, docker gateway, add server | mcp-integrator | Piper |
85
+ | subagents | subagent, agent team, swarm, teammate, worktree, parallel, background agent, spawn, multi-agent, TeammateTool | swarm-orqx | Nexus |
86
+ | config | settings, permission, CLAUDE.md, rules, sandbox, managed, enterprise, allow, deny, keybinding, context window, compaction | config-engineer | Sigil |
87
+ | skills | skill, command, plugin, SKILL.md, slash command, context engineering, spec-driven, .claude/commands, .claude/skills, marketplace | skill-craftsman | Anvil |
88
+ | integration | integrate, repository, project setup, CI/CD, headless, brownfield, monorepo, SINAPSE, git workflow | project-integrator | Conduit |
89
+ | roadmap | update, changelog, version, roadmap, new feature, what changed, migration, upgrade, adoption | roadmap-sentinel | Vigil |
90
+
91
+ **Scoring rules:**
92
+ - Count keyword matches per domain
93
+ - If one domain scores significantly higher (2+ matches above others), route there
94
+ - If multiple domains tie or the question spans domains, treat as cross-cutting
95
+ - If no domain matches strongly, treat as cross-cutting (Orion answers directly)
96
+
97
+ ### Phase 3a: Cross-Cutting Answer (Direct)
98
+
99
+ If the question is cross-cutting or general:
100
+
101
+ 1. Synthesize knowledge from the quick_reference section and SINAPSE awareness
102
+ 2. Provide a complete, actionable answer
103
+ 3. Reference relevant specialist agents the user can consult for deeper exploration
104
+ 4. Include code snippets, configuration examples, or reference tables as appropriate
105
+
106
+ ### Phase 3b: Domain-Specific Answer (Quick + Route)
107
+
108
+ If the question maps to a specific domain:
109
+
110
+ 1. **Provide a quick answer first** -- Never route without giving immediate value
111
+ - Answer the question at a surface level (3-5 lines minimum)
112
+ - Include a concrete example (code snippet, config block, or command)
113
+ 2. **Route to the specialist** for deeper expertise:
114
+ - Name the specialist agent and persona
115
+ - Explain what additional depth the specialist can provide
116
+ - Provide the activation command: `@claude-code-mastery:{agent-id}`
117
+ - Suggest a specific specialist command if applicable (e.g., `*create-hook`, `*audit-settings`)
118
+
119
+ ### Phase 4: Confidence Assessment
120
+
121
+ Rate the diagnosis confidence:
122
+
123
+ | Confidence | Criteria | Action |
124
+ |------------|----------|--------|
125
+ | HIGH | 3+ keyword matches in one domain, clear intent | Route with confidence |
126
+ | MEDIUM | 1-2 matches, ambiguous intent | Provide answer + suggest 2 possible specialists |
127
+ | LOW | No clear domain match | Answer directly, ask clarifying question |
128
+
129
+ ---
130
+
131
+ ## Output Format
132
+
133
+ ```markdown
134
+ ## Diagnosis
135
+
136
+ **Category:** {domain-name | cross-cutting}
137
+ **Confidence:** {HIGH | MEDIUM | LOW}
138
+ **Specialist:** {persona-name} ({agent-id}) | Direct Answer
139
+
140
+ ### Quick Answer
141
+
142
+ {3-10 line answer with concrete example}
143
+
144
+ ### Recommended Next Step
145
+
146
+ {Route instruction OR follow-up question for clarification}
147
+ ```
148
+
149
+ ---
150
+
151
+ ## Veto Conditions
152
+
153
+ - **NEVER** route to a specialist without providing at least a quick answer first. The user must receive immediate value from every interaction with Orion.
154
+ - **NEVER** route when confidence is LOW -- ask a clarifying question instead.
155
+ - **NEVER** load a specialist agent file during diagnosis. Only provide routing instructions for the user to activate the specialist.
156
+ - **NEVER** guess the domain when keywords are ambiguous -- synthesize a cross-cutting answer and let the user refine.
157
+
158
+ ---
159
+
160
+ ## Completion Criteria
161
+
162
+ - [ ] User question parsed and keywords extracted
163
+ - [ ] Routing matrix consulted with scored results
164
+ - [ ] Quick answer provided with concrete example
165
+ - [ ] Specialist routing provided (if domain-specific)
166
+ - [ ] Confidence level stated in output