Replies: 1 comment
-
|
I hit this exact problem and built a working PowerShell workaround. Sharing it here in case it helps others (or informs PR #150). The workaroundA PowerShell script as a PreToolUse hook that bypasses all three Unix dependencies (no bash, no jq, no POSIX permissions). PowerShell's Hook script:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Context: What
rtk init --globaldoes on UnixWhen you run
rtk init --globalon macOS or Linux, RTK sets up a full system-levelintegration with Claude Code. Four things happen:
~/.claude/settings.jsonis updated with aPreToolUsehook entry:{ "hooks": { "PreToolUse": [{ "matcher": "Bash", "hooks": [{ "type": "command", "command": "~/.claude/hooks/rtk-rewrite.sh" }] }] } }This tells Claude Code: before executing any Bash command, run this hook first.
~/.claude/hooks/rtk-rewrite.shis created — the hook script that interceptsevery command Claude Code is about to run, rewrites it through RTK if applicable,
and returns the rewritten command transparently.
~/.claude/RTK.mdis created — a slim (10-line) awareness file describingRTK's meta commands (
rtk gain,rtk discover, etc.).~/.claude/CLAUDE.mdis updated with a reference@RTK.md, so Claude Codeautomatically loads the awareness file in every session.
The result: command rewriting is enforced at the system level. When Claude Code
issues
git status, the hook intercepts it and silently rewrites it tortk git statusbefore it ever executes. The LLM has no role in this — it happens unconditionally.
What happens on Windows
Running
rtk init --globalon Windows produces:Only CLAUDE.md is updated. It receives a full ~137-line block of instructions
telling Claude to always prefix commands with
rtk. Steps 1, 2, and 3 above areskipped entirely — no hook, no
settings.jsonupdate, noRTK.md.This means on Windows, RTK relies entirely on the LLM reading the CLAUDE.md instructions
and choosing to follow them. There is no system-level enforcement. Claude may prefix
commands correctly most of the time, but it is not guaranteed — the model can forget,
deprioritize the instruction under long context, or simply not apply it consistently.
Why the hook cannot be installed on Windows
The hook mechanism has three Unix-specific dependencies that have no native Windows equivalent:
Bash —
rtk-rewrite.shis a bash script. Windows has no native bash shell.Git Bash and WSL exist, but they are not guaranteed to be present or configured
in the environment where Claude Code runs hooks.
jq— the hook script usesjqto parse and build the JSON that Claude Code'sPreToolUseprotocol requires.jqis not available by default on Windows.Unix file permissions (
chmod 755) — the hook file must be executable.Setting executable permissions uses
std::os::unix::fs::PermissionsExt, a Rusttrait that is only available on Unix targets and does not compile on Windows at all.
Because of these three blockers, the hook installer in
src/init.rsis gated behind#[cfg(unix)]. The non-Unix code path warns and falls back to CLAUDE.md injection,which is the only mechanism that works cross-platform today.
Work in progress
There is an open pull request actively working on a solution to this limitation:
PR #150 — Windows-native hook support
The reliability gap
rtk init --globalPreToolUsehook — OS-level interceptionrtk init --globalWindows users get the awareness of RTK but not the enforcement. The token savings
RTK promises (60-90%) depend on consistent command rewriting — which is only
guaranteed in hook mode.
Beta Was this translation helpful? Give feedback.
All reactions