New to Claude Skills? Learn how to install them →

Sposthog on GitHub

Subagent Orchestration

Free

Delegate tasks to focused subagents for efficient coding.

Get this skill

Free · Opens the source repo

What Subagent Orchestration does

Subagent Orchestration allows developers to delegate specific tasks to focused subagents, each operating within its own isolated context window. This approach is particularly useful for managing complex coding tasks that benefit from breaking down work into smaller, more manageable pieces. By utilizing the subagent tool, users can maintain a clean context while still achieving parallelization of independent tasks, such as exploring different areas of a codebase or planning implementations based on findings.

The skill is designed for scenarios where tasks are self-contained and do not require the full context of the parent session. This means that if a task can be summarized and does not depend on extensive conversation history, it is a good candidate for delegation. For instance, if you need to perform a broad codebase search or read multiple files for insights, delegating these tasks to subagents like Explore or Plan can save time and context space.

The bundled agents include Explore, which focuses on read-only reconnaissance, Plan, which helps in formulating implementation strategies, and General, which executes code changes identified in earlier steps. Each of these agents is tailored for specific types of work, ensuring that users can efficiently manage their coding tasks without overwhelming their primary context.

However, it is important to recognize when not to use this skill. For trivial changes that require minimal input or for tasks that inherently need the full context of the ongoing conversation, delegation may introduce unnecessary overhead. In such cases, directly executing the task is more efficient. Overall, Subagent Orchestration is ideal for developers looking to optimize their workflow by effectively managing task delegation in coding projects.

When to use it

Use this skill when you have self-contained, isolable tasks that can be handled independently, especially when parallel execution is beneficial.

When not to use it

Avoid using this skill for trivial changes or tasks that require extensive context from the parent session.

What you can build with it

Exploring a Large Codebase

When needing to understand the structure of a large codebase, use the `Explore` subagent to quickly gather insights without cluttering your main context.

Planning Implementation Steps

After gathering data with `Explore`, utilize the `Plan` subagent to create a detailed implementation strategy based on the findings.

Executing Code Changes

For independent code changes identified during exploration, delegate the task to the `General` subagent to handle the implementation efficiently.

How to install Subagent Orchestration

View source

1. Install with the skills CLI

npx skills add posthog/posthog/subagent-orchestration --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by posthog

Subagent Orchestration

You (the parent session) can delegate scoped work to focused subagents, each running in its own isolated pi process with its own context window. Use this to keep your own context clean and to parallelize independent work.

When to delegate

Delegate when a piece of work is:

  • Self-contained: it doesn't need your full conversation history, just a task and some context you can state explicitly.
  • Isolable: it would otherwise burn a lot of your context window (e.g. broad codebase search, reading many files) for a result you can summarize down to a few paragraphs.
  • Parallelizable: several independent instances of it can run at once (e.g. exploring two unrelated areas of a large codebase in the same turn).

Do not delegate trivial one-line changes, or work that fundamentally needs your full conversation context to do correctly — that's what context (below) is for, but if almost everything is relevant, delegation adds overhead for no benefit.

Bundled agents

AgentUse forToolsModelNotes
ExploreFast, read-only recon: find files, entry points, data flowread, bash, grep, find, lsFast/cheap model, falls back to your current modelReports compressed findings, never edits
PlanTurn Explore's findings (or your own) into a concrete implementation planread, bash, grep, find, lsInherits your current modelNever edits
GeneralActual implementation: make the code changes an Explore/Plan investigation identified, or any task that needs real editsread, bash, edit, write, grep, find, lsInherits your current modelSame read-write capability as you have; makes real changes

Explore and Plan are read-only. General has the same read-write capability you do — reach for it when a change is mechanical/independent enough to delegate (especially several at once via parallel mode) rather than doing every edit yourself in sequence. For a small, one-off change, just make it directly instead of delegating.

Subagents cannot themselves call subagent — they are leaves, not orchestrators. Keep all delegation decisions in your own (parent) session.

For larger fan-out orchestration — many agents, loops over file lists, staged map/verify/synthesize flows — prefer the workflow tool (if available), which runs a JavaScript script coordinating these same read-only agents and returns one synthesized result. subagent is for one-off or small parallel delegations.

A project can add its own agents (including ones that write) as .pi/agents/<name>.md files — same frontmatter convention as the bundled agents above. See agentScope below.

The context field — always fill it in

A subagent gets only its task string, plus a small automatic digest of your last few conversation turns (as a fallback, not a substitute). It does not see the files you've already read, tool results you've already seen, or decisions you've already made unless you put them in context.

Always pass context with whatever the subagent actually needs:

  • File paths and line numbers you already found.
  • Decisions already made ("use approach B, not A, because...").
  • Constraints ("don't touch files under vendor/").

A subagent given a bare one-line task and no context will waste its own turns re-discovering things you already know.

Modes

  • single — one agent, one task. Default choice.
  • paralleltasks: [...], up to 8 tasks / 4 concurrent. Use for independent work that can run at once, e.g. Exploreing two unrelated parts of a codebase together.

There is no chain mode. For a fixed pipeline (e.g. explore then plan), just call subagent twice in sequence yourself and pass the first call's output back in as the second call's context — you are already the orchestrator holding both results.

Recommended pattern

clarify -> Explore -> Plan -> implement it yourself -> confirm before any risky follow-up

This is guidance, not a rigid workflow — decide per task whether you need both steps. For a small, well-understood change, skip straight to implementing it yourself.

Returning outcomes to the user

A subagent is a means to answer the user's request, not a background task whose result can be silently acknowledged. After a subagent finishes, read its result and give the user the relevant substantive outcome in the parent response.

  • For an open-ended request such as "explore the repo", the findings are the answer: summarize the architecture, notable files, and any recommended next steps without waiting for the user to ask "what did it return?"
  • For implementation, investigation, or review tasks, state what changed or was found, name relevant file paths, and include limitations, failures, or follow-ups that matter.
  • Keep the relay proportional. Do not paste a huge transcript when a concise summary answers the request, but do not replace findings with empty praise such as "that helped" or "I can drill in further."
  • If the result is incomplete, failed, or ambiguous, say so plainly and explain the next action rather than presenting it as success.

The tool result remains available in the conversation for detailed follow-up, but the parent agent owns communicating its useful conclusion to the user.

Observability

Every run writes status.json, events.jsonl, and a full transcript.md to ~/.pi/agent/subagent-runs/<runId>/ for later inspection.

Frequently asked questions about Subagent Orchestration

Similar skills