Open claude on a terminal with CLAUDE_CODE_SANDBOXED set, and stop writing ~/.claude.json

This commit is contained in:
2026-10-30 21:31:44 +01:00
parent 28b714d5ca
commit 0a0a2207c9
15 changed files with 22 additions and 135 deletions
+6 -8
View File
@@ -1,12 +1,9 @@
"""Opens claude on the terminal for the human. It sits outside cycle/, since loop-inbox's /talk and the loop's routing calls open claude too."""
import dataclasses
from loop_claude.effects import Effects, say
from loop_claude.effects import Effects
from failure import Failure
from loop_claude.paths import Paths
from model_routing.ladder import Rung
from claude_code.trust import trust
from loop_claude.project.checkout import worktrees
@dataclasses.dataclass(frozen=True)
@@ -21,11 +18,12 @@ def claude_args(rung: Rung, args: list[str]) -> list[str]:
return [*rung.flags(), "--permission-mode", "bypassPermissions", *args]
def hand_over(command: ClaudeCommand, paths: Paths, effects: Effects) -> Failure | None:
"""Marks trusted the checkout that command runs in, and each of its worktrees, then runs claude on the terminal as command says; the failure is why claude could not start."""
trust(paths.claude_json, worktrees(command.cwd, effects), lambda text: say(text, effects))
# CLAUDE_CODE_SANDBOXED, which Claude Code doesn't document, skips its trust dialog without writing ~/.claude.json:
# docs/decisions.md → `loop-claude: every claude it or loop-inbox opens on a terminal has CLAUDE_CODE_SANDBOXED set, …`.
def hand_over(command: ClaudeCommand, effects: Effects) -> Failure | None:
"""Runs claude on the terminal as command says; the failure is why claude could not start."""
try:
effects.claude_on_terminal(command.args, command.cwd, command.env)
effects.claude_on_terminal(command.args, command.cwd, {**command.env, "CLAUDE_CODE_SANDBOXED": "1"})
except OSError as failure:
return Failure(str(failure.strerror))
return None