RTK Rewrite OpenClaw Plugin
This plugin hooks into OpenClaw's before_tool_call lifecycle:
- - Intercepts only
exec tool calls - Calls
rtk rewrite "<command>" to request a rewrite - Replaces the original command when a rewrite is available
- Supports optional audit logs compatible with Claude Code hook audit format
Prerequisites
INLINECODE3 must be installed and available in PATH.
CODEBLOCK0
Install Plugin Files
Copy plugin files to the OpenClaw extensions directory:
CODEBLOCK1
Configuration
- -
enabled: Enables rewrite behavior. Default true. - INLINECODE7 : Prints rewrite logs to console. Default
false. - INLINECODE9 : Writes hook-style audit logs. Default
false. - INLINECODE11 : Optional audit directory. Falls back to
RTK_AUDIT_DIR or ~/.local/share/rtk.
Verification
CODEBLOCK2
RTK 重写 OpenClaw 插件
该插件钩入 OpenClaw 的 beforetoolcall 生命周期:
- - 仅拦截 exec 工具调用
- 调用 rtk rewrite 请求重写
- 当有可用重写时替换原始命令
- 支持与 Claude Code 钩子审计格式兼容的可选审计日志
前置条件
rtk 必须已安装并可在 PATH 中使用。
bash
brew install rtk-ai/tap/rtk
安装插件文件
将插件文件复制到 OpenClaw 扩展目录:
bash
mkdir -p ~/.openclaw/extensions/rtk-rewrite
cp index.ts openclaw.plugin.json ~/.openclaw/extensions/rtk-rewrite/
openclaw config set plugins.entries.rtk-rewrite.enabled true
openclaw gateway restart
配置
- - enabled:启用重写行为。默认值为 true。
- verbose:将重写日志打印到控制台。默认值为 false。
- audit:写入钩子风格的审计日志。默认值为 false。
- auditDir:可选的审计目录。回退到 RTKAUDITDIR 或 ~/.local/share/rtk。
验证
bash
rtk rewrite git status
rtk hook-audit --since 7 -v