feat: add CLAUDE_PERMISSION_MODE for Claude Code auto mode#78
Open
LikunYDev wants to merge 1 commit intosix-ddc:mainfrom
Open
feat: add CLAUDE_PERMISSION_MODE for Claude Code auto mode#78LikunYDev wants to merge 1 commit intosix-ddc:mainfrom
LikunYDev wants to merge 1 commit intosix-ddc:mainfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new optional
CLAUDE_PERMISSION_MODEenv var that appends--permission-mode <mode>to theclaudelaunch 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-permissionsworkaround 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/bypassPermissionsskips 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— newclaude_permission_modefield. Acceptsdefault,acceptEdits,plan,auto,bypassPermissions, or unset. Invalid values raiseValueErrorat startup so typos don't silently fall through.src/ccbot/tmux_manager.py— extracted a small pure helperbuild_claude_command(base, permission_mode, resume_session_id)so the command-string assembly is now testable without tmux.--permission-modeis placed before--resumeso the mode applies to resumed sessions.Configcases (valid modes, trim, case-sensitivity, empty, invalid rejection) + 11build_claude_commandcases (all modes, resume combinations, no-op).README.md,README_CN.md,README_RU.md,.env.exampleupdated. The headless-VPS tip block now recommendsCLAUDE_PERMISSION_MODE=autofirst, withbypassPermissionscalled out as a last resort.Backward compatibility
Fully backward-compatible. Leaving
CLAUDE_PERMISSION_MODEunset produces the exact same launch command as today (claudeorclaude --resume <id>). Users who already embed a flag insideCLAUDE_COMMANDare unaffected.Test plan
uv run ruff check src/ tests/— passesuv run pyright src/ccbot/config.py src/ccbot/tmux_manager.py— 0 errorsuv run python -m pytest tests/ccbot/test_config.py tests/ccbot/test_tmux_command.py— 37 passedCLAUDE_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