These launchers make sure Claude Code never sees ANTHROPIC_API_KEY, so sessions bill to your Claude Chat account instead of an Anthropic API key. They cover both the CLI and the opcode desktop app.
Platform support: scripts target macOS; they also work on Linux if opcode/claude are on PATH or you set OPCODE_BIN/CLAUDE_CODE_BIN. Windows is not supported.
From a clone of this repo:
bash scripts/install.shInstall location defaults to ~/.local/bin; override with TARGET_DIR=/your/bin bash scripts/install.sh.
Ensure your PATH includes the target directory (e.g. add export PATH="$HOME/.local/bin:$PATH" to your shell rc).
Scripts are Bash and embed their own shebangs, so you can invoke the installer from zsh/fish with bash scripts/install.sh. On Linux, just ensure opcode/claude are on PATH or set OPCODE_BIN/CLAUDE_CODE_BIN.
Clean uninstall: removes the only two installed files (no other traces):
bash scripts/install.sh --uninstallYou can also curl | bash the installer directly from the raw URL if you prefer:
curl -fsSL https://raw.githubusercontent.com/instantlyeasy/claude-code-billing-guard/main/scripts/install.sh | bashTo pin to a tag (recommended once releases exist):
curl -fsSL https://raw.githubusercontent.com/instantlyeasy/claude-code-billing-guard/v1.0.0/scripts/install.sh | bashTo change the install location when piping:
TARGET_DIR="$HOME/.local/bin" curl -fsSL https://raw.githubusercontent.com/instantlyeasy/claude-code-billing-guard/main/scripts/install.sh | bashRun Claude Code through the wrapper so the API key is scrubbed before the process starts:
claude-code-chat [normal-claude-code-args]If you prefer an alias, append this to ~/.zshrc:
echo "alias claude-code='claude-code-chat'" >> ~/.zshrcStart the GUI with the same scrubbed environment. Always launch via the wrapper (or an alias to it); double-clicking the app or calling the bundle binary directly skips the guard and may pass ANTHROPIC_API_KEY.
The launcher tries common macOS paths; if you installed elsewhere, set OPCODE_BIN to the executable inside your app bundle (e.g. /Applications/opcode.app/Contents/MacOS/opcode).
OPCODE_BIN=/Applications/opcode.app/Contents/MacOS/opcode opcode-chat
# or rely on the defaults if you installed to /Applications
opcode-chatFor convenience, append this alias to ~/.zshrc:
echo "alias opcode='OPCODE_BIN=/Applications/opcode.app/Contents/MacOS/opcode opcode-chat'" >> ~/.zshrcIf you want opcode on your PATH to always point at the guard, symlink it:
ln -sf "$HOME/.local/bin/opcode-chat" "$HOME/.local/bin/opcode"If you keep ANTHROPIC_API_KEY around for other tools, add a .envrc in your Claude projects so any shell and editor spawned there drops the key automatically:
unset ANTHROPIC_API_KEY
unset ANTHROPIC_API_KEY_FILE
unset ANTHROPIC_API_KEY_PATHThen run direnv allow in that directory.
- In the shell you use to launch Claude Code or opcode, run
env | grep ANTHROPIC_API_KEY; it should print nothing. - Start a Claude Code session and confirm usage lands in your Claude Chat account (not the Anthropic API key account).
Billing selection happens as soon as Claude Code detects ANTHROPIC_API_KEY in its environment. Plugins or config inside the session cannot reliably override that early detection, so removing the key from the process environment is the most robust solution.