Skip to content

feat: add CLAUDE_PERMISSION_MODE for Claude Code auto mode#78

Open
LikunYDev wants to merge 1 commit intosix-ddc:mainfrom
LikunYDev:feat/auto-mode-upstream-pr
Open

feat: add CLAUDE_PERMISSION_MODE for Claude Code auto mode#78
LikunYDev wants to merge 1 commit intosix-ddc:mainfrom
LikunYDev:feat/auto-mode-upstream-pr

Conversation

@LikunYDev
Copy link
Copy Markdown
Contributor

Summary

Adds a new optional CLAUDE_PERMISSION_MODE env var that appends --permission-mode <mode> to the claude launch command in each new tmux window. This gives users a first-class way to opt into Claude Code's auto mode — which is strictly safer than the --dangerously-skip-permissions workaround the README currently suggests for headless/VPS setups.

Why auto mode > bypass

Claude Code's recently-added auto mode runs actions without prompting, but a background safety classifier evaluates every action and blocks the risky ones (arbitrary code download/exec, exfiltration to external endpoints, force-pushes to main, IAM/permission changes, etc.). --dangerously-skip-permissions / bypassPermissions skips every check including the classifier.

For a Telegram-driven bot where the operator can't approve interactive prompts in-terminal, auto mode is the natural fit — autonomous execution with guardrails — and it's what the README example previously had to compromise on.

Docs: https://code.claude.com/docs/en/permission-modes.md#eliminate-prompts-with-auto-mode

Changes

  • src/ccbot/config.py — new claude_permission_mode field. Accepts default, acceptEdits, plan, auto, bypassPermissions, or unset. Invalid values raise ValueError at startup so typos don't silently fall through.
  • src/ccbot/tmux_manager.py — extracted a small pure helper build_claude_command(base, permission_mode, resume_session_id) so the command-string assembly is now testable without tmux. --permission-mode is placed before --resume so the mode applies to resumed sessions.
  • Tests — 8 new Config cases (valid modes, trim, case-sensitivity, empty, invalid rejection) + 11 build_claude_command cases (all modes, resume combinations, no-op).
  • DocsREADME.md, README_CN.md, README_RU.md, .env.example updated. The headless-VPS tip block now recommends CLAUDE_PERMISSION_MODE=auto first, with bypassPermissions called out as a last resort.

Backward compatibility

Fully backward-compatible. Leaving CLAUDE_PERMISSION_MODE unset produces the exact same launch command as today (claude or claude --resume <id>). Users who already embed a flag inside CLAUDE_COMMAND are unaffected.

Test plan

  • uv run ruff check src/ tests/ — passes
  • uv run pyright src/ccbot/config.py src/ccbot/tmux_manager.py — 0 errors
  • uv run python -m pytest tests/ccbot/test_config.py tests/ccbot/test_tmux_command.py — 37 passed
  • Ran end-to-end on macOS (launchd): set CLAUDE_PERMISSION_MODE=auto, restarted the bot, created a new topic, confirmed the spawned tmux window's claude is running in auto mode.

🤖 Generated with Claude Code

Adds a validated env var that appends `--permission-mode <mode>` when
launching claude in a new window. This is a first-class way to opt into
Claude Code's auto mode (safer than `--dangerously-skip-permissions`:
auto keeps a background safety classifier that blocks risky actions,
while bypass disables all checks).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant