rtk-ai/rtk

Hook rewrite: add coverage for uv run, pnpm exec, Python path variants, and more

Open

#294 opened on 2026年3月1日

GitHub で見る
 (3 comments) (7 reactions) (0 assignees)Rust (2,914 forks)batch import
area:clieffort-mediumenhancementhelp wantedpriority:medium

Repository metrics

Stars
 (48,085 stars)
PR merge metrics
 (平均マージ 11d 1h) (30d で 45 merged PRs)

説明

Analyzed rtk discover output across 429 sessions (3,754 Bash commands) and identified ~727 missed commands that RTK already has subcommands for
but the hook script wasn't intercepting.

Updated rtk-rewrite.sh to cover all these patterns. Full test suite (55 cases) passing with zero regressions.


uv run dispatch — 378 commands (highest impact)

uv run ruff check/format ... → rtk ruff check/format ... uv run pytest ... → rtk pytest ... uv run python -m ruff check/format ... → rtk ruff check/format ... uv run python -m pytest ... → rtk pytest ... uv run mypy ... → rtk err uv run mypy ...

pnpm exec dispatch — 89 commands

pnpm exec vue-tsc --noEmit → rtk tsc --noEmit pnpm exec eslint ... → rtk lint ... pnpm exec prettier ... → rtk prettier ... pnpm exec vitest [run] → rtk vitest run

pnpm script commands — 74 commands

pnpm type-check → rtk err pnpm type-check pnpm build → rtk err pnpm build pnpm add/install/remove → rtk pnpm add/install/remove

Python path variants — 150+ commands

Previously only pytest, .venv/bin/pytest, python -m pytest, and ruff check/format were handled. Now also covers:

api/.venv/bin/python -m ruff check ... → rtk ruff check ... api/.venv/bin/python -m pytest ... → rtk pytest ... python3 -m ruff check/format ... → rtk ruff check/format ... .venv/bin/ruff check/format ... → rtk ruff check/format ... api/.venv/bin/ruff check/format ... → rtk ruff check/format ... mypy ... → rtk err ... python -m mypy ... → rtk err ... .venv/bin/python -m mypy ... → rtk err ...

uv sync — 10 commands

uv sync → rtk err uv sync

head -n fix (missing variant)

head -n 50 file → rtk read file --max-lines 50 head -n50 file → rtk read file --max-lines 50

Previously only head -50 file and head --lines=50 file were handled.


Testing

55 test cases (15 regression + 40 new), all passing:

  • All new patterns with real-world command examples
  • Edge cases: env var prefixes (PYTHONPATH=... uv run ruff), cd && cmd chains, heredoc skipping
  • No regressions on existing patterns

Estimated impact

Based on rtk discover data (30-day window):

  • ~727 additional commands would be intercepted
  • Biggest wins: uv run (378), Python path variants (150+), pnpm exec (89), pnpm type-check/build (74)

Environment

  • RTK version: 0.22.2
  • Hook mechanism: Claude Code PreToolUse:Bash hook via settings.json

🤖 Hook analysis, implementation, and test suite generated with https://claude.ai/code.

コントリビューターガイド