Documentation Index
Fetch the complete documentation index at: https://mintlify.com/rtk-ai/rtk/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Initializes RTK integration with Claude Code. Creates hook for automatic command rewriting, adds awareness documentation, and patches settings.json.Syntax
Options
Installation Modes
Install globally in
~/.claude/ (recommended)Creates:- Hook:
~/.claude/hooks/rtk-rewrite.sh - Docs:
~/.claude/RTK.md - Reference:
@RTK.mdin~/.claude/CLAUDE.md - Settings: Hook entry in
~/.claude/settings.json
Legacy mode: Full 137-line injection into CLAUDE.md (no hook)Use when:
- Windows (hooks require Unix)
- Prefer single-file setup
- Testing RTK before committing to hook
Install only the hook, skip RTK.md creationUse when:
- You want command rewriting but not meta-command awareness
- Minimalist setup
settings.json Patching
Automatically patch settings.json without prompting
Skip settings.json patching, print manual instructions instead
Other Options
Display current RTK configuration status (doesn’t modify anything)
Remove all RTK artifacts:
- Hook file
- RTK.md
- @RTK.md reference from CLAUDE.md
- settings.json hook entry
Installation Modes
Default (Global)
~/.claude/hooks/rtk-rewrite.sh(executable)~/.claude/RTK.md(10-line awareness doc)@RTK.mdreference in~/.claude/CLAUDE.md- Hook entry in
~/.claude/settings.json(with prompt)
- Prompts for settings.json consent (default: No)
- Idempotent (safe to run multiple times)
- Backs up settings.json before modification
- Stores SHA-256 hash for integrity checks
Auto-patch (No Prompt)
Manual Patch (Print Instructions)
Local (Project-specific)
./CLAUDE.md (no hook, no global config).
Use when:
- Working in a specific project
- Team wants RTK awareness in repo
- Don’t want global changes
Hook-only (Minimal)
gain, discover, proxy) but will rewrite raw commands to RTK.
Legacy (Full Injection)
~/.claude/CLAUDE.md (no hook, no RTK.md).
Use when:
- Windows (hooks require Unix)
- Prefer single-file setup
- Testing before committing to hook
Hook Behavior
The RTK rewrite hook (rtk-rewrite.sh) runs before every Bash tool use in Claude Code:
What it does:
- Checks if
rtkis installed (command -v rtk) - Checks if
jqis installed (for JSON parsing) - Rewrites raw commands to RTK equivalents:
git status→rtk git statuscargo test→rtk cargo testls -la→rtk ls -la
- Preserves unsupported commands unchanged
- Gracefully falls back if RTK/jq missing
- Runs before
set -euo pipefailto avoid crashes on missing deps - Fails silently if RTK not installed
- Preserves original command if rewrite fails
- SHA-256 hash stored on install
- Runtime verification via
rtk verify - Prevents tampering
settings.json Structure
RTK adds this entry to~/.claude/settings.json:
- Preserves existing hooks and settings
- Appends to
PreToolUsearray (doesn’t replace) - Idempotent (won’t add duplicate entries)
Output Examples
Successful Install
Migration
Show Config
Uninstall
Platform Support
| Platform | Hook Support | Recommended Mode |
|---|---|---|
| macOS | ✅ Yes | rtk init -g |
| Linux | ✅ Yes | rtk init -g |
| Windows | ❌ No | rtk init -g --claude-md |
| WSL | ✅ Yes | rtk init -g |
Idempotency
rtk init is safe to run multiple times:
- Checks if files already exist
- Compares content before overwriting
- Updates only if content changed
- Won’t duplicate settings.json entries
- Backs up before modifications
Exit Codes
0- Success1- Error (permission denied, invalid config, etc.)
Related Commands
rtk verify- Verify hook integrityrtk config- View/edit RTK configurationrtk gain- View token savings
