Routes Claude Code through APRO's LiteLLM gateway with automatic API key management via 1Password.
Two independent paths to configure Claude Code's environment — both set the same env vars:
install.js → writes ~/.config/claude/env.sh (thin bootstrap)
writes ~/.config/claude/local.env (user settings)
Claude Code auto-sources env.sh on startup
claude (wrapper) → process wrapper, symlinked to ~/.local/bin/claude
shadows the real binary, sources config, then exec's it
claude-env.sh # Remote config (fetched + cached by both paths)
env.sh # Thin bootstrap template (written by install.js)
claude # Process wrapper (bash, for developer setup)
claudestart.ps1 # Windows PowerShell equivalent of claude wrapper
install.js # One-line curl installer (Node.js, zero deps)
Config override chain: claude-env.sh defaults → local.env overrides → env var overrides.
| Command | Description |
|---|---|
node install.js |
Run installer (prompts for LiteLLM URL + 1Password item) |
CLAUDE_DEBUG=1 claude |
Launch with debug output showing resolved config |
rm ~/.cache/claude/env-remote.sh |
Force re-fetch remote config on next launch |
source ~/.config/claude/env.sh --clear-cache |
Clear all cached keys + remote config |
No build step, no tests, no package.json — all scripts run directly.
claude-env.sh— Central config: project detection, 1Password key lookup, model defaults. This is the file to edit for org-wide config changes.install.js— Curl-pipeable installer. Writes env.sh bootstrap + local.env. Uses/dev/ttyfor prompts (see Gotchas).claude— Bash process wrapper. Finds real binary viawhich -a, skips itself, sources config, thenexecs.local.env— User'sLITELLM_BASE_URLandOP_ITEMoverrides. Written by installer, never auto-modified.0600perms.
Required tools: curl, op (1Password CLI with CLI integration enabled), git
Key env vars:
| Variable | Default | Purpose |
|---|---|---|
CLAUDE_ENV_URL |
(this repo's raw URL) | Override remote config source |
CLAUDE_ENV_UPDATE_TTL |
300 |
Cache TTL in seconds for remote config |
CLAUDE_MODEL |
claude-opus-4-6 |
Override default model |
CLAUDE_PROJECT |
(auto from git remote) | Override project name for key lookup |
CLAUDE_DEBUG |
0 |
Show resolved config on launch |
CLAUDE_FORCE |
0 |
Installer: overwrite existing env.sh without prompting |
Runtime files (not in repo):
| File | Purpose |
|---|---|
~/.config/claude/env.sh |
Thin bootstrap (written by installer) |
~/.config/claude/local.env |
User overrides (written by installer) |
~/.cache/claude/env-remote.sh |
Cached remote config (auto-refreshed) |
~/.cache/claude/<project>.key |
Cached API keys (12h TTL) |
~/.config/claude/middleware.sh |
Optional pre-launch hook (process wrapper only) |
- Bash:
set -euo pipefail, functions prefixed with_claude_or_for cleanup viaunset - Security:
umask 077before writing sensitive files,0600perms on keys/configs - Cache pattern: atomic write to
.tmp.$$thenmvto final path - Node: vanilla Node.js with zero dependencies (must work via
curl | node)
/dev/ttyprompting —install.jsopens/dev/ttydirectly for interactive prompts because stdin is the piped script when run viacurl | node. Falls back to defaults silently if TTY unavailable.statcross-platform — Cache age usesstat -f %m(macOS) with fallback tostat -c %Y(Linux). Both appear inclaude-env.sh,claude, andenv.sh.- Wrapper self-skip —
claudewrapper useswhich -a claudeand comparesreadlink -fto skip itself when finding the real binary. Breaks if the real claude isn't on PATH. env.shis sourced, not executed — Bothenv.shandclaude-env.shrun in the caller's shell context. Variables must be exported explicitly.returnworks (notexit).- Middleware is process-wrapper only —
~/.config/claude/middleware.shis sourced by theclaudewrapper but NOT by the env.sh bootstrap path. Users of the bootstrap path don't get middleware. - Key cache files —
.keyfiles in~/.cache/claude/are gitignored in this repo but the pattern also matches the runtime cache. The 12h TTL is inclaude-env.sh, not configurable via env var. - 1Password
opaccount — Hardcoded toaproorg.1password.euinclaude-env.shandclaudestart.ps1. Not overridable via local.env.
- Bash (4.0+, POSIX-compatible subset) and PowerShell (5.1+/7+) +
op(1Password CLI),curl,stat,git(002-token-ttl-cache) - Flat files —
~/.cache/claude/<project>.key(Unix),%LOCALAPPDATA%\claude\<project>.key(Windows) (002-token-ttl-cache) - Bash 4.0+ (POSIX-compatible subset), PowerShell 5.1+/7+ +
git(already required),op(1Password CLI, already required) (003-auto-custom-headers) - N/A — environment variables only, no persistent state (003-auto-custom-headers)
- 002-token-ttl-cache: Added Bash (4.0+, POSIX-compatible subset) and PowerShell (5.1+/7+) +
op(1Password CLI),curl,stat,git