Problem
RTK tracks token savings via rtk gain, but users must manually run it to see their savings. There's no automatic visibility into the value RTK provides at the end of each Claude Code session.
Meanwhile, 4 open issues on anthropics/claude-code request exactly this kind of session analytics — and Anthropic hasn't shipped anything:
Existing Solution
A community-built Session Summary hook already solves this. It's a Claude Code SessionEnd hook (bash) that displays 15 configurable analytics sections at every session exit:
- Duration, tools, errors, files, git diff, LOC, models, cache, cost, RTK savings, ratio, thinking, context...
- RTK integration: captures baseline at SessionStart (
rtk gain snapshot), computes per-session delta at SessionEnd
- Fully toggleable: if RTK isn't installed, the section is simply hidden
- Single dependency:
jq
- Open source: claude-code-ultimate-guide/examples/hooks
How RTK integration works
- SessionStart hook (
rtk-baseline.sh): runs rtk gain > /tmp/rtk-baseline-<key>.txt
- SessionEnd hook (
session-summary.sh): reads baseline, runs rtk gain again, computes delta
- Displays per-session savings: commands count, tokens saved, percentage
Note: The hook currently uses rtk gain text output. The --format json flag could enable more precise parsing.
Proposal
Option A: rtk install-hooks (recommended quick win)
New command that installs the SessionStart + SessionEnd hooks into ~/.claude/hooks/ and patches settings.json:
rtk install-hooks # Install session summary hooks
rtk install-hooks --uninstall # Remove them
Pros: One-command setup, leverages existing battle-tested hook code, minimal Rust changes
Cons: Bash dependency, external hook maintenance
Option B: rtk session-summary (native Rust)
RTK embeds the session summary logic natively. Pure Rust, no bash/jq dependency. Could hook into Claude Code's SessionEnd event.
Pros: No external dependencies, faster, tighter integration
Cons: Significant development effort, needs to replicate 15 sections of analytics
Option C: Documentation + reference (immediate)
Add a "Companion Tools" section to the README documenting the session summary hook as a recommended companion for automatic RTK savings visibility.
Pros: Zero code changes, immediate value, community attribution
Cons: Users must install manually, no tight integration
Option D: Bundle hook in repo
Copy the hook scripts into a hooks/ directory in the RTK repo, maintained in sync with upstream.
Pros: Single repo, discoverable
Cons: Sync maintenance burden, potential version drift
Recommendation
Phase 1 (now): Option C — document the hook in README as companion tool
Phase 2 (next): Option A — rtk install-hooks command for one-click setup
Phase 3 (roadmap): Option B — native Rust implementation for zero-dependency experience
References
Problem
RTK tracks token savings via
rtk gain, but users must manually run it to see their savings. There's no automatic visibility into the value RTK provides at the end of each Claude Code session.Meanwhile, 4 open issues on anthropics/claude-code request exactly this kind of session analytics — and Anthropic hasn't shipped anything:
Existing Solution
A community-built Session Summary hook already solves this. It's a Claude Code SessionEnd hook (bash) that displays 15 configurable analytics sections at every session exit:
rtk gainsnapshot), computes per-session delta at SessionEndjqHow RTK integration works
rtk-baseline.sh): runsrtk gain > /tmp/rtk-baseline-<key>.txtsession-summary.sh): reads baseline, runsrtk gainagain, computes deltaProposal
Option A:
rtk install-hooks(recommended quick win)New command that installs the SessionStart + SessionEnd hooks into
~/.claude/hooks/and patchessettings.json:Pros: One-command setup, leverages existing battle-tested hook code, minimal Rust changes
Cons: Bash dependency, external hook maintenance
Option B:
rtk session-summary(native Rust)RTK embeds the session summary logic natively. Pure Rust, no bash/jq dependency. Could hook into Claude Code's SessionEnd event.
Pros: No external dependencies, faster, tighter integration
Cons: Significant development effort, needs to replicate 15 sections of analytics
Option C: Documentation + reference (immediate)
Add a "Companion Tools" section to the README documenting the session summary hook as a recommended companion for automatic RTK savings visibility.
Pros: Zero code changes, immediate value, community attribution
Cons: Users must install manually, no tight integration
Option D: Bundle hook in repo
Copy the hook scripts into a
hooks/directory in the RTK repo, maintained in sync with upstream.Pros: Single repo, discoverable
Cons: Sync maintenance burden, potential version drift
Recommendation
Phase 1 (now): Option C — document the hook in README as companion tool
Phase 2 (next): Option A —
rtk install-hookscommand for one-click setupPhase 3 (roadmap): Option B — native Rust implementation for zero-dependency experience
References