Meet NanoCo, maintainers of NanoClaw: we raised $12M to give every member of your team a professional assistant →
Skills
Infrastructure Official

rtk Token Compression

Install the rtk proxy into agent containers to cut token usage on common dev commands by 60–90%.

What it does

  • Routes container Bash calls through rtk for 60–90% token savings
  • Compresses output from git, cargo, pytest, docker, kubectl, and more
  • Wires in transparently via a Claude Code PreToolUse hook — no CLAUDE.md changes
  • Mounts the rtk binary read-only into the target agent group's containers
  • Re-runnable — replaces existing mounts and hooks instead of duplicating them
  • Reports savings with `rtk gain`

What you'll need

  • NanoClaw installed and running
  • At least one agent group (find IDs with `ncl groups list`)

Install

/add-rtk

How it works

rtk is a CLI proxy that shrinks the output of common dev commands — git, cargo, pytest, docker, kubectl, and others — before it reaches the model, delivering 60–90% token savings. The /add-rtk skill installs it on the host and wires it into a target agent group’s containers so every Bash call the agent makes is filtered through rtk automatically.

The integration has three pieces. The rtk binary lives at ~/.local/bin/rtk on the host and is mounted read-only at /usr/local/bin/rtk inside the container. A PreToolUse hook in the agent group’s settings.json runs rtk hook claude on every Bash call, so interception is transparent — there are no CLAUDE.md instructions to maintain and the agent doesn’t need to know rtk exists.

Setup

The skill installs rtk from its upstream install script:

curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh

It confirms the binary landed at ~/.local/bin/rtk (moving and chmod +x-ing it if the installer put it elsewhere), then verifies with ~/.local/bin/rtk --version.

Next it identifies the target group with ncl groups list and applies two changes per group. The mount is added to the additional_mounts JSON array on the container_configs row: the skill reads the current value, drops any existing entry for /usr/local/bin/rtk, appends the rtk mount, and writes the merged array back. The hook is added to data/v2-sessions/<group-id>/.claude-shared/settings.json — mounted at /home/node/.claude/settings.json inside the container — using jq to remove any prior rtk hook claude Bash hook before appending a fresh one. Both edits are built to be idempotent, so re-running the skill replaces rather than duplicates.

Finally it restarts the container so the new mount and hook take effect:

ncl groups restart --id <group-id>

Verifying and tips

  • Confirm the binary is live inside the container before relying on the hook:

    docker exec "$(docker ps --filter "name=<group-id>" --format '{{.Names}}' | head -1)" rtk --version

    Checking --version here surfaces a missing or non-executable mount immediately, instead of letting it fail silently as a broken hook.

  • Once wired, ask the agent to run something like git status — rtk intercepts it silently. Track cumulative savings with ~/.local/bin/rtk gain.

  • Apply the skill to each agent group separately; the mount and hook are per-group, so a new group won’t inherit rtk automatically.

  • If you see rtk: command not found inside the container, the mount wasn’t applied or the container wasn’t restarted — check additional_mounts for the /usr/local/bin/rtk entry and restart the group.

  • If the hook isn’t firing, inspect .hooks.PreToolUse in the group’s settings.json and re-add the hook if it’s missing.

  • A permission denied on the binary is fixed with chmod +x ~/.local/bin/rtk.