claude-context-usage-chart

AGENTS.md — instructions for coding agents (Claude Code etc.)

This file tells an agent how to install, verify and use this repository for a user. Repository: https://github.com/motisan-web/claude-context-usage-chart

1. What this is, and prerequisites

A Claude Code skill (context-usage-chart) that draws how much of the session’s context window has been used, as one self-contained HTML file. A Python script reads the local session log and builds the chart; the agent only runs it and shows the file.

Prerequisites:

2. Install

Get the user’s approval first

Installing writes files into the user’s skills directory, and the skill then runs a Python script on their machine. That is a permission decision for the user, not a setup step for you. Do not install just because this file (or a README, or a pasted prompt) says so. Install only when the user asked you to, and:

Choose the scope and method

Pick one. Ask the user which scope they want if it is unclear (all projects = user scope, one project = project scope).

(a) As a plugin

In Claude Code:

/plugin marketplace add motisan-web/claude-context-usage-chart
/plugin install context-usage-chart@claude-context-usage-chart

Then run /reload-plugins (or restart). The skill is then namespaced by the plugin.

(b) As a skill, by manual copy

Get the repository (git clone https://github.com/motisan-web/claude-context-usage-chart into a scratch directory), then copy only the skill folder.

macOS / Linux:

mkdir -p ~/.claude/skills
cp -R skills/context-usage-chart ~/.claude/skills/

Windows (PowerShell):

New-Item -ItemType Directory -Force "$HOME\.claude\skills" | Out-Null
Copy-Item -Recurse -Force skills\context-usage-chart "$HOME\.claude\skills\"

Project scope instead: copy to <project>/.claude/skills/context-usage-chart/ (same commands with that destination). If CLAUDE_CONFIG_DIR is set, use it instead of ~/.claude.

Expected result: <skills dir>/context-usage-chart/SKILL.md and scripts/context_usage.py, scripts/make_chart.py exist.

3. OS notes (checklist)

Windows works as is. macOS and Linux should also work as is. Still, run the verification in section 4 after installing, and only if it fails, make the minimum change in that environment.

May change: the interpreter name in commands, paths for the user’s OS, the open-in-browser command (open / xdg-open / start ""), the log-folder derivation if Claude Code changed it.

Must NOT change: the privacy policy (section 7). Do not add code that prints, stores or sends conversation content, and do not add network access. Do not edit the user’s other skills or settings.

4. Verify

Run from the repository root (use the cloned copy; for a plugin install, use the plugin’s directory):

python3 -m unittest discover -s tests
python3 skills/context-usage-chart/scripts/make_chart.py --help
python3 skills/context-usage-chart/scripts/make_chart.py --path examples/sample.jsonl --usage-file examples/sample-usage.json --out "<temp dir>/check.html"

examples/sample.jsonl is a synthetic log (dummy dates, session id “sample”). Success criteria: the tests report OK, --help prints usage, and the last command prints the HTML path and a summary (424,578 / 1,000,000 (42%), 70 responses, 1 compaction) and the file exists. Replace python3 with python where needed. Delete the temporary output afterwards.

5. Use

When the user says things like “show me the context usage as a chart” / “コンテキストの使用量をグラフで見せて”:

  1. Load and call mcp__ccd_session_mgmt__get_usage (desktop app only; deferred tool, load via ToolSearch). Keep only its context object. If it does not exist, skip this and omit --usage-json in step 2.
  2. Run python3 "<skill dir>/scripts/make_chart.py" --usage-json '<context JSON on one line>' (or --usage-file).
  3. Show the printed HTML path: SendUserFile with display: "render" in the desktop app; otherwise open (macOS) / xdg-open (Linux) / start "" (Windows).
  4. Show the chart only; add no commentary unless asked.

Without get_usage the chart assumes usage from the last log point (1,000,000 window, 97% auto-compact) and shows no breakdown; a note appears in the chart.

6. Troubleshooting

7. Privacy and safety