claude-all-hands 1.0.1 → 1.0.2

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 (160) hide show
  1. package/.claude/agents/code-simplifier.md +52 -0
  2. package/.claude/agents/curator.md +189 -245
  3. package/.claude/agents/documentor.md +147 -0
  4. package/.claude/agents/planner.md +123 -166
  5. package/.claude/agents/researcher.md +58 -41
  6. package/.claude/agents/surveyor.md +81 -0
  7. package/.claude/agents/worker.md +74 -0
  8. package/.claude/commands/audit-docs.md +94 -0
  9. package/.claude/commands/continue.md +120 -0
  10. package/.claude/commands/create-docs.md +100 -0
  11. package/.claude/commands/create-skill.md +107 -0
  12. package/.claude/commands/create-specialist.md +111 -0
  13. package/.claude/commands/curator-audit.md +4 -0
  14. package/.claude/commands/debug.md +183 -0
  15. package/.claude/commands/plan.md +199 -102
  16. package/.claude/commands/validate.md +11 -0
  17. package/.claude/commands/whats-next.md +106 -134
  18. package/.claude/envoy/envoy +11 -14
  19. package/.claude/envoy/package-lock.json +1388 -0
  20. package/.claude/envoy/package.json +29 -0
  21. package/.claude/envoy/src/cli.ts +126 -0
  22. package/.claude/envoy/src/commands/base.ts +216 -0
  23. package/.claude/envoy/src/commands/gemini.ts +999 -0
  24. package/.claude/envoy/src/commands/git.ts +639 -0
  25. package/.claude/envoy/src/commands/index.ts +73 -0
  26. package/.claude/envoy/src/commands/knowledge.ts +187 -0
  27. package/.claude/envoy/src/commands/perplexity.ts +129 -0
  28. package/.claude/envoy/src/commands/plan/core.ts +134 -0
  29. package/.claude/envoy/src/commands/plan/findings.ts +446 -0
  30. package/.claude/envoy/src/commands/plan/gates.ts +672 -0
  31. package/.claude/envoy/src/commands/plan/index.ts +135 -0
  32. package/.claude/envoy/src/commands/plan/lifecycle.ts +648 -0
  33. package/.claude/envoy/src/commands/plan/plan-file.ts +138 -0
  34. package/.claude/envoy/src/commands/plan/prompts.ts +285 -0
  35. package/.claude/envoy/src/commands/plan/protocols.ts +166 -0
  36. package/.claude/envoy/src/commands/repomix.ts +99 -0
  37. package/.claude/envoy/src/commands/tavily.ts +220 -0
  38. package/.claude/envoy/src/commands/xai.ts +168 -0
  39. package/.claude/envoy/src/lib/design.ts +41 -0
  40. package/.claude/envoy/src/lib/feedback-schemas.ts +154 -0
  41. package/.claude/envoy/src/lib/findings.ts +215 -0
  42. package/.claude/envoy/src/lib/gates.ts +572 -0
  43. package/.claude/envoy/src/lib/git.ts +132 -0
  44. package/.claude/envoy/src/lib/index.ts +188 -0
  45. package/.claude/envoy/src/lib/knowledge.ts +594 -0
  46. package/.claude/envoy/src/lib/markdown.ts +75 -0
  47. package/.claude/envoy/src/lib/observability.ts +262 -0
  48. package/.claude/envoy/src/lib/paths.ts +130 -0
  49. package/.claude/envoy/src/lib/plan-io.ts +117 -0
  50. package/.claude/envoy/src/lib/prompts.ts +231 -0
  51. package/.claude/envoy/src/lib/protocols.ts +314 -0
  52. package/.claude/envoy/src/lib/repomix.ts +133 -0
  53. package/.claude/envoy/src/lib/retry.ts +138 -0
  54. package/.claude/envoy/src/lib/watcher.ts +167 -0
  55. package/.claude/envoy/tsconfig.json +21 -0
  56. package/.claude/hooks/scripts/scan_agents.py +62 -0
  57. package/.claude/hooks/scripts/scan_commands.py +50 -0
  58. package/.claude/hooks/scripts/scan_skills.py +46 -70
  59. package/.claude/hooks/scripts/validate_artifacts.py +128 -0
  60. package/.claude/hooks/startup.sh +26 -24
  61. package/.claude/protocols/bug-discovery.yaml +55 -0
  62. package/.claude/protocols/debugging.yaml +51 -0
  63. package/.claude/protocols/discovery.yaml +53 -0
  64. package/.claude/protocols/implementation.yaml +84 -0
  65. package/.claude/settings.json +37 -97
  66. package/.claude/skills/brainstorming/SKILL.md +54 -0
  67. package/.claude/skills/commands-development/SKILL.md +630 -0
  68. package/.claude/skills/commands-development/references/arguments.md +252 -0
  69. package/.claude/skills/commands-development/references/patterns.md +796 -0
  70. package/.claude/skills/commands-development/references/tool-restrictions.md +376 -0
  71. package/.claude/skills/discovery-mode/SKILL.md +108 -0
  72. package/.claude/skills/hooks-development/SKILL.md +332 -0
  73. package/.claude/skills/hooks-development/references/command-vs-prompt.md +269 -0
  74. package/.claude/skills/hooks-development/references/examples.md +658 -0
  75. package/.claude/skills/hooks-development/references/hook-types.md +463 -0
  76. package/.claude/skills/hooks-development/references/input-output-schemas.md +469 -0
  77. package/.claude/skills/hooks-development/references/matchers.md +470 -0
  78. package/.claude/skills/hooks-development/references/troubleshooting.md +587 -0
  79. package/.claude/skills/implementation-mode/SKILL.md +171 -0
  80. package/.claude/skills/research-tools/SKILL.md +35 -33
  81. package/.claude/skills/skills-development/SKILL.md +192 -0
  82. package/.claude/skills/skills-development/references/api-security.md +226 -0
  83. package/.claude/skills/skills-development/references/be-clear-and-direct.md +531 -0
  84. package/.claude/skills/skills-development/references/common-patterns.md +595 -0
  85. package/.claude/skills/skills-development/references/core-principles.md +437 -0
  86. package/.claude/skills/skills-development/references/executable-code.md +175 -0
  87. package/.claude/skills/skills-development/references/iteration-and-testing.md +474 -0
  88. package/.claude/skills/skills-development/references/recommended-structure.md +168 -0
  89. package/.claude/skills/skills-development/references/skill-structure.md +372 -0
  90. package/.claude/skills/skills-development/references/use-xml-tags.md +466 -0
  91. package/.claude/skills/skills-development/references/using-scripts.md +113 -0
  92. package/.claude/skills/skills-development/references/using-templates.md +112 -0
  93. package/.claude/skills/skills-development/references/workflows-and-validation.md +510 -0
  94. package/.claude/skills/skills-development/templates/router-skill.md +73 -0
  95. package/.claude/skills/skills-development/templates/simple-skill.md +33 -0
  96. package/.claude/skills/skills-development/workflows/add-reference.md +96 -0
  97. package/.claude/skills/skills-development/workflows/add-script.md +93 -0
  98. package/.claude/skills/skills-development/workflows/add-template.md +74 -0
  99. package/.claude/skills/skills-development/workflows/add-workflow.md +120 -0
  100. package/.claude/skills/skills-development/workflows/audit-skill.md +138 -0
  101. package/.claude/skills/skills-development/workflows/create-domain-expertise-skill.md +605 -0
  102. package/.claude/skills/skills-development/workflows/create-new-skill.md +191 -0
  103. package/.claude/skills/skills-development/workflows/get-guidance.md +121 -0
  104. package/.claude/skills/skills-development/workflows/upgrade-to-router.md +161 -0
  105. package/.claude/skills/skills-development/workflows/verify-skill.md +204 -0
  106. package/.claude/skills/subagents-development/SKILL.md +325 -0
  107. package/.claude/skills/subagents-development/references/context-management.md +567 -0
  108. package/.claude/skills/subagents-development/references/debugging-agents.md +714 -0
  109. package/.claude/skills/subagents-development/references/error-handling-and-recovery.md +502 -0
  110. package/.claude/skills/subagents-development/references/evaluation-and-testing.md +374 -0
  111. package/.claude/skills/subagents-development/references/orchestration-patterns.md +591 -0
  112. package/.claude/skills/subagents-development/references/subagents.md +508 -0
  113. package/.claude/skills/subagents-development/references/writing-subagent-prompts.md +517 -0
  114. package/.claude/statusline.sh +24 -0
  115. package/bin/cli.js +110 -72
  116. package/package.json +1 -1
  117. package/.claude/agents/explorer.md +0 -62
  118. package/.claude/agents/parallel-worker.md +0 -121
  119. package/.claude/commands/curation-fix.md +0 -92
  120. package/.claude/commands/new-branch.md +0 -36
  121. package/.claude/commands/parallel-discovery.md +0 -69
  122. package/.claude/commands/parallel-orchestration.md +0 -99
  123. package/.claude/commands/plan-checkpoint.md +0 -37
  124. package/.claude/envoy/commands/__init__.py +0 -1
  125. package/.claude/envoy/commands/base.py +0 -95
  126. package/.claude/envoy/commands/parallel.py +0 -439
  127. package/.claude/envoy/commands/perplexity.py +0 -86
  128. package/.claude/envoy/commands/plans.py +0 -451
  129. package/.claude/envoy/commands/tavily.py +0 -156
  130. package/.claude/envoy/commands/vertex.py +0 -358
  131. package/.claude/envoy/commands/xai.py +0 -124
  132. package/.claude/envoy/envoy.py +0 -122
  133. package/.claude/envoy/pyrightconfig.json +0 -4
  134. package/.claude/envoy/requirements.txt +0 -2
  135. package/.claude/hooks/capture-queries.sh +0 -3
  136. package/.claude/hooks/scripts/enforce_planning.py +0 -118
  137. package/.claude/hooks/scripts/enforce_rg.py +0 -34
  138. package/.claude/hooks/scripts/validate_skill.py +0 -81
  139. package/.claude/skills/claude-envoy-curation/SKILL.md +0 -162
  140. package/.claude/skills/claude-envoy-usage/SKILL.md +0 -46
  141. package/.claude/skills/command-development/SKILL.md +0 -206
  142. package/.claude/skills/command-development/examples/simple-commands.md +0 -212
  143. package/.claude/skills/command-development/references/frontmatter-reference.md +0 -221
  144. package/.claude/skills/hook-development/SKILL.md +0 -127
  145. package/.claude/skills/hook-development/examples/command-hooks.md +0 -301
  146. package/.claude/skills/hook-development/examples/prompt-hooks.md +0 -114
  147. package/.claude/skills/hook-development/references/event-reference.md +0 -226
  148. package/.claude/skills/repomix-extraction/SKILL.md +0 -91
  149. package/.claude/skills/skill-development/SKILL.md +0 -168
  150. package/.claude/skills/skill-development/examples/complete-skill-examples.md +0 -281
  151. package/.claude/skills/skill-development/references/progressive-disclosure.md +0 -141
  152. package/.claude/skills/skill-development/references/writing-style.md +0 -180
  153. package/.claude/skills/skill-development/scripts/validate-skill.sh +0 -144
  154. package/.claude/skills/specialist-builder/SKILL.md +0 -327
  155. package/.claude/skills/specialist-builder/docs/agent-catalog.md +0 -28
  156. package/.claude/skills/specialist-builder/examples/complete-agent-examples.md +0 -206
  157. package/.claude/skills/specialist-builder/references/system-prompt-patterns.md +0 -281
  158. package/.claude/skills/specialist-builder/references/triggering-examples.md +0 -162
  159. package/.claude/skills/specialist-builder/scripts/validate-agent.sh +0 -137
  160. /package/.claude/{envoy/claude-envoy.py → skills/claude-envoy-patterns/SKILL.md} +0 -0
