{"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":null,"httpStatus":null,"severity":"error","filePath":"src/hooks/init.rs","lineNumber":407,"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":389,"sourceCodeEnd":425,"githubUrl":"https://github.com/rtk-ai/rtk/blob/0924356b4caba4989607227b7c8824d3d8098719/src/hooks/init.rs#L389-L425","documentation":"rtk's `rtk init` refuses --codex together with --auto-patch. In Codex mode, patch-mode selection (PatchMode::Auto / Skip) is not supported; Codex setup decides patching behavior internally, so an explicit --auto-patch request conflicts. The validation runs before run_codex_mode is entered, guaranteeing a clean failure.","triggerScenarios":"Running `rtk init --codex --auto-patch`. Fires whenever `codex` is true and `patch_mode` matches PatchMode::Auto, immediately after the --hook-only conflict check.","commonSituations":"A user who previously ran `rtk init --auto-patch` for Claude hooks re-runs the command adding --codex to switch agents, keeping both flags. Shell aliases or wrappers that bake --auto-patch into every init invocation.","solutions":["Run `rtk init --codex` without a patch-mode flag (Codex mode manages patching itself)","If you need --auto-patch, drop --codex and use the default agent path: `rtk init --auto-patch`"],"exampleFix":"// before\nrtk init --codex --auto-patch\n// after\nrtk init --codex","handlingStrategy":"validation","validationCode":"const codex = args.includes(\"--codex\");\nconst patchFlags = [\"--auto-patch\", \"--no-patch\"];\nif (codex && patchFlags.some(f => args.includes(f))) throw new Error(\"patch-mode flags are not allowed with --codex\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not pass patch-mode flags when --codex is set; Codex mode manages patching internally","Strip patch-mode flags from shared flag arrays when the target agent is codex"],"tags":["cli","validation","codex","patch-mode","conflicting-flags"],"backgroundTag":"mutually-exclusive-flags","analyzedSha":"0924356b4caba4989607227b7c8824d3d8098719","analyzedAt":"2026-09-19T19:25:29.612Z","contentChangedAt":"2026-09-19T19:25:29.612Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}