Skip to content

Refresh RTK integration: migrate to rtk hook claude + ship Python worktree.yaml#1

Merged
SDDKKK merged 3 commits into
mainfrom
overlay/rtk-integration-refresh
Apr 23, 2026
Merged

Refresh RTK integration: migrate to rtk hook claude + ship Python worktree.yaml#1
SDDKKK merged 3 commits into
mainfrom
overlay/rtk-integration-refresh

Conversation

@SDDKKK
Copy link
Copy Markdown
Owner

@SDDKKK SDDKKK commented Apr 23, 2026

Summary

  • Migrates all 9 RTK hook references (8 subagents + settings.overlay.json) from the legacy $HOME/.claude/hooks/rtk-rewrite.sh wrapper to the current rtk hook claude direct-binary API. The wrapper stopped shipping with rtk 0.37.x, so every subagent Bash call in Hiskens projects has been running raw — rtk discover measured 0.2% coverage across 12357 commands in the last 30 days.
  • Ships a Python/MATLAB default worktree.yaml at overlays/hiskens/templates/trellis/worktree.yaml. It lands in consumer projects via the WORKFLOW_OVERLAY_TARGETS mechanism (configurators/index.ts:L301-303), overriding the base pnpm-oriented template. Comes with commented rtk ruff / uv run pytest verify examples for Python and a MATLAB variant; leaves the block commented so non-Python dev_types (matlab, trellis, test, docs) aren't broken.
  • Adds overlays/hiskens/RTK-INTEGRATION.md as a maintainer-facing doc next to MAINTENANCE.md. Records the hook API migration history, preferred command shapes (rtk ruff preferred; uv run pytest stays until feat: add uv run support rtk-ai/rtk#1405 lands), the rationale for keeping verify: commented, and a maintainer checklist for future hook-wiring changes.

Why

The 0.2% RTK coverage was traced to the missing rtk-rewrite.sh referenced in overlay-shipped subagent frontmatters. Fixing only the hook API (commit 1) closes that gap for every existing and future Hiskens project. The worktree.yaml template (commit 2) removes the per-project need to rediscover the uv run ruff pain — new trellis init --overlay hiskens runs get Python-correct defaults out of the box.

The uv run pytestrtk pytest migration is intentionally deferred. pytest has no global binary in typical uv-managed Python projects, and rtk 0.37.2 does not yet unwrap uv run prefixes (open PR rtk-ai/rtk#1405 addresses this). RTK-INTEGRATION.md captures the follow-up action once that lands and is released.

Test plan

  • Sanity-test the hook migration by triggering a subagent Bash call in a Hiskens project running this overlay version; rtk gain should show subagent-sourced counts climbing (previously flat).
  • Run trellis init --overlay hiskens in a scratch directory and verify .trellis/worktree.yaml matches the new template (overlay layer winning over base).
  • Run trellis update on an existing Hiskens project and confirm the worktree.yaml diff is shown for review (non-destructive, per update.ts pipeline).
  • Verify grep -r "rtk-rewrite" overlays/hiskens/ returns empty.
  • Verify all 9 rtk hook references use rtk hook claude: grep -r "rtk hook claude" overlays/hiskens/ | wc -l should equal 9.

🤖 Generated with Claude Code

SDDKKK and others added 3 commits April 23, 2026 16:15
The 8 subagent frontmatters and settings.overlay.json referenced a
legacy `$HOME/.claude/hooks/rtk-rewrite.sh` shell wrapper that no
longer ships with rtk (0.37.2 replaced it with a direct `rtk hook
claude` binary command). Without the script file on disk, PreToolUse
hooks fail silently and every subagent Bash call runs raw — measured
via `rtk discover` as 0.2% RTK coverage across 12357 commands in the
last 30 days.

Aligns overlay hook targets with the current global settings.json
pattern (`"command": "rtk hook claude"`) used outside subagents.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Base Trellis ships a pnpm-oriented worktree.yaml template that leaves
Python projects to hand-craft verify commands — in practice every
Hiskens project ends up rewriting the same `uv run ruff check .` block.

This overlay template lands at `.trellis/worktree.yaml` via the
WORKFLOW_OVERLAY_TARGETS mechanism (applied after base template during
`trellis init` / `trellis update`). It ships Hiskens-correct defaults:

- `copy:` list expanded for multi-agent worktrees (scripts/spec/agents/
  hooks/skills all copied per worktree so subagent pipelines work).
- `verify:` block uses commented RTK-preferred examples for Python
  (`rtk ruff`) and MATLAB, with `uv run ruff` as fallback. Left
  commented because Hiskens dev_types include non-Python variants.
- `rtk ruff` is preferred because ruff has a global binary and RTK
  compresses its output. `uv run pytest` stays because pytest lives
  in the uv-managed env (no global binary); will migrate to
  `rtk uv run pytest` after rtk-ai/rtk#1405 lands.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Captures the current RTK hook contract (`rtk hook claude`), the migration
history away from the legacy `rtk-rewrite.sh` wrapper, the rationale
behind the commented verify: block in the new worktree.yaml template,
and the upstream rtk-ai/rtk#1405 dependency that will unblock
`rtk uv run pytest` once released.

Sits next to MAINTENANCE.md as maintainer-facing docs (not shipped to
consumer projects via the overlay template pipeline).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@SDDKKK SDDKKK merged commit b8a4df7 into main Apr 23, 2026
SDDKKK added a commit that referenced this pull request Apr 23, 2026
Adds two new pitfalls to fork-sync-guide.md's Common Pitfalls
section, captured from the 2026-04-23 Anhui_CIM sync:

- Pitfall 8: Syncing downstream from a stale fork main. `trellis
  update --overlay hiskens` reads overlay files from the fork's
  filesystem; if the local main is behind origin/main (e.g.
  after merging a PR on GitHub without `git pull`), the consumer
  gets a stale overlay. Measured case: Round 4 shipped partial
  state because local main sat at ef56d94 while origin/main had
  advanced to b8a4df7 (PR #1 merge).

- Pitfall 9: Trusting trellis update reports without hook-command
  verification. A single hook command line can silently stay on
  the old `/home/<user>/.claude/hooks/rtk-rewrite.sh` absolute
  path after an incorrectly keep-local triage decision. Added a
  2-second `grep -HnE '^\s*command:' .claude/agents/*.md` sanity
  check that catches this + the inverse (unexpected command lines).

Also adds two entries to the Anti-checklist: don't skip `git pull
--ff-only` before downstream sync; don't ship without grepping
agent command lines.

Task directory `.trellis/tasks/04-23-downstream-sync-round4/`
included with full execution log of Round 4 + 4b.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant