{"record":{"id":"57904733f57518f5","repo":"rtk-ai/rtk","slug":"codex-cannot-be-combined-with-hook-only","errorCode":null,"errorMessage":"--codex cannot be combined with --hook-only","messagePattern":"--codex cannot be combined with --hook-only","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/hooks/init.rs","lineNumber":404,"sourceCode":"    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\");\n        }\n\n        if install_cursor && !global {\n            anyhow::bail!(\"Cursor hooks are global-only. Use: rtk init -g --agent cursor\");\n        }\n","sourceCodeStart":386,"sourceCodeEnd":422,"githubUrl":"https://github.com/rtk-ai/rtk/blob/0924356b4caba4989607227b7c8824d3d8098719/src/hooks/init.rs#L386-L422","documentation":"rtk's `rtk init` rejects the combination of --codex and --hook-only. Codex mode runs its own dedicated setup path (run_codex_mode), which already implies a hook-only style configuration, so an explicit --hook-only request is contradictory. The bail fires before any filesystem changes are made.","triggerScenarios":"Running `rtk init --codex --hook-only`. Fires whenever the parsed `codex` flag is true and `hook_only` is true, after the --claude-md conflict check inside the `codex` branch of HooksInit::run.","commonSituations":"A user who normally runs `rtk init --hook-only` adds --codex to switch agents, assuming the two flags compose. Automation scripts that always append --hook-only regardless of agent selection.","solutions":["Remove --hook-only: `rtk init --codex` (Codex mode already handles hook setup its own way)","Remove --codex and keep plain hook-only init: `rtk init --hook-only`"],"exampleFix":"// before\nrtk init --codex --hook-only\n// after\nrtk init --codex","handlingStrategy":"validation","validationCode":"const codex = args.includes(\"--codex\");\nconst hookOnly = args.includes(\"--hook-only\");\nif (codex && hookOnly) throw new Error(\"--codex cannot be combined with --hook-only\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember --codex already implies its own hook setup; never pair it with --hook-only","Keep agent selection (--codex) and installation style (--hook-only) in separate script variables and only use one at a time"],"tags":["cli","validation","codex","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"}