-
Notifications
You must be signed in to change notification settings - Fork 738
Expand file tree
/
Copy pathrtk-baseline.sh
More file actions
39 lines (32 loc) · 1.16 KB
/
Copy pathrtk-baseline.sh
File metadata and controls
39 lines (32 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# .claude/hooks/rtk-baseline.sh
# Event: SessionStart
# Save RTK gain baseline for session-summary.sh delta tracking
#
# This hook captures RTK's cumulative stats at session start.
# At session end, session-summary.sh reads this baseline, captures current stats,
# and computes the delta to show per-session RTK savings.
#
# Configuration:
# SESSION_SUMMARY_RTK=0 - Force disable (skip baseline capture)
# SESSION_SUMMARY_RTK=1 - Force enable
# (default: auto-detect if rtk is in PATH)
#
# Place in: ~/.claude/hooks/rtk-baseline.sh
# Register in: ~/.claude/settings.json under SessionStart event
set -euo pipefail
RTK_ENABLED="${SESSION_SUMMARY_RTK:-auto}"
# Auto-detect RTK availability
if [[ "$RTK_ENABLED" == "auto" ]]; then
command -v rtk &>/dev/null && RTK_ENABLED=1 || RTK_ENABLED=0
fi
# Skip if disabled or RTK not available
if [[ "$RTK_ENABLED" != "1" ]]; then
exit 0
fi
# Build baseline file path (must match session-summary.sh)
baseline_key=$(echo "${CLAUDE_PROJECT_DIR:-$(pwd)}" | tr '/' '-')
baseline_file="/tmp/rtk-baseline${baseline_key}.txt"
# Capture current RTK cumulative stats
rtk gain > "$baseline_file" 2>/dev/null || true
exit 0