Skip to content

rtk: fleet install + chezmoi-managed config with dialed-back hook filters#8

Draft
simshanith wants to merge 2 commits into
mainfrom
simshanith/rtk
Draft

rtk: fleet install + chezmoi-managed config with dialed-back hook filters#8
simshanith wants to merge 2 commits into
mainfrom
simshanith/rtk

Conversation

@simshanith

Copy link
Copy Markdown
Owner

What

Two commits making rtk consistent across the fleet:

  1. 8abb636 (pre-existing on this branch): rtk installs via the committed mise baseline; one-time rtk init -g documented in 2026_REFRESH.md.
  2. 27333d0: rtk's config is now chezmoi-managed — one shared template (.chezmoitemplates/rtk-config.toml) rendered to ~/.config/rtk/config.toml on linux and ~/Library/Application Support/rtk/config.toml on darwin (rtk hard-wires the Library path and ignores XDG on macOS — verified empirically). The unused path is suppressed per-OS in .chezmoiignore. Both entries are .tmpl so symlink-mode chezmoi writes real files; sandboxed rtk invocations must be able to read the config (same ELOOP lesson as ~/.gitattributes).

Why the dialed-back filters

Analysis of rtk's history DB (1,498 commands) + Claude session transcripts:

  • 66% of rtk calls saved zero tokens; savings concentrate in read/ls/ps/vitest/gh/git-commit (~665K of 702K lifetime).
  • rtk grep backends to BSD grep on macOS (even with ripgrep on PATH) and swallows its usage errors with exit 0 → silent empty results; caused a real derailment (rg --glob in a dep-upgrade session). grep was also 254/287 of all hook parse failures. Lifetime savings: 6.1K.
  • rtk curl: 2 tokens saved on 138K input.
  • rtk diff: failed to parse 28 of 36 calls; condensing strips hunk context.
  • rtk git compact filters stripped needed output (e.g. git stash SHA → extra rev-parse round-trip), so git is restricted to commit/fetch (88%/66% avg savings) via transparent_prefixes.

Verify any rewrite decision with rtk hook check "<cmd>".

Verification

  • chezmoi diff --source <worktree> against the live darwin config: empty (byte-identical render, apply is a no-op on this machine).
  • chezmoi managed: Library chain managed with matching perms (no chmod churn); .config/rtk correctly ignored on darwin.
  • Hook matrix via rtk hook check: rg/grep/curl/diff + non-commit/fetch git pass through; commit/fetch/ls/gh/ps/vitest still rewrite.

rtk (token-optimizing Claude Code proxy) now installs fleet-wide via the
committed mise baseline instead of machine-local config.toml, so a fresh
checkout gets it. Document the one-time `rtk init -g` step in 2026_REFRESH.md;
left manual since it writes to ~/.claude/ (unmanaged by chezmoi).
One shared template (.chezmoitemplates/rtk-config.toml) rendered to
~/.config/rtk/ on linux and ~/Library/Application Support/rtk/ on darwin
(rtk ignores XDG there); the unused path is suppressed per-OS in
.chezmoiignore. Entries are .tmpl so symlink mode writes real files —
sandboxed rtk must read its own config (same lesson as ~/.gitattributes).

The config itself dials the hook back to where filtering pays off:
- exclude rg/grep/curl/diff: rtk grep backends to BSD grep and swallows
  its errors with exit 0 (silent empty results); grep was 254/287 of all
  parse failures; curl saved 2 tokens on 138K input; diff failed to
  parse 28 of 36 calls and strips hunk context
- git restricted to commit/fetch (88%/66% avg savings) via
  transparent_prefixes: compact filters stripped needed output, e.g.
  git stash SHAs, forcing follow-up rev-parse calls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant