sub-agent-review
Review Claude Code sub-agent implementations for best practices in configuration, tool access, hooks, and delegation patterns. Use when creating, auditing, or optimizing sub-agents.
What this skill does
# Sub-Agent Implementation Review
Review Claude Code sub-agent configurations for best practices.
**Target:** $ARGUMENTS (path to sub-agent file or agents directory)
## When to Use This Skill
- Creating new sub-agents
- Auditing existing sub-agent configurations
- Optimizing sub-agent performance and cost
- Reviewing tool access and permissions
- Implementing sub-agent hooks
## Review Process
1. **Discover** - Find agent files at $ARGUMENTS (`.claude/agents/` or `~/.claude/agents/`)
2. **Validate** - Check frontmatter and configuration
3. **Evaluate** - Score against best practices
4. **Report** - Generate findings with recommendations
## Sub-Agent File Structure
### File Format
Sub-agents are Markdown files with YAML frontmatter:
```markdown
---
name: code-reviewer
description: Reviews code for quality and best practices
tools: Read, Glob, Grep
model: sonnet
---
You are a code reviewer. When invoked, analyze the code and provide
specific, actionable feedback on quality, security, and best practices.
```
### Storage Locations
| Location | Scope | Priority | Use Case |
|----------|-------|----------|----------|
| `--agents` CLI flag | Session only | 1 (highest) | Testing, automation |
| `.claude/agents/` | Project | 2 | Team-shared agents |
| `~/.claude/agents/` | User | 3 | Personal agents |
| Plugin `agents/` | Plugin scope | 4 (lowest) | Distributed agents |
## Frontmatter Configuration
### Required Fields
| Field | Description | Example |
|-------|-------------|---------|
| `name` | Unique identifier (kebab-case) | `code-reviewer` |
| `description` | When Claude should delegate | `Reviews code for quality. Use proactively after code changes.` |
### Optional Fields
| Field | Description | Default |
|-------|-------------|---------|
| `tools` | Allowed tools (allowlist) | Inherits all |
| `disallowedTools` | Denied tools (denylist) | None |
| `model` | `sonnet`, `opus`, `haiku`, `inherit` | `inherit` |
| `permissionMode` | Permission handling | `default` |
| `skills` | Skills to preload | None |
| `hooks` | Lifecycle hooks | None |
## Configuration Checklist
### 1. Naming & Description
- [ ] Name is kebab-case and descriptive
- [ ] Description explains WHEN to use the agent
- [ ] Description includes "use proactively" if auto-delegation desired
- [ ] Description is specific enough for accurate delegation
**BAD:**
```yaml
name: helper
description: Helps with stuff
```
**GOOD:**
```yaml
name: code-reviewer
description: Expert code review specialist. Proactively reviews code for quality, security, and maintainability. Use immediately after writing or modifying code.
```
### 2. Tool Access
- [ ] Only necessary tools are granted
- [ ] Read-only agents exclude Write/Edit
- [ ] Dangerous tools require justification
- [ ] MCP tools considered if needed
**Tool Categories:**
| Category | Tools | Use Case |
|----------|-------|----------|
| **Read-only** | Read, Glob, Grep | Research, review |
| **Modification** | Write, Edit | Implementation |
| **Execution** | Bash | Commands, builds |
| **All** | (inherited) | Full capability |
**GOOD (read-only reviewer):**
```yaml
tools: Read, Grep, Glob, Bash
disallowedTools: Write, Edit
```
### 3. Model Selection
- [ ] Model matches task complexity
- [ ] Cost-sensitive tasks use Haiku
- [ ] Complex reasoning uses Sonnet/Opus
- [ ] `inherit` used when parent model is appropriate
| Model | Best For | Cost |
|-------|----------|------|
| `haiku` | Fast searches, simple tasks | Low |
| `sonnet` | Balanced capability/speed | Medium |
| `opus` | Complex reasoning | High |
| `inherit` | Match parent context | Varies |
### 4. Permission Modes
- [ ] Permission mode matches use case
- [ ] `bypassPermissions` used only when necessary
- [ ] `dontAsk` used for non-interactive agents
| Mode | Behavior | Use Case |
|------|----------|----------|
| `default` | Standard prompts | Interactive agents |
| `acceptEdits` | Auto-accept edits | Trusted modifiers |
| `dontAsk` | Auto-deny prompts | Background agents |
| `bypassPermissions` | Skip all checks | Automation (dangerous) |
| `plan` | Read-only exploration | Research agents |
### 5. System Prompt Quality
- [ ] Prompt is focused and specific
- [ ] Clear workflow/steps defined
- [ ] Output format specified
- [ ] Constraints stated explicitly
- [ ] No unnecessary verbosity
**Prompt Structure:**
```markdown
---
[frontmatter]
---
[Role statement - who the agent is]
When invoked:
1. [First step]
2. [Second step]
3. [Third step]
[Detailed guidelines]
[Output format specification]
```
### 6. Skills Preloading
- [ ] Only necessary skills preloaded
- [ ] Skills match agent's domain
- [ ] No duplicate/conflicting skills
```yaml
skills:
- api-conventions
- error-handling-patterns
```
### 7. Hooks Configuration
- [ ] Hooks validate dangerous operations
- [ ] Hook scripts are executable
- [ ] Exit codes used correctly
- [ ] Hooks don't block legitimate operations
**Hook Exit Codes:**
| Code | Behavior |
|------|----------|
| 0 | Allow operation |
| 1 | Error (operation continues) |
| 2 | Block operation |
**Example: Validate SQL queries**
```yaml
hooks:
PreToolUse:
- matcher: "Bash"
hooks:
- type: command
command: "./scripts/validate-readonly-query.sh"
```
## Best Practices
### Design Principles
| Principle | Description |
|-----------|-------------|
| **Single Purpose** | Each agent excels at one specific task |
| **Minimal Tools** | Grant only necessary permissions |
| **Clear Delegation** | Description enables accurate auto-delegation |
| **Version Control** | Project agents checked into repo |
### When to Use Sub-Agents vs Main Conversation
**Use Sub-Agents:**
- Task produces verbose output (tests, logs, docs)
- Need specific tool restrictions
- Work is self-contained
- Can return a summary
**Use Main Conversation:**
- Frequent back-and-forth needed
- Multiple phases share context
- Quick, targeted changes
- Latency matters
### Common Patterns
#### 1. Isolate High-Volume Operations
```
Use a subagent to run the test suite and report only failing tests
```
#### 2. Parallel Research
```
Research auth, database, and API modules in parallel using separate subagents
```
#### 3. Chain Sub-Agents
```
Use code-reviewer to find issues, then use fixer to resolve them
```
### Foreground vs Background
| Mode | Permissions | Questions | Use Case |
|------|-------------|-----------|----------|
| **Foreground** | Interactive prompts | Passed through | Complex tasks |
| **Background** | Pre-approved only | Auto-denied | Parallel work |
## Anti-Patterns
| Anti-Pattern | Problem | Fix |
|--------------|---------|-----|
| **God Agent** | Does everything | Split by responsibility |
| **Vague Description** | Wrong delegation | Be specific about when to use |
| **Over-Permissioned** | Security risk | Limit tools to necessary |
| **Missing Hooks** | Unsafe operations | Add validation hooks |
| **Hardcoded Model** | Inflexible | Use `inherit` unless specific need |
| **No Constraints** | Unpredictable | Define clear boundaries in prompt |
| **Verbose Prompt** | Context waste | Keep focused and specific |
## Review Output Format
```markdown
## Sub-Agent Review: [agent-name]
### Summary
[1-2 sentence overview]
### Configuration Score
| Category | Score | Notes |
|----------|-------|-------|
| Naming & Description | X/5 | |
| Tool Access | X/5 | |
| Model Selection | X/5 | |
| Permission Mode | X/5 | |
| System Prompt | X/5 | |
| Hooks | X/5 | |
| **Overall** | **X/5** | |
### Critical Issues
- [ ] [Issue] - Location: [field]
### Recommendations
- [ ] [Recommendation] - Priority: [High/Medium/Low]
### Strengths
- [What the configuration does well]
```
## Built-in Sub-Agents Reference
| Agent | Model | Tools | Purpose |
|-------|-------|-------|---------|
| **Explore** | Haiku | Read-only | Fast codebase search |
| **Plan** | Inherit | Read-only | Research for planning |
| **general-purpose** | Inherit | All | 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.