Feature Request: Hook event for context window threshold alerts
Resolved 💬 3 comments Opened Jan 21, 2026 by danielemiconi Closed Jan 25, 2026
Summary
Add a new hook event that triggers when the context window reaches a configurable threshold (e.g., 50%, 75%, 90%).
Use Case
When working on long sessions, users may want to be notified before running out of context space. Currently, there's no way to automate this - users must manually run /context to check usage.
Proposed Solution
Add a new hook event like ContextWindowThreshold that:
- Triggers when context usage crosses a configurable percentage
- Provides token count and percentage in the hook's stdin JSON
- Allows users to run custom scripts (e.g., desktop notifications, sound alerts)
Example configuration:
{
"hooks": {
"ContextWindowThreshold": [
{
"matcher": "50",
"hooks": [
{
"type": "command",
"command": "notify-send 'Claude Code' 'Context at 50%'"
}
]
}
]
}
}
Alternatives Considered
- Adding instructions in
CLAUDE.mdto remind Claude to warn the user (current workaround, but not automated) - Using
Stophook to parse logs (not reliable, no API access to token metrics)
Additional Context
This would greatly improve UX for users who work on complex, long-running tasks.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