Summary
Provide a supported way to not use the bundled CLI — both at install time (a packaging extra that skips shipping _bundled/) and at runtime (an env var / option that forces resolution to an external claude). Today the bundled binary is mandatory: it's baked into the wheel and it takes priority over a system claude, so users who already have a CLI on PATH pay for a copy they never run.
Motivation
1. Size. On SDK 0.2.123 the _bundled/ directory is ~253 MB — the single largest thing most installs pull in. For anyone who already manages claude separately (npm global, mise/asdf, distro package, container base image), that 253 MB is pure dead weight: downloaded on every pip install / uv tool upgrade, never executed. This is a regression in spirit from #349, which was closed by switching to a native binary — the "ink bloat" went away but the on-disk footprint went up.
2. Correctness / control. Several open issues stem specifically from the bundled binary, and an opt-out would give affected users a clean workaround:
Users who pin a known-good external CLI can't reliably do so today, because…
3. Surprising precedence. In _internal/transport/subprocess_cli.py, _find_cli() checks _find_bundled_cli() before shutil.which("claude"). So a system claude on PATH is silently shadowed by the bundled copy unless the caller passes ClaudeAgentOptions(cli_path=...) explicitly. "I installed my own claude on PATH" does not do what most users expect.
Proposed solution
Any one of these would solve it; ideally the first two together:
- Packaging extra to skip the bundle. Publish the CLI as an optional component so
pip install claude-agent-sdk (or an explicit claude-agent-sdk[no-cli] / a claude-agent-sdk[bundled] opt-in) can install without _bundled/. When absent, resolution simply falls through to PATH.
- Runtime opt-out env var, e.g.
CLAUDE_AGENT_SDK_NO_BUNDLE=1 (mirroring the existing CLAUDE_AGENT_SDK_SKIP_VERSION_CHECK), that makes _find_cli() skip _find_bundled_cli() and go straight to PATH / known locations.
- Optional precedence flip / documentation: let callers prefer a
PATH claude over the bundled one (an env or option), and document the current order explicitly.
Workaround today
ClaudeAgentOptions(cli_path=...) bypasses the bundled binary at runtime, and deleting _bundled/ reclaims the 253 MB — but the delete is undone by the next pip install / uv tool upgrade, so there's no durable slim install.
Environment
claude-agent-sdk 0.2.123 (Python), Linux x86_64
_bundled/ measured at ~253 MB
Summary
Provide a supported way to not use the bundled CLI — both at install time (a packaging extra that skips shipping
_bundled/) and at runtime (an env var / option that forces resolution to an externalclaude). Today the bundled binary is mandatory: it's baked into the wheel and it takes priority over a systemclaude, so users who already have a CLI onPATHpay for a copy they never run.Motivation
1. Size. On SDK
0.2.123the_bundled/directory is ~253 MB — the single largest thing most installs pull in. For anyone who already managesclaudeseparately (npm global, mise/asdf, distro package, container base image), that 253 MB is pure dead weight: downloaded on everypip install/uv tool upgrade, never executed. This is a regression in spirit from #349, which was closed by switching to a native binary — the "ink bloat" went away but the on-disk footprint went up.2. Correctness / control. Several open issues stem specifically from the bundled binary, and an opt-out would give affected users a clean workaround:
claudebinary hangs when stdout is not a TTY (pipe / file / launchd / cron / Docker) #926 — bundledclaudehangs when stdout isn't a TTY (pipe / cron / launchd / Docker)_bundled/claudeprotocol-incompatible in container env (silentinitializetimeout)trace_id/ thinking blocksUsers who pin a known-good external CLI can't reliably do so today, because…
3. Surprising precedence. In
_internal/transport/subprocess_cli.py,_find_cli()checks_find_bundled_cli()beforeshutil.which("claude"). So a systemclaudeonPATHis silently shadowed by the bundled copy unless the caller passesClaudeAgentOptions(cli_path=...)explicitly. "I installed my own claude on PATH" does not do what most users expect.Proposed solution
Any one of these would solve it; ideally the first two together:
pip install claude-agent-sdk(or an explicitclaude-agent-sdk[no-cli]/ aclaude-agent-sdk[bundled]opt-in) can install without_bundled/. When absent, resolution simply falls through toPATH.CLAUDE_AGENT_SDK_NO_BUNDLE=1(mirroring the existingCLAUDE_AGENT_SDK_SKIP_VERSION_CHECK), that makes_find_cli()skip_find_bundled_cli()and go straight toPATH/ known locations.PATHclaudeover the bundled one (an env or option), and document the current order explicitly.Workaround today
ClaudeAgentOptions(cli_path=...)bypasses the bundled binary at runtime, and deleting_bundled/reclaims the 253 MB — but the delete is undone by the nextpip install/uv tool upgrade, so there's no durable slim install.Environment
claude-agent-sdk0.2.123 (Python), Linux x86_64_bundled/measured at ~253 MB