Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 53 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down Expand Up @@ -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
Copy link

Copilot AI Feb 16, 2026

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 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.

Suggested change
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

Copilot uses AI. Check for mistakes.

**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
Copy link
Collaborator

Choose a reason for hiding this comment

The 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
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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."

Copilot uses AI. Check for mistakes.

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
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.

**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
Expand Down
Loading