Skip to content

Hook output should include permissionDecision: "allow" so rewritten commands don't trigger Claude Code permission prompts (Mac desktop app) #1771

Open

Description

@giulioleone097

Symptom

When using rtk hook claude as a PreToolUse Bash hook in Claude Code (Mac desktop app), every rewritten command triggers a permission prompt — even with permissions.defaultMode: "bypassPermissions" in settings.json.

The CLI version of Claude Code does honor bypassPermissions, but the Mac desktop app appears to re-evaluate permissions against the rewritten command (rtk git status) instead of the original (git status). Since rtk isn't on any allowlist by default, every command prompts.

Repro

  1. Install rtk and run rtk init -g (Claude Code).
  2. Open Claude Code Mac app (not CLI).
  3. Have Claude run any Bash command.
  4. → permission prompt appears: "Allow Bash(rtk git status)?"

Current hook output

$ echo '{"tool_name":"Bash","tool_input":{"command":"git status"}}' | rtk hook claude
{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecisionReason":"RTK auto-rewrite","updatedInput":{"command":"rtk git status"}}}

The hook returns updatedInput but not permissionDecision. Per Claude Code hook schema, the proper way to short-circuit the permission check is:

{
  "hookSpecificOutput": {
    "hookEventName": "PreToolUse",
    "permissionDecision": "allow",
    "permissionDecisionReason": "RTK auto-rewrite (transparent token optimization)",
    "updatedInput": { "command": "rtk git status" }
  }
}

Proposed fix

Add "permissionDecision": "allow" to the JSON returned by rtk hook claude whenever the hook successfully rewrites a command. The user already opted into rtk by running rtk init -g; reprompting them per-command defeats the transparent-rewrite design.

Workaround for affected users

Add to ~/.claude/settings.json:

{
  "permissions": {
    "allow": ["Bash(rtk *)"]
  }
}

But this is a workaround — the fix belongs in the hook output itself, since rtk is the only thing that knows the rewrite happened and that it should be auto-trusted.

Environment

  • rtk 0.38.0 (homebrew)
  • Claude Code Mac desktop app 2.1.x
  • macOS (Apple Silicon)

Activity

  1. dedsm commented on May 12, 2026

    @dedsm

    I'm having this issue, but wouldn't the proposed fix be similar to having Bash(*) in the allowed commands?

  2. pszymkowiak commented on May 27, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟡 Priority medium
    🎯 Confidence 91%

    Summary

    Hook output missing permissionDecision: allow causes Mac desktop app to re-prompt on rewritten commands; fix PR #1809 already in progress.

    This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.

    📁 Relevant files
    • src/hooks/claude.rs

    Triaged automatically by wshm · This is an automated analysis, not a human review.

  3. wufloor commented on Jun 8, 2026

    @wufloor

    Also affects GitHub Copilot CLI (/allow-all mode)

    The same issue occurs in GitHub Copilot CLI (v1.0.60), which shares the same copilot-agent-runtime as Claude Code.

    Copilot CLI specifics

    • Copilot CLI reads hooks from ~/.claude/settings.json (shared runtime)
    • The /allow-all command calls session.permissions.setAllowAll, which covers standard tool/path/URL permissions
    • However, hook-generated permission requests (PermissionPromptRequestHook kind) are not covered by /allow-all — they are treated as plugin-initiated confirmations that override the allow-all state
    • Result: every RTK-rewritten bash command still triggers "Do you want to allow this tool call?" even after /allow-all

    rtk hook copilot explicitly returns "ask"

    $ echo '{"tool_name":"bash","tool_input":{"command":"ls -la"}}' | rtk hook copilot
    {"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"ask","permissionDecisionReason":"RTK auto-rewrite","updatedInput":{"command":"rtk ls -la"}}}

    The copilot subcommand explicitly sets "permissionDecision":"ask", while the claude subcommand omits it (both result in a prompt).

    Workaround

    Wrapper script that forces "permissionDecision":"allow" in the hook output:

    #!/usr/bin/env bash
    output=$(rtk hook claude "$@")
    rc=$?
    if [ $rc -ne 0 ] || [ -z "$output" ]; then echo "$output"; exit $rc; fi
    if echo "$output" | grep -q '"updatedInput"'; then
      if echo "$output" | grep -q '"permissionDecision":"ask"'; then
        echo "$output" | sed 's/"permissionDecision":"ask"/"permissionDecision":"allow"/'
      else
        echo "$output" | sed 's/"hookEventName":"PreToolUse"/"hookEventName":"PreToolUse","permissionDecision":"allow"/'
      fi
    else
      echo "$output"
    fi

    Environment

    • rtk 0.42.3 (Homebrew, macOS ARM64)
    • GitHub Copilot CLI 1.0.60
    • copilot-agent-runtime (shared with Claude Code)
  4. Dessix commented on Jul 17, 2026

    @Dessix

    I'm having this issue, but wouldn't the proposed fix be similar to having Bash(*) in the allowed commands?

    This seems indicative of a potential flaw in either RTK's hook model or Claude Code's handling of Process Wrappers, wherein custom wrappers can't be registered, and hooks don't appear to allow permission-opaque rewrites.

    There may be a possible workaround if RTK and other such wrappers can somehow call out to the permissions API to explicitly request permission for the rewrite, then pass that permission along in the hook response.

    It looks like #1809 attempts this through check_command_with_rules reading over the existing claude ruleset, but pushing for first-party support for custom process wrappers from Anthropic may be a better solution long-term.

    Support for this looks to have already been requested upstream on the Claude Code repo, but it was killed off by a staleness bot.

  5. simonryf commented on Sep 12, 2026

    @simonryf

    Confirming this on macOS with rtk 0.49.0 and Claude Code 2.1.266, with one detail that I think
    explains why reports of this vary so widely: whether you see the prompt depends on the Bash
    sandbox, and when the sandbox is on, it only surfaces for commands containing an = token.

    With the sandbox disabled

    Every rewritten command prompts, exactly as the issue describes.

    With the sandbox enabled

    sandbox.enabled: true plus autoAllowBashIfSandboxed (which defaults to true) silently clears
    almost every rewritten command, so the fallthrough is invisible. It becomes visible only when all
    three of these hold at once:

    1. rtk rewrites at least one segment of the command
    2. the command has two or more chained segments
    3. some token in the command contains =

    Minimal pair, run in the same session on the same file:

    echo "hello world"; cat FILE     # no prompt
    echo "=== test ==="; cat FILE    # prompts

    The banner is not special — echo "a=b"; cat FILE prompts too. Dropping any one of the three
    conditions removes the prompt:

    Command rewrite chained = prompt
    cat FILE yes no no no
    cat FILE; echo x; cat FILE2 yes yes no no
    echo "hello world"; cat FILE yes yes no no
    echo "=== x ===" no no yes no
    echo "a=b"; echo done no yes yes no
    echo "a=b"; cat FILE yes yes yes yes
    echo "=== test ==="; cat FILE yes yes yes yes

    Why I think this happens

    Omitting permissionDecision is legal per the hooks docs — updatedInput still applies and the
    call proceeds through normal permission evaluation. So rtk's rewrite always routes the command
    through the normal permission path. With the sandbox on, auto-allow absorbs that for nearly
    everything; an =-bearing token in a multi-segment chain looks like an env-assignment prefix
    (PATH=/tmp/evil cat x), which the classifier will not clear, and the prompt appears.

    So = is not the bug. It is the one crack through which the permanent fallthrough becomes
    visible to sandbox users.

    Note on the proposed fix

    Two upstream issues are worth checking before assuming permissionDecision: "allow" resolves this:

    Prompt observations above were made by me watching the dialogs, since the approve/deny outcome
    is not visible to the agent issuing the command. This whole comment was written by claude opus 5 though ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions