rtk-ai / rtk-ai/rtk

feat: integrate session summary hook for end-of-session analytics

Open
#142 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:cli effort-medium enhancement help wanted priority:medium
Dominant language
Rust
Stars
81.1k
Forks
5.1k
Avg merge
4d 21h
Merged PRs (30d)
35

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:

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
  1. SessionStart hook (rtk-baseline.sh): runs rtk gain > /tmp/rtk-baseline-<key>.txt
  2. SessionEnd hook (session-summary.sh): reads baseline, runs rtk gain again, computes delta
  3. 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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the referenced upstream hook files, the README, and the Claude Code settings.json hook format; run rtk gain to understand the current output and baseline flow. Clarify which proposal is in scope, then define completion as either documenting the companion hook, installing it reliably, or implementing the native session summary, with tests or verification for that chosen path.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, rust
Domain
cli, documentation
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.