agent-authoring
Creates and configures Claude Code subagents (custom agents). Covers frontmatter fields, tool restrictions, model selection, hooks, memory, skills preloading, and common patterns. Follows official Anthropic best practices. USE WHEN: user mentions "create agent", "subagent", "custom agent", ".claude/agents", "agent file", "delegate task", "isolated context", "agent memory", "agent hooks" DO NOT USE FOR: creating skills - use `skill-authoring`; creating hooks standalone - use `hook-authoring`; creating MCP servers - use `mcp-authoring`
What this skill does
# Agent/Subagent Authoring — Official Best Practices
## File Structure
Agents are Markdown files with YAML frontmatter. The body becomes the system prompt.
```
.claude/agents/my-agent.md # Project-scoped (commit to VCS)
~/.claude/agents/my-agent.md # User-scoped (all projects)
```
## YAML Frontmatter — All Fields
See [quick-ref/frontmatter-reference.md](quick-ref/frontmatter-reference.md) for detailed field docs.
```yaml
---
name: code-reviewer # Required. Lowercase + hyphens
description: | # Required. When Claude should delegate
Expert code review specialist. Use proactively after code changes.
tools: Read, Grep, Glob, Bash # Allowlist (inherits all if omitted)
disallowedTools: Write, Edit # Denylist (removed from inherited/allowed)
model: sonnet # sonnet | opus | haiku | inherit (default)
permissionMode: default # default | acceptEdits | dontAsk | bypassPermissions | plan
maxTurns: 50 # Max agentic turns before stopping
skills: # Skills preloaded into context at startup
- api-conventions
- error-handling
mcpServers: # MCP servers available to this agent
- slack # Reference existing server by name
memory: user # user | project | local — persistent memory
background: false # true = always run as background task
isolation: worktree # Run in temporary git worktree
hooks: # Lifecycle hooks (scoped to this agent)
PreToolUse:
- matcher: "Bash"
hooks:
- type: command
command: "./scripts/validate.sh"
---
```
## System Prompt (Body)
The markdown body IS the system prompt. Subagents receive ONLY this + basic env details (cwd, etc.), NOT the full Claude Code system prompt.
**Effective prompt structure:**
```markdown
You are a [role] specializing in [domain].
When invoked:
1. [First action]
2. [Second action]
3. [Third action]
[Domain-specific checklist or criteria]
Provide feedback organized by:
- Critical issues (must fix)
- Warnings (should fix)
- Suggestions (consider)
Include specific examples of how to fix issues.
```
## Description — Critical for Delegation
Claude delegates based on the description. Include "Use proactively" to encourage automatic delegation.
**Good:** `"Expert code review specialist. Use proactively after code changes."`
**Bad:** `"Reviews code"` — too vague, Claude won't know when to delegate.
## Key Design Decisions
### When to use agents vs skills vs main conversation
| Use Case | Mechanism |
|----------|-----------|
| Verbose output you don't need in main context | Agent |
| Enforce tool restrictions | Agent |
| Self-contained work returning a summary | Agent |
| Reusable knowledge/instructions inline | Skill |
| Frequent back-and-forth needed | Main conversation |
| Quick, targeted changes | Main conversation |
### Model selection
| Model | Use for |
|-------|---------|
| `haiku` | Fast exploration, simple search, low-cost |
| `sonnet` | Balanced — code review, analysis, most tasks |
| `opus` | Complex reasoning, architecture decisions |
| `inherit` | Same as main conversation (default) |
### Tool restrictions
- Read-only agent: `tools: Read, Grep, Glob, Bash`
- Full capabilities: omit `tools` (inherits all)
- Block specific tools: `disallowedTools: Write, Edit`
- Restrict spawning: `tools: Agent(worker, researcher), Read`
## Common Patterns
See [quick-ref/patterns.md](quick-ref/patterns.md) for detailed examples.
**Code reviewer** — Read-only, focused on quality
**Debugger** — Can edit, diagnosis-to-fix workflow
**Domain expert** — Specialized knowledge (data science, security)
**Parallel research** — Multiple agents exploring independently
**Chain** — Sequential agents, each building on previous results
## Memory
When `memory` is set, the agent gets a persistent directory across sessions.
| Scope | Location | Use when |
|-------|----------|----------|
| `user` | `~/.claude/agent-memory/<name>/` | Learnings across all projects |
| `project` | `.claude/agent-memory/<name>/` | Project-specific, shareable via VCS |
| `local` | `.claude/agent-memory-local/<name>/` | Project-specific, not committed |
The agent automatically gets Read/Write/Edit tools + instructions for managing MEMORY.md.
**Tip:** Include in prompt: "Update your agent memory as you discover patterns, codepaths, and architectural decisions."
## Anti-Patterns
| Anti-Pattern | Fix |
|--------------|-----|
| Too many responsibilities | One agent, one job. Create separate agents for different tasks |
| No description or vague description | Detailed description with "use proactively" |
| Overly permissive tools | Grant only what's needed |
| Expecting subagents to spawn subagents | Not supported. Use chains from main conversation |
| Forgetting subagents lose parent context | They start fresh. Preload skills or provide full instructions |
## Checklist
- [ ] `name` and `description` set (both required)
- [ ] Description explains WHEN to delegate, not just what
- [ ] Tools restricted to minimum necessary
- [ ] Model chosen based on task complexity
- [ ] System prompt has clear workflow steps
- [ ] Tested with real scenarios
- [ ] Committed to `.claude/agents/` (project) or `~/.claude/agents/` (user)
## Reference
- [All frontmatter fields](quick-ref/frontmatter-reference.md)
- [Common agent patterns](quick-ref/patterns.md)
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.