claude-sudo

A sudo mode for Claude Code. While it is armed:
- Claude stops asking you to approve every tool call.
sudo inside a tool call just works — no hanging password prompt, no password
in the transcript, no NOPASSWD line in /etc/sudoers.
- Your password lives in the OS keyring. Claude never sees it;
sudo gets it
directly from an askpass helper.
- A policy still blocks the unrecoverable things, and every privileged command
is written to an audit log.
Off by default. Armed per session, expires on its own, and never outlives the
session that armed it.
Shift+Tab → ⏵⏵ bypass permissions sudo
> install ripgrep system-wide
● sudo pacman -S --noconfirm ripgrep (no prompt, no password question)
curl -fsSL https://raw.githubusercontent.com/broisnischal/claude-sudo/main/install.sh | bash
Turning it on
Pick whichever fits how you work — the installer asks once, and you can change
your mind at any time.
| |
|---|
claude-sudo autoarm on | Every new session starts in sudo mode. No keystroke, no command. |
Shift+Tab → ⏵⏵ bypass permissions | Arms that session; cycling out of the mode disarms it. |
/sudo on | Arms the current session explicitly, until it expires or ends. |
csudo | Starts Claude Code already armed. |
Auto-arm is off until you choose it, because it means every new session skips
permission prompts from its first message. When it is on, the session also tells
Claude that sudo authenticates from the keyring — so it stops asking you for a
password or offering to edit /etc/sudoers.
Sudo mode as a Shift+Tab mode
Claude Code's permission modes are a compiled-in set —
default, plan, acceptEdits, auto, bypassPermissions, dontAsk — so a
seventh entry called "sudo" cannot be added to the cycle. Instead claude-sudo
becomes one of them.
Every hook payload carries permission_mode, so cycling into bypass
permissions arms sudo mode, and cycling out of it disarms again. Shift+Tab is
the switch, and the status line says sudo while it is live.
That entry is also the honest place for it: it is already the "don't ask me"
mode. Riding on it makes it safer than bare bypass, because the policy below
still applies — Claude Code consults hooks before the permission system in every
mode, and a hook deny is returned unchanged.
One wrinkle worth knowing: a hook ask is not honoured in a mode that never
prompts — it degrades to allow. So in bypass permissions the ask tier is
escalated to a refusal that tells you to Shift+Tab back to a mode that prompts.
Set ask-in-bypass to allow if you would rather have the old behaviour.
claude-sudo modes show # which modes arm sudo mode
claude-sudo modes set dontAsk # use a different entry
claude-sudo modes off # no coupling; arm only with /sudo on
Why plain sudo hangs inside Claude Code
A Bash tool call runs as a child of claude. It has no terminal of its own, but
it does inherit the controlling terminal, so sudo decides it can prompt —
and writes [sudo] password for you: to a terminal Claude cannot read and you
cannot see. The command sits there until it times out.
claude-sudo fixes that the way sudo intends: sudo -A, with SUDO_ASKPASS
pointing at a helper that answers from the keyring.
Install
curl -fsSL https://raw.githubusercontent.com/broisnischal/claude-sudo/main/install.sh | bash
Needs bash 4+, jq, sudo, and one secret store: libsecret
(secret-tool, i.e. gnome-keyring or KWallet), the macOS keychain, pass,
or gnupg as a fallback.
The one-liner clones into ~/.local/share/claude-sudo and keeps it a git
checkout, so claude-sudo update pulls later versions. To work from your own
clone instead:
git clone https://github.com/broisnischal/claude-sudo ~/src/claude-sudo
cd ~/src/claude-sudo && ./install.sh --in-place
It links claude-sudo and csudo into ~/.local/bin, wires three hooks into
~/.claude/settings.json (backing it up first, keeping the last five backups),
installs the /sudo command and the sudo status line badge, asks for your sudo
password once — in your own terminal, never inside a Claude session — and
asks whether to arm every session automatically.
The status line is a wrapper: whatever renderer you already had is recorded and
runs inside it, so your existing status line keeps working untouched.
claude-sudo statusline uninstall puts the original back.
Want to store the password later? ./install.sh --no-password, then
claude-sudo passwd. Any install prefix works — nothing depends on the
directory being named claude-sudo.
As a Claude Code plugin instead: