Feature Request: Token Usage & Context Visibility
It would be very useful to have visibility into token consumption and context size directly from the CLI, similar to Claude Code's /context and /cost commands.
Motivation
Currently, Deep Code already stores token usage data internally in sessions-index.json. According to the docs, each session entry tracks:
"token 用量 and 活跃 token 数"
However, there is no way to view this information from the CLI interface. Users have no visibility into:
- How many tokens they have consumed in the current session
- How much of the context window is being used
- What is consuming the most tokens (system prompt, conversation history, skills, MCP tools)
Proposed Commands
/tokens – Show current session token consumption
Displays the token usage breakdown for the current session:
- Input tokens (this turn)
- Output tokens (this turn)
- Thinking tokens (if thinking mode is enabled)
- Total tokens (entire session)
- Estimated cost (based on model pricing)
/context – Show context window breakdown
Displays what is consuming the context window:
- System prompt size (tokens)
- Conversation history size (# of messages, tokens)
- Skills loaded and their contribution
- Active MCP tools and their descriptions size
- Total context window usage (e.g., 15K / 128K / 1M)
/cost – Show cumulative session cost
Shows the estimated cost of the current session based on model pricing:
- Per-turn cost breakdown
- Total session cost
- Thinking vs non-thinking token cost
Why This Matters
- Cost awareness – Helps users monitor spend when using paid API models (especially with reasoning/thinking tokens which add significant cost)
- Debug context limits – When approaching context window limits, users can identify the culprit (bloated history, too many skills, etc.)
- Optimization feedback – Allows users to measure the impact of prompt optimization, skill trimming, or MCP cleanup
- Parity with alternatives – Tools like Claude Code already offer
/context and /cost; adding these would reduce friction for users migrating to or evaluating Deep Code
Implementation Notes
- The data already exists in
~/.deepcode/projects/<project-code>/sessions-index.json which stores "token 用量" per session entry
- For real-time context window tracking, the token counts could be computed from the messages being sent to the model API
- A lightweight tokenizer or cached counts per message would suffice — no need for full tokenization on every request
This is an open-ended feature request. Happy to help with implementation or testing.
Feature Request: Token Usage & Context Visibility
It would be very useful to have visibility into token consumption and context size directly from the CLI, similar to Claude Code's
/contextand/costcommands.Motivation
Currently, Deep Code already stores token usage data internally in
sessions-index.json. According to the docs, each session entry tracks:However, there is no way to view this information from the CLI interface. Users have no visibility into:
Proposed Commands
/tokens– Show current session token consumptionDisplays the token usage breakdown for the current session:
/context– Show context window breakdownDisplays what is consuming the context window:
/cost– Show cumulative session costShows the estimated cost of the current session based on model pricing:
Why This Matters
/contextand/cost; adding these would reduce friction for users migrating to or evaluating Deep CodeImplementation Notes
~/.deepcode/projects/<project-code>/sessions-index.jsonwhich stores "token 用量" per session entryThis is an open-ended feature request. Happy to help with implementation or testing.