Skip to main content

Overview

Initializes RTK integration with Claude Code. Creates hook for automatic command rewriting, adds awareness documentation, and patches settings.json.

Syntax

Options

Installation Modes

flag
Install globally in ~/.claude/ (recommended)Creates:
  • Hook: ~/.claude/hooks/rtk-rewrite.sh
  • Docs: ~/.claude/RTK.md
  • Reference: @RTK.md in ~/.claude/CLAUDE.md
  • Settings: Hook entry in ~/.claude/settings.json
flag
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
flag
Install only the hook, skip RTK.md creationUse when:
  • You want command rewriting but not meta-command awareness
  • Minimalist setup

settings.json Patching

flag
Automatically patch settings.json without prompting
flag
Skip settings.json patching, print manual instructions instead

Other Options

flag
Display current RTK configuration status (doesn’t modify anything)
flag
Remove all RTK artifacts:
  • Hook file
  • RTK.md
  • @RTK.md reference from CLAUDE.md
  • settings.json hook entry

Installation Modes

Default (Global)

Creates:
  1. ~/.claude/hooks/rtk-rewrite.sh (executable)
  2. ~/.claude/RTK.md (10-line awareness doc)
  3. @RTK.md reference in ~/.claude/CLAUDE.md
  4. Hook entry in ~/.claude/settings.json (with prompt)
Behavior:
  • 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)

Same as default but skips settings.json prompt.

Manual Patch (Print Instructions)

Creates hook and RTK.md but prints manual settings.json instructions instead of patching.

Local (Project-specific)

Injects full RTK instructions into ./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)

Installs only the rewrite hook. Claude won’t know about meta-commands (gain, discover, proxy) but will rewrite raw commands to RTK.

Legacy (Full Injection)

Injects 137-line RTK instructions directly into ~/.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:
  1. Checks if rtk is installed (command -v rtk)
  2. Checks if jq is installed (for JSON parsing)
  3. Rewrites raw commands to RTK equivalents:
    • git status → rtk git status
    • cargo test → rtk cargo test
    • ls -la → rtk ls -la
  4. Preserves unsupported commands unchanged
  5. Gracefully falls back if RTK/jq missing
Guards:
  • Runs before set -euo pipefail to avoid crashes on missing deps
  • Fails silently if RTK not installed
  • Preserves original command if rewrite fails
Integrity:
  • SHA-256 hash stored on install
  • Runtime verification via rtk verify
  • Prevents tampering

settings.json Structure

RTK adds this entry to ~/.claude/settings.json:
Merging:
  • Preserves existing hooks and settings
  • Appends to PreToolUse array (doesn’t replace)
  • Idempotent (won’t add duplicate entries)

Output Examples

Successful Install

Migration

Show Config

Uninstall

Platform Support

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 - Success
  • 1 - Error (permission denied, invalid config, etc.)
  • rtk verify - Verify hook integrity
  • rtk config - View/edit RTK configuration
  • rtk gain - View token savings