Agent skill

Nested Subagents

by ruvnet in ruvnet/ruflo

Spawn nested sub-agents (agents that spawn sub-agents, up to depth=5) via Claude Code's native Task tool — for context-managed deep delegation

MITAuto-check: notesAgent Workflows

Install Nested Subagents

skills CLI
$ npx skills add ruvnet/ruflo --skill nested-subagents -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install ruvnet/ruflo nested-subagents --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/ruvnet/ruflo.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/ruflo-agent/skills/nested-subagents .claude/skills/nested-subagents && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
nested-subagents
GitHub stars
74k
Token cost
~1k tokens
SKILL.md length
478 words
Files
1
Skills in repo
264
Repo updated
First seen
Licence
MIT

At a glance

Spawn nested sub-agents (agents that spawn sub-agents, up to depth=5) via Claude Code's native Task tool — for context-managed deep delegation

  • Works in 5 steps: Invoke the coordinator — spawn… → The coordinator decomposes first — it… → Children spawn children — any… → …
  • Tasks that involve Subagents
  • SKILL.md covers When to use, Steps, Depth budget and Benefits, plus 2 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Nested Subagents is an agent skill from ruvnet/ruflo. Spawn nested sub-agents (agents that spawn sub-agents, up to depth=5) via Claude Code's native Task tool — for context-managed deep delegation

Its SKILL.md is about 1k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Agent Workflows, covering Subagents. The repository describes itself as: 🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory…. The licence is MIT.

When your agent uses it

  • Tasks that involve Subagents

Example prompts

  • “/nested-subagents”

Requirements

  • Pre-approved tools (allowed-tools): Task, TodoWrite, Read, Grep, Glob, Bash

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  1. Invoke the coordinator — spawn nested-coordinator as your top-level agent
  2. The coordinator decomposes first — it lays out the spawn tree via TodoWrite before any Task call. Inspect the tree before approving deep…
  3. Children spawn children — any nested-coordinator (or any other agent whose YAML frontmatter declares tools: [..., Task]) can itself call…
  4. Each level reports a summary — children return ~200-token structured summaries, not full transcripts. The whole point is to keep the…
  5. Tree shape is persisted — the post-task hook writes parent_agent_id and depth to AgentDB on every spawn (ADR-147 P2). Query after the run…

What it can do on your machine

Read from SKILL.md and the folder at commit de590e1. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Task
    • TodoWrite
    • Read
    • Grep
    • Glob
    • Bash

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Nested Subagents loads about 1k tokens when it runs. Until then it costs about 40 tokens; SKILL.md has 478 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~40
When it runs · the whole SKILL.md, loaded when a task matches
~1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NotePre-approves every shell command (allowed-tools: Bash)SKILL.md
    allowed-tools: Task, TodoWrite, Read, Grep, Glob, Bash

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from ruvnet/ruflo at commit de590e1, republished under its MIT licence (© ruvnet). 478 words, ~1,030 tokens.

