Claude Code's usage-limit auto-continue doesn't run in Remote Control sessions. Hooks resume them.
说明与用途
Claude Code 在远程控制会话中,使用限制自动继续功能失效。通过添加钩子实现会话在5小时重置后自动恢复,并在周使用率达到85%时阻止工作。
问题
Claude Code’s built‑in auto‑continue (autoContinueAtUsageLimit) fails to start in Remote Control sessions, causing sessions to stall at the usage‑limit reset instead of resuming automatically.
结果
The hooks reliably resume sessions after the 5‑hour reset in Remote Control mode and enforce an 85% weekly usage cap, eliminating manual intervention.
工作流
- 1. Enable autoContinueAtUsageLimit in user settings.
- 2. Create hooks directory ~/.claude/hooks/usage-guard/ and add usage_guard.py script.
- 3. Configure hooks in ~/.claude/settings.json for Stop, StopFailure, UserPromptSubmit, and PreToolUse.
- 4. Ensure asyncRewake:true and appropriate timeouts.
- 5. Run sessions; hooks will wait for reset, resume session, or block at 85% usage.
- 6. Monitor usage via added lines in prompts.
证据
Claude Code’s built‑in auto‑continue (autoContinueAtUsageLimit) fails to start in Remote Control sessions
The docs list the cases where the built‑in wait doesn't start: Remote Control and agent team teammate sessions
The fix is a pair of hooks, Stop and StopFailure, with asyncRewake. They wait for the 5‑hour reset and wake the session with exit 2, unless the built‑in already resumed it.
Checked with two real probe sessions and 35 unit tests. Not tested live: a real 5‑hour reset, the 85% paths and a real rate_limit StopFailure payload.
- 记录日期: 2026-10-04T09:40:59.299Z