majiayu000/agent-authoring
Guide for authoring specialized AI agents. Use when creating, updating, or improving agents, choosing models, defining focus areas, configuring tools, or learning agent best practices.
npx skills add https://github.com/majiayu000/claude-skill-registry --skill agent-authoring
Advanced agent authoring guidance:
Agents are specialized AI assistants that run in separate subprocesses with focused expertise. They have:
When to use agents:
Focus areas define what the agent is expert in. They should be:
Specific, not generic:
Concrete, with examples:
5-15 focus areas that cover the agent's expertise comprehensively.
Example from evaluator agent:
## Focus Areas
- YAML Frontmatter Validation
- Markdown Structure
- Tool Permissions
- Description Quality
- File Organization
- Progressive Disclosure
- Integration Patterns
Sonnet (default choice for most agents):
Haiku (for simple, fast tasks):
Opus (for complex reasoning):
Decision guide:
Why restrict tools:
Common tool patterns:
Read-only analyzer:
allowed_tools:
- Read
- Glob
- Grep
- Bash
Examples: evaluator, audit-skill
Code generator/modifier:
allowed_tools:
- Read
- Edit
- Write
- Grep
- Glob
- Bash
Examples: test-runner
Minimal/focused:
allowed_tools:
- Read
- AskUserQuestion
Example: When agent only needs to read and ask questions
If unspecified: Agent inherits all tools from parent (usually not desired)
default (most common):
acceptEdits (for editing workflows):
plan (for planning agents):
Most agents use default - only use others when you have a specific workflow need.
Agent hooks are lifecycle hooks defined in YAML frontmatter, scoped to that specific agent.
When to use agent hooks:
When to use settings.json hooks instead:
Available events:
| Event | Trigger | Use Case |
| ------------- | ---------------------- | ----------------------------- |
| PreToolUse | Before agent uses tool | Validation, blocking, logging |
| PostToolUse | After tool completes | Formatting, notifications |
| Stop | Agent finishes | Cleanup, notifications |
Configuration syntax:
---
name: code-reviewer
description: Review code with automatic linting
hooks:
PreToolUse:
- matcher: "Bash"
hooks:
- type: command
command: "./scripts/validate-command.sh"
PostToolUse:
- matcher: "Edit|Write"
hooks:
- type: command
command: "./scripts/run-linter.sh"
timeout: 10
---
Key points:
"Edit|Write", "Bash", "*")Three proven patterns for building effective agents. Each pattern includes complete templates you can copy and customize.
📄 See design-patterns.md for detailed templates
Quick overview:
Per Claude Code specification, agents are single files only:
agents/
├── code-reviewer.md # Single file agent
├── bash-expert.md # Single file agent
└── security-auditor.md # Single file agent
No subdirectories or reference files supported.
| Need | Use |
| ---------------------------------------- | ----------------------------- |
| Reference files / progressive disclosure | Skill |
| Single-file focused capability | Agent |
| Large documentation (>500 lines) | Skill (can split content) |
If you need reference files, convert to a skill instead:
skills/evaluator/
├── SKILL.md # Main skill file
├── evaluation-criteria.md # Reference file
└── examples.md # Reference file
📄 See ~/.claude/docs/agent-vs-skill-structure.md for details
Since agents must be single files:
Start by clarifying:
Questions to ask:
Use AskUserQuestion to clarify ambiguities before proceeding.
Check for existing agents:
ls -la ~/.claude/agents/
Look for similar agents that might overlap.
Model selection:
Tool selection:
Permission mode:
default unless you have specific needGuidelines:
Good examples (from evaluator):
Bad examples:
This section explains HOW the agent works:
Include:
Example from evaluator:
## Evaluation Framework
### Correctness Criteria
- YAML frontmatter with required fields
- Valid model value
- Name matches filename
...
## Evaluation Process
### Step 1: Identify Extension Type
...
### Step 2: Apply Type-Specific Validation
...
Requirements:
Formula: [What it does] for [use cases]. Expert/Use when [triggers]. [Key features]
Good example:
description: Master of defensive Bash scripting for production automation, CI/CD pipelines, and system utilities. Expert in safe, portable, and testable shell scripts.
Bad example:
description: Helps with bash scripts
File location: ~/.claude/agents/agent-name.md
Filename should match name in frontmatter.
Basic structure:
---
name: agent-name
description: [comprehensive description with triggers]
model: sonnet
allowed_tools:
- Read
- [other tools]
---
## Focus Areas
- [Specific area 1]
- [Specific area 2]
...
## Approach
[How the agent works, methodologies, processes]
## [Optional Additional Sections]
[Examples, best practices, output formats, etc.]
Test invocation:
Validate with /audit-agent:
/audit-agent agent-name
This will check:
Choosing the right customization type is critical. Each has distinct characteristics and use cases.
📄 See agent-decision-guide.md for agent-specific decision framework
📄 See when-to-use-what.md for detailed decision guide (shared)
Quick guide:
Real-world examples showing what makes a good agent. Each example is analyzed to explain why it works well.
📄 See examples.md for detailed analysis
Examples covered:
Each example includes the full frontmatter, focus areas, and analysis of what makes it effective.
10. Follow naming conventions - Use kebab-case, match filename to name
For detailed standards and validation:
~/.claude/agents/agent-name.md/audit-agent commandSee audit-coordinator skill for comprehensive standards.
This skill is part of the authoring skill family:
For validation, use the corresponding audit skills:
Creating a new agent:
~/.claude/agents/agent-name.md/audit-agent agent-nameTake majiayu000/agent-authoring from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.