agent-builder
Create custom agents for Claude Code including YAML frontmatter, system prompts, tool restrictions, and discovery optimization. Use when creating, building, or designing agents, or when asked about agent creation, subagent configuration, Task tool delegation, or agent best practices.
What this skill does
# Agent Builder
A comprehensive guide for creating custom agents in Claude Code. Agents are specialized AI assistants that run in **separate context windows**, enabling focused, autonomous task execution.
---
## Quick Reference
### YAML Frontmatter Fields
| Field | Required | Description |
|-------|----------|-------------|
| `name` | Yes | Unique identifier (lowercase-with-hyphens) |
| `description` | Yes | When to invoke — **critical for discovery** |
| `tools` | No | Allowed tools (inherits all if omitted) |
| `model` | No | `haiku`, `sonnet`, `opus`, or `inherit` |
| `permissionMode` | No | `default`, `acceptEdits`, `bypassPermissions`, `plan` |
| `skills` | No | Auto-load Skills when agent starts |
### File Locations
| Scope | Location | Use Case |
|-------|----------|----------|
| Project | `.claude/agents/agent-name.md` | Team workflows (git-shared) |
| Personal | `~/.claude/agents/agent-name.md` | Individual use (all projects) |
### Common Tool Patterns
```yaml
# Read-only (safest)
tools: Read, Grep, Glob
# File modification
tools: Read, Write, Edit, Grep, Glob
# Git operations only
tools: Bash(git:*)
# Specific commands
tools: Bash(npm test:*), Bash(npm run:*), Read, Grep
# Full shell (use sparingly)
tools: Bash
```
### Model Selection Guide
| Model | Best For | Tradeoff |
|-------|----------|----------|
| `haiku` | Quick checks, simple tasks | Fast, cheap, less capable |
| `sonnet` | Balanced work (default) | Good balance |
| `opus` | Complex analysis, critical tasks | Most capable, slower, expensive |
| `inherit` | Consistency with main conversation | Adapts to user's model |
---
## 6-Phase Workflow
### Phase 1: Requirements Gathering
**Use AskUserQuestion** to understand what the user needs:
**Key Questions**:
1. What task should this agent handle?
2. What expertise/role should it have?
3. Who will use it — team or personal?
4. What should it be able to do vs NOT do?
5. How should it present results?
**Example Questions**:
```
What specific task should this agent handle?
├── Code review (quality, security, style)
├── Debugging (error investigation, root cause)
├── Testing (run tests, fix failures)
├── Documentation (generate, verify, update)
└── Other: [describe]
Who will use this agent?
├── Just me (personal: ~/.claude/agents/)
├── My team (project: .claude/agents/)
```
### Phase 2: Scope Selection
**Decision Tree**:
```
Is this a team workflow?
├── Yes → Project scope: .claude/agents/
│ (Committed to git, shared automatically)
│
└── No → Is it project-specific?
├── Yes → Project scope: .claude/agents/
└── No → Personal scope: ~/.claude/agents/
(Available across all your projects)
```
**Create the file**:
```bash
# Project scope (team)
mkdir -p .claude/agents
touch .claude/agents/agent-name.md
# Personal scope (individual)
mkdir -p ~/.claude/agents
touch ~/.claude/agents/agent-name.md
```
### Phase 3: Description Crafting
**The description field is CRITICAL** — it determines whether Claude automatically discovers and uses your agent.
**Formula**: `[Role/Expertise] + [What it does] + [When to invoke] + [Trigger terms]`
**Bad (won't be discovered)**:
```yaml
description: Helps with code
```
**Good (specific, discoverable)**:
```yaml
description: Expert code reviewer specializing in security and quality. Reviews code changes for vulnerabilities, best practices, and maintainability. Use when reviewing code, checking PRs, or when the user mentions code review, pull request review, or security audit.
```
**Breaking down a good description**:
1. **Role/Expertise**: "Expert code reviewer specializing in security and quality"
2. **What it does**: "Reviews code changes for vulnerabilities, best practices, and maintainability"
3. **When to invoke**: "Use when reviewing code, checking PRs"
4. **Trigger terms**: "code review, pull request review, or security audit"
**Proactive Language** (increases automatic invocation):
- "Use PROACTIVELY after code changes"
- "MUST be invoked when tests fail"
- "Automatically use when user mentions..."
**Trigger Term Categories**:
- **Actions**: review, analyze, debug, fix, test, check, audit
- **Objects**: code, PR, tests, errors, performance, security
- **Contexts**: before deploy, after changes, when failing, during review
**Length**: 50-150 words is the sweet spot.
### Phase 4: Tool Configuration
**Security Principle**: Start with minimal tools, add only what's needed.
**Progressive Tool Access**:
```yaml
# Level 1: Read-only (safest)
tools: Read, Grep, Glob
# Level 2: Can modify files
tools: Read, Write, Edit, Grep, Glob
# Level 3: Specific shell commands
tools: Read, Grep, Glob, Bash(git:*), Bash(npm test:*)
# Level 4: Full shell (use carefully)
tools: Read, Write, Edit, Bash, Grep, Glob
```
**Granular Bash Patterns**:
```yaml
# Git commands only
tools: Bash(git:*)
# Specific git commands
tools: Bash(git diff:*), Bash(git log:*), Bash(git status:*)
# npm commands only
tools: Bash(npm:*)
# Test commands only
tools: Bash(npm test:*), Bash(pytest:*), Bash(jest:*)
```
**Tool Selection by Agent Type**:
| Agent Type | Recommended Tools |
|------------|-------------------|
| Code analyzer | `Read, Grep, Glob` |
| Code reviewer | `Read, Grep, Glob, Bash(git diff:*)` |
| Test runner | `Read, Edit, Bash(npm test:*), Grep, Glob` |
| Debugger | `Read, Edit, Bash, Grep, Glob` |
| Fixer/Refactorer | `Read, Write, Edit, Grep, Glob` |
### Phase 5: System Prompt Design
**Key Insight**: Agents run in **separate context** — they don't see conversation history. System prompts must be **self-contained** with complete workflows.
**Effective Structure**:
```markdown
You are [role] specializing in [expertise].
## When Invoked
1. [First action — gather context]
2. [Second action — analyze/process]
3. [Third action — produce output]
4. [Fourth action — verify/validate]
## Focus Areas
- Specific thing to check
- Another thing to verify
- Important consideration
## Output Format
[How to present results]
## Constraints
- What NOT to do
- Boundaries to respect
```
**System Prompt Patterns**:
**1. Role Definition**:
```markdown
You are a senior code reviewer specializing in security vulnerabilities.
Your primary focus is identifying OWASP Top 10 risks.
```
**2. When Invoked (critical for autonomous work)**:
```markdown
## When Invoked
1. Run `git diff HEAD` to see recent changes
2. Identify modified files and their purpose
3. Review each change against security checklist
4. Present findings with severity levels
```
**3. Checklist Pattern**:
```markdown
## Review Checklist
- [ ] No SQL injection vulnerabilities
- [ ] Input validation on all boundaries
- [ ] No exposed secrets or credentials
- [ ] Proper authentication checks
- [ ] Authorization verified for each endpoint
```
**4. Output Format**:
```markdown
## Output Format
Present findings as:
### Summary
[One-line verdict: PASS/FAIL/NEEDS ATTENTION]
### Critical Issues
[Must fix before merge]
### Warnings
[Should fix]
### Suggestions
[Nice to have]
```
**5. Constraints**:
```markdown
## Constraints
- Do NOT modify code unless explicitly asked
- Do NOT change API contracts
- Focus ONLY on security-related issues
- ALWAYS explain WHY something is a risk
```
**6. Decision Tree (for branching logic)**:
```markdown
## Decision Flow
If no changes detected:
→ Report "No changes to review"
If only test files changed:
→ Focus on test coverage and assertions
If API endpoints modified:
→ Prioritize authentication/authorization review
Otherwise:
→ Full security review
```
### Phase 6: Testing & Iteration
**Test Discovery**:
```
# Natural language requests (should trigger agent)
> Review my recent code changes
> Check this PR for security issues
> Audit the authentication module
# Explicit invocation (always works)
> Use the code-reviewer agent to check this
```
**Verify Tool Access**:
```bash
# Check agent can use its tools
# If agent needs git, test manually first
git diff 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.