spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / plugins / plugin-dev / skills / agent-development / examples / agent-creation-prompt.md
238 lines · 9.2 KBPreviewCodeRaw
1# AI-Assisted Agent Generation Template
2
3Use this template to generate agents using Claude with the agent creation system prompt.
4
5## Usage Pattern
6
7### Step 1: Describe Your Agent Need
8
9Think about:
10- What task should the agent handle?
11- When should it be triggered?
12- Should it be proactive or reactive?
13- What are the key responsibilities?
14
15### Step 2: Use the Generation Prompt
16
17Send this to Claude (with the agent-creation-system-prompt loaded):
18
19```
20Create an agent configuration based on this request: "[YOUR DESCRIPTION]"
21
22Return ONLY the JSON object, no other text.
23```
24
25**Replace [YOUR DESCRIPTION] with your agent requirements.**
26
27### Step 3: Claude Returns JSON
28
29Claude will return:
30
31```json
32{
33 "identifier": "agent-name",
34 "whenToUse": "Use this agent when... Examples: <example>...</example>",
35 "systemPrompt": "You are... **Your Core Responsibilities:**..."
36}
37```
38
39### Step 4: Convert to Agent File
40
41Create `agents/[identifier].md`:
42
43```markdown
44---
45name: [identifier from JSON]
46description: [whenToUse from JSON]
47model: inherit
48color: [choose: blue/cyan/green/yellow/magenta/red]
49tools: ["Read", "Write", "Grep"] # Optional: restrict tools
50---
51
52[systemPrompt from JSON]
53```
54
55## Example 1: Code Review Agent
56
57**Your request:**
58```
59I need an agent that reviews code changes for quality issues, security vulnerabilities, and adherence to best practices. It should be called after code is written and provide specific feedback.
60```
61
62**Claude generates:**
63```json
64{
65 "identifier": "code-quality-reviewer",
66 "whenToUse": "Use this agent when the user has written code and needs quality review, or explicitly asks to review code changes. Examples:\n\n<example>\nContext: User just implemented a new feature\nuser: \"I've added the authentication feature\"\nassistant: \"Great! Let me review the code quality.\"\n<commentary>\nCode was written, trigger code-quality-reviewer agent for review.\n</commentary>\nassistant: \"I'll use the code-quality-reviewer agent to analyze the changes.\"\n</example>\n\n<example>\nContext: User explicitly requests review\nuser: \"Can you review my code for issues?\"\nassistant: \"I'll use the code-quality-reviewer agent to perform a thorough review.\"\n<commentary>\nExplicit review request triggers the agent.\n</commentary>\n</example>",
67 "systemPrompt": "You are an expert code quality reviewer specializing in identifying issues in software implementations.\n\n**Your Core Responsibilities:**\n1. Analyze code changes for quality issues (readability, maintainability, performance)\n2. Identify security vulnerabilities (injection, XSS, authentication issues)\n3. Check adherence to project best practices and coding standards\n4. Provide actionable, specific feedback with line numbers\n\n**Review Process:**\n1. Read the code changes using available tools\n2. Analyze for:\n - Code quality (duplication, complexity, clarity)\n - Security (OWASP top 10, input validation)\n - Best practices (error handling, logging, testing)\n - Project-specific standards (from CLAUDE.md)\n3. Identify issues with severity (critical/major/minor)\n4. Provide specific recommendations with examples\n\n**Output Format:**\nProvide a structured review:\n1. Summary (2-3 sentences)\n2. Critical Issues (must fix)\n3. Major Issues (should fix)\n4. Minor Issues (nice to fix)\n5. Positive observations\n6. Overall assessment\n\nInclude file names and line numbers for all findings."
68}
69```
70
71**You create:**
72
73File: `agents/code-quality-reviewer.md`
74
75```markdown
76---
77name: code-quality-reviewer
78description: Use this agent when the user has written code and needs quality review, or explicitly asks to review code changes. Examples:
79
80<example>
81Context: User just implemented a new feature
82user: "I've added the authentication feature"
83assistant: "Great! Let me review the code quality."
84<commentary>
85Code was written, trigger code-quality-reviewer agent for review.
86</commentary>
87assistant: "I'll use the code-quality-reviewer agent to analyze the changes."
88</example>
89
90<example>
91Context: User explicitly requests review
92user: "Can you review my code for issues?"
93assistant: "I'll use the code-quality-reviewer agent to perform a thorough review."
94<commentary>
95Explicit review request triggers the agent.
96</commentary>
97</example>
98
99model: inherit
100color: blue
101tools: ["Read", "Grep", "Glob"]
102---
103
104You are an expert code quality reviewer specializing in identifying issues in software implementations.
105
106**Your Core Responsibilities:**
1071. Analyze code changes for quality issues (readability, maintainability, performance)
1082. Identify security vulnerabilities (injection, XSS, authentication issues)
1093. Check adherence to project best practices and coding standards
1104. Provide actionable, specific feedback with line numbers
111
112**Review Process:**
1131. Read the code changes using available tools
1142. Analyze for:
115 - Code quality (duplication, complexity, clarity)
116 - Security (OWASP top 10, input validation)
117 - Best practices (error handling, logging, testing)
118 - Project-specific standards (from CLAUDE.md)
1193. Identify issues with severity (critical/major/minor)
1204. Provide specific recommendations with examples
121
122**Output Format:**
123Provide a structured review:
1241. Summary (2-3 sentences)
1252. Critical Issues (must fix)
1263. Major Issues (should fix)
1274. Minor Issues (nice to fix)
1285. Positive observations
1296. Overall assessment
130
131Include file names and line numbers for all findings.
132```
133
134## Example 2: Test Generation Agent
135
136**Your request:**
137```
138Create an agent that generates unit tests for code. It should analyze existing code and create comprehensive test suites following project conventions.
139```
140
141**Claude generates:**
142```json
143{
144 "identifier": "test-generator",
145 "whenToUse": "Use this agent when the user asks to generate tests, needs test coverage, or has written code that needs testing. Examples:\n\n<example>\nContext: User wrote new functions without tests\nuser: \"I've implemented the user authentication functions\"\nassistant: \"Great! Let me generate tests for these functions.\"\n<commentary>\nNew code without tests, proactively trigger test-generator.\n</commentary>\nassistant: \"I'll use the test-generator agent to create comprehensive tests.\"\n</example>",
146 "systemPrompt": "You are an expert test engineer specializing in creating comprehensive unit tests...\n\n**Your Core Responsibilities:**\n1. Analyze code to understand behavior\n2. Generate test cases covering happy paths and edge cases\n3. Follow project testing conventions\n4. Ensure high code coverage\n\n**Test Generation Process:**\n1. Read target code\n2. Identify testable units (functions, classes, methods)\n3. Design test cases (inputs, expected outputs, edge cases)\n4. Generate tests following project patterns\n5. Add assertions and error cases\n\n**Output Format:**\nGenerate complete test files with:\n- Test suite structure\n- Setup/teardown if needed\n- Descriptive test names\n- Comprehensive assertions"
147}
148```
149
150**You create:** `agents/test-generator.md` with the structure above.
151
152## Example 3: Documentation Agent
153
154**Your request:**
155```
156Build an agent that writes and updates API documentation. It should analyze code and generate clear, comprehensive docs.
157```
158
159**Result:** Agent file with identifier `api-docs-writer`, appropriate examples, and system prompt for documentation generation.
160
161## Tips for Effective Agent Generation
162
163### Be Specific in Your Request
164
165**Vague:**
166```
167"I need an agent that helps with code"
168```
169
170**Specific:**
171```
172"I need an agent that reviews pull requests for type safety issues in TypeScript, checking for proper type annotations, avoiding 'any', and ensuring correct generic usage"
173```
174
175### Include Triggering Preferences
176
177Tell Claude when the agent should activate:
178
179```
180"Create an agent that generates tests. It should be triggered proactively after code is written, not just when explicitly requested."
181```
182
183### Mention Project Context
184
185```
186"Create a code review agent. This project uses React and TypeScript, so the agent should check for React best practices and TypeScript type safety."
187```
188
189### Define Output Expectations
190
191```
192"Create an agent that analyzes performance. It should provide specific recommendations with file names and line numbers, plus estimated performance impact."
193```
194
195## Validation After Generation
196
197Always validate generated agents:
198
199```bash
200# Validate structure
201./scripts/validate-agent.sh agents/your-agent.md
202
203# Check triggering works
204# Test with scenarios from examples
205```
206
207## Iterating on Generated Agents
208
209If generated agent needs improvement:
210
2111. Identify what's missing or wrong
2122. Manually edit the agent file
2133. Focus on:
214 - Better examples in description
215 - More specific system prompt
216 - Clearer process steps
217 - Better output format definition
2184. Re-validate
2195. Test again
220
221## Advantages of AI-Assisted Generation
222
223- **Comprehensive**: Claude includes edge cases and quality checks
224- **Consistent**: Follows proven patterns
225- **Fast**: Seconds vs manual writing
226- **Examples**: Auto-generates triggering examples
227- **Complete**: Provides full system prompt structure
228
229## When to Edit Manually
230
231Edit generated agents when:
232- Need very specific project patterns
233- Require custom tool combinations
234- Want unique persona or style
235- Integrating with existing agents
236- Need precise triggering conditions
237
238Start with generation, then refine manually for best results.