hooks/copilot/rtk-awareness.md
Usage: Token-optimized CLI proxy (60-90% savings on dev operations)
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.
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
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 gainfails, you may havereachingforthejack/rtk(Rust Type Kit) installed instead. Checkwhich rtkand reinstall from rtk-ai/rtk.
rtk hook reads PreToolUse JSON from stdin, detects the agent format, and responds appropriately:
VS Code Copilot Chat (supports updatedInput — transparent rewrite, no denial):
git status → rtk hook intercepts via PreToolUsertk hook detects VS Code format (tool_name/tool_input keys)hookSpecificOutput.updatedInput.command = "rtk git status"GitHub Copilot CLI (deny-with-suggestion — CLI ignores updatedInput today, see issue #2013):
git status → rtk hook intercepts via PreToolUsertk hook detects Copilot CLI format (toolName/toolArgs keys)permissionDecision: deny with reason: "Token savings: use 'rtk git status' instead"rtk git statusWhen Copilot CLI adds updatedInput support, only rtk hook needs updating — no config changes.
| 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 |