Nested Subagents logo

Nested Subagents

CommunityPopular
ruvnet
nested-subagents

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

Overview

Publisherruvnet
Repositoryruflo
Skill namenested-subagents
Stars
72.7K
Forks
8.6K
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by ruvnet on GitHub. Read the source before you install it.

Installation

Install the Nested Subagents AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/ruvnet/ruflo.git /tmp/ruflo
mkdir -p .claude/skills
cp -r /tmp/ruflo/plugins/ruflo-agent/skills/nested-subagents .claude/skills/nested-subagents
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Nested Subagents in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Nested Subagents on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Nested Subagents is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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.

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 attributionparent_agent_id lineage gives accurate per-tree spend, not just flat per-agent.
  • Maps cleanly onto ruflo's existing orchestratorsruflo-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.

Related

  • 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

Frequently asked questions

What does the Nested Subagents AI skill 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

Why use Nested Subagents on TypingMind?

Because you install it once and use it with any model. Nested Subagents is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Nested Subagents in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/ruvnet/ruflo/tree/main/plugins/ruflo-agent/skills/nested-subagents. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Nested Subagents?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Nested Subagents?

As many as you like. As long as a model supports skills, you can use Nested Subagents with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Nested Subagents AI skill free?

Yes. It is published on GitHub by ruvnet under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