@@ -0,0 +1,508 @@
1
+ <file_format>
2
+ Subagent file structure:
3
+
4
+ ```markdown
5
+ ---
6
+ name: your-subagent-name
7
+ description: Description of when this subagent should be invoked
8
+ tools: tool1, tool2, tool3 # Optional - inherits all tools if omitted
9
+ model: sonnet # Optional - specify model alias or 'inherit'
10
+ skills: skill1, skill2 # CRITICAL - skills to auto-load for domain expertise
11
+ permissionMode: default # Optional - permission handling mode
12
+ ---
13
+
14
+ <role>
15
+ Your subagent's system prompt using pure XML structure. This defines the subagent's role, capabilities, and approach.
16
+ </role>
17
+
18
+ <constraints>
19
+ Hard rules using NEVER/MUST/ALWAYS for critical boundaries.
20
+ </constraints>
21
+
22
+ <workflow>
23
+ Step-by-step process for consistency.
24
+ </workflow>
25
+ ```
26
+
27
+ **Critical**: Use pure XML structure in the body. Remove ALL markdown headings (##, ###). Keep markdown formatting within content (bold, lists, code blocks).
28
+
29
+ <configuration_fields>
30
+ | Field | Required | Description |
31
+ |-------|----------|-------------|
32
+ | `name` | Yes | Unique identifier using lowercase letters and hyphens |
33
+ | `description` | Yes | Natural language description of purpose. Include when Claude should invoke this. |
34
+ | `tools` | No | Comma-separated list. If omitted, inherits all tools from main thread |
35
+ | `model` | No | `sonnet`, `opus`, `haiku`, or `inherit`. If omitted, uses default subagent model |
36
+ | `skills` | No | **CRITICAL FOR CAPABILITIES** - Comma-separated skill names to auto-load. Skills provide domain expertise. Without skills, agent has no specialized knowledge. |
37
+ | `permissionMode` | No | Permission handling: `default`, `acceptEdits`, `bypassPermissions`, `plan`, `ignore` |
38
+ </configuration_fields>
39
+
40
+ <skills_field_importance>
41
+ **The `skills` field is critical for dictating agent capabilities.**
42
+
43
+ Skills are loaded into the subagent's context automatically when it starts:
44
+ - Provides domain expertise the agent needs to complete tasks
45
+ - Without skills, agent operates with only base knowledge
46
+ - Skills should match the agent's purpose (e.g., researcher needs `research-tools`)
47
+
48
+ **Example:**
49
+ ```yaml
50
+ ---
51
+ name: researcher
52
+ description: External research specialist with web search capability
53
+ tools: Read, Glob, Grep, Bash
54
+ skills: research-tools
55
+ ---
56
+ ```
57
+
58
+ The researcher agent auto-loads `research-tools` (web search, deep research) skill, giving it the domain expertise needed to perform research tasks.
59
+ </skills_field_importance>
60
+ </file_format>
61
+
62
+ <storage_locations>
63
+ | Type | Location | Scope | Priority |
64
+ |------|----------|-------|----------|
65
+ | **Project** | `.claude/agents/` | Current project only | Highest |
66
+ | **User** | `~/.claude/agents/` | All projects | Lower |
67
+ | **CLI** | `--agents` flag | Current session | Medium |
68
+ | **Plugin** | Plugin's `agents/` dir | All projects | Lowest |
69
+
70
+ When subagent names conflict, higher priority takes precedence.
71
+ </storage_locations>
72
+
73
+ <execution_model>
74
+ <black_box_model>
75
+ Subagents execute in isolated contexts without user interaction.
76
+
77
+ **Key characteristics:**
78
+ - Subagent receives input parameters from main chat
79
+ - Subagent runs autonomously using available tools
80
+ - Subagent returns final output/report to main chat
81
+ - User only sees final result, not intermediate steps
82
+
83
+ **This means:**
84
+ - ✅ Subagents can use Read, Write, Edit, Bash, Grep, Glob, WebSearch, WebFetch
85
+ - ✅ Subagents can access MCP servers (non-interactive tools)
86
+ - ✅ Subagents can make decisions based on their prompt and available data
87
+ - ❌ **Subagents CANNOT use AskUserQuestion**
88
+ - ❌ **Subagents CANNOT present options and wait for user selection**
89
+ - ❌ **Subagents CANNOT request confirmations or clarifications from user**
90
+ - ❌ **User does not see subagent's tool calls or intermediate reasoning**
91
+ </black_box_model>
92
+
93
+ <workflow_implications>
94
+ **When designing subagent workflows:**
95
+
96
+ Keep user interaction in main chat:
97
+ ```markdown
98
+ # ❌ WRONG - Subagent cannot do this
99
+ ---
100
+ name: requirement-gatherer
101
+ description: Gathers requirements from user
102
+ tools: AskUserQuestion # This won't work!
103
+ ---
104
+
105
+ You ask the user questions to gather requirements...
106
+ ```
107
+
108
+ ```markdown
109
+ # ✅ CORRECT - Main chat handles interaction
110
+ Main chat: Uses AskUserQuestion to gather requirements
111
+
112
+ Launch subagent: Uses requirements to research/build (no interaction)
113
+
114
+ Main chat: Present subagent results to user
115
+ ```
116
+ </workflow_implications>
117
+ </execution_model>
118
+
119
+ <tool_configuration>
120
+ <inherit_all_tools>
121
+ Omit the `tools` field to inherit all tools from main thread:
122
+
123
+ ```yaml
124
+ ---
125
+ name: code-reviewer
126
+ description: Reviews code for quality and security
127
+ ---
128
+ ```
129
+
130
+ Subagent has access to all tools, including MCP tools.
131
+ </inherit_all_tools>
132
+
133
+ <specific_tools>
134
+ Specify tools as comma-separated list for granular control:
135
+
136
+ ```yaml
137
+ ---
138
+ name: read-only-analyzer
139
+ description: Analyzes code without making changes
140
+ tools: Read, Grep, Glob
141
+ ---
142
+ ```
143
+
144
+ Use `/agents` command to see full list of available tools.
145
+ </specific_tools>
146
+ </tool_configuration>
147
+
148
+ <model_selection>
149
+ <model_capabilities>
150
+ **Sonnet 4.5** (`sonnet`):
151
+ - "Best model in the world for agents" (Anthropic)
152
+ - Exceptional at agentic tasks: 64% problem-solving on coding benchmarks
153
+ - SWE-bench Verified: 49.0%
154
+ - **Use for**: Planning, complex reasoning, validation, critical decisions
155
+
156
+ **Haiku 4.5** (`haiku`):
157
+ - "Near-frontier performance" - 90% of Sonnet 4.5's capabilities
158
+ - SWE-bench Verified: 73.3% (one of world's best coding models)
159
+ - Fastest and most cost-efficient
160
+ - **Use for**: Task execution, simple transformations, high-volume processing
161
+
162
+ **Opus** (`opus`):
163
+ - Highest performance on evaluation benchmarks
164
+ - Most capable but slowest and most expensive
165
+ - **Use for**: Highest-stakes decisions, most complex reasoning
166
+
167
+ **Inherit** (`inherit`):
168
+ - Uses same model as main conversation
169
+ - **Use for**: Ensuring consistent capabilities throughout session
170
+ </model_capabilities>
171
+
172
+ <orchestration_strategy>
173
+ **Sonnet + Haiku orchestration pattern** (optimal cost/performance):
174
+
175
+ ```markdown
176
+ 1. Sonnet 4.5 (Coordinator):
177
+ - Creates plan
178
+ - Breaks task into subtasks
179
+ - Identifies parallelizable work
180
+
181
+ 2. Multiple Haiku 4.5 instances (Workers):
182
+ - Execute subtasks in parallel
183
+ - Fast and cost-efficient
184
+ - 90% of Sonnet's capability for execution
185
+
186
+ 3. Sonnet 4.5 (Validator):
187
+ - Integrates results
188
+ - Validates output quality
189
+ - Ensures coherence
190
+ ```
191
+
192
+ **Benefit**: Use expensive Sonnet only for planning and validation, cheap Haiku for execution.
193
+ </orchestration_strategy>
194
+
195
+ <decision_framework>
196
+ **When to use each model**:
197
+
198
+ | Task Type | Recommended Model | Rationale |
199
+ |-----------|------------------|-----------|
200
+ | Simple validation | Haiku | Fast, cheap, sufficient capability |
201
+ | Code execution | Haiku | 73.3% SWE-bench, very fast |
202
+ | Complex analysis | Sonnet | Superior reasoning, worth the cost |
203
+ | Multi-step planning | Sonnet | Best for breaking down complexity |
204
+ | Quality validation | Sonnet | Critical checkpoint, needs intelligence |
205
+ | Batch processing | Haiku | Cost efficiency for high volume |
206
+ | Critical security | Sonnet | High stakes require best model |
207
+ | Output synthesis | Sonnet | Ensuring coherence across inputs |
208
+ </decision_framework>
209
+ </model_selection>
210
+
211
+ <invocation>
212
+ <automatic>
213
+ Claude automatically selects subagents based on:
214
+ - Task description in user's request
215
+ - `description` field in subagent configuration
216
+ - Current context
217
+ </automatic>
218
+
219
+ <explicit>
220
+ Users can explicitly request a subagent:
221
+
222
+ ```
223
+ > Use the code-reviewer subagent to check my recent changes
224
+ > Have the test-runner subagent fix the failing tests
225
+ ```
226
+ </explicit>
227
+ </invocation>
228
+
229
+ <management>
230
+ <using_agents_command>
231
+ **Recommended**: Use `/agents` command for interactive management:
232
+ - View all available subagents (built-in, user, project, plugin)
233
+ - Create new subagents with guided setup
234
+ - Edit existing subagents and their tool access
235
+ - Delete custom subagents
236
+ - See which subagents take priority when names conflict
237
+ </using_agents_command>
238
+
239
+ <direct_file_management>
240
+ **Alternative**: Edit subagent files directly:
241
+ - Project: `.claude/agents/subagent-name.md`
242
+ - User: `~/.claude/agents/subagent-name.md`
243
+
244
+ Follow the file format specified above (YAML frontmatter + system prompt).
245
+ </direct_file_management>
246
+
247
+ <cli_based_configuration>
248
+ **Temporary**: Define subagents via CLI for session-specific use:
249
+
250
+ ```bash
251
+ claude --agents '{
252
+ "code-reviewer": {
253
+ "description": "Expert code reviewer. Use proactively after code changes.",
254
+ "prompt": "You are a senior code reviewer. Focus on quality, security, and best practices.",
255
+ "tools": ["Read", "Grep", "Glob", "Bash"],
256
+ "model": "sonnet"
257
+ }
258
+ }'
259
+ ```
260
+
261
+ Useful for testing configurations before saving them.
262
+ </cli_based_configuration>
263
+ </management>
264
+
265
+ <example_subagents>
266
+ <test_writer>
267
+ ```markdown
268
+ ---
269
+ name: test-writer
270
+ description: Creates comprehensive test suites. Use when new code needs tests or test coverage is insufficient.
271
+ tools: Read, Write, Grep, Glob, Bash
272
+ model: sonnet
273
+ skills: testing-patterns
274
+ ---
275
+
276
+ <role>
277
+ You are a test automation specialist creating thorough, maintainable test suites.
278
+ </role>
279
+
280
+ <workflow>
281
+ 1. Analyze the code to understand functionality
282
+ 2. Identify test cases (happy path, edge cases, error conditions)
283
+ 3. Write tests using the project's testing framework
284
+ 4. Run tests to verify they pass
285
+ </workflow>
286
+
287
+ <test_quality_criteria>
288
+ - Test one behavior per test
289
+ - Use descriptive test names
290
+ - Follow AAA pattern (Arrange, Act, Assert)
291
+ - Include edge cases and error conditions
292
+ - Avoid test interdependencies
293
+ </test_quality_criteria>
294
+ ```
295
+ </test_writer>
296
+
297
+ <debugger>
298
+ ```markdown
299
+ ---
300
+ name: debugger
301
+ description: Investigates and fixes bugs. Use when errors occur or behavior is unexpected.
302
+ tools: Read, Edit, Bash, Grep, Glob
303
+ model: sonnet
304
+ skills: debugging-patterns
305
+ ---
306
+
307
+ <role>
308
+ You are a debugging specialist skilled at root cause analysis and systematic problem-solving.
309
+ </role>
310
+
311
+ <workflow>
312
+ 1. **Reproduce**: Understand and reproduce the issue
313
+ 2. **Isolate**: Identify the failing component
314
+ 3. **Analyze**: Examine code, logs, and stack traces
315
+ 4. **Hypothesize**: Form theories about the cause
316
+ 5. **Test**: Verify hypotheses systematically
317
+ 6. **Fix**: Implement and verify the solution
318
+ </workflow>
319
+
320
+ <debugging_techniques>
321
+ - Add logging/print statements to trace execution
322
+ - Use binary search to isolate the problem
323
+ - Check assumptions (inputs, state, environment)
324
+ - Review recent changes that might have introduced the bug
325
+ - Verify fix doesn't break other functionality
326
+ </debugging_techniques>
327
+ ```
328
+ </debugger>
329
+ </example_subagents>
330
+
331
+ <tool_security>
332
+ <core_principle>
333
+ **"Permission sprawl is the fastest path to unsafe autonomy."** - Anthropic
334
+
335
+ Treat tool access like production IAM: start from deny-all, allowlist only what's needed.
336
+ </core_principle>
337
+
338
+ <why_it_matters>
339
+ **Security risks of over-permissioning**:
340
+ - Agent could modify wrong code (production instead of tests)
341
+ - Agent could run dangerous commands (rm -rf, data deletion)
342
+ - Agent could expose protected information
343
+ - Agent could skip critical steps (linting, testing, validation)
344
+
345
+ **Example vulnerability**:
346
+ ```markdown
347
+ ❌ Bad: Agent drafting sales email has full access to all tools
348
+ Risk: Could access revenue dashboard data, customer financial info
349
+
350
+ ✅ Good: Agent drafting sales email has Read access to Salesforce only
351
+ Scope: Can draft email, cannot access sensitive financial data
352
+ ```
353
+ </why_it_matters>
354
+
355
+ <permission_patterns>
356
+ **Tool access patterns by trust level**:
357
+
358
+ **Trusted data processing**:
359
+ - Full tool access appropriate
360
+ - Working with user's own code
361
+ - Example: refactoring user's codebase
362
+
363
+ **Untrusted data processing**:
364
+ - Restricted tool access essential
365
+ - Processing external inputs
366
+ - Example: analyzing third-party API responses
367
+ - Limit: Read-only tools, no execution
368
+ </permission_patterns>
369
+
370
+ <audit_checklist>
371
+ **Tool access audit**:
372
+ - [ ] Does this subagent need Write/Edit, or is Read sufficient?
373
+ - [ ] Should it execute code (Bash), or just analyze?
374
+ - [ ] Are all granted tools necessary for the task?
375
+ - [ ] What's the worst-case misuse scenario?
376
+ - [ ] Can we restrict further without blocking legitimate use?
377
+
378
+ **Default**: Grant minimum necessary. Add tools only when lack of access blocks task.
379
+ </audit_checklist>
380
+ </tool_security>
381
+
382
+ <prompt_caching>
383
+ <benefits>
384
+ Prompt caching for frequently-invoked subagents:
385
+ - **90% cost reduction** on cached tokens
386
+ - **85% latency reduction** for cache hits
387
+ - Cached content: ~10% cost of uncached tokens
388
+ - Cache TTL: 5 minutes (default) or 1 hour (extended)
389
+ </benefits>
390
+
391
+ <cache_structure>
392
+ **Structure prompts for caching**:
393
+
394
+ ```markdown
395
+ ---
396
+ name: security-reviewer
397
+ description: ...
398
+ tools: ...
399
+ model: sonnet
400
+ ---
401
+
402
+ [CACHEABLE SECTION - Stable content]
403
+ <role>
404
+ You are a senior security engineer...
405
+ </role>
406
+
407
+ <focus_areas>
408
+ - SQL injection
409
+ - XSS attacks
410
+ ...
411
+ </focus_areas>
412
+
413
+ <workflow>
414
+ 1. Read modified files
415
+ 2. Identify risks
416
+ ...
417
+ </workflow>
418
+
419
+ <severity_ratings>
420
+ ...
421
+ </severity_ratings>
422
+
423
+ --- [CACHE BREAKPOINT] ---
424
+
425
+ [VARIABLE SECTION - Task-specific content]
426
+ Current task: {dynamic context}
427
+ Recent changes: {varies per invocation}
428
+ ```
429
+
430
+ **Principle**: Stable instructions at beginning (cached), variable context at end (fresh).
431
+ </cache_structure>
432
+
433
+ <when_to_use>
434
+ **Best candidates for caching**:
435
+ - Frequently-invoked subagents (multiple times per session)
436
+ - Large, stable prompts (extensive guidelines, examples)
437
+ - Consistent tool definitions across invocations
438
+ - Long-running sessions with repeated subagent use
439
+
440
+ **Not beneficial**:
441
+ - Rarely-used subagents (once per session)
442
+ - Prompts that change frequently
443
+ - Very short prompts (caching overhead > benefit)
444
+ </when_to_use>
445
+
446
+ <cache_management>
447
+ **Cache lifecycle**:
448
+ - First invocation: Writes to cache (25% cost premium)
449
+ - Subsequent invocations: 90% cheaper on cached portion
450
+ - Cache refreshes on each use (extends TTL)
451
+ - Expires after 5 minutes of non-use (or 1 hour for extended TTL)
452
+
453
+ **Invalidation triggers**:
454
+ - Subagent prompt modified
455
+ - Tool definitions changed
456
+ - Cache TTL expires
457
+ </cache_management>
458
+ </prompt_caching>
459
+
460
+ <best_practices>
461
+ <be_specific>
462
+ Create task-specific subagents, not generic helpers.
463
+
464
+ ❌ Bad: "You are a helpful assistant"
465
+ ✅ Good: "You are a React performance optimizer specializing in hooks and memoization"
466
+ </be_specific>
467
+
468
+ <clear_triggers>
469
+ Make the `description` clear about when to invoke:
470
+
471
+ ❌ Bad: "Helps with code"
472
+ ✅ Good: "Reviews code for security vulnerabilities. Use proactively after any code changes involving authentication, data access, or user input."
473
+ </clear_triggers>
474
+
475
+ <focused_tools>
476
+ Grant only the tools needed for the task (least privilege):
477
+
478
+ - Read-only analysis: `Read, Grep, Glob`
479
+ - Code modification: `Read, Edit, Bash, Grep`
480
+ - Test running: `Read, Write, Bash`
481
+
482
+ **Security note**: Over-permissioning is primary risk vector. Start minimal, add only when necessary.
483
+ </focused_tools>
484
+
485
+ <structured_prompts>
486
+ Use XML tags to structure the system prompt for clarity:
487
+
488
+ ```markdown
489
+ <role>
490
+ You are a senior security engineer specializing in web application security.
491
+ </role>
492
+
493
+ <focus_areas>
494
+ - SQL injection
495
+ - XSS attacks
496
+ - CSRF vulnerabilities
497
+ - Authentication/authorization flaws
498
+ </focus_areas>
499
+
500
+ <workflow>
501
+ 1. Analyze code changes
502
+ 2. Identify security risks
503
+ 3. Provide specific remediation
504
+ 4. Rate severity
505
+ </workflow>
506
+ ```
507
+ </structured_prompts>
508
+ </best_practices>