Download SKILL.mdSave it as .claude/skills/nested-subagents/SKILL.md (or your agent's skills folder).
name
nested-subagents
description
Spawn nested sub-agents (agents that spawn sub-agents, up to depth=5) via Claude Code's native Task tool — for context-managed deep delegation
allowed-tools
Task, TodoWrite, Read, Grep, Glob, Bash
argument-hint
<problem-statement>

Nested Sub-Agents

Spawn a tree of sub-agents where each child can itself spawn children, up to 5 levels deep. The motivation is context management, not parallelism: each level gets a fresh context window so deep work doesn't blow the top-level agent's context budget.

When to use

  • The problem decomposes into nested layers (research → expand → verify → synthesize), each of which would otherwise pollute the parent's context.
  • A single agent's context window would not be enough to hold all the intermediate state.
  • The leaves of the tree are different subagent_types and need their own specialized prompts (e.g., pii-detector at one leaf, tester at another).

Skip this skill when flat fan-out (Task × N in one message) suffices — nesting adds latency.

Steps

  1. Invoke the coordinator — spawn nested-coordinator as your top-level agent:

    Task({
      subagent_type: "nested-coordinator",
      name: "root-coordinator",
      description: "Decompose and delegate <problem>",
      prompt: "<problem statement, with constraints and expected output shape>"
    })
  2. The coordinator decomposes first — it lays out the spawn tree via TodoWrite before any Task call. Inspect the tree before approving deep work.

  3. Children spawn children — any nested-coordinator (or any other agent whose YAML frontmatter declares tools: [..., Task]) can itself call Task to spawn the next level. Leaf agents (without Task in their tools list) cannot.

  4. Each level reports a summary — children return ~200-token structured summaries, not full transcripts. The whole point is to keep the parent's context clean.

  5. Tree shape is persisted — the post-task hook writes parent_agent_id and depth to AgentDB on every spawn (ADR-147 P2). Query after the run for cost attribution and pattern learning.

Depth budget

SourceLimit
Anthropic API5 levels (announced 2026-06-09)
Ruflo default (pre-task hook)4 levels — one-level guard band, configurable in claude-flow.config.json
Strict-mode env varCLAUDE_FLOW_STRICT_NESTING=true to enforce the ruflo cap

The hook returns a typed NESTING_DEPTH_EXCEEDED error at the cap, with the full chain in the payload so the parent can decide to summarize, hand off, or abort.

Show full SKILL.md (180 more words)Show less

Benefits

  • Context isolation per level — top-level coordinator never sees inner chatter; leaf summaries climb back up.
  • Deeper delegation without re-summarization — eliminates the "summarize at level 1 to fit it all" anti-pattern that flat fan-out forces.
  • Tree-shaped cost attribution — parent_agent_id lineage gives accurate per-tree spend, not just flat per-agent.
  • Maps cleanly onto ruflo's existing orchestrators — ruflo-sparc:sparc-orchestrator (5 phases ≈ 5 levels), ruflo-goals:dossier-investigator (recursive entity expansion), v3-queen-coordinator (hierarchical-mesh top).

Anti-patterns (do NOT)

  • Pass Task to leaf agents. Leaves must not spawn. Add the leaf's subagent_type directly under the coordinator instead.
  • Wrap a Tier-1 codemod in a coordinator. Codemods (hooks_codemod) are depth-0 deterministic transforms — never put them inside a spawn tree.
  • Nest "for cleanliness". A premature nesting layer wastes latency and cost without saving context. If one agent can do the work, use one agent.
  • Return full transcripts from a child. That defeats the entire purpose of nesting. Children return structured summaries.
  • Agent: ruflo-agent:nested-coordinator — the orchestrator
  • ADR-147 — design rationale and four-phase rollout
  • ADR-144 — authorization propagation shares the depth counter as AuthScope.delegationDepth
  • ADR-099 — dossier investigator (recursive parallel research) is the textbook deep use case

© ruvnet, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in plugins/ruflo-agent/skills/nested-subagents of ruvnet/ruflo.

Open the folder on GitHubat commit de590e1

Compare with similar skills

Nested Subagents next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Nested Subagents compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Nested Subagents this skillruvnet/ruflo74k—~1kAutomated safety check: NotesMIT
Claude Code Agent Developmentanthropics/claude-plugins-official37k8 repos~2.8kAutomated safety check: PassApache-2.0
Subagent Driven DevelopmentAsvarox/allkaraoke26137 repos~1.2kAutomated safety check: PassNone
Dispatching Parallel Agentsultralisp/ultralisp25840 repos~1.5kAutomated safety check: PassNone
Paseo Advisor Second Opiniongetpaseo/paseo20k1 repos~756Automated safety check: PassCustom licence
Task Observerrebelytics/one-skill-to-rule-them-all3.2k1 repos~12kAutomated safety check: PassCC-BY-4.0

Similar skills

  • Claude Code Agent Development

    anthropics/claude-plugins-official

    Official

    Explains how to write agents for Claude Code plugins: the markdown file with YAML frontmatter, trigger descriptions, model and color settings, and system prompt design.

    37k GitHub starsUsed in 8 repos~2.8k tokens
    Agent WorkflowsAuto-check passed
  • Subagent Driven Development

    Asvarox/allkaraoke

    A skill your agent uses when executing implementation plans with independent tasks in the current session

    261 GitHub starsUsed in 37 repos~1.2k tokens
    Agent WorkflowsAuto-check passed
  • Dispatching Parallel Agents

    ultralisp/ultralisp

    A skill your agent uses when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies

    258 GitHub starsUsed in 40 repos~1.5k tokens
    Agent WorkflowsAuto-check passed
  • Launches one separate agent through Paseo to give a second opinion on the current task, with a self-contained briefing and no permission to edit files.

    20k GitHub starsUsed in 1 repo~756 tokens
    Agent WorkflowsAuto-check passed
  • Task Observer

    rebelytics/one-skill-to-rule-them-all

    Monitors task execution for skill improvement opportunities.

    3.2k GitHub starsUsed in 1 repo~12k tokens
    Agent WorkflowsAuto-check passed
  • O2 Review Loop

    openobserve/openobserve

    Splits a change into planner, coder and independent reviewer roles: you confirm a spec, a subagent implements it, and a separate reviewer checks each round's local WIP commit.

    22k GitHub stars~3.7k tokensUpdated today
    Agent WorkflowsAuto-check passed

More from ruvnet/ruflo

All 264 skills in this repo
  • Stores, searches, and retrieves successful patterns with HNSW-indexed semantic search so agents can reuse past solutions instead of relearning them.

    74k GitHub starsUsed in 2 repos~830 tokens
    Auto-check passed
  • Runs claude-flow CLI security scans for input validation, path traversal, SQL injection, XSS, hardcoded secrets and known CVEs, and writes an audit report.

    74k GitHub starsUsed in 2 repos~823 tokens
    Auto-check passed
  • Applies the SPARC method (specification, pseudocode, architecture, refinement, completion) with 17 specialized modes and multi-agent orchestration, from research to deployment.

    74k GitHub starsUsed in 2 repos~829 tokens
    Auto-check passed
  • Coordinates a hierarchical swarm of specialized agents through the claude-flow CLI for work that spans several files or modules at once.

    74k GitHub starsUsed in 2 repos~779 tokens
    Auto-check passed
  • Sets up and drives Ruflo, an npm-installed orchestration layer for multi-agent swarms, persistent memory, routing, hooks and its MCP tool catalog.

    74k GitHub starsUsed in 1 repo~975 tokens
    Auto-check passed
  • Agent Coordination

    ruvnet/ruflo

    Reference for spawning, listing, monitoring and stopping agents with claude-flow commands, with agent type families, routing codes and coordination tips.

    74k GitHub starsUsed in 2 repos~519 tokens
    Auto-check passed

Categories

Questions about Nested Subagents

What does Nested Subagents do?

Spawn nested sub-agents (agents that spawn sub-agents, up to depth=5) via Claude Code's native Task tool — for context-managed deep delegation. Nested Subagents is an agent skill from ruvnet/ruflo.

When should I use Nested Subagents?

Nested Subagents fits situations like: tasks that involve Subagents.

How do I install Nested Subagents in Claude Code?

Run `npx skills add ruvnet/ruflo --skill nested-subagents -a claude-code`. Or copy the skill folder (plugins/ruflo-agent/skills/nested-subagents in ruvnet/ruflo) into .claude/skills/nested-subagents in your project. Claude Code loads it when a task matches its description.

How do I install Nested Subagents in Codex?

Run `npx skills add ruvnet/ruflo --skill nested-subagents -a codex`. Or copy the skill folder (plugins/ruflo-agent/skills/nested-subagents in ruvnet/ruflo) into .agents/skills/nested-subagents in your project. Codex loads it when a task matches its description.

Can I use Nested Subagents in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add ruvnet/ruflo --skill nested-subagents -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/nested-subagents, .gemini/skills/nested-subagents, .github/skills/nested-subagents and .opencode/skills/nested-subagents in your project.

What does Nested Subagents need to run?

SKILL.md names no scripts, command-line tools or credentials: Nested Subagents is instructions for the agent only. Its frontmatter pre-approves these tools: Task, TodoWrite, Read, Grep, Glob, Bash.

Does Nested Subagents access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Nested Subagents safe to install?

Our automated static check of SKILL.md found notes only (pre-approves every shell command (allowed-tools: bash)), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.

What licence does Nested Subagents use?

Nested Subagents is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Nested Subagents use?

About 1k tokens (SKILL.md is roughly 4.1k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Nested Subagents?

Skills that share tags, products or a category with Nested Subagents: Claude Code Agent Development (anthropics/claude-plugins-official, 37k stars), Subagent Driven Development (Asvarox/allkaraoke, 261 stars), Dispatching Parallel Agents (ultralisp/ultralisp, 258 stars) and Paseo Advisor Second Opinion (getpaseo/paseo, 20k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Nested Subagents?

ruvnet (a GitHub user) maintains it in ruvnet/ruflo, which has 74,012 GitHub stars. The repository holds 264 skills in this directory. The repository was last updated on October 7, 2026.

Source: ruvnet/ruflo on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.