Available in
Marketplaces, most starred first
Tags
Add to README
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
By House-lovers7v0.3.1MITIn 2 marketplaces
Detects token-wasting Claude Code sessions (context re-read bloat) and closes the loop: nudges the model to compact & delegate, and surfaces 'time to cut' in your statusline and notifications.
You run one by typing its /name in Claude Code.
1 caution to review before installing
A command runs shell commands (! syntax) when you invoke it
Static checks of hooks, mods, MCP servers and commands. Not a security audit.
2 marketplaces, most starred first
claude-code, tokens, usage, prompt-caching, hooks, statusline
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
95% of my Claude Code tokens were cache re-reads — not output. This plugin
detects when a session enters that token-wasting phase and, unlike
monitoring-only tools, closes the loop: it tells the model itself to propose
/compact and delegate to subagents, and surfaces "time to cut this session"
in your statusline and notifications.
日本語版は README.ja.md へ。
At a glance
additionalContext injection → the model itself starts proposing /compact and delegating/compact cuts live context a median 66% (29 real compactions, monotonic with pre-compaction size). Reproduce with scripts/compaction_effect.py. Across days, a workload-normalized 4-day series shows the per-session median cacheRead/output ratio falling monotonically 233x → 83x after the loop went live — while the raw cache-read share (~94%) and the hot-session rate did not improve (details).Prompt caching in Claude Code is automatic and cheap per token — but every request re-reads the entire cached context. Run one session for a few hours and the numbers look like this (one full day of real work: 2026-07-02, 12 projects, 2,592 deduplicated requests):
input 1.5M
output 1.6M
cacheRead 347M <- 95% of all tokens
The worst sessions ran at a 231–313x cacheRead/output ratio. A statusline warning alone didn't change behavior (mine was ignored past 2x the threshold). What worked was making the model aware: once the session crosses a threshold, every prompt carries an injected instruction to wrap up, compact, and delegate.
One detection engine (scripts/session_health.py), three surfaces:
| Surface | Mechanism | What you see |
|---|---|---|
| Model self-correction | UserPromptSubmit hook (installed automatically) | When hot, the model starts proposing /compact / a fresh session at task boundaries and delegates exploration to subagents |
| Statusline | optional, see below | 📜req56·120x → 🟡 → 🔥req231·246x ⚠️/compact |
| Stop notification | optional, see below | your "response done" notification gains | cut point: req231 / re-read 246x -> /compact |
Plus /session-health:usage-report: a token breakdown of the last day across
project × session × subagent × model, with request-level deduplication
(streaming writes each request as multiple JSONL records — naive summing
double-counts 2–3x) and subagent transcripts included (they live in separate
files under <session>/subagents/; miss them and delegation looks like zero).
Everything runs on local transcript files. Nothing leaves your machine.
Full usage reports scan local Claude Code transcript files under
~/.claude/projects/, including subagent transcripts, and can take time on
large histories. For faster checks, narrow the scan:
python3 scripts/usage_report.py --project agent-company-os
python3 scripts/usage_report.py --current ~/.claude/projects/.../session.jsonl
python3 scripts/usage_report.py --transcript ~/.claude/projects/.../session.jsonl
Future work may add an incremental cache for repeated full reports.
Claude Code plugins are powerful — they can add commands, hooks, agents, and MCP servers, so being wary of a plugin from a personal repository is the correct instinct. Here is exactly what this one adds.
This plugin installs:
/session-health:usage-reportUserPromptSubmit hook that runs scripts/session_health.py hookIt does not install:
All analysis is performed on local Claude Code transcript files under
~/.claude/projects/. Nothing leaves your machine.
If you'd rather verify than trust: read hooks/hooks.json
first — it declares exactly when Claude Code runs what — then the two scripts
under scripts/ and commands/usage-report.md.
/plugin marketplace add House-lovers7/claude-code-session-health
/plugin install session-health@house-lovers7
The hook and /session-health:usage-report work immediately. Two optional surfaces:
Statusline — see scripts/statusline-example.sh,
or add one line to your existing statusline script:
health=$(printf '%s' "$input" | python3 "<plugin>/scripts/session_health.py" statusline 2>/dev/null)
Built from public signals: copy clicks on this site, GitHub stars and activity, the README and the manifest. Not a security audit or an endorsement.
npx claudepluginhub house-lovers7/claude-code-session-health --plugin session-healthPlugins from other owners that cover similar ground