claude-codex-fallback

Runs Claude CLI first and retries with Codex only on usage-limit errors.

366|90|Updated Aug 22, 2026
One-click install
npx skills add https://github.com/bam-bam-2/solo-skills --skill claude-codex-fallback-bam-bam-2
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: claude-codex-fallback
Source: https://github.com/bam-bam-2/solo-skills/tree/main/skills/claude-codex-fallback
Command: npx skills add https://github.com/bam-bam-2/solo-skills --skill claude-codex-fallback-bam-bam-2

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve? CLI-based automation breaks silently when a Claude account hits its weekly or usage limit, and naive retry logic wastes time re-running on transient network or auth errors. This Skill implements a disciplined fallback that switches to Codex only when a genuine usage-limit message is detected. ## Core Features & Use Cases - Conditional fallback: Runs Claude Code first, then re-executes the same prompt with Codex CLI only when output matches real usage-limit phrases like "weekly limit" or "usage limit". - Secure prompt handling: Stores prompts in a mode-600 mktemp file deleted on exit, and reads the OAuth token from ~/.config/llm/claude-oauth-token without logging or transmitting it. - Failure transparency: If Codex also fails, both errors are recorded together instead of emitting a fake successful result. - Use Case: A cron-driven content pipeline calls llm-with-fallback.sh nightly; when the Claude weekly limit resets mid-week, jobs automatically complete via Codex without manual intervention. ## Quick Start Pipe your prompt into scripts/llm-with-fallback.sh with optional max-turns and model arguments to run Claude first with automatic Codex fallback on usage limits.

Frequently Asked Questions about claude-codex-fallback

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fall back from Claude Code to Codex CLI automatically?

Run the prompt through a wrapper script that executes Claude first, scans stdout and stderr for usage-limit phrases, and re-runs the identical prompt with codex exec only on a match. The provided llm-with-fallback.sh implements exactly this pattern.

How to detect Claude usage limit errors in CLI output?

Grep stdout and stderr for phrases like "weekly limit", "usage limit", "hit your limit", or "limit ... resets". Plain network errors, auth failures, and generic rate limits should not trigger a model switch.

Does the fallback script require both Claude and Codex installed?

Yes, both the claude and codex CLIs must be installed locally since the script invokes each binary directly. Claude OAuth is read from ~/.config/llm/claude-oauth-token, while Codex uses its own existing ChatGPT auth store.

Is the OAuth token safe when using a fallback wrapper script?

The script only reads the token file and exports it as an environment variable for the Claude CLI; it never prints, logs, or transmits the value. Prompts are kept in mode-600 temporary files deleted on exit.

What happens if both Claude and Codex fail?

The original Claude error and the fallback error are recorded together, and the script exits non-zero. It does not emit partial output as if it were a successful result, so downstream automation can detect the failure.