{"name":"CLAUDE_CODE_FORK_SUBAGENT","slug":"claude-code-fork-subagent","family":"env","title":"Environment variables","noun":"environment variable","description":"Controls [fork mode](\/docs\/en\/sub-agents#turn-fork-mode-on-or-off), which lets Claude spawn [forked subagents](\/docs\/en\/sub-agents#fork-the-current-conversation) itself and is on by default in interactive sessions only. Set to `1` to turn it on in `claude -p` and the Agent SDK as well, or `0` to turn it off in every kind of session. You can run `\/subtask` whether or not fork mode is on. The interactive default requires Claude Code v2.1.232 or later; on earlier versions, set the variable to `1` to turn fork mode on","description_source":"docs","described_by":{"doc":"claude-code\/env-vars","title":"Environment variables"},"presence":{"first_seen":"2.1.138","removed_in":null,"in_current_build":true,"newest_mined":"2.1.309","builds":150,"mined_builds":150,"first_cited":{"version":"2.1.232","released_at":"2026-08-13 21:30:53","spans":2}},"aliases":[],"entries":[{"version":"2.1.302","anchor":"fork-subagent-enablement-gains-a-settings-kill-switch-and-a","heading":"New forkSubagentDisabled setting turns off fork mode","line":"Fork mode can now be turned off with the `forkSubagentDisabled` setting, and a server-controlled switch can also turn it off","released_at":"2026-10-16 16:48:28","reason":"found in this entry's text"},{"version":"2.1.302","anchor":"attribution-header-gains-project-tag-fork-subagent-gating-r","heading":"Attribution block can name a project, and one fork subagent check no longer reads its variable","line":"The attribution block can now carry a project tag, and one fork subagent check now depends on remote sessions instead of `CLAUDE_CODE_FORK_SUBAGENT`","released_at":"2026-10-16 16:48:28","reason":"found in this entry's text"},{"version":"2.1.302","anchor":"agent-tool-schema-text-subagents-forced-into-background-by","heading":"Background subagent wording now names the terminal, desktop app and VS Code","line":"Claude Code's text now says the run-in-background option is withheld when subagents are forced into the background, including with `CLAUDE_CODE_FORK_SUBAGENT=1`","released_at":"2026-10-16 16:48:28","reason":"found in this entry's text"},{"version":"2.1.302","anchor":"fork-subagent-text-added-to-the-agent-tool-prompt-fork-is-o","heading":"Claude is told when to fork the conversation into a subagent","line":"The Agent tool's instructions include a 'When to fork' section on forked subagents, which you can turn off with an environment variable or setting","released_at":"2026-10-16 16:48:28","reason":"found in this entry's text"},{"version":"2.1.232","anchor":"three-more-variables-can-be-set-from-settings-json","heading":"Three more variables can be set from settings.json","line":"You can now set OTEL_SERVICE_NAME, OTEL_TRACES_EXPORT_INTERVAL and CLAUDE_CODE_FORK_SUBAGENT in settings.json.","released_at":"2026-08-13 21:30:53","reason":"named in this entry, found in this entry's text"},{"version":"2.1.232","anchor":"fork-subagent-setting-is-resolved-once-per-session-with-the-","heading":"Fork-subagent setting is resolved once per session, with the environment checked first","line":"Setting CLAUDE_CODE_FORK_SUBAGENT decides fork subagents up front, and the answer is cached per session.","released_at":"2026-08-13 21:30:53","reason":"named in this entry, found in this entry's text"},{"version":"2.1.232","anchor":"forked-subagents-are-on-by-default","heading":"Forked subagents are on by default","line":"Forked subagents are on by default in interactive sessions; set `CLAUDE_CODE_FORK_SUBAGENT` to false to opt out.","released_at":"2026-08-13 21:30:53","reason":"named in this entry, found in this entry's text"},{"version":"2.1.117","anchor":"fork-command","heading":"\/fork Command","line":null,"released_at":"2026-04-21 21:54:08","reason":"found in this entry's text"},{"version":"2.1.117","anchor":"fork-subagent-feature-gate-gradual-rollout","heading":"Fork Subagent Feature Gate [Gradual Rollout]","line":null,"released_at":"2026-04-21 21:54:08","reason":"found in this entry's text"}],"entries_total":9,"docs":[{"source":"claude-code","path":"env-vars","title":"Environment variables","documented":true},{"source":"claude-code","path":"agent-sdk\/python","title":"Agent SDK reference - Python","documented":false},{"source":"claude-code","path":"changelog","title":"Claude Code changelog","documented":false},{"source":"claude-code","path":"sub-agents","title":"Create custom subagents","documented":false},{"source":"claude-code","path":"whats-new\/2026-w17","title":"Week 17 \u00b7 April 20\u201324, 2026","documented":false},{"source":"claude-code","path":"whats-new\/2026-w33","title":"Week 33 \u00b7 August 10\u201314, 2026","documented":false}],"docs_total":6,"gates":[],"related":[{"name":"CLAUDE_CODE_FORK_SUBAGENT_DEFAULT_ON","slug":"claude-code-fork-subagent-default-on","description":null}],"url":"https:\/\/changelogs.core-directive.com\/reference\/env\/claude-code-fork-subagent","family_url":"https:\/\/changelogs.core-directive.com\/reference\/env.json"}