feat(rtk): add an rtk plugin whose Claude Code hook routes Bash calls through rtk when it is installed #179

Open
opened 2026-11-20 18:40:29 +00:00 by Claude · 0 comments
Owner

What

Add a new plugin, plugins/rtk, holding one hook primitive that a consumer deploys with apm install (Claude target: merged into .claude/settings.json, ownership recorded in .claude/apm-hooks.json). On a PreToolUse call with matcher Bash, it runs:

command -v rtk >/dev/null 2>&1 && exec rtk hook claude || exit 0

With rtk on PATH, the call is rewritten by rtk; without it, the hook exits 0 and the command runs as typed.

Why

Consumers that make rtk a required tool need its hook in the tracked project settings. A hand-written hook entry there is owned by nothing: since apm-cli 0.29.0, apm audit --ci compares only apm-owned hook entries, so it neither flags nor protects a hand-written one. Shipped as a primitive, apm owns the entry and the audit checks that it is present and unaltered. A separate plugin keeps it opt-in per repository and keeps plugins/git about git.

Notes

  • Executable primitive: consumers allow it with apm approve and commit the executables entry in their apm.yml; say so in the plugin README.
  • The guard is required: the hook must be harmless on a machine without rtk.
  • No rtk init of any kind in the plugin: a project-level rtk init writes a CLAUDE.md, and a global rtk init -g is the user's own choice.
  • Test with rtk present (a git status call is rewritten; rtk hook check or a live session) and absent (unchanged, exit 0). Say in the README what happens when the user also has a global rtk init -g hook: if the two double-wrap a command, document how to detect it (rtk init --show).
  • A consumer that hand-writes a byte-identical entry next to the deployed one gets "ambiguous duplicate APM-owned hook entry" from apm audit (read in apm-cli 0.36.1); mention it in the README.
  • rtk hook claude exists in rtk 0.42.4; state the minimum rtk version the hook was tested with.
## What Add a new plugin, `plugins/rtk`, holding one hook primitive that a consumer deploys with `apm install` (Claude target: merged into `.claude/settings.json`, ownership recorded in `.claude/apm-hooks.json`). On a `PreToolUse` call with matcher `Bash`, it runs: ```sh command -v rtk >/dev/null 2>&1 && exec rtk hook claude || exit 0 ``` With `rtk` on `PATH`, the call is rewritten by `rtk`; without it, the hook exits 0 and the command runs as typed. ## Why Consumers that make `rtk` a required tool need its hook in the tracked project settings. A hand-written hook entry there is owned by nothing: since apm-cli 0.29.0, `apm audit --ci` compares only apm-owned hook entries, so it neither flags nor protects a hand-written one. Shipped as a primitive, apm owns the entry and the audit checks that it is present and unaltered. A separate plugin keeps it opt-in per repository and keeps `plugins/git` about git. ## Notes - Executable primitive: consumers allow it with `apm approve` and commit the `executables` entry in their `apm.yml`; say so in the plugin README. - The guard is required: the hook must be harmless on a machine without `rtk`. - No `rtk init` of any kind in the plugin: a project-level `rtk init` writes a `CLAUDE.md`, and a global `rtk init -g` is the user's own choice. - Test with `rtk` present (a `git status` call is rewritten; `rtk hook check` or a live session) and absent (unchanged, exit 0). Say in the README what happens when the user also has a global `rtk init -g` hook: if the two double-wrap a command, document how to detect it (`rtk init --show`). - A consumer that hand-writes a byte-identical entry next to the deployed one gets "ambiguous duplicate APM-owned hook entry" from `apm audit` (read in apm-cli 0.36.1); mention it in the README. - `rtk hook claude` exists in `rtk` 0.42.4; state the minimum `rtk` version the hook was tested with.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mortis/Holocron#179