-
Notifications
You must be signed in to change notification settings - Fork 84
docs: add session summary hook as companion tool #143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,7 @@ rtk filters and compresses command outputs before they reach your LLM context, s | |
|
|
||
| **How to verify you have the correct rtk:** | ||
| ```bash | ||
| rtk --version # Should show "rtk 0.18.0" | ||
| rtk --version # Should show "rtk 0.18.1" | ||
| rtk gain # Should show token savings stats | ||
| ``` | ||
|
|
||
|
|
@@ -700,6 +700,58 @@ cp ~/.claude/settings.json.bak ~/.claude/settings.json | |
|
|
||
| See **[TROUBLESHOOTING.md](docs/TROUBLESHOOTING.md)** for more issues and solutions. | ||
|
|
||
| ## Companion Tools | ||
|
|
||
| ### Session Summary Hook — Automatic RTK Savings Visibility | ||
|
|
||
| RTK tracks savings via `rtk gain`, but you have to run it manually. The **Session Summary hook** displays your RTK token savings automatically at every Claude Code session exit — alongside 14 other analytics sections (duration, tools, files, git diff, cost, cache, etc.). | ||
|
|
||
| **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 | ||
|
|
||
| **Example output (RTK section):** | ||
| ``` | ||
| 🔧 RTK Savings | ||
| Commands: 41 (+33 this session) | ||
| Tokens saved: 25.3K (+12.4K this session, 73%) | ||
| ``` | ||
|
|
||
| **Install:** | ||
| ```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 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we directly integrate this ? |
||
| curl -fsSL https://raw.githubusercontent.com/FlorianBruniaux/claude-code-ultimate-guide/main/examples/hooks/bash/rtk-baseline.sh -o ~/.claude/hooks/rtk-baseline.sh | ||
| chmod +x ~/.claude/hooks/session-summary.sh ~/.claude/hooks/rtk-baseline.sh | ||
|
|
||
| # 2. Add to ~/.claude/settings.json (merge with existing hooks) | ||
| ``` | ||
|
Comment on lines
+728
to
+729
|
||
|
|
||
| Add these entries to your `settings.json`: | ||
| ```json | ||
| { | ||
| "hooks": { | ||
| "SessionStart": [ | ||
| { | ||
| "hooks": [{ "type": "command", "command": "~/.claude/hooks/rtk-baseline.sh" }] | ||
| } | ||
| ], | ||
| "Stop": [ | ||
| { | ||
| "hooks": [{ "type": "command", "command": "~/.claude/hooks/session-summary.sh", "timeout": 10000 }] | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ``` | ||
|
Comment on lines
+733
to
+747
|
||
|
|
||
| **Requirements:** `jq` (`brew install jq` / `apt install jq`) | ||
|
|
||
| **Configuration:** All 15 sections are toggleable via environment variables or a config CLI. If RTK isn't installed, the savings section is simply hidden. | ||
|
|
||
| For full documentation, configuration options, and the config CLI tool, see the [Session Summary hook README](https://github.com/FlorianBruniaux/claude-code-ultimate-guide/blob/main/examples/hooks/README.md#session-summarysh-v3). | ||
|
|
||
| ## For Maintainers | ||
|
|
||
| ### Security Review Workflow | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent hook name: the text says "A
SessionEndhook" 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 "AStophook" or add a note that Stop is the hook event name that runs at session end.