/sessionlog:tokenusagefrom sessionlog
Extracts and reports input/output token counts from Claude Code session logs. Activated by queries about token usage, token counts, or API usage summaries.
Ships in sessionlog. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Extract and report input/output token counts from Claude Code session logs.
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.
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"
Present results as a clean table:
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
7 skills in this plugin
/compactsessionlog:compactThis skill should be used when the user asks to "compact session", "compress session", "save session context", "sessionlog compact", "compact this session", "prepare for clear", or wants to create a compressed summary of the current session that can be continued after clearing context.
/continuesessionlog:continueThis skill should be used when the user asks to "continue session", "resume session", "pick up where I left off", "sessionlog continue", "continue from compact", "load session context", or wants to restore context from a previously compacted session file.
/exportsessionlog:exportThis skill should be used when the user asks to "export session log", "convert session to json", "export conversation", "save session", "sessionlog export", "export this session", or wants to export the current Claude Code session as a standard LLM conversation JSON file and human-readable TXT transcript.
/export-allsessionlog:export-allThis 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.
/infosessionlog:infoThis 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.
/recapsessionlog:recapThis skill should be used when the user asks to "recap", "brief me", "remind me", "what did we work on", "what happened last time", "catch me up on recent sessions", "sessionlog recap", "session recap", "recent session summary", "tldr sessions", or wants a quick summary of what was worked on in recent sessions for this project.
npx claudepluginhub florianbuetow/claude-code --plugin sessionlogOther plugins' skills for the same job