Skip to content

Fix Claude Code Bash "Allow for session" approving every command - #4629

Merged
SawyerHood merged 2 commits into
get-bb:mainfrom
stefanroex:claude-code-bash-session-approval
Oct 2, 2026
Merged

SawyerHood merged 2 commits into
get-bb:mainfrom
stefanroex:claude-code-bash-session-approval

Conversation

@stefanroex

@stefanroex stefanroex commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Human comments

I'm improving how the Claude Code provider follows Claude Code's own permission settings and patterns. Related PRs: #4628, #4630. Each PR stands on its own and can be merged in any order. One more PR is pending: honouring permissions.ask from settings.json in full access mode, which depends on these initial PRs.

What was wrong

In Accept Edits, run npm --version and choose "Allow for session". After that, every Bash command ran without asking, such as python3 -c 'print(42)'. bb ignored the rule Claude Code suggests (Bash(npm --version)) and allowed the whole Bash tool instead. This shows most with the Claude Code sandbox off or unavailable; with it on, few commands ask in the first place.

What changed

"Allow for session" now sends back Claude Code's suggested rule, plus any folders the command needed. It covers that command only, like Claude Code's own "don't ask again". bb no longer remembers Bash approvals itself and no longer labels Bash prompts as "Network access". The first commit is a refactoring without behavior change.

How you verified

  • pnpm exec turbo run typecheck test --filter=bb-plugin-provider-claude-code passes all 352 tests.
  • New tests: only the suggested rule is sent back, and a different command still prompts. The second check fails without the fix.
  • Manually QA'd the steps above with the sandbox off: npm --version ran again without a prompt, and python3 -c 'print(42)' prompted.

AGENT GENERATED

@stefanroex stefanroex changed the title Limit Claude Code Bash "Allow for session" to the approved command Fix Claude Code Bash "Allow for session" approving every command Oct 1, 2026
When you choose "allow for session", bb sends Claude Code rules to
remember for that session. The rule list was derived inside one
helper from a tool name and "network access": the whole tool, or
nothing. Callers now pass the rules in, so a later change can send
the narrower rules Claude Code suggests.

Also names the Bash tool once (CLAUDE_BASH_TOOL_NAME) and adds a
helper that reads the rules Claude Code suggests from an approval
request. No behavior change.
Choosing "Allow for session" on a Bash prompt approved every Bash
command for the rest of the session. After allowing `npm --version`,
Claude could run any other command without asking, including ones
that write outside the project. This matters most with the Claude
Code sandbox turned off, where most commands ask.

