# Rtk Rewrite

> RTK rewrite plugin for OpenClaw. Intercepts exec tool calls and delegates rewrites to rtk rewrite to reduce token usage while preserving command intent.

- Skill: `luw2007/rtk-rewrite` (Agent Skill, multi-file: 5 files)
- Install (CLI): `npx skillmds@latest add luw2007/rtk-rewrite`
- Raw SKILL.md: https://api.skillmd.com/api/skills/luw2007/rtk-rewrite/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- License: MIT
- Author: luw2007 (https://skillmd.com/u/luw2007)
- Updated: 2026-09-10
- Page: https://skillmd.com/skills/luw2007/rtk-rewrite

---


# 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

`rtk` must be installed and available in `PATH`.

```bash
brew install rtk-ai/tap/rtk
```

## Install Plugin Files

Copy plugin files to the OpenClaw extensions directory:

```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
```

## Configuration

- `enabled`: Enables rewrite behavior. Default `true`.
- `verbose`: Prints rewrite logs to console. Default `false`.
- `audit`: Writes hook-style audit logs. Default `false`.
- `auditDir`: Optional audit directory. Falls back to `RTK_AUDIT_DIR` or `~/.local/share/rtk`.

## Verification

```bash
rtk rewrite "git status"
rtk hook-audit --since 7 -v
```

