---
name: claude-stats
description: Generate an interactive HTML report of your Claude Code usage (sessions, messages, tokens, active days, streaks, peak times, model usage by day, top projects/tools) by parsing ~/.claude/projects/*.jsonl. Use when the user asks for their Claude stats, usage, activity, streaks, token breakdown, or wants to see how they use Claude over time.
user-invocable: true
allowed-tools:
  - Bash(python3 *)
  - Bash(open *)
  - Read
title: claude-stats
canonical_url: https://skilld.dev/gh/benwaffle/skills/claude-stats
last_updated: 2026-10-06T14:17:38.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [build_stats.py](https://skilld.dev/api/skills-raw/benwaffle/skills/claude-stats/build_stats.py).
>
> If the user asked to install this Skill, run `npx skilld install benwaffle/skills/claude-stats`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/claude-stats`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/benwaffle/skills/claude-stats) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/claude-stats`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/claude-stats --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/claude-stats --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# claude-stats

Builds a single self-contained HTML report from the user's local Claude Code conversation logs.

## How to run

```bash
python3 "${CLAUDE_PLUGIN_ROOT:-$(dirname "$0")}/build_stats.py" [OUTPUT_HTML] [CLAUDE_DIR]
```

- `OUTPUT_HTML` — where to write the report. Defaults to `./claude_stats.html`.
- `CLAUDE_DIR` — Claude config directory. Defaults to `$CLAUDE_DIR` or `~/.claude`.

The script writes a sidecar `.json` next to the HTML (same basename) for debugging or re-use.

After running, open the HTML in the browser: `open <output_html>` (macOS) or `xdg-open` (Linux).

## What it reports

- Totals: sessions, user/assistant messages, tokens (input/output/cache-create/cache-read).
- Timeline: daily activity, token usage over time.
- **Model usage by day** (stacked bar, one color per model).
- Peak hours + peak weekdays, hour×weekday heatmap.
- Streaks: longest + current (computed over all time, not the current filter).
- Top projects, top tools, top models.
- Session table sortable by duration / messages / tokens.

## Interactive filtering

The report has a filter bar: **All time · By month · By week · Last 30d · Last 7d**. Selecting *By month* or *By week* reveals clickable chips (one per bucket, showing its message count). All charts, cards, and tables rescope to the selection.

Streaks intentionally stay all-time — streak length inside a single week is meaningless.

## Data source notes

- Scans every `*.jsonl` under `<CLAUDE_DIR>/projects/` recursively (includes subagent logs).
- Timestamps are converted to **local time** for hour-of-day / weekday bucketing.
- Excludes `<synthetic>` assistant messages from model tallies (they have no real usage).
- Distinguishes genuine user prompts from tool-result blocks (both have `type: "user"` but tool results aren't counted as user messages).
- Tool usage is counted per `tool_use` block in assistant messages.

## Typical invocation pattern

When the user asks for "my Claude stats" or "usage report":

1. Run the script to a temp path, e.g. `/tmp/claude_stats.html`.
2. Summarize the top-level numbers in chat (sessions, messages, tokens, active days, streaks, peak hour/weekday).
3. `open` the HTML so the user can explore interactively.

The report is fully client-side — Chart.js is loaded from jsdelivr CDN. No data leaves the machine.
