Skip to content

Commit 8c67a2f

Browse files
docs: update for hook-first installation mode
## README.md Updates **Quick Start section:** - Clear 3-step process: verify → install hook → test - Prominently recommend `rtk init -g` (hook-first mode) - Explain 99.5% token savings (2000 → 10 tokens) - Show alternative modes (--claude-md, local init) **Configuration section:** - New comparison table: 4 modes with token costs - Migration instructions for existing users - Clarify hook vs CLAUDE.md injection differences **Auto-Rewrite Hook section:** - Promote automated install (`rtk init -g`) as primary method - Keep manual install as fallback - Add verification step (`rtk init --show`) ## INSTALL.md Updates **Project Initialization:** - Recommend global hook-first setup (with rationale) - Show token savings: 99.5% reduction - Document local setup as alternative - Add upgrade/migration guide for existing users ## TROUBLESHOOTING.md Updates **RTK not working section:** - Option A: Automated (`rtk init -g`) - recommended - Option B: Manual install - fallback - Clarify absolute path requirement in settings.json - Add verification step ## Fixes Documentation Gaps Before: - ❌ No mode comparison - ❌ No migration guide - ❌ Manual install only - ❌ Unclear token impact After: - ✅ Clear mode comparison with use cases - ✅ Automatic migration documented - ✅ Automated install prioritized - ✅ Quantified token savings (99.5%) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 38fc860 commit 8c67a2f

3 files changed

Lines changed: 97 additions & 25 deletions

File tree

INSTALL.md

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,46 @@ rtk gain # MUST show token savings, not "command not found"
6969

7070
## Project Initialization
7171

72-
**For each project where you want to use RTK:**
72+
### Recommended: Global Hook-First Setup
73+
74+
**Best for: All projects, automatic RTK usage**
75+
76+
```bash
77+
rtk init -g
78+
# → Installs hook to ~/.claude/hooks/rtk-rewrite.sh
79+
# → Creates ~/.claude/RTK.md (10 lines, meta commands only)
80+
# → Adds @RTK.md reference to ~/.claude/CLAUDE.md
81+
# → Prints settings.json instructions
82+
83+
# Follow printed instructions to add hook to ~/.claude/settings.json
84+
# Then restart Claude Code
85+
86+
# Verify installation
87+
rtk init --show # Check hook is installed and executable
88+
```
89+
90+
**Token savings**: ~99.5% reduction (2000 tokens → 10 tokens in context)
91+
92+
### Alternative: Local Project Setup
93+
94+
**Best for: Single project without hook**
7395

7496
```bash
75-
# Navigate to project directory
7697
cd /path/to/your/project
98+
rtk init # Creates ./CLAUDE.md with full RTK instructions (137 lines)
99+
```
77100

78-
# Initialize RTK for this project (creates ./CLAUDE.md)
79-
rtk init
101+
**Token savings**: Instructions loaded only for this project
80102

81-
# OR initialize globally (creates ~/CLAUDE.md for all projects)
82-
rtk init --global
103+
### Upgrading from Previous Version
104+
105+
If you previously used `rtk init -g` with the old system (137-line injection):
106+
107+
```bash
108+
rtk init -g # Automatically migrates to hook-first mode
109+
# → Removes old 137-line block
110+
# → Installs hook + RTK.md
111+
# → Adds @RTK.md reference
83112
```
84113

85114
## Installation Verification

