Files
rtk-ai__rtk/hooks/copilot/rtk-awareness.md
T
Adrien Eppling a1673f7428 docs: scope savings claims to bash output and document the estimator
RTK was documented as delivering "60-90% token savings", which reads as a
cost reduction. What RTK actually reduces is bash output bytes. Those are
one contributor to input tokens, which are themselves only part of a bill
that also counts output tokens, so the reduction dilutes at every step.

- add docs/guide/resources/savings-explained.md as the canonical explainer:
  the savings chain, both estimators, and what RTK does not reduce
- rescope the headline claim across README (7 languages), the guide, hook
  rules, agent definitions and module READMEs
- relabel per-command tables as bash output reduction, keeping every figure
- document that reported tokens are estimates: rtk gain uses bytes/4
  (src/core/tracking.rs), filter tests use split_whitespace().count().
  Neither is a real tokenizer, so ratios hold but absolute counts do not

Remove figures that had no source: the $3/Mtok constant and its $36
example, the +/-10% tokenization accuracy claim, the 99.5% hook-install
figure, the invented session tables in README and INSTALL, and the 30-50%
parser range.

CHANGELOG is untouched. Shipped release notes stay as a historical record.
2026-07-22 18:33:54 +02:00

3.2 KiB

RTK — Copilot Integration (VS Code Copilot Chat + Copilot CLI)

Usage: Token-optimized CLI proxy (cuts up to 90% of bash output)

What's automatic

The .github/copilot-instructions.md file is loaded at session start by both Copilot CLI and VS Code Copilot Chat. It instructs Copilot to prefix commands with rtk automatically.

The .github/hooks/rtk-rewrite.json hook adds a PreToolUse safety net via rtk hook — a cross-platform Rust binary that intercepts raw bash tool calls and rewrites them. No shell scripts, no jq dependency, works on Windows natively.

Meta commands (always use directly)

rtk gain              # Token savings dashboard for this session
rtk gain --history    # Per-command history with savings %
rtk discover          # Scan session history for missed rtk opportunities
rtk proxy <cmd>       # Run raw (no filtering) but still track it

Installation verification

rtk --version   # Should print: rtk X.Y.Z
rtk gain        # Should show a dashboard (not "command not found")
which rtk       # Verify correct binary path

⚠️ Name collision: If rtk gain fails, you may have reachingforthejack/rtk (Rust Type Kit) installed instead. Check which rtk and reinstall from rtk-ai/rtk.

How the hook works

rtk hook reads PreToolUse JSON from stdin, detects the agent format, and responds appropriately:

VS Code Copilot Chat (supports updatedInput — transparent rewrite, no denial):

  1. Agent runs git statusrtk hook intercepts via PreToolUse
  2. rtk hook detects VS Code format (tool_name/tool_input keys)
  3. Returns hookSpecificOutput.updatedInput.command = "rtk git status"
  4. Agent runs the rewritten command silently — no denial, no retry

GitHub Copilot CLI (deny-with-suggestion — CLI ignores updatedInput today, see issue #2013):

  1. Agent runs git statusrtk hook intercepts via PreToolUse
  2. rtk hook detects Copilot CLI format (toolName/toolArgs keys)
  3. Returns permissionDecision: deny with reason: "Token savings: use 'rtk git status' instead"
  4. Copilot reads the reason and re-runs rtk git status

When Copilot CLI adds updatedInput support, only rtk hook needs updating — no config changes.

Integration comparison

Tool Mechanism Hook output File
Claude Code PreToolUse hook with updatedInput Transparent rewrite hooks/rtk-rewrite.sh
VS Code Copilot Chat PreToolUse hook with updatedInput Transparent rewrite .github/hooks/rtk-rewrite.json
GitHub Copilot CLI PreToolUse deny-with-suggestion Denial + retry .github/hooks/rtk-rewrite.json
OpenCode Plugin tool.execute.before Transparent rewrite hooks/opencode-rtk.ts
(any) Custom instructions Prompt-level guidance .github/copilot-instructions.md