From ea7e86714f7dca5674532875d2fb0d33028caf5c Mon Sep 17 00:00:00 2001 From: 8519mark <113274097+8519mark@users.noreply.github.com> Date: Sat, 30 Aug 2025 10:09:01 +0900 Subject: [PATCH] add `end of command options` to sanitize user prompt (#130) The PR should address the issue where user prompt maybe treated as a option with leading `-` Assuming `claude` does follow POSIX standard, the `--` option should solve the issue. fixes #129 --- src/claude_code_sdk/_internal/transport/subprocess_cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/claude_code_sdk/_internal/transport/subprocess_cli.py b/src/claude_code_sdk/_internal/transport/subprocess_cli.py index 47bcad7..4d6edce 100644 --- a/src/claude_code_sdk/_internal/transport/subprocess_cli.py +++ b/src/claude_code_sdk/_internal/transport/subprocess_cli.py @@ -157,7 +157,7 @@ class SubprocessCLITransport(Transport): cmd.extend(["--input-format", "stream-json"]) else: # String mode: use --print with the prompt - cmd.extend(["--print", str(self._prompt)]) + cmd.extend(["--print", "--", str(self._prompt)]) return cmd