Skip to content

rtk init treats any mention of @RTK.md as the reference line: install adds none, Codex rewrites user prose, --show reports ok #4650

Done

Description

@KuSh

On install, rtk init treats any mention of @RTK.md in the user's instruction file as the RTK reference line. Uninstall now matches the exact trimmed line (#4405), but the install side and init --show still match a substring.

Reproduced in an isolated HOME on develop e542dca and on #4405's head:

  1. Claude, rtk init -g --auto-patch with ~/.claude/CLAUDE.md:

    # Mine
    
    @RTK.md is my notes file.
    

    The file is left unchanged and no @RTK.md line is added, so RTK.md is never loaded, yet the summary prints CLAUDE.md: @RTK.md reference added. Source: src/hooks/init/claude.rs:108 (content.contains(RTK_MD_REF)).

  2. Codex, rtk init -g --codex with ~/.codex/AGENTS.md:

    # Agents
    
    Read @RTK.md for details.
    

    The user's sentence becomes Read @/home/<user>/.codex/RTK.md for details., no reference line is added, and the summary prints AGENTS.md: @…/RTK.md reference added. Source: src/hooks/init/agents_md.rs:171-178 (contains + content.replace(RTK_MD_REF, rtk_md_ref) over the whole file).

  3. rtk init --show on the CLAUDE.md from case 1 reports [ok] Global (~/.claude/CLAUDE.md): @RTK.md reference. Source: src/hooks/init/mod.rs:2107.

  4. BOM-prefixed reference, rtk init -g --uninstall with ~/.claude/CLAUDE.md = \xEF\xBB\[email protected]\n, as a Windows editor may save it: RTK.md is deleted and the @RTK.md line stays, so it now points at a missing file. str::trim does not strip U+FEFF, so the exact-line predicate below misses it too. The same happens on develop.

The correct predicate already exists: has_rtk_reference (agents_md.rs:235) compares whole trimmed lines, and the uninstall paths use it. The relative-to-absolute migration in case 2 would need to replace only the matching line, not every occurrence.

Activity

  1. rtk-wshm-sync-bot commented on Oct 18, 2026

    @rtk-wshm-sync-bot

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟠 Priority high
    🎯 Confidence 95%

    Summary

    rtk init's install/--show/uninstall paths use substring matching for the @RTK.md reference instead of the existing whole-trimmed-line predicate, causing false-positive success reports, corrupted user prose (Codex), and BOM-unaware uninstall.

    📁 Relevant files
    • src/hooks/init/claude.rs
    • src/hooks/init/agents_md.rs
    • src/hooks/init/mod.rs

    Suggested Actions

    1. Reuse has_rtk_reference (agents_md.rs:235) in claude.rs:108 and mod.rs:2107 instead of content.contains(RTK_MD_REF)
    2. Fix agents_md.rs:171-178 to replace only the matching line via has_rtk_reference, not content.replace over the whole fi…
    3. Normalize/strip U+FEFF BOM before the trimmed-line comparison so uninstall matches BOM-prefixed reference lines
    4. Add regression tests covering cases 1-4 (Claude false-positive, Codex prose rewrite, --show false-positive, BOM uninsta…

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

  2. KuSh commented on Nov 29, 2026

    @KuSh
    CollaboratorAuthor

    Correction to cases 1 and 3 above, after measuring Claude Code itself (2.1.332, isolated config dir, local Messages API stand-in): Claude Code imports @RTK.md written inside a sentence or a list item, so @RTK.md is my notes file. does load RTK.md and --show was right to report it. The Claude half of this issue was wrong for those inputs. What Claude Code really skips (Read @RTK.md., (@RTK.md), inline code, fenced blocks) is now #5344.

    Cases 2 (Codex rewriting user prose) and 4 (BOM-prefixed reference left behind on uninstall) are real and fixed by #5206.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:clibugpriority:high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions