xiaolai/nlpm/writing-agents
Claude Code and agent skill by xiaolai/nlpm
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
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-agentsSemi-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.mdfile 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
Bad Example (too vague -- 40% trigger accuracy)
Problems: generic context, generic query, no decision logic shown.
Good Example (specific scenario -- 92% trigger accuracy)
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
| Part | Purpose | What it carries | |
|---|---|---|---|
| Prose trigger phrases | Breadth | Obvious, edge-case and non-obvious triggers, one short phrase each | |
1 <example> | Anchor | The main positive trigger: user asks, assistant dispatches | |
| "Not for …" sentence | Boundary | The adjacent request that belongs to a sibling agent or to no agent |
Example for a "performance-profiler" agent:
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 type | Model | Signal words in body | Examples | |
|---|---|---|---|---|
| Mechanical / parsing / formatting / counting | haiku | count, list, extract, format, parse, scan | scanner, parser, formatter, counter, lister | |
| Analysis / reasoning / moderate judgment | sonnet | analyze, review, evaluate, summarize, compare | linter, reviewer, extractor, summarizer | |
| Complex judgment / orchestration / multi-agent | opus | coordinate, decide, assess, synthesize, architect | QC coordinator, architect, strategy planner |
Quick Heuristic
Count the instruction lines in your agent body. Then check for judgment words.
Judgment words: evaluate, decide, assess, determine, weigh, prioritize, recommend, judge, infer, synthesize.
Cost Impact
| Model | Relative cost | When to upgrade | |
|---|---|---|---|
| haiku | 1x | Agent produces wrong output on edge cases | |
| sonnet | 10x | Agent produces wrong output on easy cases | |
| opus | 30x | Agent 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 type | Common over-grant | Correct tools | |
|---|---|---|---|
| Audit/review agent | Write, Edit, Bash | Read, Glob, Grep | |
| Code generator | Read, Grep (unused) | Write, Edit, Bash | |
| Orchestrator | Read, Write (does no IO) | Task | |
| Scanner | Bash (uses grep) | Grep, Glob, Read |
Tool Reference
| Tool | When to include | |
|---|---|---|
| Read | Agent reads file contents | |
| Write | Agent creates new files | |
| Edit | Agent modifies existing files | |
| Glob | Agent searches for files by pattern | |
| Grep | Agent searches file contents | |
| Bash | Agent runs shell commands (linters, tests, builds) | |
| Task | Agent dispatches sub-agents | |
| WebFetch | Agent 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
Pattern: Severity-Tagged Findings
Pattern: Pass/Fail Gate
5. System Prompt Structure
Order matters. Claude reads top-to-bottom and front-loads early instructions.
The Five Sections
Section Sizing
| Section | Target lines | Over-budget signal | |
|---|---|---|---|
| Mission | 2-3 | More than one paragraph | |
| Instructions | 5-15 | More than 20 numbered steps | |
| Boundaries | 3-7 | More than 10 "Do NOT" items | |
| Output Format | 5-15 | Defining more than 3 output sections | |
| Error Handling | 3-5 | More 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)
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)
Changes made (one per problem above):
- R09: added 1
<example>block in the description (+15) - R09: added a "Not for" clause -- style issues and fixing code (+5)
- R10: opus -> sonnet (analysis-tier task: reasoning, not orchestration) (+5)
- R11: tools 7 -> 3; Glob, Read and Grep are each named by an instruction step (+12)
- R11: dropped Write and Edit from a read-only review agent (+10)
- R12: defined the output format (+10)
- Description: 0 -> 6 trigger phrases and a "Use when" sentence (not scored)
- Added boundaries and error handling (not scored)
Total: +57, so 43 + 57 = 100.
7. Common Mistakes
| Mistake | Impact | Fix | |
|---|---|---|---|
| No examples | 40% trigger accuracy | Add 1 specific scenario example + a "Not for" sentence | |
| 3-4 examples in the description | Always-on context on every turn | Keep the best one; move trigger phrases into the prose | |
| Opus for mechanical work | 30x cost for same result | Use haiku for parsing, sonnet for analysis | |
| All tools granted | Agent writes when it should only read | List only tools the body references | |
| No output format | Different format each run | Define exact output template | |
| Body over 60 lines | Agent is doing too much | Split into focused sub-agents | |
| "Be thorough" in body | Meaningless filler | Replace with specific instructions | |
| No error handling | Silent failures | Add 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
- SKILL.md in the repositoryCheckingcodex/skills/writing-agents/SKILL.md
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
[](https://verified-skill.com/skills/xiaolai/nlpm/writing-agents)