feat: add allowBypassPermissionsMode setting#658
Conversation
Allow bypass permissions mode to appear in the mode list via settings.json without requiring the --allow-dangerously-skip-permissions CLI flag. The disableBypassPermissionsMode setting retains priority.
There was a problem hiding this comment.
Pull request overview
Adds a new permissions.allowBypassPermissionsMode setting to make “Bypass Permissions” mode selectable from the mode carousel / plan-mode exit UI without requiring the CLI allow-flag, while still respecting existing disables (settings + Statsig gate).
Changes:
- Extend
PermissionsSchemawith optional booleanallowBypassPermissionsMode. - Include
permissions.allowBypassPermissionsModein the managed-settings nested key expansion used for logging. - Update bypass-mode availability logic to allow the new setting as an alternative to the CLI allow-flag.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/utils/settings/types.ts | Adds the new permissions.allowBypassPermissionsMode boolean to the Zod settings schema. |
| src/utils/settings/settings.ts | Adds allowBypassPermissionsMode to the permissions nested-key allowlist for managed-settings logging. |
| src/utils/permissions/permissionSetup.ts | Broadens isBypassPermissionsModeAvailable to include the new settings-based enablement path. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Security: read allowBypassPermissionsMode only from trusted settings sources (user/local/flag/policy), excluding projectSettings to prevent a malicious repo from enabling bypass mode - UX: update error messages to reference the correct CLI flag (--allow-dangerously-skip-permissions) and the new settings option - Tests: add schema validation tests for the new field
Vasanthdev2004
left a comment
There was a problem hiding this comment.
Review: allowBypassPermissionsMode setting
Reviewed on head e89385e. CI green ✅. 6 files, +58/-3.
This is a clean, well-scoped feature — the settings.json equivalent of the existing --allow-dangerously-skip-permissions CLI flag. The security properties are correct and the code follows established patterns.
✅ Security: projectSettings excluded
hasAllowBypassPermissionsMode() only checks userSettings, localSettings, flagSettings, and policySettings — same trusted-source pattern as hasSkipDangerousModePermissionPrompt() and hasAutoModeOptIn(). A malicious project can't enable bypass mode via .claude/settings.json. This is the critical security property and it's correct.
✅ Precedence: disable still wins
settingsDisableBypassPermissionsMode and growthBookDisableBypassPermissionsMode remain as && ! gates after the (A || B || C) availability check. An admin/policy disableBypassPermissionsMode: "disable" still blocks even when allowBypassPermissionsMode: true is set. Correct.
✅ Operator precedence
The explicit parentheses around (permissionMode === 'bypassPermissions' || allowDangerouslySkipPermissions || settingsAllowBypassPermissionsMode) are correct — the three availability conditions are OR'd together, then AND'd with the disable gates. No precedence bug.
✅ Zod schema + validNestedKeys
allowBypassPermissionsMode: z.boolean().optional() — correct type. Added to validNestedKeys right after disableBypassPermissionsMode — consistent placement. Test covers true/false/non-boolean.
✅ Error messages updated
Both print.ts and useReplBridge.tsx error messages now reference --allow-dangerously-skip-permissions (the actual CLI flag that makes bypass available) and the new setting. Verified that --allow-dangerously-skip-permissions exists in main.tsx as a real CLI option — it enables bypass as an option without making it the default. The error message accurately points users to both enablement paths.
🟢 Minor observation (non-blocking)
The test file only validates Zod schema parsing. A more complete test would also verify hasAllowBypassPermissionsMode() returns the right value with mock settings sources — matching the coverage pattern of the auto-mode opt-in tests. But for a 3-line settings read function following an established pattern, schema validation is a reasonable starting point.
Verdict: Approve-ready ✅
Clean feature, correct security properties, follows established patterns. The allow setting is a natural complement to the existing disable setting — both respect the trusted-source boundary.
* feat: add allowBypassPermissionsMode setting Allow bypass permissions mode to appear in the mode list via settings.json without requiring the --allow-dangerously-skip-permissions CLI flag. The disableBypassPermissionsMode setting retains priority. * fix: address Copilot review feedback on allowBypassPermissionsMode - Security: read allowBypassPermissionsMode only from trusted settings sources (user/local/flag/policy), excluding projectSettings to prevent a malicious repo from enabling bypass mode - UX: update error messages to reference the correct CLI flag (--allow-dangerously-skip-permissions) and the new settings option - Tests: add schema validation tests for the new field
Summary
permissions.allowBypassPermissionsModeboolean setting insettings.jsontrue, bypass permissions mode appears in the mode carousel (Shift+Tab) and plan mode exit options — without requiring the--allow-dangerously-skip-permissionsCLI flagdisableBypassPermissionsModesetting (admin/policy) retains priority and can still block bypass modeUsage
{ "permissions": { "allowBypassPermissionsMode": true } }Files changed
src/utils/settings/types.ts— Zod schema: new optional boolean fieldsrc/utils/settings/settings.ts—validNestedKeyswhitelist: register the new field for settings expansionsrc/utils/permissions/permissionSetup.ts—isBypassPermissionsModeAvailablecondition: OR with the new settingTest plan
npm run build)"permissions": { "allowBypassPermissionsMode": true }to~/.claude/settings.jsonclaudewithout any CLI flag → Shift+Tab cycles through modes including "Bypass Permissions""disableBypassPermissionsMode": "disable"alongside it → bypass mode is hidden (disable wins)