Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions src/claude_agent_sdk/_internal/transport/subprocess_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,29 @@ def __init__(

def _find_cli(self) -> str:
"""Find Claude Code CLI binary."""
if cli := shutil.which("claude"):
# On Windows, npm creates both 'claude' (bash script) and 'claude.cmd' (batch file)
# We need to use 'claude.cmd' for proper execution on Windows
search_name = "claude.cmd" if sys.platform == "win32" else "claude"

if cli := shutil.which(search_name):
return cli

locations = [
Path.home() / ".npm-global/bin/claude",
Path("/usr/local/bin/claude"),
Path.home() / ".local/bin/claude",
Path.home() / "node_modules/.bin/claude",
Path.home() / ".yarn/bin/claude",
]
# Fallback locations to check manually
if sys.platform == "win32":
locations = [
Path.home() / "AppData/Roaming/npm/claude.cmd",
Path.home() / ".npm-global/bin/claude.cmd",
Path.home() / "node_modules/.bin/claude.cmd",
Path.home() / ".yarn/bin/claude.cmd",
]
else:
locations = [
Path.home() / ".npm-global/bin/claude",
Path("/usr/local/bin/claude"),
Path.home() / ".local/bin/claude",
Path.home() / "node_modules/.bin/claude",
Path.home() / ".yarn/bin/claude",
]

for path in locations:
if path.exists() and path.is_file():
Expand Down
Loading