Problem
When Claude Code's OAuth session expires and claude -p is invoked, it hangs indefinitely retrying authentication instead of failing fast. This blocks macroclaw completely — the user gets no response and no error.
Proposed solution
Run claude auth status as a parallel guard alongside each claude -p invocation:
- Start both in parallel: spawn
claude -p <prompt> and claude auth status concurrently
- If auth status fails (non-zero exit), kill the
claude -p process and report to the user immediately (e.g. "Claude auth expired — run /login to re-authenticate")
- If auth status succeeds, let
claude -p continue normally (discard the auth check result)
This avoids the overhead of a blocking pre-check on every request while still catching expired auth quickly. The auth check is fast (~1-2s) so it will resolve well before a hanging claude -p would time out.
Alternatives considered
- Pre-check before every request: adds latency to every invocation even when auth is fine
- Timeout then check: slower to detect the issue — user waits for the timeout before getting feedback
ANTHROPIC_API_KEY env var: bypasses OAuth entirely but requires managing API keys separately
Additional context
claude -p hanging on expired auth has no built-in CLI fix (no --no-retry flag exists)
- The subprocess stdin hanging bug was fixed in v2.1.79, but auth retry hanging is a separate issue
Problem
When Claude Code's OAuth session expires and
claude -pis invoked, it hangs indefinitely retrying authentication instead of failing fast. This blocks macroclaw completely — the user gets no response and no error.Proposed solution
Run
claude auth statusas a parallel guard alongside eachclaude -pinvocation:claude -p <prompt>andclaude auth statusconcurrentlyclaude -pprocess and report to the user immediately (e.g. "Claude auth expired — run/loginto re-authenticate")claude -pcontinue normally (discard the auth check result)This avoids the overhead of a blocking pre-check on every request while still catching expired auth quickly. The auth check is fast (~1-2s) so it will resolve well before a hanging
claude -pwould time out.Alternatives considered
ANTHROPIC_API_KEYenv var: bypasses OAuth entirely but requires managing API keys separatelyAdditional context
claude -phanging on expired auth has no built-in CLI fix (no--no-retryflag exists)