Claude Code and Codex
Alfred is the scheduler and guardrail layer; Claude Code is the default engine. Codex can be enabled as an optional per-agent engine, including review-safe Codex-only or Claude-first hybrid routing.
Full guide at docs/CLAUDE_CODE.md. Highlights:
Default billing posture: Alfred uses the local CLI account you have already authenticated. It does not need Anthropic or OpenAI API keys for the normal Claude Code / Codex CLI flow.
Install
Section titled “Install”npm install -g @anthropic-ai/claude-codeinstall.sh handles this. Confirm with claude --version.
Authenticate
Section titled “Authenticate”claudeFirst-run opens a browser against your Anthropic account. Subsequent claude -p calls use the cached auth.
Keep ANTHROPIC_API_KEY unset if you want Claude Code to use Pro/Max subscription auth. Claude Code gives environment-variable API keys priority over subscription auth.
Pro vs Max
Section titled “Pro vs Max”| Tier | Use case |
|---|---|
| Pro | Validate the framework, occasional agent runs |
| Max 5x / 20x | Continuous fleet, multiple codenames at frequent cadences |
A typical Lucius firing on a small backend issue burns 30-80 turns. Lucius alone running every 20 minutes against an active issue queue averages 2000-3500 turns/day. Add Bane, Drake, Ra’s, Nightwing and you exceed Pro quota in a day.
Recommendation: Pro to validate, Max once you’ve got 2+ daily codenames. The two-account swap pattern below also lets you split spend.
Engine routing
Section titled “Engine routing”Claude account routing and engine routing are different:
alfred claude primary|secondary|swapchooses which local Claude Code auth directory future Claude firings use.alfred engine set <codename> <claude|codex|hybrid>chooses whether that codename uses Claude, Codex, or Claude-first fallback.
alfred engine statusalfred engine status luciusalfred engine set rasalghul codexalfred engine set lucius hybridalfred codex statusalfred codex probealfred auth status| Mode | Behavior |
|---|---|
claude | Claude Code only. |
codex | Codex only. |
hybrid | Claude first, Codex fallback on Claude auth, budget, or rate-limit errors. |
Two-account swap (alfred claude)
Section titled “Two-account swap (alfred claude)”Two Anthropic accounts? On macOS, alfred claude flips the launchd
CLAUDE_CONFIG_DIR env var so macOS launchd-spawned claude uses either the
primary ~/.claude/ directory or a secondary config such as
~/.claude-secondary/. Primary is set explicitly so older ~/.claude.json
files cannot accidentally win Claude Code’s default profile lookup.
alfred claude status # which account is activealfred claude primary # set CLAUDE_CONFIG_DIR=~/.claudealfred claude secondary # set CLAUDE_CONFIG_DIR=~/.claude-secondaryalfred claude swap # toggleSet up the secondary account once:
mkdir -p ~/.claude-secondaryCLAUDE_CONFIG_DIR=$HOME/.claude-secondary claudeTypical use: run on primary, hit a usage cap or auth issue (Slack alert from set_global_block), alfred claude swap, fleet resumes on secondary’s quota.
On Linux, set CLAUDE_CONFIG_DIR in ~/.alfredrc and redeploy or restart the
systemd user timers. There is no launchctl setenv equivalent.
CLAUDE_BIN
Section titled “CLAUDE_BIN”If claude isn’t on the PATH that the host scheduler inherits, set the absolute path in ~/.alfredrc:
CLAUDE_BIN=/Users/you/.local/share/fnm/aliases/default/bin/claudeOptional Codex
Section titled “Optional Codex”Set CODEX_BIN if codex is not on the host scheduler PATH. codex_invoke() defaults to a read-only sandbox and writes artifacts under $ALFRED_HOME/state/codex/.
CODEX_BIN=$HOME/.local/bin/codexCODEX_MODEL=gpt-5.4CODEX_SANDBOX=read-onlyCODEX_APPROVAL_POLICY=neverdeploy.sh links an interactive-shell codex binary into ~/.local/bin/codex when one exists. Rendered scheduler units include ~/.local/bin in PATH.
Cost mental model
Section titled “Cost mental model”Under the default subscription-backed path, Alfred does not add token-metered charges by itself. It consumes the same Claude Code usage pool your terminal sessions consume.
If ANTHROPIC_API_KEY is present, Claude Code can use API billing instead of subscription auth. Anthropic usage credits can also let paid-plan users continue after included limits at standard API pricing if they choose that path. Spend caps in SpendState are runaway-loop safety rails, not provider bill-tracking.
Troubleshooting
Section titled “Troubleshooting”Full list at docs/CLAUDE_CODE.md#troubleshooting. Most common:
claude: command not foundfrom a scheduled agent: setCLAUDE_BIN.codex: command not foundfrom a scheduled agent: rerundeploy.shafter installing Codex, or setCODEX_BIN.error_rate_limitimmediately on every firing: usage cap hit, swap accounts, wait, upgrade, or intentionally use provider-approved usage credits.error_max_turnson every firing of one agent: tighten scope or widen the budget in that agent’s runner.