docs: add session summary hook as companion tool#143
docs: add session summary hook as companion tool#143FlorianBruniaux wants to merge 2 commits intomasterfrom
Conversation
…vings visibility Closes #142 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR adds documentation for a community-built Session Summary hook as a companion tool for RTK, implementing "Option C" from issue #142. The documentation enables users to automatically see their RTK token savings at the end of each Claude Code session without manually running rtk gain.
Changes:
- Adds a new "Companion Tools" section to README.md with installation instructions and usage examples for the Session Summary hook
- Documents the two-hook system (SessionStart baseline capture + Stop/SessionEnd summary display) with curl-based installation
- Includes JSON configuration snippet for settings.json and example output showing per-session RTK savings
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| **How it works:** | ||
| 1. A `SessionStart` hook captures an RTK baseline (`rtk gain` snapshot) | ||
| 2. A `SessionEnd` hook computes the per-session delta and displays it |
There was a problem hiding this comment.
Inconsistent hook name: the text says "A SessionEnd hook" but the JSON configuration on line 740 uses "Stop" as the hook name. These should match for clarity. Based on the JSON example being the actual configuration, consider changing this line to say "A Stop hook" or add a note that Stop is the hook event name that runs at session end.
| 2. A `SessionEnd` hook computes the per-session delta and displays it | |
| 2. A `Stop` hook (session end) computes the per-session delta and displays it |
| { | ||
| "hooks": { | ||
| "SessionStart": [ | ||
| { | ||
| "hooks": [{ "type": "command", "command": "~/.claude/hooks/rtk-baseline.sh" }] | ||
| } | ||
| ], | ||
| "Stop": [ | ||
| { | ||
| "hooks": [{ "type": "command", "command": "~/.claude/hooks/session-summary.sh", "timeout": 10000 }] | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ``` |
There was a problem hiding this comment.
The JSON structure shown here has inconsistent nesting compared to the PreToolUse hook examples elsewhere in the README (lines 495-511). The PreToolUse hooks include a "matcher" field at the same level as "hooks", but this configuration omits it. Verify whether SessionStart and Stop hooks require or support a matcher field. If they don't require it, the current structure is correct; if they do, a matcher should be added for consistency.
| # 2. Add to ~/.claude/settings.json (merge with existing hooks) | ||
| ``` |
There was a problem hiding this comment.
The instruction says "merge with existing hooks" but the JSON example shows a complete hooks object structure that would replace existing hooks if copied as-is. Consider clarifying the merge instructions, such as: "If you already have hooks configured, add these SessionStart and Stop arrays to your existing hooks object. If you don't have any hooks yet, you can use this complete structure."
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| ```bash | ||
| # 1. Download hooks | ||
| mkdir -p ~/.claude/hooks | ||
| curl -fsSL https://raw.githubusercontent.com/FlorianBruniaux/claude-code-ultimate-guide/main/examples/hooks/bash/session-summary.sh -o ~/.claude/hooks/session-summary.sh |
There was a problem hiding this comment.
can we directly integrate this ?
|
we need to reduce or restructure the readme . it's too massive. |
Summary
rtk gainto see themCloses #142 (Option C: Documentation + reference)
Context
4 open issues on anthropics/claude-code request session analytics visibility (#1109, #18550, #16373, #22625) — Anthropic hasn't shipped anything. The community-built Session Summary hook already solves this with 15 configurable analytics sections, including per-session RTK token savings.
Test plan
🤖 Generated with Claude Code