feat: integrate session summary hook for end-of-session analytics
#142 opened on Feb 16, 2026
Repository metrics
- Stars
- (48,085 stars)
- PR merge metrics
- (Avg merge 11d 1h) (45 merged PRs in 30d)
Description
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:
- #1109 - Usage Metrics Visibility for Max Subscribers
- #18550 - Automatic Cost Tracking and Reporting
- #16373 - Auto-spawn subagents with persistent session summaries
- #22625 - Per-Subagent Token Usage Tracking
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 gainsnapshot), 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): runsrtk gain > /tmp/rtk-baseline-<key>.txt - SessionEnd hook (
session-summary.sh): reads baseline, runsrtk gainagain, computes delta - Displays per-session savings: commands count, tokens saved, percentage
Note: The hook currently uses
rtk gaintext output. The--format jsonflag 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
- Session Summary hook: https://github.com/FlorianBruniaux/claude-code-ultimate-guide/blob/main/examples/hooks/bash/session-summary.sh
- RTK baseline hook: https://github.com/FlorianBruniaux/claude-code-ultimate-guide/blob/main/examples/hooks/bash/rtk-baseline.sh
- Config CLI: https://github.com/FlorianBruniaux/claude-code-ultimate-guide/blob/main/examples/hooks/bash/session-summary-config.sh
- Hook documentation: https://github.com/FlorianBruniaux/claude-code-ultimate-guide/blob/main/examples/hooks/README.md#session-summarysh-v3