xiaolai/nlpm/writing-agents

Claude Code and agent skill by xiaolai/nlpm

Trust tier 2
  • community
  • ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

How to write Claude Code agents: example blocks, model choice, least-privilege tools.

Install

npx vskill@latest install xiaolai/nlpm/writing-agents

Semi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard

SKILL.md

The same SKILL.md was published earlier as xiaolai/nlpm/writing-agents.

Writing Agents

Scope: covers Claude Code agent .md file authoring (Markdown + frontmatter at .claude/agents/). Codex CLI defines agents differently — as [agents.<name>] TOML tables in .codex/config.toml; see [[nlpm:conventions-codex]]. Antigravity subagents are under-documented at this writing; see [[nlpm:conventions-antigravity]]. For multi-agent orchestration, see [[orchestration]]. For plugin architecture, see [[writing-plugins]].

1. Example Blocks Make or Break Triggering

Without <example> blocks, Claude guesses when to dispatch your agent. With them, it pattern-matches against real scenarios.

Target: 1 well-chosen example + 1 "Not for …" sentence, whole description ≤1,200 characters.

The description sits in the Agent tool's text on every turn and is the only thing Claude sees when choosing an agent. Examples therefore stay in the description -- moved into the body, they are invisible to routing -- but every extra example is always-on context. One example that shows the main positive trigger, trigger phrases in the prose, and an explicit exclusion carry the routing signal at a fraction of the tokens.

Example Block Anatomy
xml
<example>
Context: [what the user is doing -- not just "user needs help"]
user: "[realistic user message that should trigger this agent]"
assistant: "[what Claude says when dispatching -- shows the decision logic]"
</example>
Bad Example (too vague -- 40% trigger accuracy)
xml
<example>
Context: User needs code review
user: "review my code"
assistant: "I'll use the reviewer agent."
</example>

Problems: generic context, generic query, no decision logic shown.

Good Example (specific scenario -- 92% trigger accuracy)
xml
<example>
Context: User just pushed changes to the authentication module and wants feedback before merging
user: "Can you check if the auth changes look good before I create the PR?"
assistant: "I'll dispatch the security-reviewer agent to check the auth changes for vulnerabilities, token handling, and session management best practices."
</example>

Why it works: specific context (auth module, pre-PR), realistic query (how users actually talk), decision logic visible (what the agent will check).

One Example, Prose Triggers, One Exclusion
PartPurposeWhat it carries
Prose trigger phrasesBreadthObvious, edge-case and non-obvious triggers, one short phrase each
1 <example>AnchorThe main positive trigger: user asks, assistant dispatches
"Not for …" sentenceBoundaryThe adjacent request that belongs to a sibling agent or to no agent

Example for a "performance-profiler" agent:

yaml
description: |
Profiles slow endpoints, memory growth and query plans. Use when a request is
slow, memory climbs over time (possible leak), or the user is choosing between
two implementations on speed. Not for fixing the code it measures; it reports
hot spots only.
<example>
Context: User wants to profile their API
user: "Profile the /api/users endpoint, it's slow"
assistant: "I'll dispatch the performance-profiler to trace the /api/users endpoint..."
</example>

A second example is allowed when a distinct trigger cannot be said in prose, but it costs context on every turn; nlpm's R09 gives full credit for one.

2. Model Selection

Task typeModelSignal words in bodyExamples
Mechanical / parsing / formatting / countinghaikucount, list, extract, format, parse, scanscanner, parser, formatter, counter, lister
Analysis / reasoning / moderate judgmentsonnetanalyze, review, evaluate, summarize, comparelinter, reviewer, extractor, summarizer
Complex judgment / orchestration / multi-agentopuscoordinate, decide, assess, synthesize, architectQC coordinator, architect, strategy planner
Quick Heuristic

Count the instruction lines in your agent body. Then check for judgment words.

< 20 instruction lines AND no judgment words → haiku
20-50 instruction lines OR judgment words → sonnet
> 50 instruction lines OR coordination logic → opus

Judgment words: evaluate, decide, assess, determine, weigh, prioritize, recommend, judge, infer, synthesize.

Cost Impact
ModelRelative costWhen to upgrade
haiku1xAgent produces wrong output on edge cases
sonnet10xAgent produces wrong output on easy cases
opus30xAgent coordinates other agents or makes architectural decisions

Rule: start with haiku, upgrade only when output quality requires it.

3. Tool Least-Privilege

Only list tools the agent body actually references. Every extra tool is a potential misuse vector.

Common Mistakes
Agent typeCommon over-grantCorrect tools
Audit/review agentWrite, Edit, BashRead, Glob, Grep
Code generatorRead, Grep (unused)Write, Edit, Bash
OrchestratorRead, Write (does no IO)Task
ScannerBash (uses grep)Grep, Glob, Read
Tool Reference
ToolWhen to include
ReadAgent reads file contents
WriteAgent creates new files
EditAgent modifies existing files
GlobAgent searches for files by pattern
GrepAgent searches file contents
BashAgent runs shell commands (linters, tests, builds)
TaskAgent dispatches sub-agents
WebFetchAgent fetches a URL

4. Output Format

Every agent MUST define its output format in the body. Without it, output varies between invocations -- making results unparseable by parent agents.

