rtk icon indicating copy to clipboard operation
rtk copied to clipboard

RTK.md template carries one-time setup content and a dangling reference

Open karldreher opened this issue 4 months ago • 4 comments

User Story

As a developer running rtk init, I want the generated RTK.md to contain only content that's useful every session, so that the always-loaded context rtk init installs into my Claude Code config doesn't carry one-time setup instructions and dead references on every single session.

Background

rtk init installs ~/.claude/RTK.md from the template at hooks/claude/rtk-awareness.md, and users are expected to @RTK.md-import it into their global CLAUDE.md — meaning its full contents are loaded into context on every session, not just once.

claude doctor surfaced two issues with this template:

  1. "Installation Verification" section is one-time content in an always-loaded file (lines 14–22):

    ## Installation Verification
    
    ​```bash
    rtk --version         # Should show: rtk X.Y.Z
    rtk gain              # Should work (not "command not found")
    which rtk             # Verify correct binary
    ​```
    
    ⚠️ **Name collision**: If `rtk gain` fails, you may have
    reachingforthejack/rtk (Rust Type Kit) installed instead.
    

    This is useful exactly once — right after install, to confirm rtk is on PATH and isn't shadowed by the unrelated reachingforthejack/rtk (Rust Type Kit) package. It has no relevance to any session after that, but because it lives in the always-imported RTK.md, every session pays the token cost of loading it.

  2. Dangling reference to a nonexistent section (line 29):

    Refer to CLAUDE.md for full command reference.
    

    The generated CLAUDE.md has no "full command reference" section for RTK — this line points at content that doesn't exist, so it's dead weight at best and misleading at worst.

Both were confirmed directly against the source template in this repo (hooks/claude/rtk-awareness.md), copied via src/hooks/init.rs — this isn't local drift in one user's file, it's present in what rtk init ships today.

Proposed Change

  • Remove the "Installation Verification" section from hooks/claude/rtk-awareness.md (and any other RTK.md templates that carry it, e.g. hooks/codex/, if applicable).
    • Alternative worth considering instead of outright deletion: move this content to INSTALL.md, or print it as part of rtk init's own command output, so the verification steps are still discoverable right after install without living in the always-loaded file. Leaving the exact approach to maintainer judgment.
  • Remove the dangling "Refer to CLAUDE.md for full command reference." line (line 29), or replace it with an accurate pointer if such a reference section is intended to exist elsewhere.

Acceptance Criteria

  • [ ] hooks/claude/rtk-awareness.md no longer contains the "Installation Verification" section (or it has been relocated out of the always-loaded template, per maintainer preference).
  • [ ] The dangling "Refer to CLAUDE.md for full command reference." line is removed or corrected.
  • [ ] A fresh rtk init regenerates ~/.claude/RTK.md without the removed section/line.
  • [ ] No other docs (README variants, hooks/*/README.md, etc.) reference the removed section in a way that would also go stale.

karldreher avatar Jul 30 '26 02:07 karldreher

wshm · Automated triage by AI

🔍 Automated Triage

📋 Category docs
🟢 Priority low
🎯 Confidence 90%

Summary

RTK.md template (hooks/claude/rtk-awareness.md) includes one-time install-verification content and a dangling 'refer to CLAUDE.md' reference that add token cost to every session; trim/relocate the section and fix or remove the dead reference.

This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.

📁 Relevant files
  • hooks/claude/rtk-awareness.md
  • hooks/codex/
  • src/hooks/init.rs

Triaged automatically by wshm · This is an automated analysis, not a human review.

pszymkowiak avatar Jul 30 '26 02:07 pszymkowiak

I would like to take this, but I found conflicting current state and want to avoid duplicating work.

PR #3322 implemented the acceptance criteria and was closed with the note that it duplicated #3308. However, #3308 is not accessible as either an issue or PR, current develop still contains both the one-time verification block and the dangling CLAUDE.md reference, and #3306 remains open with no linked active PR.

Is #3306 available for a new PR using the same narrow scope (Claude/Codex awareness templates plus a regression test), or is another change pending elsewhere?

koi-lee avatar Aug 01 '26 07:08 koi-lee

Reinforcing this from the delivery side rather than the template's content: on my machine the fixed template never arrives at all, so a corrected rtk-awareness.md would not reach an existing install.

Measured here:

rtk --version 0.45.0 (current release)
~/.claude/RTK.md mtime 2026-06-11
template last changed a1673f7, 2026-07-22 (docs: scope savings claims to bash output), first in the 0.44.0-rc line

The installed file still carries the pre-a1673f7 wording:

mine:     **Usage**: Token-optimized CLI proxy (60-90% savings on dev operations)
upstream: **Usage**: Token-optimized CLI proxy (cuts up to 90% of bash output)

So the file predates the template change by about six weeks and has not moved since, even though the binary is two minor versions further on.

The write logic itself is fine — src/hooks/init.rs:1163 does

write_if_changed(&rtk_md_path, RTK_SLIM, RTK_MD, ctx)?;

which would replace it correctly. It just only ever runs inside rtk init, and upgrading the binary does not re-run init. The practical effect is that ~/.claude/RTK.md pins to whatever release first installed it and then drifts silently — and because it is @RTK.md-imported into CLAUDE.md, that stale copy is loaded into every session.

That matters for this issue and for #2734 specifically: even once the one-time-setup block and the circular Refer to CLAUDE.md line are fixed in the template, existing installs keep the old text indefinitely unless the user happens to re-run rtk init — and nothing tells them to.

Two cheap options, either would close the gap:

  • embed the template hash in the binary and have the hook compare it on first use per session, printing a one-line RTK.md is from an older release — run \rtk init`` when it differs;
  • or have the upgrade path itself call the same write_if_changed, which is already idempotent and already prints nothing when the file matches.

Happy to test either against this install.

Filed with Claude Code; every figure above is from this machine.

HetCreep avatar Aug 11 '26 19:08 HetCreep

Reasonably accomplished with closure of https://github.com/rtk-ai/rtk/issues/3186.

karldreher avatar Sep 16 '26 03:09 karldreher