rtk-ai / rtk-ai/rtk

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

Open
#294 4 comments 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:cli effort-medium enhancement help wanted priority:medium
Dominant language
Rust
Stars
81.1k
Forks
5.1k
Avg merge
4d 21h
Merged PRs (30d)
35

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with rtk-rewrite.sh and the existing 55-case hook test suite; compare the listed uv, pnpm, Python-path, uv sync, and head -n patterns with current rewrites. Done means the 40 new cases and 15 regression cases pass, including env prefixes, command chains, heredocs, and existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
shell
Domain
cli, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.