Skip to content

rtk init: one command shape for every agent instead of three #4248

Open

Description

@KuSh

Problem

rtk init picks the target agent in three different ways:

  • no flag: Claude Code (the default);
  • a dedicated flag: --gemini, --codex, --copilot, --opencode;
  • the --agent enum: claude, cursor, trae, windsurf, cline, kilocode, antigravity, kimi, pi, hermes, droid, vibe, omp.

On top of these, the mode flags --claude-md, --hook-only, --auto-patch and --no-patch mean something for some agents and nothing for others.

main.rs resolves all of this with an if / else if chain in a fixed order. The last branch is a shared path that installs Claude Code unless something turns it off. Any combination the chain does not expect is therefore settled by the order of the branches or by falling through to Claude, and the command still exits 0.

Symptoms

All of these exit 0, with a fresh HOME, LC_ALL=C, on develop plus #3000:

rtk init -g --gemini  --agent cursor --dry-run   # Gemini only, Cursor dropped
rtk init -g --codex   --agent cursor --dry-run   # Codex only, Cursor dropped
rtk init -g --copilot --agent trae   --dry-run   # Copilot only, Trae dropped
rtk init -g --opencode --agent pi    --dry-run   # Pi only, OpenCode dropped
rtk init -g --agent windsurf --claude-md --dry-run   # --claude-md ignored
rtk init    --agent cline    --hook-only --dry-run   # --hook-only ignored
rtk init -g --agent cursor   --no-patch  --dry-run   # hooks.json patched anyway

The Claude fall-through is behind two bugs filed so far:

The mixed shapes also leak into the docs: #3429 found rtk init --cursor, a flag that does not exist, in the troubleshooting guide.

Fixing each combination as it is found means adding one more guard to the chain each time. #3000 added one; a Claude-only flag check for Cursor, Windsurf and Cline would add three more.

Proposal

One command shape: rtk init [-g] [--uninstall] --agent <name> [options].

  • Every agent is an --agent value, including gemini, codex, copilot and opencode. The old flags stay as deprecated aliases that map to --agent, so existing docs and scripts keep working.

  • Each agent declares what it supports:

    • scopes (global, project or both);
    • whether it has a file that --auto-patch / --no-patch governs;
    • whether it has --claude-md / --hook-only style modes.

    An option the agent does not support is an error, in the form --codex already uses (--codex cannot be combined with --claude-md).

  • Dispatch is one match on the agent, with no default branch, so a new agent that forgets its arm fails to compile instead of installing Claude Code. Install, uninstall and --show go through the same table.

  • Two targets in one invocation (for example --gemini --agent cursor) are either rejected or supported explicitly with a repeatable --agent. Which of the two is a maintainer decision. It also settles the open question in rtk init --opencode appears to skip Claude hook installation #4046 / fix(init): install Claude hook with OpenCode #4052 of whether --opencode means "OpenCode only" or "Claude Code plus OpenCode".

Behaviour for the single-target forms stays as it is today. The change is that every combination the current chain resolves silently either works as written or fails with a message.

Activity

  1. added
    bug
    help wanted
    on Sep 25, 2026
  2. rtk-wshm-sync-bot commented on Sep 25, 2026

    @rtk-wshm-sync-bot

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟠 Priority high
    🎯 Confidence 85%

    Summary

    rtk init's if/else chain lets conflicting agent flags silently drop targets or ignore mode flags and still exit 0; proposes a single --agent-based dispatch table

    📁 Relevant files
    • src/main.rs

    Suggested Actions

    1. Decide the maintainer call on rtk init --opencode appears to skip Claude hook installation #4046/fix(init): install Claude hook with OpenCode #4052: whether two-target invocations are rejected or repeatable --agent
    2. Design the per-agent capability table (scopes, patch support, mode flags) before refactoring main.rs's if/else chain
    3. Cross-reference rtk init -g --agent cursor fails #2097, rtk init --uninstall -g --agent kilocode (and windsurf/cline/antigravity/kimi) runs the Claude uninstaller instead — removing Claude's config and nothing of the named agent #3404, RuboCop autocorrect aliases missed, rtk init --cursor in troubleshooting does not exist, Windows config path undocumented — plus what I could not verify and why #3429 as prior symptoms of the same fall-through design
    4. Scope as a larger refactor rather than another one-off guard; track alongside rtk init --codex --uninstall exits 0 when the hook path was refused and the hook may still be registered #4164 (uninstall exit-0 on refusal)

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

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:clibughelp wantedpriority:high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions