rtk-ai/rtk · error

--codex cannot be combined with --no-patch

Error message

--codex cannot be combined with --no-patch

What it means

rtk's `rtk init` rejects --codex together with --no-patch (PatchMode::Skip). As with --auto-patch, patch-mode selection is not configurable in Codex mode, so combining the agent flag with a skip-patch request is contradictory and bails out before any setup work.

Solutions

  1. Run `rtk init --codex` without --no-patch (Codex mode controls patch behavior itself)
  2. If skipping patches is essential, omit --codex: `rtk init --no-patch`

Example fix

// before
rtk init --codex --no-patch
// after
rtk init --codex
Defensive patterns

Strategy: validation

Validate before calling

const codex = args.includes("--codex");
const patchFlags = ["--auto-patch", "--no-patch"];
if (codex && patchFlags.some(f => args.includes(f))) throw new Error("patch-mode flags are not allowed with --codex");

Prevention

When it happens

Trigger: Running `rtk init --codex --no-patch`. Fires whenever `codex` is true and `patch_mode` matches PatchMode::Skip, as the last check in the codex validation block before run_codex_mode.

Common situations: A user switching from `rtk init --no-patch` to Codex integration keeps the old flag in place. CI scripts parameterized with PATCH_FLAGS='--no-patch' that also hardcode --codex.

Understand the failure class

Background: "mutually exclusive" flag errors: what "can't supply both nx and xx", "--raw is not compatible with -i" and "cannot be used with" mean, and how to fix them — this error's family across 29 libraries.

Related errors


AI-assisted analysis of rtk-ai/rtk@0924356b4c (2026-09-19). Data as JSON: /api/errors/ed67989cca36bd37. Report an issue: GitHub.

Appendix: source

Thrown at src/hooks/init.rs:410

    ctx: InitContext,
) -> Result<()> {
    let InitContext { dry_run, .. } = ctx;
    // Validation: Codex mode conflicts
    if codex {
        if install_opencode {
            anyhow::bail!("--codex cannot be combined with --opencode");
        }
        if claude_md {
            anyhow::bail!("--codex cannot be combined with --claude-md");
        }
        if hook_only {
            anyhow::bail!("--codex cannot be combined with --hook-only");
        }
        if matches!(patch_mode, PatchMode::Auto) {
            anyhow::bail!("--codex cannot be combined with --auto-patch");
        }
        if matches!(patch_mode, PatchMode::Skip) {
            anyhow::bail!("--codex cannot be combined with --no-patch");
        }
        run_codex_mode(global, ctx)?;
    } else {
        // Validation: Global-only features
        if install_opencode && !global {
            anyhow::bail!("OpenCode plugin is global-only. Use: rtk init -g --opencode");
        }

        if install_cursor && !global {
            anyhow::bail!("Cursor hooks are global-only. Use: rtk init -g --agent cursor");
        }

        if install_windsurf && !global {
            anyhow::bail!("Windsurf support is global-only. Use: rtk init -g --agent windsurf");
        }

        if install_windsurf {
            run_windsurf_mode(ctx)?;

View on GitHub (pinned to 0924356b4c)