Shows how much context window is left — without opening the terminal.
One line. Glanceable. Use for quick checks.
bash
python3 scripts/context_report.py
Full breakdown with per-file system prompt, conversation split, trends, and thinking status. Use when the user asks for specifics.
bash
python3 scripts/context_report.py --detailed
Both modes auto-detect the most recently updated session. Options:
text
--session <key> Target a specific session
--agent <name> Target a specific agent (default: main)
--detailed Full breakdown instead of compact one-liner
When the user asks "check context", "how much context", "context window", or similar casual phrases.
Show the unicode bar, percentage, estimated turns remaining, and average tokens per turn:
text
🟢 [███░░░░░░░░░░░░░░░░░] 15% | ~736 turns left | 427 tokens/turn
Run the compact script ( python3 scripts/context_report.py) and extract the bar/percentage. Get avg tokens/turn and turns remaining from the detailed script or session_status. Strip all * characters before sending to Slack (see Slack rendering fix below).
Add a contextual one-liner when context is 75%+ used (see Guidance section). Otherwise, just show the line.
When the user explicitly asks "detailed context", "full context check", "context breakdown", or "show me everything":
text
🟢 [███████████░░░░░░░░░] Context Usage: 113.7K / 202.8K (56%)
────────────────────
Token Breakdown
System Prompt: ~10.2K tokens (5%)
AGENTS.md: ~2.0K tokens
SOUL.md: ~416 tokens
TOOLS.md: ~717 tokens
IDENTITY.md: ~65 tokens
USER.md: ~83 tokens
HEARTBEAT.md: ~48 tokens
BOOTSTRAP.md: ~18 tokens
MEMORY.md: ~2.3K tokens
📦 Framework overhead: ~5.3K (tool schemas, skill list, runtime)
• Conversation: ~103.5K tokens (51%)
• 📊 Total Used: 113.7K (56%)
• Remaining: 89.1K (44%)
────────────────────
Trends
• Avg tokens per turn: ~316 tokens
• ⏳ Estimated turns remaining: ~281
────────────────────
Session Stats
• 📥 Total input: 2.1K | 📤 Total output: 318 | Cache hit rate: 100%
• Thinking: active (35/200 responses)
Run the detailed script and strip all * characters for Slack compatibility.
The bar uses █ (filled) and ░ (empty) across 20 segments (each = 5%). The bar colour shifts: green under 60%, yellow 60-80%, red over 80%.
The compact report can run automatically every 10 messages. This is disabled by default — the user must explicitly enable it.
To enable, the user must say something like "auto-check my context" or "enable context auto-check". Once enabled:
.msg-counter.json (same directory as SKILL.md)The counter survives compaction. If the file is missing, create it starting at 0:
json
{"count": 0}
To disable, the user can say "disable context auto-check" — delete the counter file and stop checking.
Important: Never enable this automatically. Only enable when the user explicitly asks.
The script outputs raw data. The LLM adds a contextual one-liner based on the conversation.
When to add guidance:
Slack rendering fix:
The script uses *text* for emphasis, which Slack interprets as italics and can break rendering of the detailed output (long messages with many italics markers fail to display). When the channel is Slack:
* characters from the script output before displayingHow to write it: One line, specific to the current task. For compact mode, append after the one-liner. For detailed mode, append after the final divider.
Examples:
| Tight — wrap up and commit, start fresh for anything new.Rules:
text
✅ Exact (from provider):
• Total tokens used (from transcript)
• Context window limit (from session store)
• Cache hit rate
⚠ Estimated:
• Per-file system prompt breakdown (chars ÷ 4)
• Turns remaining (extrapolated from recent growth rate)
• Thinking token count (bundled by provider, not separately reported)
.jsonl) as source of truth — the session store can lag behind by thousands of tokens