Skills for Claude Code CLI such as full stack dev Cloudflare, React, Tailwind v4, and AI integrations.
Python aianthropicautomationclaude-codeclaude-skillscloudflaredevtoolsproductivityreactskillstailwindvite
feat(sub-agent-patterns): Add Bash approval spam prevention learnings
Jez36483e8f1c21
diff --git a/skills/sub-agent-patterns/.claude-plugin/plugin.json b/skills/sub-agent-patterns/.claude-plugin/plugin.jsonindex ae0bb247..53136627 100644--- a/skills/sub-agent-patterns/.claude-plugin/plugin.json+++ b/skills/sub-agent-patterns/.claude-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "sub-agent-patterns",- "description": "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. Use when: bulk operations across many items, parallel research, multi-file audits, or any repetitive task requiring judgment.",+ "description": "Expert code reviewer. Use proactively after code changes.","version": "1.0.0","author": {"name": "Jeremy Dawes",diff --git a/skills/sub-agent-patterns/SKILL.md b/skills/sub-agent-patterns/SKILL.mdindex 56c4707d..0fbbd59b 100644--- a/skills/sub-agent-patterns/SKILL.md+++ b/skills/sub-agent-patterns/SKILL.md@@ -10,7 +10,7 @@ user-invocable: true# Sub-Agents in Claude Code**Status**: Production Ready ✅-**Last Updated**: 2026-01-10+**Last Updated**: 2026-01-14**Source**: https://code.claude.com/docs/en/sub-agentsSub-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.@@ -207,14 +207,79 @@ Complete list of tools that can be assigned to sub-agents:**Tool Access Patterns by Agent Type:**-| Agent Type | Recommended Tools |-|------------|-------------------|-| Read-only reviewers | `Read, Grep, Glob, LS` |-| Code writers | `Read, Write, Edit, Bash, Glob, Grep` |-| Research agents | `Read, Grep, Glob, WebFetch, WebSearch` |-| Documentation | `Read, Write, Edit, Glob, Grep, WebFetch` |-| Orchestrators | `Read, Grep, Glob, Task` |-| Full access | Omit `tools` field (inherits all) |+| Agent Type | Recommended Tools | Notes |+|------------|-------------------|-------|+| Read-only reviewers | `Read, Grep, Glob, LS` | No write capability |+| File creators | `Read, Write, Edit, Glob, Grep` | ⚠️ **No Bash** - avoids approval spam |+| Script runners | `Read, Write, Edit, Glob, Grep, Bash` | Use when CLI execution needed |+| Research agents | `Read, Grep, Glob, WebFetch, WebSearch` | Read-only external access |+| Documentation | `Read, Write, Edit, Glob, Grep, WebFetch` | No Bash for cleaner workflow |+| Orchestrators | `Read, Grep, Glob, Task` | Minimal tools, delegates to specialists |+| Full access | Omit `tools` field (inherits all) | Use sparingly |++**⚠️ Tool Access Principle**: If an agent doesn't need Bash, don't give it Bash. Each bash command requires approval, causing workflow interruptions. See "Avoiding Bash Approval Spam" below.++### Avoiding Bash Approval Spam (CRITICAL)++When sub-agents have Bash in their tools list, they often default to using `cat > file << 'EOF'` heredocs for file creation instead of the Write tool. Each unique bash command requires user approval, causing:++- Dozens of approval prompts per agent run+- Slow, frustrating workflow+- Hard to review (heredocs are walls of minified content)++**Root Causes**:+1. **Models default to bash for file ops** - Training data bias toward shell commands+2. **Bash in tools list = Bash gets used** - Even if Write tool is available+3. **Instructions get buried** - A "don't use bash" rule at line 300 of a 450-line prompt gets ignored++**Solutions** (in order of preference):++1. **Remove Bash from tools list** (if not needed):+ ```yaml+ # Before - causes approval spam+ tools: Read, Write, Edit, Glob, Grep, Bash++ # After - clean file operations+ tools: Read, Write, Edit, Glob, Grep+ ```+ If the agent only creates files, it doesn't need Bash. The orchestrator can run necessary scripts after.++2. **Put critical instructions FIRST** (immediately after frontmatter):+ ```markdown+ ---+ name: site-builder+ tools: Read, Write, Edit, Glob, Grep+ model: sonnet+ ---++ ## ⛔ CRITICAL: USE WRITE TOOL FOR ALL FILES++ **You do NOT have Bash access.** Create ALL files using the **Write tool**.++ ---++ [rest of prompt...]+ ```+ Instructions at the top get followed. Instructions buried 300 lines deep get ignored.++3. **Remove contradictory instructions**:+ ```markdown+ # BAD - contradictory+ Line 75: "Copy images with `cp -r intake/images/* build/images/`"+ Line 300: "NEVER use cp, mkdir, cat, or echo"++ # GOOD - consistent+ Only mention the pattern you want used. Remove all bash examples if you want Write tool.+ ```++**When to keep Bash:**+- Agent needs to run external CLIs (wrangler, npm, git)+- Agent needs to execute scripts+- Agent needs to check command outputs++**Testing**: Before vs after removing Bash:+- **Before** (with Bash): 11+ heredoc approval prompts, wrong patterns applied+- **After** (no Bash): Mostly Write tool usage, correct patterns, minimal prompts### Using /agents Command (Recommended)@@ -445,28 +510,50 @@ Send agents to the background while continuing work in your main session:### Model Selection Strategy-Match model to task requirements for cost and speed optimization:+**Quality-First Approach**: Default to Sonnet for most agents. The cost savings from Haiku rarely outweigh the quality loss.++| Model | Best For | Speed | Cost | Quality |+|-------|----------|-------|------|---------|+| `sonnet` | **Default for most agents** - content generation, reasoning, file creation | Balanced | Standard | ✅ High |+| `opus` | Creative work, complex reasoning, quality-critical outputs | Slower | Premium | ✅ Highest |+| `haiku` | **Only for simple script execution** where quality doesn't matter | 2x faster | 3x cheaper | ⚠️ Variable |+| `inherit` | Match main conversation | Varies | Varies | Matches parent |-| Model | Best For | Speed | Cost |-|-------|----------|-------|------|-| `haiku` | Simple lookups, format checks, fast reads | 2x faster | 3x cheaper |-| `sonnet` | Complex reasoning, code generation | Balanced | Standard |-| `opus` | Deep analysis, architectural decisions | Slower | Premium |-| `inherit` | Match main conversation | Varies | Varies |+**Why Sonnet Default?**-**Pattern**: Use Haiku for high-volume simple tasks, Sonnet for judgment-heavy work:+Testing showed significant quality differences:+- **Haiku**: Wrong stylesheet links, missing CSS, wrong values, incorrect patterns+- **Sonnet**: Correct patterns, proper validation, fewer errors++| Task Type | Recommended Model | Why |+|-----------|-------------------|-----|+| Content generation | Sonnet | Quality matters |+| File creation | Sonnet | Patterns must be correct |+| Code writing | Sonnet | Bugs are expensive |+| Audits/reviews | Sonnet | Judgment required |+| Creative work | Opus | Maximum quality |+| Deploy scripts | Haiku (OK) | Just running commands |+| Simple format checks | Haiku (OK) | Pass/fail only |++**Pattern**: Default Sonnet, use Opus for creative, Haiku only when quality truly doesn't matter:```yaml----name: format-checker-model: haiku # Fast, cheap - just checking patterns-tools: Read, Grep, Glob+name: site-builder+model: sonnet # Content quality matters - NOT haiku+tools: Read, Write, Edit, Glob, Grep+---++---+name: creative-director+model: opus # Creative work needs maximum quality+tools: Read, Write, Edit, Glob, Grep-------name: architecture-reviewer-model: opus # Deep reasoning needed-tools: Read, Grep, Glob, Bash+name: deploy-runner+model: haiku # Just running wrangler commands - quality irrelevant+tools: Read, Bash---```@@ -907,9 +994,12 @@ Rare (agents work on different items), but if it happens:1. **Start with Claude-generated agents**: Use `/agents` to generate initial config, then customize2. **Design focused sub-agents**: Single, clear responsibility per agent3. **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+4. **Don't give Bash unless needed**: Prevents approval spam (see "Avoiding Bash Approval Spam")+5. **Put critical instructions FIRST**: Instructions at top of prompt get followed, buried ones get ignored+6. **Remove contradictory instructions**: If you want Write tool, remove all bash examples+7. **Default to Sonnet model**: Quality matters more than cost savings (see Model Selection)+8. **Version control**: Check `.claude/agents/` into git for team sharing+9. **Use inherit for model sparingly**: Better to explicitly set model for predictable behavior---@@ -940,12 +1030,22 @@ Config fields:name, description (required)tools, model, permissionMode, skills, hooks (optional)-Core tools:- Read-only: Read, Grep, Glob, LS, TodoRead- Write: Write, Edit, MultiEdit, NotebookEdit- Execute: Bash, BashOutput, KillShell- Web: WebFetch, WebSearch- Advanced: Task, Skill, LSP, MCPSearch+Tool access principle:+ ⚠️ Don't give Bash unless agent needs CLI execution+ File creators: Read, Write, Edit, Glob, Grep (no Bash!)+ Script runners: Read, Write, Edit, Glob, Grep, Bash (only if needed)+ Research: Read, Grep, Glob, WebFetch, WebSearch++Model selection (quality-first):+ Default: sonnet (most agents - quality matters)+ Creative: opus (maximum quality)+ Scripts only: haiku (just running commands)+ ⚠️ Avoid Haiku for content generation - quality drops significantly++Instruction placement:+ ⛔ Critical instructions go FIRST (right after frontmatter)+ ⚠️ Instructions buried 300+ lines deep get ignored+ ✅ Remove contradictory instructions (pick one pattern)Delegation:Batch size: 5-8 items per agent@@ -959,7 +1059,6 @@ Orchestration:Advanced:Background: Ctrl+B during agent execution- Models: haiku (fast), sonnet (balanced), opus (deep)Context: 130k+ and 90+ tool calls work fine for real workHooks: PreToolUse, PostToolUse, Stop events@@ -986,4 +1085,4 @@ Resume agents:----**Last Updated**: 2026-01-10+**Last Updated**: 2026-01-14diff --git a/skills/sub-agent-patterns/rules/sub-agent-patterns.md b/skills/sub-agent-patterns/rules/sub-agent-patterns.mdnew file mode 100644index 00000000..4070c67c--- /dev/null+++ b/skills/sub-agent-patterns/rules/sub-agent-patterns.md@@ -0,0 +1,126 @@+---+description: Patterns for effective sub-agent delegation - tool access principle, model selection, prompt templates, workflow patterns+alwaysApply: false+---++# Sub-Agent Delegation Patterns++Operational knowledge for effective sub-agent delegation in Claude Code.++---++## Tool Access Principle (CRITICAL)++**If an agent doesn't need Bash, don't give it Bash.**++| Agent needs to... | Give tools | Don't give |+|-------------------|------------|------------|+| Create files only | Read, Write, Edit, Glob, Grep | Bash |+| Run scripts/CLIs | Read, Write, Edit, Glob, Grep, Bash | — |+| Read/audit only | Read, Glob, Grep | Write, Edit, Bash |++**Why?** Models default to `cat > file << 'EOF'` heredocs instead of Write tool. Each bash command requires approval, causing dozens of prompts per agent run.++**Fix Bash approval spam:**+1. Remove Bash from tools list if not needed+2. Put critical instructions FIRST (right after frontmatter)+3. Remove contradictory instructions (don't mention bash if you want Write tool)++---++## Model Selection (Quality-First)++| Model | Best For |+|-------|----------|+| **Sonnet** | Most agents - content, files, code (default) |+| **Opus** | Creative work, quality-critical outputs |+| **Haiku** | Only script runners where quality doesn't matter |++**Why Sonnet default?** Testing showed Haiku produces wrong patterns, missing CSS, incorrect values. Sonnet gets it right first time.++---++## The Sweet Spot++**Best use case**: Tasks that are **repetitive but require judgment**.++Example: Auditing 70 skills manually = tedious. But each audit needs intelligence (check docs, compare versions, decide what to fix). Perfect for parallel agents with clear instructions.++**Not good for**: Simple tasks (just do them), highly creative tasks (need human direction), tasks requiring cross-file coordination (agents work independently).++---++## Effective Prompt Template++```+For each [item]:+1. Read [source file]+2. Verify with [external check - npm view, API call, etc.]+3. Check [authoritative source]+4. Score/evaluate+5. FIX issues found ← Critical instruction+```++**Key elements**:+- **"FIX issues found"** - Without this, agents only report. With it, they take action.+- **Exact file paths** - Prevents ambiguity and wrong-file edits+- **Output format template** - Ensures consistent, parseable reports+- **Batch size ~5 items** - Enough work to be efficient, not so much that failures cascade++---++## Workflow Pattern++```+1. ME: Launch 2-3 parallel agents with identical prompt, different item lists+2. AGENTS: Work in parallel (read → verify → check → edit → report)+3. AGENTS: Return structured reports (score, status, fixes applied, files modified)+4. ME: Review changes (git status, spot-check diffs)+5. ME: Commit in batches with meaningful changelog+6. ME: Push and update progress tracking+```++**Why agents don't commit**: Allows human review, batching, and clean commit history.++---++## Signs a Task Fits This Pattern++✅ Same steps repeated for many items+✅ Each item requires judgment (not just transformation)+✅ Items are independent (no cross-item dependencies)+✅ Clear success criteria (score, pass/fail, etc.)+✅ Authoritative source exists to verify against++❌ Items depend on each other's results+❌ Requires creative/subjective decisions+❌ Single complex task (use regular agent instead)+❌ Needs human input mid-process++---++## Real Example: Skill Audits++**Task**: Audit 70 skills for version accuracy and content correctness++**Prompt template**:+```+Deep audit these 5 skills. For each:+1. Read SKILL.md+2. Verify versions with npm view+3. Check official docs (use cloudflare-docs MCP or WebFetch)+4. Score 1-10+5. FIX issues found++Skills: [list of 5]+```++**Results**:+- 15 Cloudflare skills audited in ~3 minutes (3 parallel agents)+- 10 Frontend skills audited in ~2 minutes (2 parallel agents)+- Caught: outdated versions, wrong limits, missing features+- All fixed automatically by agents++---++**Last Updated**: 2026-01-14