Skip to content

feat: add auto permission mode to claude-code module#830

Open
maschwenk wants to merge 5 commits intocoder:mainfrom
maschwenk:maschwenk/claude-code-auto-mode
Open

feat: add auto permission mode to claude-code module#830
maschwenk wants to merge 5 commits intocoder:mainfrom
maschwenk:maschwenk/claude-code-auto-mode

Conversation

@maschwenk
Copy link
Copy Markdown

Summary

Test plan

  • All 19 terraform tests pass (terraform test -verbose)
  • Added test_claude_code_auto_permission_mode tftest
  • Added claude-auto-permission-mode TypeScript test verifying both --permission-mode auto and --enable-auto-mode are passed
  • Container test with auto mode (requires Linux/Colima)
  • Verify bypass permissions TOS prompt no longer appears on task startup

🤖 Generated with Claude Code using Claude Opus 4.6

maschwenk and others added 2 commits April 2, 2026 15:09
Add `auto` as a valid `permission_mode` option for the claude-code module,
passing `--enable-auto-mode` to the CLI when selected.

Also fix the bypass permissions TOS prompt appearing interactively by
pre-seeding `bypassPermissionsModeAccepted` in `~/.claude.json` during
install. This affects all task-based setups since the start script always
passes `--dangerously-skip-permissions` when `report_tasks` is true.

Workaround for: anthropics/claude-code#25503

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The --enable-auto-mode flag is unnecessary; --permission-mode auto works
directly. Also pre-seed autoModeAccepted in ~/.claude.json to suppress
the interactive "Enable auto mode?" confirmation prompt, matching the
same pattern used for bypass permissions mode.

Refactored accept_bypass_permissions into a generic accept_permission_mode
function that handles both bypass and auto mode prompts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@maschwenk maschwenk marked this pull request as ready for review April 2, 2026 19:17
Comment on lines +241 to +244
# Pre-accept permission mode prompts so they don't appear interactively.
# Claude Code shows a confirmation dialog for bypass permissions and auto
# modes that blocks non-interactive/headless usage.
# Workaround for: https://github.com/anthropics/claude-code/issues/25503
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this actually an issue?

I notice we pass the permission_mode through the start.sh script and plan seems to work perfectly fine with no prompts appearing. I am fairly positive we handle this with the internal claude configuration we do here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I try to use Tasks

Image

I seem to get this when the Claude Code module boots in the Task ui. I can try to debug some more

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I try to use Tasks

Image I seem to get this when the Claude Code module boots in the Task ui. I can try to debug some more

Which versions of Coder, and Claude-Code are you using? bypassPermissionsModeAccepted should be set to true whenever task mode is recognized by the coder exp mcp configure claude-code command that is run which can be a bit confusing since its not in the module scope.

@blinkagent
Copy link
Copy Markdown
Contributor

blinkagent bot commented Apr 2, 2026

@maschwenk The bypassPermissionsModeAccepted pre-seeding in the new accept_permission_mode function is already handled in both existing paths:

So the bypass-specific part of this PR is redundant. The only net-new thing needed is autoModeAccepted = true for the new auto permission mode — and that should be added to the same places (configure_standalone_mode in install.sh, and configureClaude in cli/exp_mcp.go) rather than as a separate function that runs after report_tasks.

@DevelopmentCats
Copy link
Copy Markdown
Collaborator

DevelopmentCats commented Apr 2, 2026

@maschwenk The bypassPermissionsModeAccepted pre-seeding in the new accept_permission_mode function is already handled in both existing paths:

So the bypass-specific part of this PR is redundant. The only net-new thing needed is autoModeAccepted = true for the new auto permission mode — and that should be added to the same places (configure_standalone_mode in install.sh, and configureClaude in cli/exp_mcp.go) rather than as a separate function that runs after report_tasks.

@maschwenk This is what I was referring to earlier when I was mentioning that this was already accounted for, but I can help try to understand why this is not working for you if you can share your coder and claude-code module and cli versions for the template

I am definitely down for adding the "auto" mode to the module though 😸

@maschwenk
Copy link
Copy Markdown
Author

@DevelopmentCats ahhhh ok I think I see what's going on. I think one of our custom scripts must be clobbering some stuff. Ok yes I will revert all the non-auto-mode stuff. Thank you for your time!

@DevelopmentCats
Copy link
Copy Markdown
Collaborator

DevelopmentCats commented Apr 2, 2026

@DevelopmentCats ahhhh ok I think I see what's going on. I think one of our custom scripts must be clobbering some stuff. Ok yes I will revert all the non-auto-mode stuff. Thank you for your time!

No worries at all! I am glad I could at least convey that since the internal coder exp mcp configure logic even confuses me sometimes haha

…to mode

Remove the separate accept_permission_mode function and bypass permissions
pre-seeding (already handled by coder exp mcp configure and
configure_standalone_mode). Add autoModeAccepted to configure_standalone_mode
and as a post-install step for task mode. Remove --enable-auto-mode flag
(--permission-mode auto is sufficient).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@maschwenk
Copy link
Copy Markdown
Author

@DevelopmentCats restricted the changes to just the auto mode stuff. Now I guess the question is should I be instead doing this in cli/exp_mcp.go for coder exp mcp configure claude-code?

@DevelopmentCats
Copy link
Copy Markdown
Collaborator

@DevelopmentCats restricted the changes to just the auto mode stuff. Now I guess the question is should I be instead doing this in cli/exp_mcp.go for coder exp mcp configure claude-code?

If you we didn't already do this through exp_mcp.go you probably would indeed want to add it there.

It is sometimes confusing because this is only run for task configuration, so generally we have to account for things like that in both the module and the configure command since its only run when in task mode with the command which is intentional.

@DevelopmentCats
Copy link
Copy Markdown
Collaborator

Also @maschwenk I am pretty sure this would be a patch version bump now if You can go ahead and update the claude versions for a patch bump in the README, and then we should be good.

maschwenk and others added 2 commits April 3, 2026 14:54
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.

2 participants