skills/claude-agent-sdk/sub-agent-delegation/SKILL.md
Delegate work to sub-agents via the Task/Agent tool — parallel research, isolated context windows, specialized expertise. Covers when sub-agents help vs hurt, prompt shape, and result handling. Use this skill when building agents that need to research in parallel, process independent work items, or isolate context-heavy sub-tasks. Activate when: sub-agents, Task tool, Agent tool, parallel agents, agent delegation, spawn agent, multi-agent.
npx skillsauth add latestaiagents/agent-skills sub-agent-delegationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Sub-agents are isolated agent invocations spawned from a parent. They run in a fresh context, do focused work, and return a single result. Use them to parallelize, specialize, and protect context.
Parent agent sees a Task (or Agent) tool. When invoked, it spawns a sub-agent with:
The sub-agent's intermediate tool calls are NOT visible to the parent — only the final result.
import { query } from "@anthropic-ai/claude-agent-sdk";
for await (const msg of query({
prompt: "Research and compare the top 3 vector databases. Summarize pros/cons.",
options: {
model: "claude-sonnet-4-6",
allowedTools: ["Task", "WebFetch", "Read"],
},
})) { /* ... */ }
The parent agent decides to invoke Task with a prompt like "Research Pinecone's pros and cons. Use WebFetch. Report in under 200 words." Three parallel Task calls, three independent contexts, three summaries returned.
The parent can issue multiple tool calls in one step:
Parent: Let me research all three in parallel.
[tool_use: Task] Research Pinecone...
[tool_use: Task] Research Weaviate...
[tool_use: Task] Research Qdrant...
Three sub-agents run concurrently. Parent waits for all three results, then synthesizes.
Sub-agents start with nothing. Prompt them like a smart colleague who just walked in:
Bad prompt: "Find info about Pinecone" Good prompt: "Research Pinecone as a vector DB for a 10M-vector production workload. Find pricing, latency at 10M scale, clustering support, filtering support. Report as a 200-word summary with bullet points for each metric. Do not cover marketing fluff."
hooks: {
PostToolUse: async ({ toolName, output }) => {
if (toolName === "Task") {
await db.logDelegation({ prompt: output.prompt, result: output.result });
}
},
}
Log every delegation. Sub-agents can fail, loop, or hallucinate like any agent — audit them.
Sub-agents cost extra — they run a full model inference. But they save parent tokens:
Net: you pay more compute, save context window for reasoning. Worth it when parent is doing long reasoning on top of research.
Create multiple agent "personas" — each a sub-agent type with specialized prompts and tools:
// Parent system prompt:
"You orchestrate work across:
- 'researcher' sub-agents (WebFetch, Read) for gathering info
- 'reviewer' sub-agents (Read, Grep) for code review
- 'writer' sub-agents (Read, Write) for drafting
Delegate to the right one based on the task."
The parent plans; specialists execute.
A sub-agent can return errors:
Always have the parent sanity-check sub-agent output before passing to user.
development
Test skills for correct activation, content quality, and regression — both automated checks (frontmatter validity, lint) and manual verification (query-suite activation testing). Covers CI integration and how to catch skill regressions before users do. Use this skill when adding skills to a repo, setting up CI for a skill library, or debugging "the skill exists but doesn't work". Activate when: test skills, validate skills, skill CI, skill linting, skill activation test, skill regression.
documentation
Write the YAML frontmatter for a SKILL.md file so it activates reliably — name, description, and activation keywords that the model matches against. Covers length, tone, and the most common frontmatter mistakes. Use this skill when authoring a new skill, fixing a skill that isn't auto-activating, or reviewing skills for publication. Activate when: SKILL.md frontmatter, skill description, skill activation, skill YAML, write a skill, author a skill.
development
Design skills that fire at the right moment — neither over-eager (noise) nor under-eager (silent). Covers activation specificity, trigger phrases, disambiguation between overlapping skills, and debugging activation. Use this skill when multiple skills could fire on the same query, a skill never fires, or a skill fires too often. Activate when: skill won't activate, skill over-activates, overlapping skills, skill triggers, skill selection, skill disambiguation.
development
Structure SKILL.md content so the model reads just enough — concise summary up front, progressively deeper detail, examples on demand. Covers section ordering, length budgets, when to split into multiple skills. Use this skill when writing or refactoring a skill body, one skill has grown too long, or a skill is wordy but not useful. Activate when: SKILL.md structure, skill content, skill too long, split skill, progressive disclosure, skill body.