@clawnet/template-minimal 0.0.1
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.
- package/.agents/skills/claude-agent-sdk/.claude-plugin/plugin.json +13 -0
- package/.agents/skills/claude-agent-sdk/SKILL.md +954 -0
- package/.agents/skills/claude-agent-sdk/references/mcp-servers-guide.md +387 -0
- package/.agents/skills/claude-agent-sdk/references/permissions-guide.md +429 -0
- package/.agents/skills/claude-agent-sdk/references/query-api-reference.md +437 -0
- package/.agents/skills/claude-agent-sdk/references/session-management.md +419 -0
- package/.agents/skills/claude-agent-sdk/references/subagents-patterns.md +464 -0
- package/.agents/skills/claude-agent-sdk/references/top-errors.md +503 -0
- package/.agents/skills/claude-agent-sdk/rules/claude-agent-sdk.md +96 -0
- package/.agents/skills/claude-agent-sdk/scripts/check-versions.sh +55 -0
- package/.agents/skills/claude-agent-sdk/templates/basic-query.ts +55 -0
- package/.agents/skills/claude-agent-sdk/templates/custom-mcp-server.ts +161 -0
- package/.agents/skills/claude-agent-sdk/templates/error-handling.ts +283 -0
- package/.agents/skills/claude-agent-sdk/templates/filesystem-settings.ts +211 -0
- package/.agents/skills/claude-agent-sdk/templates/multi-agent-workflow.ts +318 -0
- package/.agents/skills/claude-agent-sdk/templates/package.json +30 -0
- package/.agents/skills/claude-agent-sdk/templates/permission-control.ts +211 -0
- package/.agents/skills/claude-agent-sdk/templates/query-with-tools.ts +54 -0
- package/.agents/skills/claude-agent-sdk/templates/session-management.ts +151 -0
- package/.agents/skills/claude-agent-sdk/templates/subagents-orchestration.ts +166 -0
- package/.agents/skills/claude-agent-sdk/templates/tsconfig.json +22 -0
- package/.claude/settings.local.json +70 -0
- package/.claude/skills/moltbook-example/SKILL.md +79 -0
- package/.claude/skills/post/SKILL.md +130 -0
- package/.env.example +4 -0
- package/.vercel/README.txt +11 -0
- package/.vercel/project.json +1 -0
- package/AGENTS.md +114 -0
- package/CLAUDE.md +532 -0
- package/README.md +44 -0
- package/api/index.ts +3 -0
- package/biome.json +14 -0
- package/clark_avatar.jpeg +0 -0
- package/package.json +21 -0
- package/scripts/wake.ts +38 -0
- package/skills/clawbook/HEARTBEAT.md +142 -0
- package/skills/clawbook/SKILL.md +219 -0
- package/skills/moltbook-example/SKILL.md +79 -0
- package/skills/moltbook-example/bot/index.ts +61 -0
- package/src/agent/prompts.ts +98 -0
- package/src/agent/runner.ts +526 -0
- package/src/agent/tool-definitions.ts +1151 -0
- package/src/agent-options.ts +14 -0
- package/src/bot-identity.ts +41 -0
- package/src/constants.ts +15 -0
- package/src/handlers/heartbeat.ts +21 -0
- package/src/handlers/openai-compat.ts +95 -0
- package/src/handlers/post.ts +21 -0
- package/src/identity.ts +83 -0
- package/src/index.ts +30 -0
- package/src/middleware/cron-auth.ts +53 -0
- package/src/middleware/sigma-auth.ts +147 -0
- package/src/runs.ts +49 -0
- package/tests/agent/prompts.test.ts +172 -0
- package/tests/agent/runner.test.ts +353 -0
- package/tests/agent/tool-definitions.test.ts +171 -0
- package/tests/constants.test.ts +24 -0
- package/tests/handlers/openai-compat.test.ts +128 -0
- package/tests/handlers.test.ts +133 -0
- package/tests/identity.test.ts +66 -0
- package/tests/index.test.ts +108 -0
- package/tests/middleware/cron-auth.test.ts +99 -0
- package/tests/middleware/sigma-auth.test.ts +198 -0
- package/tests/runs.test.ts +56 -0
- package/tests/skill.test.ts +71 -0
- package/tsconfig.json +14 -0
- package/vercel.json +9 -0
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
# Subagents Patterns
|
|
2
|
+
|
|
3
|
+
Guide to designing and orchestrating specialized subagents.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## What Are Subagents?
|
|
8
|
+
|
|
9
|
+
Specialized agents with:
|
|
10
|
+
- **Specific expertise** - Focused domain knowledge
|
|
11
|
+
- **Custom tools** - Only tools they need
|
|
12
|
+
- **Different models** - Match capability to task cost
|
|
13
|
+
- **Dedicated prompts** - Tailored instructions
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## When to Use Subagents
|
|
18
|
+
|
|
19
|
+
### ✅ Use Subagents When:
|
|
20
|
+
|
|
21
|
+
- Task requires different expertise areas
|
|
22
|
+
- Some subtasks need different models (cost optimization)
|
|
23
|
+
- Tool access should be restricted per role
|
|
24
|
+
- Clear separation of concerns needed
|
|
25
|
+
- Multiple steps with specialized knowledge
|
|
26
|
+
|
|
27
|
+
### ❌ Don't Use Subagents When:
|
|
28
|
+
|
|
29
|
+
- Single straightforward task
|
|
30
|
+
- All work can be done by one agent
|
|
31
|
+
- Overhead of orchestration > benefit
|
|
32
|
+
- Tools/permissions don't vary
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## AgentDefinition Structure
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
type AgentDefinition = {
|
|
40
|
+
description: string; // When to use this agent
|
|
41
|
+
prompt: string; // System prompt for agent
|
|
42
|
+
tools?: string[]; // Allowed tools (optional)
|
|
43
|
+
model?: 'sonnet' | 'opus' | 'haiku' | 'inherit'; // Model (optional)
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Field Guidelines
|
|
48
|
+
|
|
49
|
+
**description**:
|
|
50
|
+
- Clear, action-oriented
|
|
51
|
+
- When to invoke this agent
|
|
52
|
+
- 1-2 sentences
|
|
53
|
+
- Examples: "Run test suites", "Deploy to production"
|
|
54
|
+
|
|
55
|
+
**prompt**:
|
|
56
|
+
- Agent's role and behavior
|
|
57
|
+
- Instructions and constraints
|
|
58
|
+
- What to do and what not to do
|
|
59
|
+
- Can be detailed (100-500 tokens)
|
|
60
|
+
|
|
61
|
+
**tools**:
|
|
62
|
+
- If omitted, inherits all tools from main agent
|
|
63
|
+
- Use to restrict agent to specific tools
|
|
64
|
+
- Examples: `["Read", "Grep"]` for read-only
|
|
65
|
+
|
|
66
|
+
**model**:
|
|
67
|
+
- `"haiku"` - Fast, cost-effective ($0.25/$1.25 per MTok)
|
|
68
|
+
- `"sonnet"` - Balanced ($3/$15 per MTok)
|
|
69
|
+
- `"opus"` - Maximum capability ($15/$75 per MTok)
|
|
70
|
+
- `"inherit"` - Use main agent's model
|
|
71
|
+
- If omitted, inherits main agent's model
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Design Patterns
|
|
76
|
+
|
|
77
|
+
### Pattern 1: DevOps Pipeline
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
agents: {
|
|
81
|
+
"test-runner": {
|
|
82
|
+
description: "Run automated test suites and verify coverage",
|
|
83
|
+
prompt: `You run tests.
|
|
84
|
+
|
|
85
|
+
Execute:
|
|
86
|
+
- Unit tests
|
|
87
|
+
- Integration tests
|
|
88
|
+
- End-to-end tests
|
|
89
|
+
|
|
90
|
+
FAIL if any tests fail. Report clear errors.`,
|
|
91
|
+
tools: ["Bash", "Read"],
|
|
92
|
+
model: "haiku" // Fast, cost-effective
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
"security-checker": {
|
|
96
|
+
description: "Security audits and vulnerability scanning",
|
|
97
|
+
prompt: `You check security.
|
|
98
|
+
|
|
99
|
+
Scan for:
|
|
100
|
+
- Exposed secrets
|
|
101
|
+
- Dependency vulnerabilities
|
|
102
|
+
- Permission issues
|
|
103
|
+
- OWASP compliance
|
|
104
|
+
|
|
105
|
+
Block deployment if critical issues found.`,
|
|
106
|
+
tools: ["Read", "Grep", "Bash"],
|
|
107
|
+
model: "sonnet" // Balance for analysis
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
"deployer": {
|
|
111
|
+
description: "Application deployment and rollbacks",
|
|
112
|
+
prompt: `You deploy applications.
|
|
113
|
+
|
|
114
|
+
Process:
|
|
115
|
+
1. Deploy to staging
|
|
116
|
+
2. Verify health checks
|
|
117
|
+
3. Deploy to production
|
|
118
|
+
4. Create rollback plan
|
|
119
|
+
|
|
120
|
+
ALWAYS have rollback ready.`,
|
|
121
|
+
tools: ["Bash", "Read"],
|
|
122
|
+
model: "sonnet" // Reliable for critical ops
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Pattern 2: Code Review Workflow
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
agents: {
|
|
131
|
+
"syntax-checker": {
|
|
132
|
+
description: "Check syntax, formatting, and linting",
|
|
133
|
+
prompt: `You check syntax and formatting.
|
|
134
|
+
|
|
135
|
+
Run:
|
|
136
|
+
- ESLint
|
|
137
|
+
- Prettier
|
|
138
|
+
- TypeScript type checking
|
|
139
|
+
|
|
140
|
+
Report all violations clearly.`,
|
|
141
|
+
tools: ["Bash", "Read"],
|
|
142
|
+
model: "haiku" // Fast checks
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
"logic-reviewer": {
|
|
146
|
+
description: "Review logic, algorithms, and architecture",
|
|
147
|
+
prompt: `You review code logic.
|
|
148
|
+
|
|
149
|
+
Check:
|
|
150
|
+
- Algorithmic correctness
|
|
151
|
+
- Edge cases
|
|
152
|
+
- Performance issues
|
|
153
|
+
- Design patterns
|
|
154
|
+
|
|
155
|
+
Suggest improvements.`,
|
|
156
|
+
tools: ["Read", "Grep"],
|
|
157
|
+
model: "sonnet" // Complex analysis
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
"security-reviewer": {
|
|
161
|
+
description: "Review for security vulnerabilities",
|
|
162
|
+
prompt: `You review security.
|
|
163
|
+
|
|
164
|
+
Check:
|
|
165
|
+
- SQL injection
|
|
166
|
+
- XSS vulnerabilities
|
|
167
|
+
- Authentication bypass
|
|
168
|
+
- Data exposure
|
|
169
|
+
|
|
170
|
+
FAIL on critical issues.`,
|
|
171
|
+
tools: ["Read", "Grep"],
|
|
172
|
+
model: "sonnet" // Security expertise
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Pattern 3: Content Generation
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
agents: {
|
|
181
|
+
"researcher": {
|
|
182
|
+
description: "Research topics and gather information",
|
|
183
|
+
prompt: `You research topics.
|
|
184
|
+
|
|
185
|
+
Gather:
|
|
186
|
+
- Relevant information
|
|
187
|
+
- Latest trends
|
|
188
|
+
- Best practices
|
|
189
|
+
- Examples
|
|
190
|
+
|
|
191
|
+
Provide comprehensive research.`,
|
|
192
|
+
tools: ["WebSearch", "WebFetch", "Read"],
|
|
193
|
+
model: "haiku" // Fast research
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
"writer": {
|
|
197
|
+
description: "Write content based on research",
|
|
198
|
+
prompt: `You write content.
|
|
199
|
+
|
|
200
|
+
Write:
|
|
201
|
+
- Clear, engaging prose
|
|
202
|
+
- Well-structured
|
|
203
|
+
- Audience-appropriate
|
|
204
|
+
- Fact-based
|
|
205
|
+
|
|
206
|
+
Use research provided.`,
|
|
207
|
+
tools: ["Write", "Read"],
|
|
208
|
+
model: "sonnet" // Quality writing
|
|
209
|
+
},
|
|
210
|
+
|
|
211
|
+
"editor": {
|
|
212
|
+
description: "Edit and polish content",
|
|
213
|
+
prompt: `You edit content.
|
|
214
|
+
|
|
215
|
+
Check:
|
|
216
|
+
- Grammar and spelling
|
|
217
|
+
- Clarity and flow
|
|
218
|
+
- Consistency
|
|
219
|
+
- Formatting
|
|
220
|
+
|
|
221
|
+
Polish to perfection.`,
|
|
222
|
+
tools: ["Read", "Edit"],
|
|
223
|
+
model: "sonnet" // Quality editing
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Pattern 4: Incident Response
|
|
229
|
+
|
|
230
|
+
```typescript
|
|
231
|
+
agents: {
|
|
232
|
+
"incident-detector": {
|
|
233
|
+
description: "Detect and triage incidents",
|
|
234
|
+
prompt: `You detect incidents.
|
|
235
|
+
|
|
236
|
+
Monitor:
|
|
237
|
+
- Error rates
|
|
238
|
+
- Response times
|
|
239
|
+
- System health
|
|
240
|
+
- Alerts
|
|
241
|
+
|
|
242
|
+
Assess severity and impact.`,
|
|
243
|
+
tools: ["Bash", "Read"],
|
|
244
|
+
model: "haiku" // Fast detection
|
|
245
|
+
},
|
|
246
|
+
|
|
247
|
+
"root-cause-analyzer": {
|
|
248
|
+
description: "Analyze root cause of incidents",
|
|
249
|
+
prompt: `You analyze root causes.
|
|
250
|
+
|
|
251
|
+
Investigate:
|
|
252
|
+
- Logs
|
|
253
|
+
- Metrics
|
|
254
|
+
- Recent changes
|
|
255
|
+
- Dependencies
|
|
256
|
+
|
|
257
|
+
Identify exact cause.`,
|
|
258
|
+
tools: ["Bash", "Read", "Grep"],
|
|
259
|
+
model: "sonnet" // Deep analysis
|
|
260
|
+
},
|
|
261
|
+
|
|
262
|
+
"fix-implementer": {
|
|
263
|
+
description: "Implement fixes for incidents",
|
|
264
|
+
prompt: `You implement fixes.
|
|
265
|
+
|
|
266
|
+
Fix:
|
|
267
|
+
- Apply patches
|
|
268
|
+
- Rollback changes
|
|
269
|
+
- Update config
|
|
270
|
+
- Deploy hotfixes
|
|
271
|
+
|
|
272
|
+
Verify fix resolves issue.`,
|
|
273
|
+
tools: ["Read", "Edit", "Bash"],
|
|
274
|
+
model: "sonnet" // Careful fixes
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## Orchestration Strategies
|
|
282
|
+
|
|
283
|
+
### Sequential Execution
|
|
284
|
+
|
|
285
|
+
Main agent coordinates agents in order:
|
|
286
|
+
|
|
287
|
+
```
|
|
288
|
+
test-runner → security-checker → deployer
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
**Use when**: Steps must happen in order
|
|
292
|
+
|
|
293
|
+
### Parallel Execution
|
|
294
|
+
|
|
295
|
+
Main agent delegates to multiple agents at once:
|
|
296
|
+
|
|
297
|
+
```
|
|
298
|
+
test-runner
|
|
299
|
+
security-checker } in parallel
|
|
300
|
+
code-reviewer
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
**Use when**: Steps are independent
|
|
304
|
+
|
|
305
|
+
### Conditional Execution
|
|
306
|
+
|
|
307
|
+
Main agent decides which agents to use based on context:
|
|
308
|
+
|
|
309
|
+
```
|
|
310
|
+
if (tests fail) → test-fixer
|
|
311
|
+
if (security issue) → security-fixer
|
|
312
|
+
if (all pass) → deployer
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
**Use when**: Different paths needed
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
|
|
319
|
+
## Model Selection Strategy
|
|
320
|
+
|
|
321
|
+
### Cost vs Capability
|
|
322
|
+
|
|
323
|
+
| Model | Cost (in/out) | Speed | Use For |
|
|
324
|
+
|-------|---------------|-------|---------|
|
|
325
|
+
| Haiku | $0.25/$1.25 | Fastest | Monitoring, simple checks |
|
|
326
|
+
| Sonnet | $3/$15 | Medium | Code review, analysis |
|
|
327
|
+
| Opus | $15/$75 | Slowest | Complex reasoning |
|
|
328
|
+
|
|
329
|
+
### Optimization Tips
|
|
330
|
+
|
|
331
|
+
```typescript
|
|
332
|
+
// ✅ Good: Match model to task
|
|
333
|
+
agents: {
|
|
334
|
+
"monitor": { model: "haiku" }, // Simple checks
|
|
335
|
+
"reviewer": { model: "sonnet" }, // Analysis
|
|
336
|
+
"architect": { model: "opus" } // Complex design
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// ❌ Bad: Opus for everything
|
|
340
|
+
agents: {
|
|
341
|
+
"monitor": { model: "opus" }, // Wasteful
|
|
342
|
+
"reviewer": { model: "opus" }, // Wasteful
|
|
343
|
+
"simple-task": { model: "opus" } // Wasteful
|
|
344
|
+
}
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
## Tool Restriction Patterns
|
|
350
|
+
|
|
351
|
+
### Read-Only Agent
|
|
352
|
+
|
|
353
|
+
```typescript
|
|
354
|
+
{
|
|
355
|
+
description: "Analyze code without modifications",
|
|
356
|
+
tools: ["Read", "Grep", "Glob"],
|
|
357
|
+
model: "haiku"
|
|
358
|
+
}
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### Write-Only Agent
|
|
362
|
+
|
|
363
|
+
```typescript
|
|
364
|
+
{
|
|
365
|
+
description: "Generate new files",
|
|
366
|
+
tools: ["Write"],
|
|
367
|
+
model: "sonnet"
|
|
368
|
+
}
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
### Modify Agent
|
|
372
|
+
|
|
373
|
+
```typescript
|
|
374
|
+
{
|
|
375
|
+
description: "Edit existing files",
|
|
376
|
+
tools: ["Read", "Edit"],
|
|
377
|
+
model: "sonnet"
|
|
378
|
+
}
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### Full Access Agent
|
|
382
|
+
|
|
383
|
+
```typescript
|
|
384
|
+
{
|
|
385
|
+
description: "Complete control",
|
|
386
|
+
tools: ["Read", "Write", "Edit", "Bash", "Grep", "Glob"],
|
|
387
|
+
model: "sonnet"
|
|
388
|
+
}
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
---
|
|
392
|
+
|
|
393
|
+
## Communication Between Agents
|
|
394
|
+
|
|
395
|
+
Agents communicate through the main agent:
|
|
396
|
+
|
|
397
|
+
```
|
|
398
|
+
Main Agent: "Run tests"
|
|
399
|
+
↓
|
|
400
|
+
Test Runner: "Tests passed"
|
|
401
|
+
↓
|
|
402
|
+
Main Agent: "Deploy to staging"
|
|
403
|
+
↓
|
|
404
|
+
Deployer: "Deployed to staging"
|
|
405
|
+
↓
|
|
406
|
+
Main Agent: "Verify health"
|
|
407
|
+
↓
|
|
408
|
+
Monitor: "Health checks passing"
|
|
409
|
+
↓
|
|
410
|
+
Main Agent: "Deploy to production"
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
**No direct agent-to-agent communication**.
|
|
414
|
+
|
|
415
|
+
---
|
|
416
|
+
|
|
417
|
+
## Best Practices
|
|
418
|
+
|
|
419
|
+
### ✅ Do
|
|
420
|
+
|
|
421
|
+
- Give agents clear, specific roles
|
|
422
|
+
- Match model to task complexity
|
|
423
|
+
- Restrict tools per agent's needs
|
|
424
|
+
- Write detailed prompts with constraints
|
|
425
|
+
- Use descriptive agent names
|
|
426
|
+
- Test agents independently
|
|
427
|
+
- Monitor which agents are invoked
|
|
428
|
+
|
|
429
|
+
### ❌ Don't
|
|
430
|
+
|
|
431
|
+
- Create overlapping responsibilities
|
|
432
|
+
- Use Opus for simple tasks
|
|
433
|
+
- Give all agents all tools
|
|
434
|
+
- Write vague prompts
|
|
435
|
+
- Use generic names like "agent1"
|
|
436
|
+
- Skip testing in isolation
|
|
437
|
+
- Assume agents will coordinate perfectly
|
|
438
|
+
|
|
439
|
+
---
|
|
440
|
+
|
|
441
|
+
## Troubleshooting
|
|
442
|
+
|
|
443
|
+
### Agent Not Invoked
|
|
444
|
+
|
|
445
|
+
**Problem**: Main agent doesn't call subagent
|
|
446
|
+
|
|
447
|
+
**Solution**: Improve `description` to be more specific
|
|
448
|
+
|
|
449
|
+
### Wrong Agent Invoked
|
|
450
|
+
|
|
451
|
+
**Problem**: Main agent calls incorrect subagent
|
|
452
|
+
|
|
453
|
+
**Solution**: Make descriptions more distinct
|
|
454
|
+
|
|
455
|
+
### Agent Lacks Capability
|
|
456
|
+
|
|
457
|
+
**Problem**: Agent can't complete task
|
|
458
|
+
|
|
459
|
+
**Solution**: Add required tools or upgrade model
|
|
460
|
+
|
|
461
|
+
---
|
|
462
|
+
|
|
463
|
+
**For more details**: See SKILL.md
|
|
464
|
+
**Examples**: templates/subagents-orchestration.ts
|