Add hook event or config for auto-handling rate limit prompts
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
When hitting the plan usage/rate limit, Claude Code shows an interactive prompt asking the user to choose an action (wait, switch model, etc.). This requires manual intervention, which is problematic when:
- Running long tasks unattended
- Using Claude Code in workflows where you step away from the terminal
- You always want to choose "wait" and resume automatically
Currently, the Notification hook does NOT fire for rate limit prompts, so there's no way to even get notified about this event, let alone auto-handle it.
Proposed Solution
Either (or both):
- Add a new hook event
OnRateLimit— This would allow users to be notified and/or script automatic responses when rate limits are hit. Consistent with the existing hook system (PreToolUse,PostToolUse,Notification).
- Add a config option like
"rateLimitAction": "wait"— A simpler approach: let users specify a default action insettings.jsonso the prompt is skipped entirely.
Additionally, it would be helpful if the rate limit prompt also triggered the existing Notification hook, so users with notification scripts (e.g., push to phone) can be alerted.
Alternative Solutions
- Wrapping Claude Code with
expect/pexpectto auto-respond to the prompt (fragile, not recommended) - Manually monitoring the terminal (defeats the purpose of autonomous operation)
Priority
Medium - Important for my workflow
Feature Category
CLI commands and flags
Use Case Example
// settings.json - option 1: simple config
{
"rateLimitAction": "wait"
}
// settings.json - option 2: hook-based
{
"hooks": {
"OnRateLimit": [{
"matcher": "",
"hooks": [{
"type": "command",
"command": "echo 'wait'"
}]
}]
}
}
Additional Context
Related issues:
- #16607 — Allow agent to pick up where it was when interrupted
- #27471 — Continue after rate limit pause (closed as dup of #16607)
These issues focus on resuming after the wait. This issue focuses on automatically choosing to wait in the first place, and integrating the rate limit event into the hook system.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