nested-subagents
하는 일
이 스킬은 한 에이전트의 메모리에 다 담기 어려운 큰 문제를 위해 최대 다섯 단계 깊이의 하위 에이전트 트리를 만드는 방법을 안내합니다. 작업이 여러 층으로 나뉘는 복잡한 일을 맡기는 사람을 위한 스킬입니다.
사용하는 경우
- ✓문제가 조사, 확장, 검증, 요약 같은 여러 층으로 나뉠 때.
- ✓한 에이전트의 맥락에 중간 작업을 다 담을 수 없을 때.
- ✓작업의 각 부분에 서로 다른 전문 역할이 필요할 때.
스킬 링크
https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-agent/skills/nested-subagents/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“이 시장 조사를 여러 층으로 나눠, 하위 에이전트가 각 부분을 조사하고 검증한 뒤 요약하게 해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 먼저 작업 트리를 계획하는 조율자를 시작하고, 깊이 한도 안에서 자식 에이전트를 만들며, 자식 에이전트는 다시 자식을 만들 수 있습니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
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-detectorat one leaf,testerat another).
Skip this skill when flat fan-out (Task × N in one message) suffices — nesting adds latency.
Steps
Invoke the coordinator — spawn
nested-coordinatoras 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>" })The coordinator decomposes first — it lays out the spawn tree via
TodoWritebefore anyTaskcall. Inspect the tree before approving deep work.Children spawn children — any
nested-coordinator(or any other agent whose YAML frontmatter declarestools: [..., Task]) can itself callTaskto spawn the next level. Leaf agents (withoutTaskin their tools list) cannot.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.
Tree shape is persisted — the
post-taskhook writesparent_agent_idanddepthto AgentDB on every spawn (ADR-147 P2). Query after the run for cost attribution and pattern learning.
Depth budget
| Source | Limit |
|---|---|
| Anthropic API | 5 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 var | CLAUDE_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 attribution —
parent_agent_idlineage 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
Taskto leaf agents. Leaves must not spawn. Add the leaf'ssubagent_typedirectly 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
자주 묻는 질문
에이전트를 나란히 실행하지 않고 중첩하는 이유는 무엇인가요?
중첩은 속도보다 맥락 관리를 위한 것이라고 스킬은 설명합니다. 각 단계가 새 맥락 창을 가집니다.
얼마나 깊이 갈 수 있나요?
최대 다섯 단계까지입니다.
언제 건너뛰어야 하나요?
단순한 병렬 작업으로 충분하면 건너뛰라고 스킬은 설명합니다. 중첩은 시간이 더 걸리기 때문입니다.
상세 정보
작성자의 원본 설명
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
repo: ruvnet/ruflo
인기도
- GitHub 스타
- 81k
- 순위
- #1558
- 라이선스
- MIT
- 업데이트
- 2026. 11. 2.
댓글
- …
이 저장소의 다른 스킬
agent-adaptive-coordinator
81k작업량이 바뀔 때 에이전트 무리를 나누고 재배치해, 작업에 맞는 배치를 고르도록 에이전트를 돕습니다.
agent-agent
81k큰 목표를 순서가 있는 행동 계획으로 나누고, 조건이 바뀌면 다시 계획하도록 에이전트를 가르칩니다.
agent-agentic-payments
81kAI 쇼핑을 위한 지출 위임장을 관리합니다. 지출 상한, 시간 창, 판매자 규칙, 서명된 승인을 포함합니다.
agent-analyze-code-quality
81k에이전트가 파일을 바꾸지 않고, 코드 품질 문제와 코드 냄새, 기술 부채, 리팩터링 아이디어를 찾아 검토하도록 돕습니다.
비슷한 스킬
add-model-provider
394k에이전트가 안전한 설정 명령으로 새 AI 모델 제공자를 OpenClaw에 연결하고, API 키를 평문으로 두지 않으며, 실시간 테스트를 실행하도록 돕습니다.
acp-router
394k에이전트가 OpenClaw를 통해 Claude Code나 Cursor 같은 코딩 도우미에 작업을 전달해, 작업이 그 도구에서 실행되도록 돕습니다.
browser-automation
394k에이전트가 로그인, 탭, 페이지 응답이 멈췄을 때의 복구를 포함해 웹 페이지를 단계별로 조작하도록 가르칩니다.