Skip to content

Use Claude Code, Codex, VSCode, Pi, and OpenCode (and 6 other harnesses) for free (1.3B+ free tokens) from your terminal, app, IDE, or phone, and now from the browser with native browser sessions (multi-harness + multi-model) like OpenClaw (voice supported + ToS friendly)

Python

Prevent unintended Claude auto mode requests (#1522)

Ali Khokhar5b5209428ff8
diff --git a/pyproject.toml b/pyproject.toml
index bfdf9a79..183299bc 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "free-claude-code"
-version = "5.13.7"
+version = "5.13.8"
description = "Local proxy connecting coding agents to OpenAI-compatible AI providers"
readme = "README.md"
requires-python = ">=3.14.0"
diff --git a/src/free_claude_code/cli/launchers/claude.py b/src/free_claude_code/cli/launchers/claude.py
index 288a7fef..75cff6f5 100644
--- a/src/free_claude_code/cli/launchers/claude.py
+++ b/src/free_claude_code/cli/launchers/claude.py
@@ -15,6 +15,9 @@ from .common import preflight_proxy, resolve_client_binary, run_client_process
_DISPLAY_NAME = "Claude Code"
_INSTALL_HINT = "Install Claude Code with: npm install -g @anthropic-ai/claude-code"
+_DEFAULT_PERMISSION_MODE_ARGS = ("--permission-mode", "default")
+_PERMISSION_MODE_FLAG = "--permission-mode"
+_BYPASS_PERMISSIONS_FLAG = "--dangerously-skip-permissions"
def launch(argv: Sequence[str] | None = None) -> None:
@@ -59,6 +62,25 @@ def claude_binary_name() -> str:
def build_claude_launcher_command(
*, binary_path: str, argv: Sequence[str]
) -> list[str]:
- """Return the Claude wrapper command without changing user arguments."""
+ """Start Claude outside auto mode unless the user selected a mode."""
- return [binary_path, *argv]
+ args = list(argv)
+ if not _has_explicit_permission_mode(args):
+ args[:0] = _DEFAULT_PERMISSION_MODE_ARGS
+
+ return [binary_path, *args]
+
+
+def _has_explicit_permission_mode(argv: Sequence[str]) -> bool:
+ """Return whether CLI arguments explicitly choose a permission mode."""
+
+ for arg in argv:
+ if arg == "--":
+ break
+ if arg in (
+ _PERMISSION_MODE_FLAG,
+ _BYPASS_PERMISSIONS_FLAG,
+ ) or arg.startswith(f"{_PERMISSION_MODE_FLAG}="):
+ return True
+
+ return False
diff --git a/tests/cli/test_claude_launcher.py b/tests/cli/test_claude_launcher.py
new file mode 100644
index 00000000..b3acb3a5
--- /dev/null
+++ b/tests/cli/test_claude_launcher.py
@@ -0,0 +1,55 @@
+import pytest
+
+from free_claude_code.cli.launchers.claude import build_claude_launcher_command
+
+
+def test_claude_launcher_defaults_to_non_auto_permission_mode() -> None:
+ assert build_claude_launcher_command(
+ binary_path="claude", argv=["fix the tests"]
+ ) == ["claude", "--permission-mode", "default", "fix the tests"]
+
+
+ "argv",
+ [
+ ["--permission-mode", "auto", "fix the tests"],
+ ["--permission-mode=acceptEdits", "fix the tests"],
+ ["--dangerously-skip-permissions", "fix the tests"],
+ ],
+)
+def test_claude_launcher_preserves_explicit_permission_choice(
+ argv: list[str],
+) -> None:
+ assert build_claude_launcher_command(binary_path="claude", argv=argv) == [
+ "claude",
+ *argv,
+ ]
+
+
[email protected]("argv", [["--permission-mode"], ["--permission-mode="]])
+def test_claude_launcher_leaves_malformed_permission_options_to_claude(
+ argv: list[str],
+) -> None:
+ assert build_claude_launcher_command(binary_path="claude", argv=argv) == [
+ "claude",
+ *argv,
+ ]
+
+
+ "argv",
+ [
+ ["explain --permission-mode auto"],
+ ["--", "--permission-mode=auto"],
+ ["--", "--dangerously-skip-permissions"],
+ ],
+)
+def test_claude_launcher_does_not_treat_prompt_text_as_a_permission_choice(
+ argv: list[str],
+) -> None:
+ assert build_claude_launcher_command(binary_path="claude", argv=argv) == [
+ "claude",
+ "--permission-mode",
+ "default",
+ *argv,
+ ]
diff --git a/tests/cli/test_entrypoints.py b/tests/cli/test_entrypoints.py
index 5baa3baf..db1dcc6f 100644
--- a/tests/cli/test_entrypoints.py
+++ b/tests/cli/test_entrypoints.py
@@ -364,7 +364,13 @@ def test_launch_claude_passes_args_and_child_env(
assert exc_info.value.code == 7
popen.assert_called_once()
- assert popen.call_args.args[0] == ["resolved-claude.cmd", "--model", "sonnet"]
+ assert popen.call_args.args[0] == [
+ "resolved-claude.cmd",
+ "--permission-mode",
+ "default",
+ "--model",
+ "sonnet",
+ ]
child_env = popen.call_args.kwargs["env"]
assert child_env["ANTHROPIC_BASE_URL"] == "http://127.0.0.1:9191"
assert child_env["ANTHROPIC_AUTH_TOKEN"] == "proxy-token"
diff --git a/uv.lock b/uv.lock
index b5330453..77e58ac1 100644
--- a/uv.lock
+++ b/uv.lock
@@ -607,7 +607,7 @@ wheels = [
[[package]]
name = "free-claude-code"
-version = "5.13.7"
+version = "5.13.8"
source = { editable = "." }
dependencies = [
{ name = "aiohttp" },