Agent Development
Design and build custom Claude Code agents with effective descriptions, tool access patterns, and self-documenting prompts. Covers Task tool delegation, model selection, memory limits, and declarative
Design and build custom Claude Code agents with effective descriptions, tool access patterns, and self-documenting prompts. Covers Task tool delegation, model selection, memory limits, and declarative
Real data. Real impact.
Emerging
Developers
Per week
Open source
Skills give you superpowers. Install in 30 seconds.
Build effective custom agents for Claude Code with proper delegation, tool access, and prompt design.
The description field determines whether Claude will automatically delegate tasks.
--- name: agent-name description: | [Role] specialist. MUST BE USED when [specific triggers]. Use PROACTIVELY for [task category]. Keywords: [trigger words] tools: Read, Write, Edit, Glob, Grep, Bash model: sonnet ---
| Weak (won't auto-delegate) | Strong (auto-delegates) |
|---|---|
| "Analyzes screenshots for issues" | "Visual QA specialist. MUST BE USED when analyzing screenshots. Use PROACTIVELY for visual QA." |
| "Runs Playwright scripts" | "Playwright specialist. MUST BE USED when running Playwright scripts. Use PROACTIVELY for browser automation." |
Key phrases:
Task tool subagent_type: "agent-name" - always worksSession restart required after creating/modifying agents.
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.
Instead of restricting Bash, allowlist safe commands in
.claude/settings.json:
{ "permissions": { "allow": [ "Write", "Edit", "WebFetch(domain:*)", "Bash(cd *)", "Bash(cp *)", "Bash(mkdir *)", "Bash(ls *)", "Bash(cat *)", "Bash(head *)", "Bash(tail *)", "Bash(grep *)", "Bash(diff *)", "Bash(mv *)", "Bash(touch *)", "Bash(file *)" ] } }
Don't downgrade quality to work around issues - fix root causes instead.
| Model | Use For |
|---|---|
| Opus | Creative work (page building, design, content) - quality matters |
| Sonnet | Most agents - content, code, research (default) |
| Haiku | Only script runners where quality doesn't matter |
Add to
~/.bashrc or ~/.zshrc:
export NODE_OPTIONS="--max-old-space-size=16384"
Increases Node.js heap from 4GB to 16GB.
| Agent Type | Max Parallel | Notes |
|---|---|---|
| Any agents | 2-3 | Context accumulates; batch then pause |
| Heavy creative (Opus) | 1-2 | Uses more memory |
source ~/.bashrc or restart terminalNODE_OPTIONS="--max-old-space-size=16384" claudeAlways prefer Task sub-agents over remote API calls.
| Aspect | Remote API Call | Task Sub-Agent |
|---|---|---|
| Tool access | None | Full (Read, Grep, Write, Bash) |
| File reading | Must pass all content in prompt | Can read files iteratively |
| Cross-referencing | Single context window | Can reason across documents |
| Decision quality | Generic suggestions | Specific decisions with rationale |
| Output quality | ~100 lines typical | 600+ lines with specifics |
// ❌ WRONG - Remote API call const response = await fetch('https://api.anthropic.com/v1/messages', {...})// ✅ CORRECT - Use Task tool // Invoke Task with subagent_type: "general-purpose"
Describe what to accomplish, not how to use tools.
### Check for placeholders ```bash grep -r "PLACEHOLDER:" build/*.html
### Right (Declarative)### Check for placeholders Search all HTML files in build/ for: - PLACEHOLDER: comments - TODO or TBD markers - Template brackets like [Client Name] Any match = incomplete content. </code></pre> <h3>What to Include</h3> <table><thead><tr><th>Include</th><th>Skip</th></tr></thead><tbody><tr><td>Task goal and context</td><td>Explicit bash/tool commands</td></tr><tr><td>Input file paths</td><td>"Use X tool to..."</td></tr><tr><td>Output file paths and format</td><td>Step-by-step tool invocations</td></tr><tr><td>Success/failure criteria</td><td>Shell pipeline syntax</td></tr><tr><td>Blocking checks (prerequisites)</td><td>Micromanaged workflows</td></tr><tr><td>Quality checklists</td><td></td></tr></tbody></table> <h2>Self-Documentation Principle</h2> <blockquote> <p>"Agents that won't have your context must be able to reproduce the behaviour independently."</p> </blockquote> <p>Every improvement must be encoded into the agent's prompt, not left as implicit knowledge.</p> <h3>What to Encode</h3> <table><thead><tr><th>Discovery</th><th>Where to Capture</th></tr></thead><tbody><tr><td>Bug fix pattern</td><td>Agent's "Corrections" or "Common Issues" section</td></tr><tr><td>Quality requirement</td><td>Agent's "Quality Checklist" section</td></tr><tr><td>File path convention</td><td>Agent's "Output" section</td></tr><tr><td>Tool usage pattern</td><td>Agent's "Process" section</td></tr><tr><td>Blocking prerequisite</td><td>Agent's "Blocking Check" section</td></tr></tbody></table> <h3>Test: Would a Fresh Agent Succeed?</h3> <p>Before completing any agent improvement:</p> <ol> <li>Read the agent prompt as if you have no context</li> <li>Ask: Could a new session follow this and produce the same quality?</li> <li>If no: Add missing instructions, patterns, or references</li> </ol> <h3>Anti-Patterns</h3> <table><thead><tr><th>Anti-Pattern</th><th>Why It Fails</th></tr></thead><tbody><tr><td>"As we discussed earlier..."</td><td>No prior context exists</td></tr><tr><td>Relying on files read during dev</td><td>Agent may not read same files</td></tr><tr><td>Assuming knowledge from errors</td><td>Agent won't see your debugging</td></tr><tr><td>"Just like the home page"</td><td>Agent hasn't built home page</td></tr></tbody></table> <h2>Agent Prompt Structure</h2> <p>Effective agent prompts include:</p> <pre><code class="language-markdown">## Your Role [What the agent does] ## Blocking Check [Prerequisites that must exist] ## Input [What files to read] ## Process [Step-by-step with encoded learnings] ## Output [Exact file paths and formats] ## Quality Checklist [Verification steps including learned gotchas] ## Common Issues [Patterns discovered during development] </code></pre> <h2>Pipeline Agents</h2> <p>When inserting a new agent into a numbered pipeline (e.g., <code>HTML-01</code> → <code>HTML-05</code> → <code>HTML-11</code>):</p> <table><thead><tr><th>Must Update</th><th>What</th></tr></thead><tbody><tr><td>New agent</td><td>"Workflow Position" diagram + "Next" field</td></tr><tr><td><strong>Predecessor agent</strong></td><td>Its "Next" field to point to new agent</td></tr></tbody></table> <p><strong>Common bug</strong>: New agent is "orphaned" because predecessor still points to old next agent.</p> <p><strong>Verification</strong>:</p> <pre><code class="language-bash">grep -n "Next:.*→\|Then.*runs next" .claude/agents/*.md </code></pre> <h2>The Sweet Spot</h2> <p><strong>Best use case</strong>: Tasks that are <strong>repetitive but require judgment</strong>.</p> <p>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.</p> <p><strong>Not good for</strong>:</p> <ul> <li>Simple tasks (just do them)</li> <li>Highly creative tasks (need human direction)</li> <li>Tasks requiring cross-file coordination (agents work independently)</li> </ul> <h2>Effective Prompt Template</h2> <pre><code>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 </code></pre> <p><strong>Key elements</strong>:</p> <ul> <li><strong>"FIX issues found"</strong> - Without this, agents only report. With it, they take action.</li> <li><strong>Exact file paths</strong> - Prevents ambiguity</li> <li><strong>Output format template</strong> - Ensures consistent, parseable reports</li> <li><strong>Batch size ~5 items</strong> - Enough work to be efficient, not so much that failures cascade</li> </ul> <h2>Workflow Pattern</h2> <pre><code>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 </code></pre> <p><strong>Why agents don't commit</strong>: Allows human review, batching, and clean commit history.</p> <h2>Signs a Task Fits This Pattern</h2> <p><strong>Good fit</strong>:</p> <ul> <li>Same steps repeated for many items</li> <li>Each item requires judgment (not just transformation)</li> <li>Items are independent (no cross-item dependencies)</li> <li>Clear success criteria (score, pass/fail, etc.)</li> <li>Authoritative source exists to verify against</li> </ul> <p><strong>Bad fit</strong>:</p> <ul> <li>Items depend on each other's results</li> <li>Requires creative/subjective decisions</li> <li>Single complex task (use regular agent instead)</li> <li>Needs human input mid-process</li> </ul> <h2>Quick Reference</h2> <h3>Agent Frontmatter Template</h3> <pre><code class="language-yaml">--- name: my-agent description: | [Role] specialist. MUST BE USED when [triggers]. Use PROACTIVELY for [task category]. Keywords: [trigger words] tools: Read, Write, Edit, Glob, Grep, Bash model: sonnet --- </code></pre> <h3>Fix Bash Approval Spam</h3> <ol> <li>Remove Bash from tools if not needed</li> <li>Put critical instructions FIRST (right after frontmatter)</li> <li>Use allowlists in <code>.claude/settings.json</code></li> </ol> <h3>Memory Crash Recovery</h3> <pre><code class="language-bash">export NODE_OPTIONS="--max-old-space-size=16384" source ~/.bashrc && claude </code></pre>
No automatic installation available. Please visit the source repository for installation instructions.
View Installation Instructions1,500+ AI skills, agents & workflows. Install in 30 seconds. Part of the Torly.ai family.
© 2026 Torly.ai. All rights reserved.