Skip to content

Fix #85: alert via ntfy when Claude CLI authentication fails#88

Open
ClaydeCode wants to merge 1 commit into
mainfrom
clayde/issue-85
Open

Fix #85: alert via ntfy when Claude CLI authentication fails#88
ClaydeCode wants to merge 1 commit into
mainfrom
clayde/issue-85

Conversation

@ClaydeCode
Copy link
Copy Markdown
Owner

Summary

When Claude CLI credentials expire or are replaced, the availability pre-check returned False for both auth failures and usage limits, so Clayde silently skipped all work every cycle with no notification. This PR distinguishes the two failure modes and alerts the operator on auth failure.

What changed

  • claude.py — added a ClaudeStatus enum (AVAILABLE / USAGE_LIMIT / AUTH_FAILED). The backend pre-check method is_available() is renamed to check_availability() and now returns a ClaudeStatus. A new module-level check_claude_availability() exposes this; is_claude_available() is kept as a thin bool wrapper for callers that don't need the distinction.
  • orchestrator.pymain() now branches on the status:
    • AUTH_FAILED → send a high-priority (Priority: 5, 🚨) ntfy alert titled "Clayde: Claude CLI auth failed" via the existing ntfy infra, then skip the cycle.
    • USAGE_LIMIT → existing behaviour (silent skip, retried next tick).
    • AVAILABLE → clear the alert latch so a future failure re-alerts.
  • state.py — the alert fires once per failure streak, tracked by a top-level claude_auth_failure_notified flag in state.json (get_claude_auth_notified() / set_claude_auth_notified()). It re-arms when Claude becomes reachable again.
  • Updated README.md and CLAUDE.md; added unit tests for all three statuses, the notify-once/re-arm logic, and the new state helpers.

All 353 tests pass.

Closes #85

Recommended reading order

  1. src/clayde/claude.py — the ClaudeStatus enum and the renamed check_availability() backends (the core distinction).
  2. src/clayde/state.py — the once-per-streak latch helpers.
  3. src/clayde/orchestrator.py_notify_claude_auth_failure() and the new main() branching that ties it together.
  4. tests/test_claude.py, tests/test_orchestrator.py, tests/test_state.py — coverage for each piece.
  5. README.md, CLAUDE.md — docs.

🤖 Generated with Claude Code

Distinguish Claude authentication failures from usage/rate limits in the
availability pre-check so an expired/replaced credentials situation no
longer silently skips work every cycle.

- claude.py: add ClaudeStatus enum; rename backend is_available() ->
  check_availability() returning AVAILABLE / USAGE_LIMIT / AUTH_FAILED;
  add module-level check_claude_availability() (is_claude_available()
  kept as a bool wrapper).
- orchestrator.py: on AUTH_FAILED send a one-shot high-priority ntfy
  alert and skip; on USAGE_LIMIT keep existing silent skip. The latch is
  cleared once Claude is reachable again so a future failure re-alerts.
- state.py: persist the notified latch in a top-level
  claude_auth_failure_notified flag (get/set helpers) so the alert fires
  once per failure streak rather than every cycle.
- Update README + CLAUDE.md; add tests.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Notify via ntfy when Claude CLI authentication fails

1 participant