{"record":{"id":"2ef9aeff235d42a7","repo":"rtk-ai/rtk","slug":"codex-cannot-be-combined-with-opencode","errorCode":null,"errorMessage":"--codex cannot be combined with --opencode","messagePattern":"--codex cannot be combined with --opencode","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/hooks/init.rs","lineNumber":398,"sourceCode":"#[allow(clippy::too_many_arguments)]\npub fn run(\n    global: bool,\n    install_claude: bool,\n    install_opencode: bool,\n    install_cursor: bool,\n    install_windsurf: bool,\n    install_cline: bool,\n    claude_md: bool,\n    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\");","sourceCodeStart":380,"sourceCodeEnd":416,"githubUrl":"https://github.com/rtk-ai/rtk/blob/0924356b4caba4989607227b7c8824d3d8098719/src/hooks/init.rs#L380-L416","documentation":"`rtk init` validates that mutually exclusive flag combinations are not used together. Codex mode installs its own specific set of files/hooks, so `--codex` cannot be combined with `--opencode` (or `--claude-md`/`--hook-only`, which have their own messages). Passing both flags fails fast with this error before any files are written.","triggerScenarios":"Running `rtk init --codex --opencode` (run in src/hooks/init.rs, guarded by the `if codex { if install_opencode { bail!(...) } }` validation).","commonSituations":"A shell alias or install script that always appends `--opencode` while a user adds `--codex`; guessing that multiple editor integrations can be initialized in one command; copied command lines from docs targeting different editors.","solutions":["Run `rtk init --codex` alone (drop --opencode) if you want Codex mode.","Run two separate invocations — `rtk init --codex` and `rtk init --opencode` — if you need both editors configured.","Check `rtk init --help` for the compatible flag combinations before composing a command."],"exampleFix":"// before\nrtk init --codex --opencode\n\n// after\nrtk init --codex\nrtk init --opencode  # separate run","handlingStrategy":"validation","validationCode":"let args: Vec<String> = std::env::args().collect();\nif args.contains(&\"--codex\".to_string()) && args.contains(&\"--opencode\".to_string()) {\n    eprintln!(\"--codex and --opencode are mutually exclusive\");\n    std::process::exit(2);\n}","typeGuard":null,"tryCatchPattern":"match rtk_init(&args).err() {\n    Some(e) if e.to_string().starts_with(\"--codex cannot be combined\") => {\n        eprintln!(\"run separate `rtk init` invocations per editor mode\");\n    }\n    _ => {}\n}","preventionTips":["Check `rtk init --help` for valid flag combinations before composing the command.","Avoid aliases/scripts that blindly append editor flags to `rtk init`.","Initialize each editor integration with its own separate `rtk init` invocation."],"tags":["cli","flags","mutually-exclusive","init"],"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"}