{"record":{"id":"31f0431c72e32362","repo":"rtk-ai/rtk","slug":"codex-cannot-be-combined-with-auto-patch","errorCode":null,"errorMessage":"--codex cannot be combined with --auto-patch","messagePattern":"--codex cannot be combined with --auto-patch","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/hooks/init.rs","lineNumber":289,"sourceCode":"    hook_only: bool,\n    codex: bool,\n    patch_mode: PatchMode,\n    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        }","sourceCodeStart":271,"sourceCodeEnd":307,"githubUrl":"https://github.com/rtk-ai/rtk/blob/d977e1c31621fe8704e6500ceeb9c7a0de2b6836/src/hooks/init.rs#L271-L307","documentation":"`rtk init --codex` runs its own fixed setup and never consults the patch machinery; the validation at src/hooks/init.rs:289 rejects PatchMode::Auto (--auto-patch) alongside it because patch mode only applies to the non-codex branch that --codex skips entirely.","triggerScenarios":"`rtk init --codex --auto-patch`. The flags parse; init's validation matches patch_mode against PatchMode::Auto and bails with the conflict named.","commonSituations":"Users copying a full-featured init line from team docs (`rtk init --auto-patch --codex ...`); scripted bootstrap accumulating every 'yes' flag; upgrades where --auto-patch was previously harmless to combine.","solutions":["Run `rtk init --codex` without patch flags — codex mode has no patching step to auto-approve","If --auto-patch was for Claude Code patching, run it separately: `rtk init --auto-patch`","Trim init invocations to one mode's flags at a time"],"exampleFix":"# before\nrtk init --codex --auto-patch\n# --codex cannot be combined with --auto-patch\n\n# after\nrtk init --codex\nrtk init --auto-patch   # if patching for Claude Code was the goal","handlingStrategy":"validation","validationCode":"bash:\nif [[ \"$*\" == *--codex* && \"$*\" == *--auto-patch* ]]; then\n  echo \"--codex and --auto-patch are mutually exclusive\" >&2\n  exit 2\nfi\nrtk init \"$@\"","typeGuard":"rust:\nenum PatchMode { Ask, Auto, Skip }\nfn codex_patch_conflict(codex: bool, pm: PatchMode) -> bool {\n    codex && matches!(pm, PatchMode::Auto)\n}","tryCatchPattern":"rust:\n// clap-level: #[arg(long, conflicts_with = \"auto_patch\")] codex: bool,\nif let Err(e) = init::run(...) {\n    if e.to_string().contains(\"--codex cannot be combined with --auto-patch\") { exit(2); }\n}","preventionTips":["Patch-mode flags only apply to the non-codex branch — don't pass them with --codex","Split team init scripts per integration instead of one mega-command","Surface patch flag rules in your project's setup docs"],"tags":["init","cli","usage","flag-conflict","codex","auto-patch"],"backgroundTag":null,"analyzedSha":"d977e1c31621fe8704e6500ceeb9c7a0de2b6836","analyzedAt":"2026-08-16T05:40:46.291Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}