claude-code - 💡(How to fix) Fix [FEATURE] AskUserBash tool — let agents prompt for secrets without exposing them to the model [2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#54722Fetched 2026-04-30 06:37:50
View on GitHub
Comments
2
Participants
3
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×4commented ×2

Error Message

  • Returning stdout to the model — tempting, but a single error message can leak the secret. Keep the return channel boolean-only; let the model retry with { ok: false }.

Code Example

AskUserBash({
  label: string,    // displayed above the input field
  preview: string,  // human-readable description of what the bash command will do
  bashCmd: string,  // template; user input is substituted for $ARG1
})
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing requests — see Related issues below.
  • This is a single feature request.

Related issues

  • #29910Built-in secrets management with optional third-party integrations (open). This proposal is meaningfully smaller in scope: a single tool primitive Claude can call, not a full vault subsystem. It is a viable first step that unblocks the same security goal ("secrets should never appear in chat context") without committing to the larger architecture, and could serve as the underlying input primitive for #29910.
  • #38797Secure/masked input for sensitive data entry (closed as duplicate of #29910). This proposal differs by being a tool Claude calls during its agentic flow (not a slash command the user invokes) and by piping the value directly into a local bash command rather than storing it.

Problem statement

Today, when a user wants Claude Code to do anything that needs a secret — a GitHub PAT for gh auth login, an OPENAI_API_KEY for .env.local, an MFA code, a private SSH key — the only path inside the agentic loop is to paste the secret into chat. The moment that happens:

  • The value enters the model's context window.
  • It's transmitted to the API.
  • It's persisted in ~/.claude/projects/*.jsonl transcripts.
  • It's potentially captured in screen recordings, terminal scrollback, and IDE clipboards.

The user's only alternative is to leave Claude Code, handle the secret in a separate terminal, and come back — defeating the point of an agentic CLI.

Proposed solution

A new built-in tool, alongside AskUserQuestion:

AskUserBash({
  label: string,    // displayed above the input field
  preview: string,  // human-readable description of what the bash command will do
  bashCmd: string,  // template; user input is substituted for $ARG1
})

When Claude calls this tool, Claude Code renders an inline secure-input form. The user types or pastes their value. On submit:

  1. The input is substituted for $ARG1 (and only $ARG1) in bashCmd.
  2. The resolved command is executed locally via the user's shell.
  3. Only an exit-code-equivalent boolean is returned to the model — never the input, never the resolved command, never stdout/stderr.

The model sees { ok: true } or { ok: false } and proceeds.

Demos

Two screenshots, both showing the same tool rendered with different (label, preview, bashCmd) payloads.

Demo 1 — GitHub PAT into gh auth login:

AskUserBash({ label: "GitHub Personal Access Token", preview: "Pipe token into gh CLI — never sent to the model", bashCmd: "echo $ARG1 | gh auth login --with-token" })

<!-- drag screenshot 1 here: ~/Desktop/askuserbash-feature-request.png --> <img width="2000" height="1125" alt="Image" src="https://github.com/user-attachments/assets/8ef25e56-12dc-4c69-a56b-9ef6397aaf0d" />

Demo 2 — OpenAI key into .env.local:

AskUserBash({ label: "OPENAI_API_KEY", preview: "Append to .env.local without touching the model context", bashCmd: "printf 'OPENAI_API_KEY=%s\n' \"$ARG1\" >> .env.local" })

<!-- drag screenshot 2 here: ~/Desktop/askuserbash-feature-request-2.png --> <img width="2000" height="1125" alt="Image" src="https://github.com/user-attachments/assets/ef3235ad-c963-45ea-b4b3-16ce2d5443f5" />

Security model

ChannelVisible to model?
label, preview, bashCmd templateYes — the model authored these
User input (the value typed into the form)No
Resolved command (after $ARG1 substitution)No
stdout / stderrNo
Exit-code-equivalent booleanYes

The user sees the bashCmd template before typing — they always know exactly what will run with their input. This preserves Claude Code's existing trust model (user inspects → user approves → Claude runs) while closing the secret-shaped hole.

Use cases this unblocks

  • echo $ARG1 | gh auth login --with-token
  • printf 'OPENAI_API_KEY=%s\n' "$ARG1" >> .env.local
  • echo "$ARG1" | wrangler secret put STRIPE_WEBHOOK_SECRET
  • op item edit "Anthropic API" credential="$ARG1"
  • aws-vault exec prod --mfa-token=$ARG1 -- aws s3 ls
  • printf '%s' "$ARG1" | ssh-add -
  • kubectl create secret generic api --from-literal=token=$ARG1
  • Anything else a user would otherwise paste into chat and immediately regret.

Why a tool primitive, not a full secrets manager

AskUserBash is composable with whatever secrets infrastructure the user already has — 1Password, Doppler, AWS Secrets Manager, plain .env, Cloudflare bindings, system keychain. It's the input edge: the missing primitive that lets Claude help with secret-handling workflows without ever seeing the secret.

  • Users with no secrets infra can use it to write to .env.local.
  • Users with sophisticated infra can pipe into op item edit, wrangler secret put, vault kv put, etc.

This makes AskUserBash implementable as a small, well-scoped feature on top of the existing tool / form infrastructure, while moving the security needle today. It does not preclude #29910's larger proposal — it could be the underlying primitive that powers it.

Alternative API shapes considered

  • AskUserSecureInput(label) → value — returns the raw value to the model. Defeats the purpose; the secret still enters context.
  • A /secret slash command — user-driven only; doesn't fit Claude's agentic flow where Claude recognizes that a secret is needed and asks for it. Tool form is the right shape.
  • bashCmd with arbitrary $ARG1..N — multi-input would be a small extension; single input keeps v1 surface minimal.
  • Returning stdout to the model — tempting, but a single error message can leak the secret. Keep the return channel boolean-only; let the model retry with { ok: false }.

Priority

High — this is the single highest-leverage tactical security feature for users today, and it's small enough to ship as an MVP.

Feature category

Tools / Interactive mode (TUI) / Security

extent analysis

TL;DR

Implementing the proposed AskUserBash tool with secure input handling and local bash command execution can effectively address the issue of secrets being exposed in chat context.

Guidance

  1. Review the proposed AskUserBash API: Ensure it meets the security requirements by not returning the input value or resolved command to the model, only an exit-code-equivalent boolean.
  2. Verify the security model: Confirm that the label, preview, and bashCmd template are visible to the model, but the user input, resolved command, and stdout/stderr are not.
  3. Test with various use cases: Validate the tool's functionality with different bash commands, such as gh auth login and writing to .env.local, to ensure it works as expected.
  4. Consider composability with existing secrets infrastructure: Ensure the tool can be used with various secrets management tools and systems, such as 1Password, Doppler, or AWS Secrets Manager.

Example

AskUserBash({
  label: "GitHub Personal Access Token",
  preview: "Pipe token into gh CLI — never sent to the model",
  bashCmd: "echo $ARG1 | gh auth login --with-token"
})

Notes

The proposed solution seems to address the security concern, but it's essential to thoroughly test and review the implementation to ensure it meets the security requirements.

Recommendation

Apply the proposed AskUserBash tool as a workaround to address the immediate security concern, as it provides a secure way to handle secrets without exposing them in the chat context.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [FEATURE] AskUserBash tool — let agents prompt for secrets without exposing them to the model [2 comments, 3 participants]