Agent File Validator
Validate agent files in .claude/agents/ for correct format.
Validation Target
- With argument: validate specific file
- Without: validate all
.claude/agents/*.md
Required Frontmatter
---
name: agent-name # Required: lowercase, hyphenated, 3-50 chars
description: > # Required: 10-5000 chars, include triggering conditions + <example> blocks
Use this agent when [conditions]. Examples:
<example>
Context: [situation]
user: "[request]"
assistant: "[response using this agent]"
</example>
color: cyan # Required: yellow, red, green, blue, magenta, cyan
model: sonnet # Required: inherit, haiku, sonnet, opus, best, sonnet[1m], opus[1m], opusplan
tools: # Optional: YAML list (omit = all tools available)
- Read
- Write
- Grep
# forkContext: "true" # Optional: run in forked context (string "true"/"false")
# maxTurns: 20 # Optional: max conversation turns (positive integer)
skills: # Optional: auto-load skills (array)
- linked-skill
memory: # Optional: memory scopes to load (array)
- user
- project
- local
mcpServers: # Optional: MCP server refs or objects (array)
- server-name
hooks: # Optional: agent-scoped lifecycle hooks
PreToolUse:
- matcher: Write
hooks:
- type: command
command: ./validate.sh
PostToolUse:
- matcher: Bash
hooks:
- type: command
command: ./log.sh
permissionMode: default # Optional: permission handling
disallowedTools: # Optional: explicit tool blocking
- NotebookEdit
---
Valid Tools
Read, Write, Edit, Bash, Grep, Glob, Task,
WebFetch, WebSearch, TodoWrite, NotebookEdit
Valid Colors
yellow, red, green, blue, magenta, cyan
Valid Models
inherit, haiku, sonnet, opus, best, sonnet[1m], opus[1m], opusplan
Validation Checklist
Required Fields
-
nameexists (lowercase, hyphenated, 3-50 chars) -
descriptionexists (10-5000 chars, recommend 200-1000 with<example>blocks) -
coloris set (valid color name) -
modelis set (inherit/haiku/sonnet/opus/best/sonnet[1m]/opus[1m]/opusplan)
Optional Fields
-
toolsare valid tool names, YAML list format (omit = all tools available) -
skillsreferences existing skills (array, if set) -
forkContextis string "true" or "false" (if set) -
maxTurnsis positive integer (if set) -
memoryis valid array of: user, project, local (if set) -
mcpServersis valid array of string refs or objects (if set) -
hookshas valid structure (if set) -
permissionModeis valid value (if set) -
disallowedToolsare valid tool names (if set)
Content Structure
-
# Agent Nameheading -
## Activationsection - Process/workflow description
- Output format definition
Format Rules
-
toolsuses YAML list format (not[Read, Write]bracket array) - No duplicate tools in list
- All tools are valid tool names
Output Format
## Agent Validation Report
### Files Checked
| File | Status | Issues |
|------|--------|--------|
| code-reviewer.md | OK | None |
| my-agent.md | WARN | Missing color, model |
### Summary
- Total: [N]
- Valid: [N]
- Needs fixes: [N]
Auto-Fix
- Convert bracket array tools to YAML list format
- Convert string skills to YAML array
- Add missing
colorfield (default: cyan) - Add missing
modelfield (default: inherit) - Convert boolean forkContext to string
- Convert scalar memory to array format
- Remove invalid tools
- Add recommended sections