{"record":{"id":"ed67989cca36bd37","repo":"rtk-ai/rtk","slug":"codex-cannot-be-combined-with-no-patch","errorCode":null,"errorMessage":"--codex cannot be combined with --no-patch","messagePattern":"--codex cannot be combined with --no-patch","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/hooks/init.rs","lineNumber":292,"sourceCode":"    ctx: InitContext,\n) -> Result<()> {\n    let InitContext { dry_run, .. } = ctx;\n    // Validation: Codex mode conflicts\n    if codex {\n        if install_opencode {\n            anyhow::bail!(\"--codex cannot be combined with --opencode\");\n        }\n        if claude_md {\n            anyhow::bail!(\"--codex cannot be combined with --claude-md\");\n        }\n        if hook_only {\n            anyhow::bail!(\"--codex cannot be combined with --hook-only\");\n        }\n        if matches!(patch_mode, PatchMode::Auto) {\n            anyhow::bail!(\"--codex cannot be combined with --auto-patch\");\n        }\n        if matches!(patch_mode, PatchMode::Skip) {\n            anyhow::bail!(\"--codex cannot be combined with --no-patch\");\n        }\n        run_codex_mode(global, ctx)?;\n    } else {\n        // Validation: Global-only features\n        if install_opencode && !global {\n            anyhow::bail!(\"OpenCode plugin is global-only. Use: rtk init -g --opencode\");\n        }\n\n        if install_cursor && !global {\n            anyhow::bail!(\"Cursor hooks are global-only. Use: rtk init -g --agent cursor\");\n        }\n\n        if install_windsurf && !global {\n            anyhow::bail!(\"Windsurf support is global-only. Use: rtk init -g --agent windsurf\");\n        }\n\n        if install_windsurf {\n            run_windsurf_mode(ctx)?;","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/rtk-ai/rtk/blob/d977e1c31621fe8704e6500ceeb9c7a0de2b6836/src/hooks/init.rs#L274-L310","documentation":"Symmetric to --auto-patch: `rtk init --codex` skips the patch machinery entirely, so PatchMode::Skip (--no-patch) is meaningless inside codex mode, and the validation at src/hooks/init.rs:292 rejects the combination up front rather than accept a no-op flag.","triggerScenarios":"`rtk init --codex --no-patch`. Both flags parse; init's validation matches patch_mode against PatchMode::Skip and bails.","commonSituations":"Teams whose standard init line includes --no-patch appending --codex for one machine; defensive 'disable patching everywhere' policies colliding with codex mode's exclusivity; copy-paste evolution of setup scripts.","solutions":["Run `rtk init --codex` alone — patching never runs in codex mode, so --no-patch adds nothing","Use `rtk init --no-patch` in a separate run for the Claude Code path if needed","Keep one mode's flags per invocation when scripting setup"],"exampleFix":"# before\nrtk init --codex --no-patch\n# --codex cannot be combined with --no-patch\n\n# after\nrtk init --codex\nrtk init --no-patch      # separate run for the non-codex path","handlingStrategy":"validation","validationCode":"bash:\nif [[ \"$*\" == *--codex* && \"$*\" == *--no-patch* ]]; then\n  echo \"--codex and --no-patch are mutually exclusive\" >&2\n  exit 2\nfi\nrtk init \"$@\"","typeGuard":"rust:\nenum PatchMode { Ask, Auto, Skip }\nfn codex_no_patch_conflict(codex: bool, pm: PatchMode) -> bool {\n    codex && matches!(pm, PatchMode::Skip)\n}","tryCatchPattern":"rust:\n// clap-level: #[arg(long, conflicts_with = \"no_patch\")] codex: bool,\nif let Err(e) = init::run(...) {\n    if e.to_string().contains(\"--codex cannot be combined with --no-patch\") { exit(2); }\n}","preventionTips":["--no-patch is a no-op inside codex mode; drop it","Standardize one init invocation per target to avoid flag soup","Enforce conflicts at the parser (clap conflicts_with) rather than runtime checks"],"tags":["init","cli","usage","flag-conflict","codex","no-patch"],"backgroundTag":null,"analyzedSha":"d977e1c31621fe8704e6500ceeb9c7a0de2b6836","analyzedAt":"2026-08-16T05:40:46.291Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}