Expose context window token usage as an agent-accessible tool
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
Currently, /context is a UI-only command that displays token usage (tokens used, window size, percentage). It cannot be invoked or read by agents/skills running inside Claude Code.
Proposed Solution
Request: Expose context window stats (tokens used, total window size, percentage remaining) via a tool or API that agents can call programmatically — similar to how /compact can already be triggered by skills.
Use case: Skills that help users manage context (e.g. a "check-context" skill) currently can't read or display token usage themselves. They have to tell the user to type /context manually, which defeats the purpose of a one-click skill.
Expected behavior: An agent should be able to call something like Skill("context") or a dedicated tool (e.g. GetContextUsage) and receive { tokensUsed, contextWindow, percentUsed } in return.
Alternative Solutions
_No response_
Priority
Medium - Would be very helpful
Feature Category
CLI commands and flags
Use Case Example
_No response_
Additional Context
_No response_