Monitor context window remaining capacity with graduated warnings (CAUTION → WARNING → CRITICAL → EMERGENCY)
Install
npx agentshq add davepoon/claude-code-subagents-collection --agent context-monitorMonitor context window remaining capacity with graduated warnings (CAUTION → WARNING → CRITICAL → EMERGENCY)
Monitor how much context window remains during a Claude Code session. Issues graduated warnings so you never get killed by context exhaustion.
PostToolUse"" (every tool invocation)/tmp/cc-context-pct (other scripts can read this)| Level | Remaining | Action | |-------|-----------|--------| | CAUTION | ≤40% | Be mindful of consumption | | WARNING | ≤25% | Finish current task, save state | | CRITICAL | ≤20% | Run /compact immediately | | EMERGENCY | ≤15% | Stop everything, evacuate |
| Variable | Default | Description |
|----------|---------|-------------|
| CC_CONTEXT_MISSION_FILE | $HOME/mission.md | Path to mission/state file for evacuation template |
jq for JSON parsing~/.claude/debug/ (optional, falls back to estimation)Born from a session that hit 3% context remaining with no warning. The agent died mid-task and all in-flight work was lost.
From claude-code-hooks — battle-tested hooks from 140+ hours of autonomous Claude Code operation.