{"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":280,"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":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/rtk-ai/rtk/blob/d977e1c31621fe8704e6500ceeb9c7a0de2b6836/src/hooks/init.rs#L262-L298","documentation":"`rtk init --codex` is a self-contained mode that ONLY installs Codex integration (it calls run_codex_mode). The validation block at src/hooks/init.rs:280 rejects every flag that would select a different integration; combining --codex with --opencode is contradictory (two different agent targets), so it bails before any installation happens.","triggerScenarios":"`rtk init --codex --opencode` — the clap flags parse fine individually, but the pair reaches init's validation and bails with the exact conflict named. Common when a script concatenates option lists from two setup guides.","commonSituations":"Copy-pasting flags from different README sections (one for Codex, one for OpenCode); scripted bootstrap that accumulates options; misreading --codex as an additive integration rather than an exclusive mode.","solutions":["Run codex mode alone: `rtk init --codex`","If you also want OpenCode support, run a second separate command: `rtk init -g --opencode`","Drop --codex if OpenCode is what you actually wanted"],"exampleFix":"# before\nrtk init --codex --opencode\n# --codex cannot be combined with --opencode\n\n# after: two separate installs\nrtk init --codex\ncode  # then set up opencode separately:\nrtk init -g --opencode","handlingStrategy":"validation","validationCode":"bash:\n# --codex is exclusive: never pass another integration flag with it\nif [[ \"$*\" == *--codex* && \"$*\" == *--opencode* ]]; then\n  echo \"--codex and --opencode are mutually exclusive; run them separately\" >&2\n  exit 2\nfi\nrtk init \"$@\"","typeGuard":"rust:\nstruct InitFlags { codex: bool, opencode: bool, claude_md: bool, hook_only: bool }\nfn codex_conflicts(f: &InitFlags) -> bool {\n    f.codex && (f.opencode || f.claude_md || f.hook_only)\n}","tryCatchPattern":"rust (better: let clap reject it before runtime):\n// in the clap derive for the init subcommand:\n#[arg(long, conflicts_with_all = [\"opencode\", \"claude_md\", \"hook_only\"])]\ncodex: bool,\n// runtime catch otherwise:\nif let Err(e) = init::run(...) { if e.to_string().starts_with(\"--codex cannot\") { exit(2); } }","preventionTips":["Treat --codex as a mode, not an add-on: one mode per invocation","Run additional integrations as separate `rtk init` commands","Encode the exclusions in clap (conflicts_with) so misuse fails at parse time with usage help"],"tags":["init","cli","usage","flag-conflict","codex","opencode"],"backgroundTag":null,"analyzedSha":"d977e1c31621fe8704e6500ceeb9c7a0de2b6836","analyzedAt":"2026-08-16T05:40:46.291Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}