@@ -4,17 +4,16 @@ Complete guide to writing effective `<example>` blocks in agent descriptions for
44
55## Example Block Format
66
7- The standard format for triggering examples:
7+ The standard format for triggering examples (aligned with official Claude Code documentation) :
88
99``` markdown
1010<example >
1111Context: [ Describe the situation - what led to this interaction]
1212user: "[ Exact user message or request] "
13- assistant: "[ How Claude should respond before triggering ] "
13+ assistant: "[ How Claude invokes the agent - 'I'll use the [ agent-name ] agent to [ action ] ' ] "
1414<commentary >
1515[ Explanation of why this agent should be triggered in this scenario]
1616</commentary >
17- assistant: "[ How Claude triggers the agent - usually 'I'll use the [ agent-name] agent...'] "
1817</example >
1918```
2019
@@ -58,23 +57,15 @@ Example 2: user: "Can you check this implementation?"
5857Example 3: user: "Look over my changes"
5958```
6059
61- ### Assistant Response (Before Triggering)
60+ ### Assistant Response
6261
63- ** Purpose:** Show what Claude says before launching the agent
62+ ** Purpose:** Show Claude invoking the agent
6463
6564** Good responses:**
6665```
67- assistant: "I'll analyze your OAuth implementation."
68- assistant: "Let me review that PR for you."
69- assistant: "I'll investigate the test failure."
70- ```
71-
72- ** Proactive example:**
73- ```
74- assistant: "Great! Now let me review the code quality."
75- <commentary>
76- Code was just written, proactively trigger review agent.
77- </commentary>
66+ assistant: "I'll use the code-reviewer agent to analyze your OAuth implementation."
67+ assistant: "I'll use the pr-analyzer agent to review that PR for you."
68+ assistant: "I'll use the test-analyzer agent to investigate the test failure."
7869```
7970
8071### Commentary
@@ -104,22 +95,6 @@ test quality and coverage before continuing.
10495</commentary>
10596```
10697
107- ### Assistant Response (Triggering)
108-
109- ** Purpose:** Show how Claude invokes the agent
110-
111- ** Standard pattern:**
112- ```
113- assistant: "I'll use the [agent-name] agent to [what it will do]."
114- ```
115-
116- ** Examples:**
117- ```
118- assistant: "I'll use the code-reviewer agent to analyze the changes."
119- assistant: "Let me use the test-generator agent to create comprehensive tests."
120- assistant: "I'll use the security-analyzer agent to check for vulnerabilities."
121- ```
122-
12398## Example Types
12499
125100### Type 1: Explicit Request
@@ -145,12 +120,11 @@ Agent triggers after relevant work without explicit request:
145120<example >
146121Context: User just implemented database queries
147122user: "I've added the user search functionality"
148- assistant: "Great! Let me review it for security."
123+ assistant: "I'll use the security-analyzer agent to review the database code for security issues ."
149124<commentary >
150125Database code written. Proactively trigger security-analyzer to check
151126for SQL injection and other database security issues.
152127</commentary >
153- assistant: "I'll use the security-analyzer agent to check the database code."
154128</example >
155129```
156130
@@ -162,12 +136,10 @@ User implies need without stating it directly:
162136<example >
163137Context: User mentions code is hard to understand
164138user: "This code is confusing and hard to follow"
165- assistant: "I can help improve the code clarity ."
139+ assistant: "I'll use the code-simplifier agent to refactor for better readability ."
166140<commentary >
167- User indicates complexity issues. Trigger code-simplifier agent to refactor
168- for better readability.
141+ User indicates complexity issues. Trigger code-simplifier agent to improve clarity.
169142</commentary >
170- assistant: "I'll use the code-simplifier agent to suggest improvements."
171143</example >
172144```
173145
@@ -179,12 +151,11 @@ Agent triggers based on prior tool usage:
179151<example >
180152Context: User made multiple edits to test files
181153user: "I've updated all the tests"
182- assistant: "Great! Let me verify test quality ."
154+ assistant: "I'll use the test-quality-analyzer agent to verify the tests follow best practices ."
183155<commentary >
184156Multiple Edit tools used on test files. Proactively trigger test-quality-analyzer
185157to ensure tests follow best practices.
186158</commentary >
187- assistant: "I'll use the test-quality-analyzer agent to review the tests."
188159</example >
189160```
190161
@@ -215,17 +186,19 @@ user: "Look over these changes"
215186<example >
216187Context: User explicitly requests review
217188user: "Review my code for issues"
218- [ ...]
189+ assistant: "I'll use the code-reviewer agent to analyze the code."
190+ <commentary >
191+ Explicit review request triggers the agent.
192+ </commentary >
219193</example >
220194
221195<example >
222196Context: After user writes code
223197user: "I've implemented the feature"
224- assistant: "Great! Now let me review it ."
198+ assistant: "I'll use the code-reviewer agent to review the implementation ."
225199<commentary >
226- Code written, proactively review.
200+ Code written, proactively review for quality and issues .
227201</commentary >
228- [ ...]
229202</example >
230203```
231204
@@ -267,9 +240,9 @@ assistant: "I'll use the code-reviewer agent."
267240<example >
268241Context: User just finished implementing authentication
269242user: "Review my code"
270- assistant: "I'll use the code-reviewer agent to analyze the auth implementation."
243+ assistant: "I'll use the code-reviewer agent to analyze the auth implementation for security and best practices ."
271244<commentary >
272- Auth code written, review for security and best practices.
245+ Auth code written. Review for security and best practices.
273246</commentary >
274247</example >
275248```
@@ -350,11 +323,10 @@ More than 6 makes description too long. Focus on most important scenarios.
350323<example >
351324Context: User just implemented a new feature
352325user: "I've added the user registration feature"
353- assistant: "Great! Let me review the code quality ."
326+ assistant: "I'll use the code-reviewer agent to analyze the implementation ."
354327<commentary >
355328Code written, proactively trigger code-reviewer agent.
356329</commentary >
357- assistant: "I'll use the code-reviewer agent to analyze the implementation."
358330</example >
359331
360332<example >
@@ -373,11 +345,10 @@ Explicit review request triggers the agent.
373345<example >
374346Context: User implemented functions without tests
375347user: "I've added the data processing functions"
376- assistant: "Great! Let me generate tests for these ."
348+ assistant: "I'll use the test-generator agent to create comprehensive tests ."
377349<commentary >
378350New code without tests, proactively trigger test-generator agent.
379351</commentary >
380- assistant: "I'll use the test-generator agent to create comprehensive tests."
381352</example >
382353
383354<example >
@@ -396,11 +367,10 @@ Direct test generation request triggers the agent.
396367<example >
397368Context: User added new API endpoints
398369user: "I've implemented the REST API endpoints"
399- assistant: "I'll document these endpoints ."
370+ assistant: "I'll use the api-docs-writer agent to create comprehensive documentation ."
400371<commentary >
401372New API code, proactively generate documentation.
402373</commentary >
403- assistant: "I'll use the api-docs-writer agent to create comprehensive documentation."
404374</example >
405375
406376<example >
@@ -419,11 +389,10 @@ Documentation request triggers the agent.
419389<example >
420390Context: User ready to commit changes
421391user: "I'm ready to commit this code"
422- assistant: "Let me validate it first ."
392+ assistant: "I'll use the code-validator agent to check for issues before committing ."
423393<commentary >
424394Before commit, proactively validate with validation-agent.
425395</commentary >
426- assistant: "I'll use the code-validator agent to check for issues."
427396</example >
428397
429398<example >
0 commit comments