create-subagent
Create a specialized AI subagent with isolated context and custom configuration. Use when user says "create subagent", "create agent", "make an agent", or needs task-specific delegation.
What this skill does
# Create Subagent Create a specialized AI subagent that runs in its own context window with custom system prompt, tool access, and permissions. Subagents preserve main conversation context by handling complex tasks independently. ## Quick Start ```bash # Interactive mode - guided creation /create-subagent # Auto mode - create from name /create-subagent code-reviewer ``` ## Subagent Locations | Location | Path | Scope | Priority | |----------|------|-------|----------| | Project | `.claude/agents/<name>.md` | This project | Higher | | User | `~/.claude/agents/<name>.md` | All projects | Lower | Project-level subagents override user-level when names conflict. ## Creation Process ### 1. Determine Mode - **With argument** (`$ARGUMENTS`): Auto mode - generate from name and recent workflow - **Without argument**: Interactive mode - ask guided questions ### 2. Interactive Mode Questions Use AskUserQuestion with these prompts: **Question 1 - Role**: - Header: "Role" - Question: "What specialized role should this subagent fulfill?" - Options: - "Code quality expert" - Review, refactor, improve code - "Testing specialist" - Write and run tests - "Architecture advisor" - Design systems, plan structure - "Domain expert" - Specialized domain knowledge **Question 2 - Activation**: - Header: "Activation" - Question: "When should Claude delegate to this subagent?" - Options: - "After code changes" - Proactively review new code - "Specific keywords" - Trigger on certain terms - "Explicit request only" - Only when user asks - "High-volume operations" - Isolate verbose output **Question 3 - Tools** (multiSelect: true): - Header: "Tools" - Question: "Which tools should this subagent access?" - Options: - "Read-only" - Read, Grep, Glob (safe exploration) - "File operations" - Read, Write, Edit, Glob - "Shell commands" - Bash execution - "All tools" - Inherit everything **Question 4 - Model**: - Header: "Model" - Question: "Which model should power this subagent?" - Options: - "Sonnet (Recommended)" - Balanced performance - "Haiku (Fast)" - Quick, cost-effective - "Opus (Advanced)" - Most capable - "Inherit" - Same as main conversation **Question 5 - Scope**: - Header: "Scope" - Question: "Where should this subagent be available?" - Options: - "User-level" - Save to ~/.claude/agents/ - "Project-level" - Save to .claude/agents/ ### 3. Extract Workflow Patterns When analyzing recent conversation: 1. Identify domain from file types and commands 2. Track tool usage patterns 3. Detect repeated action sequences 4. Extract trigger keywords from user messages ### 4. Generate Subagent File ```bash # User-level ~/.claude/agents/$SUBAGENT_NAME.md # Project-level .claude/agents/$SUBAGENT_NAME.md ``` ### 5. Write Subagent Content Use this template: ```markdown --- name: subagent-name description: Role + when to invoke. Include trigger keywords for auto-delegation. tools: Read, Write, Bash # Optional, inherits all if omitted model: sonnet # Optional: sonnet, opus, haiku, inherit --- You are a [specific role] specializing in [domain]. ## Responsibilities 1. **Primary Task**: What you do first 2. **Secondary Task**: What you do next 3. **Quality Assurance**: How you verify work ## Workflow When invoked: 1. **Analyze**: Understand the current state 2. **Execute**: Perform the main task 3. **Verify**: Check results meet standards 4. **Report**: Summarize findings ## Best Practices - Guideline 1 - Guideline 2 - Common pitfall to avoid ## Output Format [Template for deliverables] ``` ## Frontmatter Reference See [reference.md](reference.md) for complete frontmatter field documentation. Key fields: | Field | Description | |-------|-------------| | `name` | Unique identifier (lowercase, hyphens) | | `description` | Role + activation triggers (critical for auto-delegation) | | `tools` | Comma-separated list; inherits all if omitted | | `disallowedTools` | Tools to explicitly deny | | `model` | `sonnet`, `opus`, `haiku`, or `inherit` | | `permissionMode` | `default`, `acceptEdits`, `dontAsk`, `bypassPermissions`, `plan` | | `skills` | Skills to preload into subagent context | | `hooks` | Lifecycle hooks for this subagent | ## Description Best Practices **Poor descriptions**: - "Helps review code" (vague, no triggers) - "API testing tool" (no context) **Good descriptions**: - "Expert code reviewer. Reviews for quality, security, maintainability. Use immediately after writing code, before commits, or when refactoring." - "API testing specialist. Validates REST endpoints, schemas, error handling. Use when testing APIs or debugging HTTP requests." ## Built-in Subagents Claude Code includes these built-in subagents: | Agent | Model | Tools | Purpose | |-------|-------|-------|---------| | Explore | Haiku | Read-only | Fast codebase exploration | | Plan | Inherit | Read-only | Research during plan mode | | general-purpose | Inherit | All | Complex multi-step tasks | ## When to Use Subagents Use subagents when: - Task produces verbose output (tests, logs) - Need to enforce tool restrictions - Work is self-contained and returns summary - Different model needed for sub-task Use main conversation when: - Frequent back-and-forth needed - Multiple phases share context - Quick, targeted changes - Latency matters ## Validation Checklist Before finalizing: 1. **YAML syntax**: Valid frontmatter with proper delimiters 2. **Description**: Includes role + activation triggers + keywords 3. **System prompt**: Clear role, structured workflow, quality criteria 4. **Tool access**: Appropriate for task, not too permissive ## Output Format After creation: ``` Subagent created: subagent-name Location: ~/.claude/agents/subagent-name.md Role: [description] Model: sonnet Tools: Read, Write, Bash To use: - Automatic: Claude delegates when context matches - Explicit: "Use the subagent-name subagent to [task]" ``` ## Examples See [examples.md](examples.md) for complete subagent examples. ## Debugging If subagent doesn't activate: 1. Check file: `ls ~/.claude/agents/subagent-name.md` 2. Verify YAML: `head -10 ~/.claude/agents/subagent-name.md` 3. Make description more specific with trigger keywords 4. Test explicit: "Use the subagent-name subagent to [task]" 5. Run `/agents` to verify it's loaded
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.