Claude Code suggests a rule with each Bash prompt, such as
`Bash(npm --version)`. bb ignored it and sent back a rule for the
whole Bash tool. It now sends back the suggested rule for the session,
so "Allow for session" means what it does in Claude Code itself: this
command, this session. bb also stops remembering Bash approvals in
its own grant list, which only knows folders, and no longer labels
Bash prompts as needing network access.
@stefanroex
stefanroex force-pushed the claude-code-bash-session-approval branch from 59b9901 to 1011bdb Compare October 1, 2026 18:03
@SawyerHood
SawyerHood merged commit 4502eab into get-bb:main Oct 2, 2026
18 checks passed
SawyerHood added a commit that referenced this pull request Oct 2, 2026
…rompt (#4630)

## Human comments

I'm improving how the Claude Code provider follows Claude Code's own
permission settings and patterns. Related PRs: #4628, #4629. Each PR
stands on its own and can be merged in any order. One more PR is
pending: honouring `permissions.ask` from `settings.json` in full access
mode, which depends on these initial PRs.

## What was wrong

Add `"ask": ["Bash(*askprobe*)"]` to a project's `.claude/settings.json`
and ask Claude to run `echo askprobe`: it runs without a prompt.

Claude Code does ask bb about it, but the request carries no details: no
folder, reason or suggested rule. bb treated requests without details as
harmless and approved them itself.

## What changed

bb now shows every approval request from Claude Code to the user. Other
requests always carry details (checked with the Claude Agent SDK across
modes, sandbox on and off), so nothing else starts prompting. Threads
set to never ask now deny these commands. Full access will follow in a
separate PR.

The first commit makes sure this holds: an earlier "Allow for session"
for a folder also approved any later request without details, because
nothing requested counted as covered. Session approvals now only cover
requests that ask for a folder or network access.

## How you verified

- `pnpm exec turbo run typecheck test
--filter=bb-plugin-provider-claude-code` passes all 350 tests.
- New tests for both changes. Each fails without its fix.
- Manually QA'd the steps above: `echo askprobe` prompted, also after an
earlier "Allow for session", and Deny was reported back to Claude.

> AGENT GENERATED

---------

Co-authored-by: SawyerHood <[email protected]>
SawyerHood added a commit that referenced this pull request Oct 2, 2026
## Human comments

I'm improving how the Claude Code provider follows Claude Code's own
permission settings and patterns. Related PRs: #4629, #4630. Each PR
stands on its own and can be merged in any order. One more PR is
pending: honouring `permissions.ask` from `settings.json` in full access
mode, which depends on these initial PRs.

## What was wrong

In a Full Access thread that starts in plan mode, approving the plan
didn't bring Claude Code back to full access. The session wasn't
launched with `allowDangerouslySkipPermissions`, so the switch to
`bypassPermissions` failed and Claude Code stayed in `default` mode.

Nobody notices yet: in `default` mode Claude Code asks about each
command, but bb approves every full access request itself (which also
means `permissions.ask` is ignored). It matters for the upcoming PR that
follows #4630 and respects ask rules in full access too.

## What changed

Full access sessions are now always launched with
`allowDangerouslySkipPermissions`, also when they start in plan mode.
Root is unchanged, because Claude Code refuses the flag there.

## How you verified

- `pnpm exec turbo run typecheck test
--filter=bb-plugin-provider-claude-code` passes all 350 tests.
- New test: a full access session that starts in plan mode gets the
flag. It fails without the fix.
- Manually QA'd, together with the follow-up that lets Claude Code's
prompts through in full access: after approving a plan in a Full Access
thread, commands ran without approval prompts.

> AGENT GENERATED

Co-authored-by: SawyerHood <[email protected]>
ymichael pushed a commit that referenced this pull request Oct 15, 2026
…4764)

## Human comments

I'm improving how the Claude Code provider follows Claude Code's own
permission settings and patterns. This is the last PR in the series and
builds on #4628 and #4630, which are merged. Related: #4629.

## What was wrong

In a Full Access thread, add `"ask": ["Bash(*askprobe*)"]` to the
project's `.claude/settings.json` and ask Claude to run `echo askprobe`:
it runs without a prompt. Claude Code does ask in its own full access
mode (`bypassPermissions`), as
[documented](https://code.claude.com/docs/en/permission-modes#actions-no-mode-auto-approves),
but bb approved every full access request itself.

## What changed

bb now shows these requests in full access threads too. Nothing else
starts prompting: in `bypassPermissions` Claude Code only asks about ask
rules and PreToolUse hooks that answer "ask". As root, bb keeps
approving requests itself, because Claude Code refuses
`bypassPermissions` there and bb runs those sessions in `default` mode.

Worth noting: an unattended full access thread, such as an automation,
now waits at such a command until someone answers.

## How you verified

- `pnpm exec turbo run typecheck test
--filter=bb-plugin-provider-claude-code` passes all 368 tests.
- New tests: an ask-rule request in a full access thread reaches the
user, which fails without the fix; as root, requests are still approved
without a prompt.
- Manually QA'd in a local dev app: in a Full Access thread that started
in plan mode, after approving the plan, `echo askprobe` prompted and `ls
-la` ran without a prompt.

> AGENT GENERATED
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