From latestaiagents
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 claudepluginhub latestaiagents/agent-skills --plugin skills-authoringThis skill uses the workspace's default tool permissions.
**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.**
Guides creating, configuring, and orchestrating Claude Code subagents and Task tool. Covers prompts, tools, models, file structures, and multi-agent workflows.
Compresses subagent prompts to ≤200-word briefs before Task/Agent tool calls, preventing high token costs from re-tokenizing full contexts in multi-agent workflows.
Creates, validates, and refines Claude Code subagents for reliable delegation. Use for building new subagents, checking configurations, improving quality, scoping tool access, permission modes, and hook validation.
Share bugs, ideas, or general feedback.
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.