README.md

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -93,21 +93,25 @@ Download from [rtk-ai/releases](https://github.com/rtk-ai/rtk/releases):
9393
## Quick Start
9494

9595
```bash
96-
# Run installation check script (recommended first step)
97-
bash scripts/check-installation.sh
96+
# 1. Verify installation
97+
rtk gain # Must show token stats, not "command not found"
9898

99-
# OR manually verify correct installation
100-
rtk gain # Must show token stats, not error
99+
# 2. Initialize for Claude Code (RECOMMENDED: hook-first mode)
100+
rtk init --global
101+
# → Installs hook + creates slim RTK.md (10 lines, 99.5% token savings)
102+
# → Follow printed instructions to add hook to ~/.claude/settings.json
101103

102-
# Initialize rtk for Claude Code
103-
rtk init --global # Add to ~/.claude/CLAUDE.md (all projects)
104-
rtk init # Add to ./CLAUDE.md (this project)
104+
# 3. Test it works
105+
rtk git status # Should show ultra-compact output
106+
rtk init --show # Verify hook is installed and executable
105107

106-
# Test basic commands
107-
rtk ls .
108-
rtk git status
108+
# Alternative modes:
109+
# rtk init --global --claude-md # Legacy: full injection (137 lines)
110+
# rtk init # Local project only (./CLAUDE.md)
109111
```
110112

113+
**New in v0.9.5**: Hook-first installation eliminates ~2000 tokens from Claude's context while maintaining full RTK functionality through transparent command rewriting.
114+
111115
## Global Flags
112116

113117
```bash
@@ -298,14 +302,24 @@ FAILED: 2/15 tests
298302

299303
## Configuration
300304

301-
rtk reads from `CLAUDE.md` files to instruct Claude Code to use rtk automatically:
305+
### Installation Modes
306+
307+
| Command | Scope | Hook | RTK.md | CLAUDE.md | Tokens in Context | Use Case |
308+
|---------|-------|------|--------|-----------|-------------------|----------|
309+
| `rtk init -g` | Global || ✅ (10 lines) | @RTK.md | ~10 | **Recommended**: All projects, automatic |
310+
| `rtk init -g --claude-md` | Global ||| Full (137 lines) | ~2000 | Legacy compatibility |
311+
| `rtk init -g --hook-only` | Global ||| Nothing | 0 | Minimal setup, hook-only |
312+
| `rtk init` | Local ||| Full (137 lines) | ~2000 | Single project, no hook |
302313

303314
```bash
304-
rtk init --show # Show current configuration
305-
rtk init # Create local CLAUDE.md
306-
rtk init --global # Create ~/CLAUDE.md
315+
rtk init --show # Show current configuration
316+
rtk init -g # Install hook + RTK.md (recommended)
317+
rtk init -g --claude-md # Legacy: full injection into CLAUDE.md
318+
rtk init # Local project: full injection into ./CLAUDE.md
307319
```
308320

321+
**Migration**: If you previously used `rtk init -g` with the old system (137-line injection), simply re-run `rtk init -g` to automatically migrate to the new hook-first approach.
322+
309323
example of 3 days session:
310324
```bash
311325
📊 RTK Token Savings
@@ -336,13 +350,27 @@ Daily Savings (last 30 days):
336350

337351
The most effective way to use rtk is with the **auto-rewrite hook** for Claude Code. Instead of relying on CLAUDE.md instructions (which subagents may ignore), this hook transparently intercepts Bash commands and rewrites them to their rtk equivalents before execution.
338352

339-
**Result**: 100% rtk adoption across all conversations and subagents, zero token overhead.
353+
**Result**: 100% rtk adoption across all conversations and subagents, zero token overhead in Claude's context.
340354

341355
### How It Works
342356

343357
The hook runs as a Claude Code [PreToolUse hook](https://docs.anthropic.com/en/docs/claude-code/hooks). When Claude Code is about to execute a Bash command like `git status`, the hook rewrites it to `rtk git status` before the command reaches the shell. Claude Code never sees the rewrite — it's transparent.
344358

345-
### Global Install (all projects)
359+
### Quick Install (Automated)
360+
361+
```bash
362+
rtk init -g
363+
# → Installs hook to ~/.claude/hooks/rtk-rewrite.sh (with executable permissions)
364+
# → Creates ~/.claude/RTK.md (10 lines, minimal context footprint)
365+
# → Adds @RTK.md reference to ~/.claude/CLAUDE.md
366+
# → Prints settings.json instructions (manual step required)
367+
368+
# Follow the printed instructions to add hook to ~/.claude/settings.json
369+
```
370+
371+
### Manual Install (Fallback)
372+
373+
If `rtk init -g` doesn't work for your setup:
346374

347375
```bash
348376
# 1. Copy the hook script

docs/TROUBLESHOOTING.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,28 @@ cat ~/.claude/CLAUDE.md | grep rtk
123123
cat ./CLAUDE.md | grep rtk
124124
```
125125

126-
**4. Optional: Install auto-rewrite hook (recommended):**
126+
**4. Install auto-rewrite hook (recommended for automatic RTK usage):**
127+
128+
**Option A: Automatic (recommended)**
129+
```bash
130+
rtk init -g
131+
# → Installs hook + RTK.md automatically
132+
# → Follow printed instructions to add hook to ~/.claude/settings.json
133+
# → Restart Claude Code
134+
135+
# Verify installation
136+
rtk init --show # Should show "✅ Hook: executable, with guards"
137+
```
138+
139+
**Option B: Manual (fallback)**
127140
```bash
128141
# Copy hook to Claude Code hooks directory
129142
mkdir -p ~/.claude/hooks
130143
cp .claude/hooks/rtk-rewrite.sh ~/.claude/hooks/
131144
chmod +x ~/.claude/hooks/rtk-rewrite.sh
132145
```
133146

134-
Then add to `~/.claude/settings.json`:
147+
Then add to `~/.claude/settings.json` (replace `~` with full path):
135148
```json
136149
{
137150
"hooks": {
@@ -141,7 +154,7 @@ Then add to `~/.claude/settings.json`:
141154
"hooks": [
142155
{
143156
"type": "command",
144-
"command": "~/.claude/hooks/rtk-rewrite.sh"
157+
"command": "/Users/yourname/.claude/hooks/rtk-rewrite.sh"
145158
}
146159
]
147160
}
@@ -150,6 +163,8 @@ Then add to `~/.claude/settings.json`:
150163
}
151164
```
152165

166+
**Note**: Use absolute path in `settings.json`, not `~/.claude/...`
167+
153168
---
154169

155170
## Problem: "command not found: rtk" after installation

0 commit comments

Comments
 (0)