Pattern: Structured Report
markdown
## Output Format
### {Section Title}
| Column1 | Column2 | Column3 |
|---------|---------|---------|
| ... | ... | ... |
### Summary
-Total items: {N}
-Issues found: {N}
-Pass/Fail: {verdict}
Pattern: Severity-Tagged Findings
markdown
## Output Format
For each finding, output:
**[SEVERITY] Finding title**
-File: `path/to/file`
-Line: {N}
-Finding: {description}
-Fix: {concrete suggestion}
Severity levels: CRITICAL > HIGH > MEDIUM > LOW > INFO
Pattern: Pass/Fail Gate
markdown
## Output Format
Final line must be exactly one of:
-`PASS: All checks passed`
-`WARN: {N} warnings found (see above)`
-`FAIL: {N} errors found (see above)`

5. System Prompt Structure

Order matters. Claude reads top-to-bottom and front-loads early instructions.

The Five Sections
markdown
## Mission
[1-2 sentences: what this agent does and WHY it exists]
## Instructions
1.[First step]
2.[Second step]
3.[Third step]
...
## Boundaries
-Do NOT [thing that would be harmful]
-Do NOT [thing that's out of scope]
-If [ambiguous situation], then [explicit resolution]
## Output Format
[Exact template -- see section 4 above]
## Error Handling
-If no files found: report "No matching files" and exit
-If tool fails: report the error and continue with remaining work
-If scope is unclear: analyze the narrower interpretation
Section Sizing
SectionTarget linesOver-budget signal
Mission2-3More than one paragraph
Instructions5-15More than 20 numbered steps
Boundaries3-7More than 10 "Do NOT" items
Output Format5-15Defining more than 3 output sections
Error Handling3-5More than 5 error cases

Total agent body: aim for 25-45 lines. Over 60 lines means the agent is doing too much -- split it.

6. Worked Example

Before (score 43/100)
yaml
---
name: code-checker
description: Check code
model: opus
tools: [Read, Write, Edit, Bash, Grep, Glob, Task]
---
markdown
You are a code checker. Check the user's code for issues.
Look at the files and find problems. Report what you find.

Problems (each scored line is a row in the nlpm:scoring Agents table):

  • R09 -- zero <example> blocks in the description: unreliable triggering (-15)
  • R09 -- no "Not for" clause: nothing tells routing what to rule out (-5)
  • R10 -- opus for a review task that sonnet handles (-5)
  • R11 -- Write, Edit, Bash, Task declared but no body step uses them (-3 each, -12)
  • R11 -- a review agent declares Write and Edit (-10)
  • R12 -- no output format: inconsistent results (-10)
  • Description has 0 trigger phrases and no "Use when..." (not scored for agents; R04 is a skills row, but routing still suffers)
  • No boundaries and no error handling (not scored; they cause scope creep and silent failures)

Total: -57, so 100 - 57 = 43.

After (score 100/100)
yaml
---
name: code-checker
description: |
Static analysis agent — checks code for bugs, type errors, and anti-patterns.
Use when reviewing code quality, running pre-commit checks, validating changes
before PR, or scanning a module suspected of a production defect. Not for style
issues (defer to the linter) or for fixing code; it reports only.
<example>
Context: User just finished implementing a new feature and wants a quality check
user: "Check the auth module for any bugs before I push"
assistant: "I'll dispatch the code-checker agent to analyze src/auth/ for bugs, type errors, and anti-patterns."
</example>
model: sonnet
tools: [Read, Glob, Grep]
---
markdown
## Mission
Analyze source code files for bugs, type errors, and anti-patterns.
Produce a structured report with severity-tagged findings.
## Instructions
1.Use Glob to discover files matching the target pattern
2.Use Read to examine each file
3.Use Grep to cross-reference imports and usage patterns
4.For each finding, classify severity and provide a concrete fix
5.Produce the output report
## Boundaries
-Do NOT modify any files (read-only analysis)
-Do NOT run shell commands
-Do NOT report style issues (defer to linter)
-If no target pattern specified, analyze all files in src/
## Output Format
For each finding:
**[SEVERITY] Finding title**
-File: `path/to/file`
-Line: {N}
-Finding: {description}
-Fix: {concrete fix}
Final line:
-`PASS: No issues found`
-`WARN: {N} warnings found`
-`FAIL: {N} errors found`
## Error Handling
-If no files match the pattern: report "No matching files for pattern: {X}"
-If a file cannot be read: skip it and note in the report

Changes made (one per problem above):

  1. R09: added 1 <example> block in the description (+15)
  2. R09: added a "Not for" clause -- style issues and fixing code (+5)
  3. R10: opus -> sonnet (analysis-tier task: reasoning, not orchestration) (+5)
  4. R11: tools 7 -> 3; Glob, Read and Grep are each named by an instruction step (+12)
  5. R11: dropped Write and Edit from a read-only review agent (+10)
  6. R12: defined the output format (+10)
  7. Description: 0 -> 6 trigger phrases and a "Use when" sentence (not scored)
  8. Added boundaries and error handling (not scored)

Total: +57, so 43 + 57 = 100.

7. Common Mistakes

MistakeImpactFix
No examples40% trigger accuracyAdd 1 specific scenario example + a "Not for" sentence
3-4 examples in the descriptionAlways-on context on every turnKeep the best one; move trigger phrases into the prose
Opus for mechanical work30x cost for same resultUse haiku for parsing, sonnet for analysis
All tools grantedAgent writes when it should only readList only tools the body references
No output formatDifferent format each runDefine exact output template
Body over 60 linesAgent is doing too muchSplit into focused sub-agents
"Be thorough" in bodyMeaningless fillerReplace with specific instructions
No error handlingSilent failuresAdd 3-5 error cases with resolution

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
91
Repository forks
25
7-day trend score
23

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Extension points

  • hookPre/post lifecycle hooks

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/xiaolai/nlpm/writing-agents/badge)](https://verified-skill.com/skills/xiaolai/nlpm/writing-agents)

Something wrong with this skill or its page? Tell us.