Skills for Claude Code CLI such as full stack dev Cloudflare, React, Tailwind v4, and AI integrations.
Python aianthropicautomationclaude-codeclaude-skillscloudflaredevtoolsproductivityreactskillstailwindvite
docs(sub-agent-patterns): Comprehensive update from official docs
Jezf314d87b887f
diff --git a/skills/sub-agent-patterns/README.md b/skills/sub-agent-patterns/README.mdindex b4df7e68..36bded65 100644--- a/skills/sub-agent-patterns/README.md+++ b/skills/sub-agent-patterns/README.md@@ -1,33 +1,84 @@# Sub-Agent Patterns Skill-Effective patterns for delegating tasks to parallel sub-agents in Claude Code.+Comprehensive guide to sub-agents in Claude Code: built-in agents, custom agent creation, configuration, and delegation patterns.## Auto-Trigger KeywordsThis skill should be suggested when the user mentions:-- "sub-agent", "sub-agents", "subagent"+**Sub-Agent Concepts:**+- "sub-agent", "sub-agents", "subagent", "subagents"- "parallel agents", "multiple agents"- "Task tool", "launch agents"+- "delegate tasks", "delegation"++**Built-in Agents:**+- "Explore agent", "explore subagent"+- "Plan agent", "plan subagent"+- "general-purpose agent"+- "thoroughness level", "quick/medium/thorough"++**Custom Agents:**+- ".claude/agents"+- "~/.claude/agents"+- "/agents command"+- "create agent", "custom agent"+- "--agents flag"++**Configuration:**+- "agent tools", "agent model"+- "permissionMode", "agent permissions"+- "agent skills", "agent hooks"+- "resumable agent", "resume agent"+- "disable agent", "Task(Explore)"++**Bulk Operations:**- "bulk operations", "batch processing"- "audit all", "update all", "check all"- "swarm", "multi-agent"-- "delegate tasks"++**Errors:**+- "agent context", "agent timeout"+- "agent not responding"## What This Skill Covers-1. **When to Delegate** - The "repetitive + judgment" sweet spot-2. **Prompt Templates** - 5-step structure that works consistently-3. **Batch Sizing** - 5-8 items per agent, 2-4 agents parallel-4. **Output Formats** - Structured reports for easy review-5. **Commit Strategy** - Agents edit, human commits-6. **Error Handling** - Retry, skip, or resolve conflicts+1. **Built-in Sub-Agents** - Explore (Haiku, read-only), Plan (Sonnet, plan mode), General-purpose (Sonnet, all tools)+2. **Custom Agent Creation** - File format, YAML frontmatter, .claude/agents/ locations+3. **Configuration Fields** - name, description, tools, model, permissionMode, skills, hooks+4. **Model Selection** - sonnet, opus, haiku, inherit+5. **/agents Command** - Interactive agent management+6. **CLI Configuration** - `--agents '{...}'` flag+7. **Resumable Agents** - Continue previous conversations with agentId+8. **Disabling Agents** - Task(AgentName) permission rules+9. **Delegation Patterns** - The "repetitive + judgment" sweet spot+10. **Prompt Templates** - 5-step structure for audits, updates, research+11. **Batch Sizing** - 5-8 items per agent, 2-4 agents parallel+12. **Commit Strategy** - Agents edit, human commits## Quick Example-```markdown-# Prompt template for sub-agents:+### Built-in Explore Agent+```+User: Where are errors handled?+Claude: [Invokes Explore with "medium" thoroughness]+ → Returns: src/services/process.ts:712+```++### Custom Agent File (.claude/agents/code-reviewer.md)+```yaml+---+name: code-reviewer+description: Expert code reviewer. Use proactively after code changes.+tools: Read, Grep, Glob, Bash+model: inherit+---+You are a senior code reviewer...+```++### Delegation Prompt Template+```markdownFor each [item]:1. Read [source file]2. Verify with [external check]@@ -38,7 +89,7 @@ For each [item]:Items: [list of 5-8 items]```-## When NOT to Use+## When NOT to Use Sub-Agents- Single complex task (do it yourself)- Simple find-replace (use scripts)@@ -47,7 +98,7 @@ Items: [list of 5-8 items]## Production Tested-- Skill audits: 25 skills in ~5 minutes (parallel batches)+- Skill audits: 68 skills across 10 tiers (parallel batches)- Description optimization: 58 skills in ~3 minutes- Multi-site updates: 12 sites with consistent changes@@ -55,3 +106,9 @@ Items: [list of 5-8 items]- `project-planning` - For planning complex multi-phase work- `project-workflow` - For session management and handoffs++## References++- [Official Sub-Agents Documentation](https://code.claude.com/docs/en/sub-agents)+- [Tools Documentation](https://code.claude.com/docs/en/tools)+- [Hooks Documentation](https://code.claude.com/docs/en/hooks)diff --git a/skills/sub-agent-patterns/SKILL.md b/skills/sub-agent-patterns/SKILL.mdindex a8db49fe..10751eb9 100644--- a/skills/sub-agent-patterns/SKILL.md+++ b/skills/sub-agent-patterns/SKILL.md@@ -1,23 +1,218 @@---name: sub-agent-patternsdescription: |- Effective patterns for delegating tasks to parallel sub-agents in Claude Code. Covers when to delegate, prompt templates, batch sizing, output formats, and commit strategies.+ Comprehensive guide to sub-agents in Claude Code: built-in agents (Explore, Plan, general-purpose), custom agent creation, configuration, and delegation patterns.- Use when: bulk operations across many items, parallel research, multi-file audits, or any repetitive task requiring judgment.+ Use when: creating custom sub-agents, delegating bulk operations, parallel research, understanding built-in agents, or configuring agent tools/models.metadata:- keywords: [sub-agent, Task tool, parallel agents, delegation, batch processing, swarm, multi-agent, bulk operations]+ keywords: [sub-agent, Task tool, parallel agents, delegation, batch processing, swarm, multi-agent, bulk operations, .claude/agents, Explore agent, Plan agent, general-purpose agent, resumable agents]----# Sub-Agent Delegation Patterns+# Sub-Agents in Claude Code**Status**: Production Ready ✅**Last Updated**: 2026-01-09+**Source**: https://code.claude.com/docs/en/sub-agents-Operational patterns for effective sub-agent delegation using Claude Code's Task tool.+Sub-agents are specialized AI assistants that Claude Code can delegate tasks to. Each sub-agent has its own context window, configurable tools, and custom system prompt.----## The Sweet Spot+## Built-in Sub-Agents++Claude Code includes three built-in sub-agents available out of the box:++### Explore Agent++Fast, lightweight agent optimized for **read-only** codebase exploration.++| Property | Value |+|----------|-------|+| **Model** | Haiku (fast, low-latency) |+| **Mode** | Strictly read-only |+| **Tools** | Glob, Grep, Read, Bash (read-only: ls, git status, git log, git diff, find, cat, head, tail) |++**Thoroughness levels** (specify when invoking):+- `quick` - Fast searches, targeted lookups+- `medium` - Balanced speed and thoroughness+- `very thorough` - Comprehensive analysis across multiple locations++**When Claude uses it**: Searching/understanding codebase without making changes. Findings don't bloat the main conversation.++```+User: Where are errors from the client handled?+Claude: [Invokes Explore with "medium" thoroughness]+ → Returns: src/services/process.ts:712+```++### Plan Agent++Specialized for **plan mode** research and information gathering.++| Property | Value |+|----------|-------|+| **Model** | Sonnet |+| **Mode** | Read-only research |+| **Tools** | Read, Glob, Grep, Bash |+| **Invocation** | Automatic in plan mode |++**When Claude uses it**: In plan mode when researching codebase to create a plan. Prevents infinite nesting (sub-agents cannot spawn sub-agents).++### General-Purpose Agent++Capable agent for complex, multi-step tasks requiring both exploration AND action.++| Property | Value |+|----------|-------|+| **Model** | Sonnet |+| **Mode** | Read AND write |+| **Tools** | All tools |+| **Purpose** | Complex research, multi-step operations, code modifications |++**When Claude uses it**:+- Task requires both exploration and modification+- Complex reasoning needed to interpret search results+- Multiple strategies may be needed+- Task has multiple dependent steps++---++## Creating Custom Sub-Agents++### File Locations++| Type | Location | Scope | Priority |+|------|----------|-------|----------|+| Project | `.claude/agents/` | Current project only | Highest |+| User | `~/.claude/agents/` | All projects | Lower |+| CLI | `--agents '{...}'` | Current session | Middle |++When names conflict, project-level takes precedence.++### File Format++Markdown files with YAML frontmatter:++```yaml+---+name: code-reviewer+description: Expert code reviewer. Use proactively after code changes.+tools: Read, Grep, Glob, Bash+model: inherit+permissionMode: default+skills: project-workflow+hooks:+ PostToolUse:+ - matcher: "Edit|Write"+ hooks:+ - type: command+ command: "./scripts/run-linter.sh"+---++Your sub-agent's system prompt goes here.++Include specific instructions, best practices, and constraints.+```++### Configuration Fields++| Field | Required | Description |+|-------|----------|-------------|+| `name` | Yes | Unique identifier (lowercase, hyphens) |+| `description` | Yes | When Claude should use this agent |+| `tools` | No | Comma-separated list. Omit = inherit all tools |+| `model` | No | `sonnet`, `opus`, `haiku`, or `inherit`. Default: sonnet |+| `permissionMode` | No | `default`, `acceptEdits`, `dontAsk`, `bypassPermissions`, `plan`, `ignore` |+| `skills` | No | Comma-separated skills to auto-load (sub-agents don't inherit parent skills) |+| `hooks` | No | `PreToolUse`, `PostToolUse`, `Stop` event handlers |++### Using /agents Command (Recommended)++```+/agents+```++Interactive menu to:+- View all sub-agents (built-in, user, project)+- Create new sub-agents with guided setup+- Edit existing sub-agents and tool access+- Delete custom sub-agents+- See which sub-agents are active++### CLI Configuration++```bash+claude --agents '{+ "code-reviewer": {+ "description": "Expert code reviewer. Use proactively after code changes.",+ "prompt": "You are a senior code reviewer. Focus on code quality, security, and best practices.",+ "tools": ["Read", "Grep", "Glob", "Bash"],+ "model": "sonnet"+ }+}'+```++---++## Using Sub-Agents++### Automatic Delegation++Claude proactively delegates based on:+- Task description in your request+- `description` field in sub-agent config+- Current context and available tools++**Tip**: Include "use PROACTIVELY" or "MUST BE USED" in description for more automatic invocation.++### Explicit Invocation++```+> Use the test-runner subagent to fix failing tests+> Have the code-reviewer subagent look at my recent changes+> Ask the debugger subagent to investigate this error+```++### Resumable Sub-Agents++Sub-agents can be resumed to continue previous conversations:++```+# Initial invocation+> Use the code-analyzer agent to review the auth module+[Agent completes, returns agentId: "abc123"]++# Resume with full context+> Resume agent abc123 and now analyze the authorization logic+```++**Use cases**:+- Long-running research across multiple sessions+- Iterative refinement without losing context+- Multi-step workflows with maintained context++### Disabling Sub-Agents++Add to settings.json permissions:++```json+{+ "permissions": {+ "deny": ["Task(Explore)", "Task(Plan)"]+ }+}+```++Or via CLI:+```bash+claude --disallowedTools "Task(Explore)"+```++---++## Delegation Patterns++### The Sweet Spot**Best use case**: Tasks that are **repetitive but require judgment**.@@ -33,9 +228,7 @@ Operational patterns for effective sub-agent delegation using Claude Code's Task- Tasks with cross-item dependencies (agents work independently)```------## Core Prompt Template+### Core Prompt TemplateThis 5-step structure works consistently:@@ -54,9 +247,7 @@ For each [item]:- **Output format template** - Ensures consistent, parseable reports- **Item list** - Explicit list of what to process------## Batch Sizing+### Batch Sizing| Batch Size | Use When ||------------|----------|@@ -71,9 +262,7 @@ For each [item]:**Parallel agents**: Launch 2-4 agents simultaneously, each with their own batch.------## Workflow Pattern+### Workflow Pattern```┌─────────────────────────────────────────────────────────────┐@@ -174,24 +363,105 @@ Output format:----## Output Format Design+## Example Custom Sub-Agents-Structure agent reports for easy scanning:+### Code Reviewer-```markdown-## [Category] Audit Summary+```yaml+---+name: code-reviewer+description: Expert code review specialist. Proactively reviews code for quality, security, and maintainability. Use immediately after writing or modifying code.+tools: Read, Grep, Glob, Bash+model: inherit+---++You are a senior code reviewer ensuring high standards of code quality and security.++When invoked:+1. Run git diff to see recent changes+2. Focus on modified files+3. Begin review immediately++Review checklist:+- Code is clear and readable+- Functions and variables are well-named+- No duplicated code+- Proper error handling+- No exposed secrets or API keys+- Input validation implemented+- Good test coverage+- Performance considerations addressed++Provide feedback organized by priority:+- Critical issues (must fix)+- Warnings (should fix)+- Suggestions (consider improving)++Include specific examples of how to fix issues.+```-| Item | Score | Status | Issues | Fixed |-|------|-------|--------|--------|-------|-| item-1 | 9.5/10 | PASS | 1 | Yes |-| item-2 | 8.0/10 | NEEDS_UPDATE | 2 | Yes |+### Debugger-### Detailed Findings+```yaml+---+name: debugger+description: Debugging specialist for errors, test failures, and unexpected behavior. Use proactively when encountering any issues.+tools: Read, Edit, Bash, Grep, Glob+---++You are an expert debugger specializing in root cause analysis.++When invoked:+1. Capture error message and stack trace+2. Identify reproduction steps+3. Isolate the failure location+4. Implement minimal fix+5. Verify solution works++Debugging process:+- Analyze error messages and logs+- Check recent code changes+- Form and test hypotheses+- Add strategic debug logging+- Inspect variable states++For each issue, provide:+- Root cause explanation+- Evidence supporting the diagnosis+- Specific code fix+- Testing approach+- Prevention recommendations++Focus on fixing the underlying issue, not the symptoms.+```++### Data Scientist++```yaml+---+name: data-scientist+description: Data analysis expert for SQL queries, BigQuery operations, and data insights. Use proactively for data analysis tasks and queries.+tools: Bash, Read, Write+model: sonnet+---++You are a data scientist specializing in SQL and BigQuery analysis.++When invoked:+1. Understand the data analysis requirement+2. Write efficient SQL queries+3. Use BigQuery command line tools (bq) when appropriate+4. Analyze and summarize results+5. Present findings clearly++Key practices:+- Write optimized SQL queries with proper filters+- Use appropriate aggregations and joins+- Include comments explaining complex logic+- Format results for readability+- Provide data-driven recommendations-#### item-1 (Score: 9.5/10)-**Issues Found**: [description]-**Fix Applied**: [what was changed]-**File**: [path]+Always ensure queries are efficient and cost-effective.```---@@ -251,77 +521,62 @@ Rare (agents work on different items), but if it happens:----## Real Examples--### Example 1: Skill Audits (This Session)--**Task**: Audit 25 Cloudflare + Frontend skills--**Approach**:-- 3 batches of 5 Cloudflare skills (parallel)-- 2 batches of 5 Frontend skills (parallel)-- Same prompt template for all+## Best Practices-**Results**:-- 25 skills audited in ~5 minutes-- Found: outdated versions, wrong limits, missing features-- All fixed automatically--### Example 2: Description Optimization--**Task**: Trim 58 skill descriptions from 400+ chars to 250-350--**Approach**:-- 6 batches of ~10 skills each (parallel)-- Prompt: "Trim description, move keywords to metadata.keywords"--**Results**:-- 58 skills processed in ~3 minutes-- 0 skills over 350 chars (was 58)--### Example 3: Multi-Site Updates (flare-sites)--**Task**: Update configuration across 12 client sites--**Approach**:-- 3 batches of 4 sites-- Each agent: read config, apply update, verify--**Results**:-- All sites updated consistently-- Changes reviewed and committed in batches+1. **Start with Claude-generated agents**: Use `/agents` to generate initial config, then customize+2. **Design focused sub-agents**: Single, clear responsibility per agent+3. **Write detailed prompts**: Specific instructions, examples, constraints+4. **Limit tool access**: Only grant necessary tools (security + focus)+5. **Version control**: Check `.claude/agents/` into git for team sharing+6. **Use inherit for model**: Adapts to main conversation's model choice----## Signs a Task Fits This Pattern--✅ **Use sub-agents when:**-- Same steps repeated for 5+ items-- Each item requires judgment (not just transformation)-- Items are independent (no cross-item dependencies)-- Clear success criteria exists-- Authoritative source available to verify against+## Performance Considerations-❌ **Don't use sub-agents when:**-- Items depend on each other's results-- Requires creative/subjective decisions-- Single complex task (use regular conversation)-- Simple transformation (use sed/grep/scripts)-- Needs human input mid-process+| Consideration | Impact |+|---------------|--------|+| **Context efficiency** | Agents preserve main context, enabling longer sessions |+| **Latency** | Sub-agents start fresh, may add latency gathering context |+| **Thoroughness** | Explore agent's thoroughness levels trade speed for completeness |---## Quick Reference```-Batch size: 5-8 items per agent (adjust for complexity)-Parallel: 2-4 agents simultaneously-Prompt: 5-step template (read → verify → check → evaluate → FIX)-Output: Structured tables + detailed findings-Commit: Human reviews, batches, commits with changelog-Errors: Retry failed batch OR skip and continue+Built-in agents:+ Explore → Haiku, read-only, quick/medium/thorough+ Plan → Sonnet, plan mode research+ General → Sonnet, all tools, read/write++Custom agents:+ Project → .claude/agents/*.md (highest priority)+ User → ~/.claude/agents/*.md+ CLI → --agents '{...}'++Config fields:+ name, description (required)+ tools, model, permissionMode, skills, hooks (optional)++Delegation:+ Batch size: 5-8 items per agent+ Parallel: 2-4 agents simultaneously+ Prompt: 5-step (read → verify → check → evaluate → FIX)++Resume agents:+ > Resume agent [agentId] and continue...```---+## References++- [Official Sub-Agents Documentation](https://code.claude.com/docs/en/sub-agents)+- [Plugins Documentation](https://code.claude.com/docs/en/plugins)+- [Tools Documentation](https://code.claude.com/docs/en/tools)+- [Hooks Documentation](https://code.claude.com/docs/en/hooks)++---+**Last Updated**: 2026-01-09