Expand description
Opt-in dangerous operations. Currently: bypass permissions.
Running the claude CLI with --permission-mode bypassPermissions
turns off all confirmation prompts for tool use. It’s legitimate
for some automation – but it’s also the fastest way to turn a bug
into a destructive action.
This module isolates that capability behind a type you have to
explicitly reach for (DangerousClient), and a runtime env-var
gate (ALLOW_ENV) you have to explicitly set.
§Example
use claude_wrapper::{Claude, QueryCommand};
use claude_wrapper::dangerous::DangerousClient;
// At process start:
// export CLAUDE_WRAPPER_ALLOW_DANGEROUS=1
let claude = Claude::builder().build()?;
let dangerous = DangerousClient::new(claude)?;
let output = dangerous
.query_bypass(QueryCommand::new("clean up the build artifacts"))
.await?;
println!("{}", output.stdout);§Why this shape
- Separate type.
DangerousClient::newis the only public path to building a bypassed query. If a reader of calling code seesDangerousClient, the danger is obvious at the call site. - Runtime env-var gate. The check happens at construction, so a caller who forgot to set the env-var gets a typed error rather than silently running with bypass off (which might surprise them) or silently running with bypass on (which might destroy things).
- Not a cargo feature. Feature-gating adds a second layer of
friction (recompile) without making the runtime behaviour any
safer. The env-var matches how Go’s
claude-code-go/dangerousgates the same operation.
§Migrating from crate::PermissionMode::BypassPermissions
The enum variant is kept (marked #[deprecated]) so existing
callers continue to compile with a warning. New code should go
through DangerousClient.
Structs§
- Dangerous
Client - Wrapper that lets callers run bypass-permissions queries against an
underlying
Claudeclient. Construction is gated by theALLOW_ENVenv-var.
Constants§
- ALLOW_
ENV - The env-var that must equal
"1"at process start forDangerousClient::newto succeed. Set deliberately – this is the explicit acknowledgement that bypass mode is OK in this process.