ginskill-init 2.7.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.
- package/.wrangler/cache/pages.json +4 -0
- package/.wrangler/cache/wrangler-account.json +6 -0
- package/DEVELOPMENT.md +510 -0
- package/README.md +104 -0
- package/agents/developer.md +56 -0
- package/agents/frontend-design.md +69 -0
- package/agents/mobile-reviewer.md +36 -0
- package/agents/review-code.md +49 -0
- package/agents/security-scanner.md +50 -0
- package/agents/tester.md +72 -0
- package/bin/cli.js +461 -0
- package/landing/ai-build-ai.png +0 -0
- package/landing/index.html +1495 -0
- package/landing/logo.png +0 -0
- package/package.json +37 -0
- package/skills/active-life-dev/SKILL.md +157 -0
- package/skills/active-life-dev/docs/auth.md +187 -0
- package/skills/active-life-dev/docs/customers.md +216 -0
- package/skills/active-life-dev/docs/integrations.md +209 -0
- package/skills/active-life-dev/docs/inventory.md +192 -0
- package/skills/active-life-dev/docs/modules.md +181 -0
- package/skills/active-life-dev/docs/orders.md +180 -0
- package/skills/active-life-dev/docs/patterns.md +319 -0
- package/skills/active-life-dev/docs/products.md +216 -0
- package/skills/active-life-dev/docs/schema.md +502 -0
- package/skills/active-life-dev/docs/setup.md +169 -0
- package/skills/active-life-dev/docs/vouchers.md +144 -0
- package/skills/ai-asset-generator/SKILL.md +247 -0
- package/skills/ai-asset-generator/docs/gen-image.md +274 -0
- package/skills/ai-asset-generator/docs/genvideo.md +341 -0
- package/skills/ai-asset-generator/docs/remove-background.md +19 -0
- package/skills/ai-asset-generator/lib/bg-remove.mjs +34 -0
- package/skills/ai-asset-generator/lib/env.mjs +48 -0
- package/skills/ai-asset-generator/lib/kie-client.mjs +100 -0
- package/skills/ai-build-ai/SKILL.md +127 -0
- package/skills/ai-build-ai/docs/agent-teams.md +293 -0
- package/skills/ai-build-ai/docs/checkpointing.md +161 -0
- package/skills/ai-build-ai/docs/create-agent.md +399 -0
- package/skills/ai-build-ai/docs/create-mcp.md +395 -0
- package/skills/ai-build-ai/docs/create-skill.md +299 -0
- package/skills/ai-build-ai/docs/headless-mode.md +614 -0
- package/skills/ai-build-ai/docs/hooks.md +578 -0
- package/skills/ai-build-ai/docs/memory-claude-md.md +375 -0
- package/skills/ai-build-ai/docs/output-styles.md +208 -0
- package/skills/ai-build-ai/docs/overview.md +162 -0
- package/skills/ai-build-ai/docs/permissions.md +391 -0
- package/skills/ai-build-ai/docs/plugins.md +396 -0
- package/skills/ai-build-ai/docs/sandbox.md +262 -0
- package/skills/ai-build-ai/docs/team-lead-workflow.md +648 -0
- package/skills/ant-design/SKILL.md +323 -0
- package/skills/ant-design/docs/components.md +160 -0
- package/skills/ant-design/docs/data-entry.md +406 -0
- package/skills/ant-design/docs/display.md +594 -0
- package/skills/ant-design/docs/feedback.md +451 -0
- package/skills/ant-design/docs/key-components.md +414 -0
- package/skills/ant-design/docs/navigation.md +310 -0
- package/skills/ant-design/docs/pro-components.md +543 -0
- package/skills/ant-design/docs/setup.md +213 -0
- package/skills/ant-design/docs/theme.md +265 -0
- package/skills/flutter-performance/SKILL.md +803 -0
- package/skills/flutter-performance/references/flutter-patterns.md +595 -0
- package/skills/icon-generator/SKILL.md +270 -0
- package/skills/mobile-app-review/SKILL.md +321 -0
- package/skills/mobile-app-review/references/apple-review.md +132 -0
- package/skills/mobile-app-review/references/google-play-review.md +203 -0
- package/skills/mongodb/SKILL.md +667 -0
- package/skills/mongodb/references/mongoose-patterns.md +368 -0
- package/skills/nestjs-architecture/SKILL.md +1086 -0
- package/skills/nestjs-architecture/references/advanced-patterns.md +590 -0
- package/skills/performance/SKILL.md +509 -0
- package/skills/react-fsd-architecture/SKILL.md +693 -0
- package/skills/react-fsd-architecture/references/fsd-patterns.md +747 -0
- package/skills/react-native-expo/SKILL.md +128 -0
- package/skills/react-native-expo/references/data-layer.md +252 -0
- package/skills/react-native-expo/references/design-system.md +252 -0
- package/skills/react-native-expo/references/navigation.md +199 -0
- package/skills/react-native-expo/references/performance.md +229 -0
- package/skills/react-native-expo/references/platform-services.md +179 -0
- package/skills/react-native-expo/references/state-management.md +209 -0
- package/skills/react-native-expo/references/ui-patterns.md +301 -0
- package/skills/react-query/SKILL.md +685 -0
- package/skills/react-query/references/query-patterns.md +365 -0
- package/skills/review-code/SKILL.md +374 -0
- package/skills/review-code/references/clean-code-principles.md +395 -0
- package/skills/review-code/references/frontend-patterns.md +136 -0
- package/skills/review-code/references/nestjs-patterns.md +184 -0
- package/skills/security-scanner/SKILL.md +366 -0
- package/skills/security-scanner/references/nestjs-security.md +260 -0
- package/skills/security-scanner/references/nextjs-security.md +201 -0
- package/skills/security-scanner/references/react-native-security.md +199 -0
- package/skills/traefik/SKILL.md +105 -0
- package/skills/traefik/docs/advanced-routing.md +186 -0
- package/skills/traefik/docs/auth-providers.md +137 -0
- package/skills/traefik/docs/cicd-devops.md +396 -0
- package/skills/traefik/docs/core-config.md +171 -0
- package/skills/traefik/docs/distributed-config.md +96 -0
- package/skills/traefik/docs/docker-compose.md +182 -0
- package/skills/traefik/docs/ha-performance.md +177 -0
- package/skills/traefik/docs/kubernetes.md +278 -0
- package/skills/traefik/docs/middleware.md +205 -0
- package/skills/traefik/docs/monitoring.md +357 -0
- package/skills/traefik/docs/security.md +391 -0
- package/skills/traefik/docs/tls-acme.md +155 -0
- package/skills/ui-ux-pro-max/SKILL.md +377 -0
- package/skills/ui-ux-pro-max/data/charts.csv +26 -0
- package/skills/ui-ux-pro-max/data/colors.csv +97 -0
- package/skills/ui-ux-pro-max/data/icons.csv +101 -0
- package/skills/ui-ux-pro-max/data/landing.csv +31 -0
- package/skills/ui-ux-pro-max/data/products.csv +97 -0
- package/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/skills/ui-ux-pro-max/data/stacks/astro.csv +54 -0
- package/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/skills/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/skills/ui-ux-pro-max/data/styles.csv +68 -0
- package/skills/ui-ux-pro-max/data/typography.csv +58 -0
- package/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
# Tutorial: Create a Custom Subagent
|
|
2
|
+
|
|
3
|
+
A subagent is a specialized AI assistant that runs in its own isolated context window with a custom system prompt, specific tools, and independent permissions. When Claude encounters a matching task, it delegates to the subagent and summarizes the result.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Step 1: Understand When to Use Subagents
|
|
8
|
+
|
|
9
|
+
| Use subagents for... | Use main conversation for... |
|
|
10
|
+
|----------------------|------------------------------|
|
|
11
|
+
| Verbose operations (test runs, log analysis) | Quick edits and targeted changes |
|
|
12
|
+
| Isolated tool access (read-only, specific commands) | Multi-step work needing conversation history |
|
|
13
|
+
| Parallel workloads (research multiple modules) | Iterative refinement with feedback |
|
|
14
|
+
| Consistent domain expertise (always-code-reviewer) | Tasks where context matters |
|
|
15
|
+
| Cost optimization (route cheap tasks to Haiku) | Complex reasoning chains |
|
|
16
|
+
|
|
17
|
+
**Key constraint:** Subagents cannot spawn other subagents. For nested delegation, chain from main conversation.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Step 2: File Format and Location
|
|
22
|
+
|
|
23
|
+
Subagents are Markdown files with YAML frontmatter:
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
.claude/agents/<name>.md ← Project-level (commit to git, team shares it)
|
|
27
|
+
~/.claude/agents/<name>.md ← Personal (available in all projects)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Important:** Subagents are loaded at session start. After adding a file manually, restart Claude Code or run `/agents` to reload without restarting.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Step 3: Full Frontmatter Reference
|
|
35
|
+
|
|
36
|
+
```yaml
|
|
37
|
+
---
|
|
38
|
+
name: my-agent # REQUIRED. Unique, lowercase, hyphens only.
|
|
39
|
+
description: | # REQUIRED. When Claude should delegate to this agent.
|
|
40
|
+
Expert [domain] specialist. Use proactively when [specific situation].
|
|
41
|
+
Invoke when user [describes trigger condition].
|
|
42
|
+
|
|
43
|
+
# Tool access (pick one approach):
|
|
44
|
+
tools: Read, Grep, Glob, Bash # Allowlist — only these tools
|
|
45
|
+
disallowedTools: Write, Edit # Denylist — all tools except these
|
|
46
|
+
|
|
47
|
+
# Model selection:
|
|
48
|
+
model: haiku # haiku | sonnet | opus | inherit (default: inherit)
|
|
49
|
+
|
|
50
|
+
# Permissions:
|
|
51
|
+
permissionMode: default # default | acceptEdits | dontAsk | bypassPermissions | plan
|
|
52
|
+
|
|
53
|
+
# Execution:
|
|
54
|
+
maxTurns: 20 # Max agentic turns before stopping
|
|
55
|
+
background: false # true = always run as background task
|
|
56
|
+
isolation: worktree # Run in isolated git worktree (auto-cleaned up)
|
|
57
|
+
|
|
58
|
+
# Advanced:
|
|
59
|
+
skills: # Preload skill content into agent's context
|
|
60
|
+
- api-conventions
|
|
61
|
+
- error-handling-patterns
|
|
62
|
+
memory: user # Persistent memory: user | project | local
|
|
63
|
+
mcpServers: # MCP servers available to this agent
|
|
64
|
+
- github
|
|
65
|
+
- slack
|
|
66
|
+
|
|
67
|
+
# Hooks scoped to this agent's lifecycle:
|
|
68
|
+
hooks:
|
|
69
|
+
PreToolUse:
|
|
70
|
+
- matcher: "Bash"
|
|
71
|
+
hooks:
|
|
72
|
+
- type: command
|
|
73
|
+
command: "./scripts/validate-command.sh"
|
|
74
|
+
---
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Step 4: Write the System Prompt
|
|
80
|
+
|
|
81
|
+
The markdown body (after frontmatter) is the agent's complete system prompt. Unlike the main conversation, agents start fresh — they don't see conversation history.
|
|
82
|
+
|
|
83
|
+
### System Prompt Template
|
|
84
|
+
|
|
85
|
+
```markdown
|
|
86
|
+
You are a [role] specializing in [domain].
|
|
87
|
+
|
|
88
|
+
## Your Mission
|
|
89
|
+
[1-2 sentences on what this agent's primary job is]
|
|
90
|
+
|
|
91
|
+
## When Invoked
|
|
92
|
+
[Numbered steps describing the agent's workflow]
|
|
93
|
+
1. First, [do this]
|
|
94
|
+
2. Then, [analyze/check/validate]
|
|
95
|
+
3. Finally, [report/fix/summarize]
|
|
96
|
+
|
|
97
|
+
## Key Principles
|
|
98
|
+
- [Principle 1]: [explanation]
|
|
99
|
+
- [Principle 2]: [explanation]
|
|
100
|
+
- [Principle 3]: [explanation]
|
|
101
|
+
|
|
102
|
+
## Output Format
|
|
103
|
+
[Describe how to structure the response]
|
|
104
|
+
- Use severity levels: CRITICAL > WARNING > SUGGESTION
|
|
105
|
+
- Include file:line references for every finding
|
|
106
|
+
- End with a summary of top priorities
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Step 5: Choose the Right Model
|
|
112
|
+
|
|
113
|
+
| Model | When to Use | Cost |
|
|
114
|
+
|-------|-------------|------|
|
|
115
|
+
| `haiku` | Fast lookups, simple searches, file reading | Cheapest |
|
|
116
|
+
| `sonnet` | Balanced tasks — code review, analysis, fixes | Medium |
|
|
117
|
+
| `opus` | Complex reasoning, architecture decisions | Most expensive |
|
|
118
|
+
| `inherit` | Use same model as main conversation (default) | Inherits |
|
|
119
|
+
|
|
120
|
+
Route cheap tasks to Haiku to reduce cost significantly.
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Step 6: Control Tool Access
|
|
125
|
+
|
|
126
|
+
### Allowlist (recommended for restrictive agents)
|
|
127
|
+
|
|
128
|
+
```yaml
|
|
129
|
+
tools: Read, Grep, Glob, Bash
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
This agent can ONLY use Read, Grep, Glob, and Bash.
|
|
133
|
+
|
|
134
|
+
### Denylist (recommended for mostly-capable agents)
|
|
135
|
+
|
|
136
|
+
```yaml
|
|
137
|
+
disallowedTools: Write, Edit, NotebookEdit
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
This agent has all tools EXCEPT Write, Edit, and NotebookEdit. Good for "read-mostly but can run Bash" agents.
|
|
141
|
+
|
|
142
|
+
### Restrict which subagents THIS agent can spawn
|
|
143
|
+
|
|
144
|
+
Only relevant if this is a main-thread agent (`claude --agent`):
|
|
145
|
+
|
|
146
|
+
```yaml
|
|
147
|
+
tools: Agent(worker, researcher), Read, Bash
|
|
148
|
+
# OR: allow all subagents
|
|
149
|
+
tools: Agent, Read, Bash
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Bash command restriction (surgical control)
|
|
153
|
+
|
|
154
|
+
```yaml
|
|
155
|
+
tools: Bash(git *), Bash(npm test *), Read, Grep
|
|
156
|
+
# Only allow git commands and npm test commands
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
The space before `*` is important: `Bash(git diff *)` matches `git diff --stat` but NOT `git diff-index`.
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Step 7: Persistent Memory
|
|
164
|
+
|
|
165
|
+
Enable memory so the agent builds institutional knowledge across conversations:
|
|
166
|
+
|
|
167
|
+
```yaml
|
|
168
|
+
memory: user # ~/.claude/agent-memory/<name>/ — cross-project
|
|
169
|
+
memory: project # .claude/agent-memory/<name>/ — project-specific, committed
|
|
170
|
+
memory: local # .claude/agent-memory-local/<name>/ — project-specific, gitignored
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
When memory is enabled:
|
|
174
|
+
- Agent gets Read, Write, Edit tools automatically (for memory files)
|
|
175
|
+
- Agent's system prompt includes first 200 lines of `MEMORY.md`
|
|
176
|
+
- Agent should curate `MEMORY.md` as it learns patterns
|
|
177
|
+
|
|
178
|
+
**System prompt addition for memory agents:**
|
|
179
|
+
```markdown
|
|
180
|
+
## Memory Instructions
|
|
181
|
+
After completing your work, update your agent memory with:
|
|
182
|
+
- New patterns or conventions you discovered
|
|
183
|
+
- Key file locations and their purposes
|
|
184
|
+
- Recurring issues and their root causes
|
|
185
|
+
- Architectural decisions worth remembering
|
|
186
|
+
|
|
187
|
+
Keep MEMORY.md concise. Write detailed notes in separate topic files.
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## Step 8: Preload Skills
|
|
193
|
+
|
|
194
|
+
Give the agent domain knowledge by preloading skill content:
|
|
195
|
+
|
|
196
|
+
```yaml
|
|
197
|
+
skills:
|
|
198
|
+
- api-conventions
|
|
199
|
+
- error-handling-patterns
|
|
200
|
+
- nestjs-architecture
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
The **full content** of each skill is injected at startup — not just descriptions. Use this to give an agent specialized context without bloating its system prompt manually.
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Step 9: Define Agent Hooks
|
|
208
|
+
|
|
209
|
+
Hooks run shell commands at specific lifecycle points:
|
|
210
|
+
|
|
211
|
+
```yaml
|
|
212
|
+
hooks:
|
|
213
|
+
PreToolUse:
|
|
214
|
+
- matcher: "Bash"
|
|
215
|
+
hooks:
|
|
216
|
+
- type: command
|
|
217
|
+
command: "./scripts/validate-bash.sh"
|
|
218
|
+
PostToolUse:
|
|
219
|
+
- matcher: "Edit|Write"
|
|
220
|
+
hooks:
|
|
221
|
+
- type: command
|
|
222
|
+
command: "npm run lint --silent"
|
|
223
|
+
Stop:
|
|
224
|
+
- hooks:
|
|
225
|
+
- type: command
|
|
226
|
+
command: "./scripts/cleanup.sh"
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Hook commands receive JSON via stdin with tool details. Exit code 2 blocks the tool call. `Stop` hooks become `SubagentStop` automatically.
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## Complete Examples
|
|
234
|
+
|
|
235
|
+
### Example 1: Read-Only Code Reviewer
|
|
236
|
+
|
|
237
|
+
```markdown
|
|
238
|
+
---
|
|
239
|
+
name: code-reviewer
|
|
240
|
+
description: Expert code review specialist. Use proactively after code changes. Analyze quality, security, and best practices without modifying files.
|
|
241
|
+
tools: Read, Grep, Glob, Bash
|
|
242
|
+
model: sonnet
|
|
243
|
+
memory: project
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
You are a senior code reviewer with expertise in TypeScript, NestJS, and React Native.
|
|
247
|
+
|
|
248
|
+
## Workflow
|
|
249
|
+
1. Run `git diff HEAD~1` to see recent changes
|
|
250
|
+
2. Identify modified files and their purpose
|
|
251
|
+
3. Read the changed files completely
|
|
252
|
+
4. Review against: security, SOLID principles, error handling, TypeScript discipline, performance, test coverage
|
|
253
|
+
|
|
254
|
+
## Review Format
|
|
255
|
+
For each issue:
|
|
256
|
+
```
|
|
257
|
+
**[SEVERITY] Short description**
|
|
258
|
+
File: path/to/file.ts:L42
|
|
259
|
+
Problem: What's wrong and why it matters
|
|
260
|
+
Fix: Concrete improved code
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
Severity: CRITICAL (security/data loss) > WARNING (architecture) > SUGGESTION (quality) > NITPICK (style)
|
|
264
|
+
|
|
265
|
+
## Memory Instructions
|
|
266
|
+
Update memory with recurring patterns, common anti-patterns found, and architectural decisions.
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### Example 2: Test Runner and Fixer
|
|
270
|
+
|
|
271
|
+
```markdown
|
|
272
|
+
---
|
|
273
|
+
name: test-fixer
|
|
274
|
+
description: Run failing tests, diagnose root causes, and implement fixes. Use when tests fail or before committing code.
|
|
275
|
+
tools: Read, Edit, Bash, Grep, Glob
|
|
276
|
+
model: sonnet
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
You are a testing expert. Your job is to find failing tests, understand why they fail, and fix them.
|
|
280
|
+
|
|
281
|
+
## Workflow
|
|
282
|
+
1. Run the test suite: `npm test -- --passWithNoTests 2>&1 | head -200`
|
|
283
|
+
2. Identify failing tests and their error messages
|
|
284
|
+
3. Find the source code causing failures
|
|
285
|
+
4. Implement minimal fixes — don't change behavior, fix the bug
|
|
286
|
+
5. Run tests again to confirm fixes
|
|
287
|
+
6. Report what was fixed and why
|
|
288
|
+
|
|
289
|
+
## Principles
|
|
290
|
+
- Fix root causes, not symptoms
|
|
291
|
+
- Keep test assertions intact — if the test expectation is wrong, flag it but don't delete
|
|
292
|
+
- One fix per problem — don't refactor surrounding code
|
|
293
|
+
- Run tests after each fix to catch regressions early
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### Example 3: Database Query Validator (with Hook)
|
|
297
|
+
|
|
298
|
+
```markdown
|
|
299
|
+
---
|
|
300
|
+
name: db-analyst
|
|
301
|
+
description: Execute read-only database queries to answer questions about data. Never modifies data.
|
|
302
|
+
tools: Bash
|
|
303
|
+
model: haiku
|
|
304
|
+
hooks:
|
|
305
|
+
PreToolUse:
|
|
306
|
+
- matcher: "Bash"
|
|
307
|
+
hooks:
|
|
308
|
+
- type: command
|
|
309
|
+
command: ".claude/agents/scripts/validate-readonly.sh"
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
You are a database analyst with read-only access.
|
|
313
|
+
|
|
314
|
+
When asked about data, write and execute SELECT queries. Present results clearly with context and key insights.
|
|
315
|
+
|
|
316
|
+
You cannot INSERT, UPDATE, DELETE, DROP, or modify any data. If asked, explain that you have read-only access and suggest the appropriate team contact for data modifications.
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
And the validation script:
|
|
320
|
+
```bash
|
|
321
|
+
#!/bin/bash
|
|
322
|
+
# .claude/agents/scripts/validate-readonly.sh
|
|
323
|
+
INPUT=$(cat)
|
|
324
|
+
CMD=$(echo "$INPUT" | jq -r '.tool_input.command // empty')
|
|
325
|
+
if echo "$CMD" | grep -iE '\b(INSERT|UPDATE|DELETE|DROP|CREATE|ALTER|TRUNCATE|REPLACE)\b' > /dev/null 2>&1; then
|
|
326
|
+
echo "Blocked: Only SELECT queries allowed." >&2
|
|
327
|
+
exit 2
|
|
328
|
+
fi
|
|
329
|
+
exit 0
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### Example 4: Background File Processor
|
|
333
|
+
|
|
334
|
+
```markdown
|
|
335
|
+
---
|
|
336
|
+
name: file-processor
|
|
337
|
+
description: Process large files or run batch operations in the background. Use for operations that produce verbose output.
|
|
338
|
+
tools: Read, Write, Bash, Glob
|
|
339
|
+
background: true
|
|
340
|
+
model: haiku
|
|
341
|
+
---
|
|
342
|
+
|
|
343
|
+
You are a file processing agent. Execute the requested batch operation efficiently.
|
|
344
|
+
|
|
345
|
+
Report only the summary when complete:
|
|
346
|
+
- How many files processed
|
|
347
|
+
- How many succeeded / failed
|
|
348
|
+
- Any errors encountered
|
|
349
|
+
- Output location
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
## Step 10: CLI-Defined Agents (Session-Only)
|
|
355
|
+
|
|
356
|
+
For quick testing or one-off automation, define agents via CLI without creating a file:
|
|
357
|
+
|
|
358
|
+
```bash
|
|
359
|
+
claude --agents '{
|
|
360
|
+
"code-reviewer": {
|
|
361
|
+
"description": "Expert code reviewer. Use proactively after code changes.",
|
|
362
|
+
"prompt": "You are a senior code reviewer. Focus on quality, security, and best practices.",
|
|
363
|
+
"tools": ["Read", "Grep", "Glob", "Bash"],
|
|
364
|
+
"model": "sonnet"
|
|
365
|
+
}
|
|
366
|
+
}'
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
Fields in CLI JSON: `description`, `prompt`, `tools`, `disallowedTools`, `model`, `permissionMode`, `maxTurns`, `skills`, `memory`, `hooks`, `mcpServers`.
|
|
370
|
+
|
|
371
|
+
---
|
|
372
|
+
|
|
373
|
+
## Managing Agents
|
|
374
|
+
|
|
375
|
+
```bash
|
|
376
|
+
# Interactive agent manager
|
|
377
|
+
/agents
|
|
378
|
+
|
|
379
|
+
# List all configured agents (CLI)
|
|
380
|
+
claude agents
|
|
381
|
+
|
|
382
|
+
# Ask Claude to use a specific agent
|
|
383
|
+
"Use the code-reviewer agent to review the auth module"
|
|
384
|
+
"Have the test-fixer agent look at the failing tests"
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
---
|
|
388
|
+
|
|
389
|
+
## Checklist Before Publishing
|
|
390
|
+
|
|
391
|
+
- [ ] `name` is lowercase, hyphens only
|
|
392
|
+
- [ ] `description` says "Use proactively when..." so Claude knows to auto-delegate
|
|
393
|
+
- [ ] Tools are restricted to minimum needed (principle of least privilege)
|
|
394
|
+
- [ ] Model is right-sized (haiku for simple, sonnet for complex)
|
|
395
|
+
- [ ] System prompt describes workflow step-by-step
|
|
396
|
+
- [ ] System prompt describes output format clearly
|
|
397
|
+
- [ ] Tested via `/agents` interface
|
|
398
|
+
- [ ] Memory enabled if the agent should learn across sessions
|
|
399
|
+
- [ ] Hooks added if tool validation is needed
|