‹ 首页

add-rtk

@nanocoai · 收录于 3 周前 · 上游提交 2 天前

Install rtk token-compression proxy into agent containers. Routes Bash tool calls through rtk for 60–90% token savings on dev commands (git, cargo, pytest, docker, kubectl, etc.).

适合你,如果使用 AI 辅助开发且想减少令牌消耗

/ 下载安装
add-rtk.skill双击,或拖进 Claude 桌面版 / Cowork,即完成安装↓ .skill↓ .zip
用别的 agent?下载 .zip 解压,把文件夹放进它的技能目录
Claude Code~/.claude/skills/(项目级 .claude/skills/)
Codex CLI~/.codex/skills/
Cursor自动读取上面两处目录
其他工具见其文档的「skills」目录;两个下载是同一份文件,只是名字不同
/ 通过 npx 安装 校验哈希
npx oh-my-skill add nanocoai/nanoclaw/add-rtk
/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- nanocoai/nanoclaw/add-rtk
/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify nanocoai/nanoclaw/add-rtk
安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
30380GitHub stars
~1.1K最小装载
~1.4K含声明引用
~1.4K文本包总量
镜像托管

怎么用

商店整理自技能原文 · 版本 879835b · 表述以原文为准
它做什么

安装后,Claude 在执行 Bash 工具调用(如 git、cargo、pytest、docker、kubectl 等开发命令)时,会自动通过 rtk 代理压缩 Token 消耗,通常可节省 60–90% 的 Token。

什么时候触发

当 Claude 通过 Bash 工具执行开发命令(如 git、cargo 等)时触发,无需用户额外指示。

装好后可以这样说
rtk 会自动拦截并压缩输出。
构建输出被压缩,节省 Token。
docker ps 经过 rtk 处理。
技能原文 SKILL.md作者撰写 · MIT · 879835b

Add rtk

Install rtk — a CLI proxy delivering 60–90% token savings on common dev commands (git, cargo, pytest, docker, kubectl, etc.) — and wire it transparently into agent containers via the Claude Code PreToolUse hook.

What this sets up
  • rtk binary at ~/.local/bin/rtk on the host
  • ~/.local/bin/rtk mounted read-only at /usr/local/bin/rtk inside the target agent group's containers
  • PreToolUse hook in the agent group's settings.json so every Bash call is automatically filtered through rtk — no CLAUDE.md instructions needed
Integration tests

This skill has no in-tree integration test by design. Its only functional reach-ins are runtime operator actions — the host-only ncl groups config add-mount (Step 3) and the settings.json PreToolUse hook write (Step 4) — neither of which leaves a line in the source tree whose deletion a test could catch. There are no package dependencies or Dockerfile edits to guard either. Conformance is idempotent apply + REMOVE.md; the mount and hook are verified at runtime (see Verify).

Step 1 — Install rtk on the host
curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh

If the script put the binary elsewhere, move it:

find ~/.local ~/.cargo/bin ~/bin -name rtk 2>/dev/null
mv "$(which rtk 2>/dev/null)" ~/.local/bin/rtk

Verify:

~/.local/bin/rtk --version
chmod +x ~/.local/bin/rtk   # if needed
Step 2 — Identify the target agent group
ncl groups list

Note the group ID (e.g. ag-1776342942165-ptgddd). Repeat Steps 3–5 for each group.

Step 3 — Mount rtk into the container config

Mount the host rtk binary read-only into the container with the host-only add-mount verb. It is idempotent — re-running skips the entry if it is already present:

ncl groups config add-mount --id <group-id> \
  --host ~/.local/bin/rtk \
  --container /usr/local/bin/rtk \
  --ro

This verb is operator-only and runs host-side (via /setup, /customize, or /manage-mounts); it is rejected from inside a container.

The host root (~/.local/bin) must also be in the external mount allowlist at ~/.config/nanoclaw/mount-allowlist.json for the mount to take effect at spawn. Add it there if it isn't already.

Verify:

ncl groups config get --id <group-id>
# Look for the /usr/local/bin/rtk mount
Step 4 — Add the PreToolUse hook to settings.json

Each agent group has a settings.json at:

data/v2-sessions/<group-id>/.claude-shared/settings.json

This file is mounted at /home/node/.claude/settings.json inside the container and is read by Claude Code for hooks, env, and model config.

Add the PreToolUse entry with jq. This drops any existing rtk Bash hook first, then appends a fresh one, so it is safe to re-run without creating duplicates:

SETTINGS="data/v2-sessions/<group-id>/.claude-shared/settings.json"

jq '.hooks.PreToolUse = ((.hooks.PreToolUse // [])
      | map(select((.hooks // []) | any(.command == "rtk hook claude") | not)))
    + [{"matcher":"Bash","hooks":[{"type":"command","command":"rtk hook claude"}]}]' \
  "$SETTINGS" > /tmp/rtk-settings.json && mv /tmp/rtk-settings.json "$SETTINGS"
Step 5 — Restart the container
ncl groups restart --id <group-id>
Verify

Confirm the binary is executable inside the container so a missing or non-executable mount surfaces immediately rather than as a silent hook failure:

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

Then ask the agent to run git status or any other supported command. rtk intercepts it silently. Check savings with:

~/.local/bin/rtk gain
Troubleshooting
rtk: command not found inside the container

Mount wasn't applied or container wasn't restarted:

ncl groups config get --id <group-id>
# Look for the /usr/local/bin/rtk mount
ncl groups restart --id <group-id>
Hook not firing

Verify the hook is in settings.json:

jq '.hooks.PreToolUse' data/v2-sessions/<group-id>/.claude-shared/settings.json

If missing, re-run Step 4.

Binary won't execute — permission denied
chmod +x ~/.local/bin/rtk
按 MIT 许可原样转载,未经改动 · 在 GitHub 查看 →

评论

登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。