⌨️CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH
Also known as CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH environment variable
It sets how deep helpers may start helpers.
Think of it like
It is like a helper who may ask a helper. But it stops a few steps down.
Example
Emma's helpers kept starting helpers, and costs grew fast. She sets the depth to 1, and only the main chat can hand out work.
Why it matters
Each layer can fan out again, so depth grows the work faster than you expect.
Definition
Example code
bash
export CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH=1
claudeCommon mistake
Key takeaways
- 1Default 3. Layers below main.
- 21 turns nesting off. Main chat only.
- 3Whole number. Cannot remove it.