sessionlog:tokenusage
/sessionlog:tokenusage
This skill should be used when the user asks to "show token usage", "how many tokens", "token count", "token stats", "input output tokens", "API usage", "usage summary", "sessionlog tokenusage", "tokenusage", or wants to extract and report input/output token counts from Claude Code session logs.
- Author
- florianbuetow ↗
- Repository
- claude-code ↗
- Licence
- MIT
- Last repository change
- 07.10.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 07.10.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
This skill should be used when the user asks to "show token usage", "how many tokens", "token count", "token stats", "input output tokens", "API usage", "usage summary", "sessionlog tokenusage", "tokenusage", or wants to extract and report input/output token counts from Claude Code session logs.
Triggers from the description
Original author description
This skill should be used when the user asks to "show token usage", "how many tokens", "token count", "token stats", "input output tokens", "API usage", "usage summary", "sessionlog tokenusage", "tokenusage", or wants to extract and report input/output token counts from Claude Code session logs.
How it works
- Steps
SKILL.md preview
---
name: sessionlog:tokenusage
description: >
This skill should be used when the user asks to "show token usage",
"how many tokens", "token count", "token stats", "input output tokens",
"API usage", "usage summary", "sessionlog tokenusage", "tokenusage",
or wants to extract and report input/output token counts from
Claude Code session logs.
disable-model-invocation: false
---
# Session Token Usage
Extract and report input/output token counts from Claude Code session logs.
## Steps
### 1. Identify session
```bash
project_dir="$HOME/.claude/projects/$(pwd | sed 's|/|-|g')"
current_session=$(ls -t "$project_dir"/*.jsonl 2>/dev/null | head -1)
session_id=$(basename "$current_session" .jsonl)
echo "Session: $session_id"
echo "Source: $current_session"
```
If the user specifies a session ID, use that instead of the most recent one.
### 2. Extract token usage
```bash
python3 -c "
import json, sys
log_file = sys.argv[1]
# Deduplicate by message ID — session logs may contain multiple
# JSONL lines per API call (streaming). Take the last usage block
# per unique message ID for accurate counts.
usage_by_msg = {}
with open(log_file) as f:
for line in f:
line = line.strip()
if not line:
continue
try:
obj = json.loads(line)
except json.JSONDecodeError:
continue
msg = obj.get('message', {})
msg_id = msg.get('id')
usage = msg.get('usage')
if msg_id and usage:
usage_by_msg[msg_id] = usage
totals = {
'input_tokens': 0,
'output_tokens': 0,
'cache_creation_input_tokens': 0,
'cache_read_input_tokens': 0,
}
for usage in usage_by_msg.values():
for key in totals:
totals[key] += usage.get(key, 0)
msg_count = len(usage_by_msg)
total_input = totals['input_tokens'] + totals['cache_creation_input_tokens'] + totals['cache_read_input_tokens']
print(f'API calls: {msg_count:>12,}')
print(f'Input tokens: {totals[\"input_tokens\"]:>12,}')
print(f'Output tokens: {totals[\"output_tokens\"]:>12,}')
print(f'Cache creation input tokens: {totals[\"cache_creation_input_tokens\"]:>12,}')
print(f'Cache read input tokens: {totals[\"cache_read_input_tokens\"]:>12,}')
print(f'Total input (all types): {total_input:>12,}')
" "$current_session"
```
### 3. Report results
Present results as a clean table:
- **Session ID** — the UUID
- **API calls** — number of unique API calls with usage data
- **Input tokens** — non-cached input tokens
- **Output tokens** — tokens generated by the model
- **Cache creation tokens** — input tokens written to prompt cache
- **Cache read tokens** — input tokens served from prompt cache
- **Total input** — sum of all input token types
Versions
The database has no other skills named sessionlog:tokenusage.
Database snapshot: 13.11.2026 · package version 509828faee4f (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 90sessionlog:info
This skill should be used when the user asks to "show session info", "find session log", "where are session logs", "current session id", "session path", "sessionlog info", or wants to identify the current Claude Code session and its log file location on disk. - 90sessionlog:export-all
This skill should be used when the user asks to "export all sessions", "export all session logs", "batch export sessions", "sessionlog export-all", "convert all sessions", or wants to export every Claude Code session for the current project as standard LLM conversation JSON and TXT files. - 100cv-usage
Use when the user asks about usage analytics, statistics, token usage, or cost summary — e.g. 'usage stats', 'token usage', 'how many sessions this week', 'show me my numbers', 'cost summary', 'usage report - 100stats
Use when user invokes /stats or asks about Claude Code usage, token consumption, session history, model distribution, or activity patterns. Generates an interactive HTML dashboard with charts and tables, auto-opens in browser. Also triggers on "how much have I used Claude",… - 95session-report
Use when the user asks to "analyze a session", "session report", "review session performance", "how did that session go", "token usage report", "cost report", or wants to understand the performance, cost, and quality of a completed Claude Code session. Accepts a session JSON file path as input. - 100claude-token-spend
Report Claude Code token consumption from local session logs - per model, per project, and per token type (input, output, cache read, cache write) over 24h / 7d / 30d / all-time windows. Reads ~/.claude/projects directly, no API key, read-only. Triggers on "my token spend",…