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,329 @@
1
+ # Task: Context Rot Audit
2
+
3
+ **Task ID:** context-rot-audit
4
+ **Version:** 1.0
5
+ **Purpose:** Audit CLAUDE.md, rules, and auto-memory for stale, incorrect, or bloated context that degrades Claude Code performance
6
+ **Orchestrator:** @project-integrator (Conduit)
7
+ **Mode:** Autonomous (elicit: false)
8
+ **Quality Standard:** Rot score calculated, all stale references identified, remediation plan generated
9
+
10
+ ---
11
+
12
+ ## Overview
13
+
14
+ Context rot occurs when CLAUDE.md, rules files, and auto-memory accumulate outdated instructions, references to deleted files, deprecated patterns, and bloated content. This audit systematically detects rot and produces a remediation plan.
15
+
16
+ ```
17
+ INPUT (project_root)
18
+ |
19
+ [PHASE 1: CLAUDE.MD SIZE AUDIT]
20
+ -> Measure line count and section sizes
21
+ -> Flag if over 500 lines
22
+ -> Identify largest sections
23
+ |
24
+ [PHASE 2: REFERENCE VALIDATION]
25
+ -> Check every file path referenced in CLAUDE.md
26
+ -> Check every file path referenced in rules
27
+ -> Report missing/moved files
28
+ |
29
+ [PHASE 3: INSTRUCTION STALENESS]
30
+ -> Check for outdated API references
31
+ -> Check for deprecated package mentions
32
+ -> Check for patterns that conflict with current code
33
+ |
34
+ [PHASE 4: RULES STRUCTURE AUDIT]
35
+ -> Verify rules match current directory structure
36
+ -> Check for orphaned rules (paths no longer exist)
37
+ -> Validate frontmatter path patterns
38
+ |
39
+ [PHASE 5: AUTO-MEMORY AUDIT]
40
+ -> Check .claude/agent-memory/ for stale entries
41
+ -> Verify referenced files still exist
42
+ -> Check for contradictory entries
43
+ |
44
+ [PHASE 6: ROT SCORE AND REMEDIATION]
45
+ -> Calculate overall rot score
46
+ -> Generate prioritized fix list
47
+ -> Produce remediation plan
48
+ |
49
+ OUTPUT: Rot score + findings report + remediation plan
50
+ ```
51
+
52
+ ---
53
+
54
+ ## Inputs
55
+
56
+ | Field | Type | Source | Required | Validation |
57
+ |-------|------|--------|----------|------------|
58
+ | project_root | string | Auto-detect | yes | Valid directory with .claude/ or CLAUDE.md |
59
+ | fix_automatically | boolean | User | no | Whether to auto-fix simple issues (default: false) |
60
+ | verbose | boolean | User | no | Show all checks including passing (default: false) |
61
+
62
+ ---
63
+
64
+ ## Preconditions
65
+
66
+ 1. Project has Claude Code configured (CLAUDE.md or .claude/ exists)
67
+ 2. Git repository for change history analysis
68
+ 3. Read access to all project files
69
+
70
+ ---
71
+
72
+ ## Phase 1: CLAUDE.md Size Audit
73
+
74
+ **Goal:** Check if CLAUDE.md has grown beyond effective size.
75
+
76
+ ### Size Thresholds
77
+
78
+ | Lines | Status | Impact |
79
+ |-------|--------|--------|
80
+ | < 100 | Lean | Optimal for auto-memory |
81
+ | 100-200 | Normal | Good for most projects |
82
+ | 200-500 | Growing | Consider splitting into rules |
83
+ | 500+ | Bloated | Actively degrades performance |
84
+
85
+ ### Steps
86
+
87
+ 1.1. Count total lines in CLAUDE.md.
88
+ 1.2. Measure each section's line count.
89
+ 1.3. Identify the top 3 largest sections.
90
+ 1.4. Flag any section over 50 lines as candidate for extraction to rules file.
91
+ 1.5. Check for duplicate information across sections.
92
+
93
+ ### Findings Format
94
+
95
+ ```yaml
96
+ size_audit:
97
+ total_lines: 347
98
+ status: "growing"
99
+ largest_sections:
100
+ - name: "Code Standards"
101
+ lines: 89
102
+ recommendation: "Extract to .claude/rules/code-standards.md"
103
+ - name: "API Reference"
104
+ lines: 67
105
+ recommendation: "Extract to .claude/rules/api.md"
106
+ duplicates_found: 2
107
+ ```
108
+
109
+ ---
110
+
111
+ ## Phase 2: Reference Validation
112
+
113
+ **Goal:** Verify every file/directory referenced in context files actually exists.
114
+
115
+ ### Steps
116
+
117
+ 2.1. Extract all file paths from CLAUDE.md (look for backtick-quoted paths, code blocks).
118
+ 2.2. Extract all file paths from `.claude/rules/*.md`.
119
+ 2.3. For each path, check if it exists in the project:
120
+
121
+ ```
122
+ Reference: `src/components/Button.tsx`
123
+ Status: EXISTS / MISSING / MOVED
124
+
125
+ Reference: `npm run test:e2e`
126
+ Status: VALID (in package.json scripts) / INVALID
127
+ ```
128
+
129
+ 2.4. Check command references against package.json scripts.
130
+ 2.5. Report all missing references with suggested fixes.
131
+
132
+ ### Findings Format
133
+
134
+ ```yaml
135
+ reference_audit:
136
+ total_references: 45
137
+ valid: 38
138
+ missing: 5
139
+ likely_moved: 2
140
+ missing_details:
141
+ - path: "src/lib/api-client.ts"
142
+ referenced_in: "CLAUDE.md:42"
143
+ suggestion: "File was renamed to src/lib/http-client.ts"
144
+ ```
145
+
146
+ ---
147
+
148
+ ## Phase 3: Instruction Staleness
149
+
150
+ **Goal:** Detect outdated instructions that could cause Claude to do the wrong thing.
151
+
152
+ ### Staleness Indicators
153
+
154
+ | Signal | Detection Method |
155
+ |--------|-----------------|
156
+ | Deprecated package | Check if version in instructions differs from package.json |
157
+ | Old API patterns | Instructions mention patterns not found in current code |
158
+ | Removed scripts | Referenced npm scripts no longer in package.json |
159
+ | Old directory structure | Instructions reference paths that were restructured |
160
+ | Version-specific instructions | Instructions tied to old framework version |
161
+
162
+ ### Steps
163
+
164
+ 3.1. Cross-reference CLAUDE.md instructions with current package.json:
165
+ - Are referenced dependencies still installed?
166
+ - Do version numbers match?
167
+ 3.2. Check if code patterns described in CLAUDE.md exist in the codebase:
168
+ - Grep for the pattern in source files
169
+ - If not found, the instruction is stale
170
+ 3.3. Check for tech-specific staleness:
171
+ - React class components mentioned but none exist
172
+ - Old import paths referenced
173
+ - Deprecated API methods mentioned
174
+
175
+ ### Findings Format
176
+
177
+ ```yaml
178
+ staleness_audit:
179
+ total_instructions_checked: 23
180
+ current: 18
181
+ stale: 4
182
+ uncertain: 1
183
+ stale_details:
184
+ - instruction: "Use getServerSideProps for data fetching"
185
+ location: "CLAUDE.md:78"
186
+ issue: "Project uses App Router with server components"
187
+ fix: "Update to describe server component patterns"
188
+ ```
189
+
190
+ ---
191
+
192
+ ## Phase 4: Rules Structure Audit
193
+
194
+ **Goal:** Verify rules files match the current project structure.
195
+
196
+ ### Steps
197
+
198
+ 4.1. List all `.claude/rules/*.md` files.
199
+ 4.2. For each rule with path-based frontmatter:
200
+ - Extract the `paths:` patterns
201
+ - Verify at least one file matches the glob pattern
202
+ - If no files match, the rule is orphaned
203
+
204
+ 4.3. Check for missing rules:
205
+ - Are there important directories with no corresponding rule?
206
+ - Compare rule coverage against project structure
207
+
208
+ 4.4. Check for conflicting rules:
209
+ - Do any rules give contradictory instructions for the same paths?
210
+
211
+ ### Findings Format
212
+
213
+ ```yaml
214
+ rules_audit:
215
+ total_rules: 6
216
+ active: 4
217
+ orphaned: 1
218
+ missing_coverage: 2
219
+ orphaned_details:
220
+ - file: ".claude/rules/graphql.md"
221
+ paths_pattern: "src/graphql/**"
222
+ issue: "No graphql directory exists (removed in v2 migration)"
223
+ missing_coverage:
224
+ - directory: "src/middleware/"
225
+ suggestion: "Create middleware.md rule for auth and validation patterns"
226
+ ```
227
+
228
+ ---
229
+
230
+ ## Phase 5: Auto-Memory Audit
231
+
232
+ **Goal:** Check agent memory files for stale entries.
233
+
234
+ ### Steps
235
+
236
+ 5.1. Scan `.claude/agent-memory/` for all memory files.
237
+ 5.2. For each memory file:
238
+ - Check if referenced files still exist
239
+ - Check if referenced patterns are still valid
240
+ - Check for contradictions with current CLAUDE.md
241
+ 5.3. Check MEMORY.md line count (should be under 200 for auto-loading).
242
+ 5.4. Identify entries that are session-specific (should not be in persistent memory).
243
+
244
+ ---
245
+
246
+ ## Phase 6: Rot Score and Remediation
247
+
248
+ **Goal:** Calculate overall health and produce a fix plan.
249
+
250
+ ### Rot Score Calculation
251
+
252
+ ```
253
+ Rot Score = (missing_refs * 3) + (stale_instructions * 5) + (orphaned_rules * 2) +
254
+ (size_penalty) + (memory_issues * 2)
255
+
256
+ Size Penalty:
257
+ < 200 lines: 0 points
258
+ 200-500 lines: 5 points
259
+ 500+ lines: 15 points
260
+
261
+ Score Interpretation:
262
+ 0-5: Healthy (green)
263
+ 6-15: Minor rot (yellow) -- schedule cleanup
264
+ 16-30: Significant rot (orange) -- clean up soon
265
+ 31+: Critical rot (red) -- clean up now
266
+ ```
267
+
268
+ ### Remediation Plan
269
+
270
+ 6.1. Generate prioritized fix list:
271
+
272
+ | Priority | Fix | Effort | Impact |
273
+ |----------|-----|--------|--------|
274
+ | P0 | Remove references to deleted files | Low | High |
275
+ | P1 | Update stale instructions | Medium | High |
276
+ | P2 | Remove orphaned rules | Low | Medium |
277
+ | P3 | Extract large CLAUDE.md sections to rules | Medium | Medium |
278
+ | P4 | Clean stale memory entries | Low | Low |
279
+
280
+ 6.2. If `fix_automatically` is true, apply P0 fixes automatically.
281
+ 6.3. Generate a summary report.
282
+
283
+ ---
284
+
285
+ ## Output Format
286
+
287
+ ```yaml
288
+ context_rot_audit_result:
289
+ rot_score: 12
290
+ severity: "yellow"
291
+ summary:
292
+ total_checks: 89
293
+ passed: 76
294
+ warnings: 8
295
+ failures: 5
296
+ phases:
297
+ size_audit:
298
+ lines: 234
299
+ status: "growing"
300
+ reference_validation:
301
+ total: 45
302
+ missing: 3
303
+ instruction_staleness:
304
+ total: 23
305
+ stale: 2
306
+ rules_structure:
307
+ total: 6
308
+ orphaned: 1
309
+ auto_memory:
310
+ total: 3
311
+ stale_entries: 1
312
+ remediation:
313
+ auto_fixed: 0
314
+ manual_fixes_needed: 7
315
+ priority_list: [...]
316
+ overall_status: "NEEDS_ATTENTION"
317
+ ```
318
+
319
+ ---
320
+
321
+ ## Veto Conditions
322
+
323
+ | Condition | Action |
324
+ |-----------|--------|
325
+ | No CLAUDE.md and no .claude/ directory | HALT -- nothing to audit |
326
+ | Project has no git history (cannot determine staleness) | WARN -- skip staleness checks |
327
+ | Rot score exceeds 50 | HALT -- critical rot, needs immediate human attention |
328
+ | Auto-fix would modify more than 10 files | HALT -- too many changes, require manual review |
329
+ | CLAUDE.md has SINAPSE-managed sections | WARN -- do not modify managed sections |
@@ -0,0 +1,278 @@
1
+ # Task: Create Custom Subagent Definition
2
+
3
+ **Task ID:** create-agent-definition
4
+ **Version:** 1.0
5
+ **Purpose:** Create a purpose-built subagent definition file for use with the Agent tool
6
+ **Orchestrator:** @swarm-orqx (Nexus)
7
+ **Mode:** Interactive (elicit: true)
8
+ **Quality Standard:** Agent file passes lint, loads correctly, and executes test prompt
9
+
10
+ ---
11
+
12
+ ## Overview
13
+
14
+ This task creates a custom subagent definition in `.claude/agents/` that can be invoked via the Agent tool. Subagents are specialized Claude instances with scoped instructions, model selection, and optional tool restrictions.
15
+
16
+ ```
17
+ INPUT (agent_purpose + scope + complexity)
18
+ |
19
+ [PHASE 1: PURPOSE DEFINITION]
20
+ -> Define what the agent does and does not do
21
+ -> Identify required tools and knowledge
22
+ -> Determine isolation needs
23
+ |
24
+ [PHASE 2: TYPE SELECTION]
25
+ -> Choose subagent type (general, explore, plan)
26
+ -> Select model (opus, sonnet, haiku)
27
+ -> Define tool restrictions
28
+ |
29
+ [PHASE 3: FILE CREATION]
30
+ -> Create .claude/agents/{name}.md
31
+ -> Write YAML frontmatter
32
+ -> Write instruction body in markdown
33
+ |
34
+ [PHASE 4: INSTRUCTION ENGINEERING]
35
+ -> Write clear behavioral instructions
36
+ -> Define output format expectations
37
+ -> Add guardrails and constraints
38
+ |
39
+ [PHASE 5: MODEL SELECTION]
40
+ -> Match complexity to model tier
41
+ -> Configure cost/quality tradeoff
42
+ -> Set max_turns if needed
43
+ |
44
+ [PHASE 6: VALIDATION]
45
+ -> Test agent with Agent tool
46
+ -> Verify tool access works as expected
47
+ -> Check output quality
48
+ |
49
+ OUTPUT: Agent definition file + test results
50
+ ```
51
+
52
+ ---
53
+
54
+ ## Inputs
55
+
56
+ | Field | Type | Source | Required | Validation |
57
+ |-------|------|--------|----------|------------|
58
+ | agent_name | string | User | yes | Kebab-case, no spaces (e.g., code-reviewer) |
59
+ | agent_purpose | string | User | yes | One-sentence description of what the agent does |
60
+ | complexity | enum | User or auto | yes | simple / standard / complex |
61
+ | tools_needed | array | User | no | List of tools the agent needs access to |
62
+ | output_format | string | User | no | Expected output structure (markdown, json, yaml) |
63
+
64
+ ---
65
+
66
+ ## Preconditions
67
+
68
+ 1. `.claude/agents/` directory exists (create if not)
69
+ 2. Understanding of the task the agent will perform
70
+ 3. Claude Code is operational for testing
71
+
72
+ ---
73
+
74
+ ## Phase 1: Purpose Definition
75
+
76
+ **Goal:** Clearly scope what the agent will and will not do.
77
+
78
+ ### Steps
79
+
80
+ 1.1. Define the agent's primary responsibility in one sentence.
81
+ 1.2. List 3-5 specific tasks the agent should handle.
82
+ 1.3. List 2-3 things the agent should NOT do (anti-scope).
83
+ 1.4. Identify what context the agent needs (files, project knowledge, etc.).
84
+
85
+ ### Purpose Template
86
+
87
+ ```
88
+ Agent: {name}
89
+ Does: {primary responsibility}
90
+ Tasks: {task1}, {task2}, {task3}
91
+ Does NOT: {anti1}, {anti2}
92
+ Needs: {context1}, {context2}
93
+ ```
94
+
95
+ ---
96
+
97
+ ## Phase 2: Type Selection
98
+
99
+ **Goal:** Choose the right subagent configuration.
100
+
101
+ ### Subagent Types
102
+
103
+ | Type | Tools Available | Best For |
104
+ |------|----------------|----------|
105
+ | **General-purpose** (default) | All tools | Implementation, analysis, complex tasks |
106
+ | **Explore** | Read, Glob, Grep, Bash(read-only) | Research, code search, documentation lookup |
107
+ | **Plan** | Read, Glob, Grep (no write) | Design, architecture, planning tasks |
108
+
109
+ ### Steps
110
+
111
+ 2.1. Match the agent's purpose to a type.
112
+ 2.2. If none fit, use general-purpose with explicit `allowed-tools` restrictions.
113
+ 2.3. Document the type decision and rationale.
114
+
115
+ ---
116
+
117
+ ## Phase 3: File Creation
118
+
119
+ **Goal:** Create the agent definition file with proper structure.
120
+
121
+ ### Agent File Template
122
+
123
+ ```markdown
124
+ ---
125
+ name: {agent-name}
126
+ description: {one-line description}
127
+ model: {opus-4|sonnet-4|haiku-4}
128
+ allowed-tools:
129
+ - Read
130
+ - Write
131
+ - Edit
132
+ - Bash
133
+ - Grep
134
+ - Glob
135
+ ---
136
+
137
+ # {Agent Name}
138
+
139
+ ## Role
140
+ {Detailed description of agent's role and expertise}
141
+
142
+ ## Instructions
143
+ {Step-by-step behavioral instructions}
144
+
145
+ ## Constraints
146
+ {What the agent must NOT do}
147
+
148
+ ## Output Format
149
+ {Expected output structure}
150
+ ```
151
+
152
+ ### Steps
153
+
154
+ 3.1. Create `.claude/agents/{name}.md` using the template above.
155
+ 3.2. Fill in YAML frontmatter with name, description, model, and allowed-tools.
156
+ 3.3. The frontmatter fields are:
157
+ - `name`: Display name for the agent
158
+ - `description`: Brief description shown in agent listings
159
+ - `model`: Which Claude model to use (see Phase 5)
160
+ - `allowed-tools`: Array of tools the agent can access (omit for all tools)
161
+
162
+ ---
163
+
164
+ ## Phase 4: Instruction Engineering
165
+
166
+ **Goal:** Write clear, effective instructions in the markdown body.
167
+
168
+ ### Instruction Best Practices
169
+
170
+ 1. **Be specific** -- "Analyze imports and suggest barrel files" not "Help with code"
171
+ 2. **Set output expectations** -- Describe the exact format you want
172
+ 3. **Add examples** -- Show input/output pairs when possible
173
+ 4. **Define boundaries** -- What the agent should refuse or escalate
174
+ 5. **Include context loading** -- Tell the agent what files to read first
175
+
176
+ ### Instruction Sections
177
+
178
+ ```markdown
179
+ ## Role
180
+ You are a {role} specialized in {domain}. Your job is to {primary task}.
181
+
182
+ ## Process
183
+ 1. First, read {relevant files}
184
+ 2. Then, analyze {what to look for}
185
+ 3. Finally, produce {output format}
186
+
187
+ ## Rules
188
+ - ALWAYS {mandatory behavior}
189
+ - NEVER {prohibited behavior}
190
+ - When unsure, {fallback behavior}
191
+
192
+ ## Output Format
193
+ Return your analysis as:
194
+ {format specification}
195
+ ```
196
+
197
+ 4.1. Write the Role section with clear identity.
198
+ 4.2. Write the Process section with numbered steps.
199
+ 4.3. Write the Rules section with ALWAYS/NEVER constraints.
200
+ 4.4. Write the Output Format section with structure specification.
201
+
202
+ ---
203
+
204
+ ## Phase 5: Model Selection
205
+
206
+ **Goal:** Choose the right model for cost and quality balance.
207
+
208
+ ### Model Selection Guide
209
+
210
+ | Model | Cost | Speed | Best For |
211
+ |-------|------|-------|----------|
212
+ | **claude-opus-4** | High | Slow | Complex analysis, architecture decisions, nuanced writing |
213
+ | **claude-sonnet-4** | Medium | Medium | Standard tasks, code review, implementation |
214
+ | **claude-haiku-4** | Low | Fast | Simple lookups, formatting, repetitive tasks |
215
+
216
+ ### Decision Matrix
217
+
218
+ ```
219
+ Is the task complex with ambiguous inputs?
220
+ YES -> opus
221
+ NO -> Does it require code generation or analysis?
222
+ YES -> sonnet
223
+ NO -> Is it a simple lookup or formatting task?
224
+ YES -> haiku
225
+ NO -> sonnet (safe default)
226
+ ```
227
+
228
+ 5.1. Evaluate task complexity against the matrix.
229
+ 5.2. Set the `model` field in frontmatter.
230
+ 5.3. Consider that subagents incur per-call costs -- haiku for high-frequency agents.
231
+
232
+ ---
233
+
234
+ ## Phase 6: Validation
235
+
236
+ **Goal:** Test that the agent works correctly.
237
+
238
+ ### Steps
239
+
240
+ 6.1. Invoke the agent using the Agent tool with a representative prompt.
241
+ 6.2. Verify the agent:
242
+ - Uses only its allowed tools
243
+ - Follows its instructions
244
+ - Produces output in the expected format
245
+ - Stays within its defined scope
246
+ 6.3. If the agent fails, iterate on instructions (most common fix).
247
+ 6.4. Run 2-3 different test prompts to cover edge cases.
248
+
249
+ ---
250
+
251
+ ## Output Format
252
+
253
+ ```yaml
254
+ agent_definition_result:
255
+ file: ".claude/agents/{name}.md"
256
+ name: "{agent-name}"
257
+ type: "{general|explore|plan}"
258
+ model: "{opus-4|sonnet-4|haiku-4}"
259
+ tools_allowed: [...]
260
+ test_results:
261
+ - prompt: "Test prompt 1"
262
+ status: "pass"
263
+ - prompt: "Test prompt 2"
264
+ status: "pass"
265
+ ready: true
266
+ ```
267
+
268
+ ---
269
+
270
+ ## Veto Conditions
271
+
272
+ | Condition | Action |
273
+ |-----------|--------|
274
+ | Agent purpose is too broad (covers 5+ unrelated domains) | HALT -- split into multiple agents |
275
+ | No clear output format defined | HALT -- define expected output before creation |
276
+ | Agent requires tools that do not exist | HALT -- verify tool availability first |
277
+ | Test prompts all fail | HALT -- rewrite instructions, do not ship broken agent |
278
+ | Agent name conflicts with existing agent | HALT -- choose unique name |