rtk-ai/rtk · error
--codex cannot be combined with --auto-patch
Error message
--codex cannot be combined with --auto-patch
What it means
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.
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`
Example fix
// before rtk init --codex --auto-patch // after rtk init --codex
Defensive patterns
Strategy: validation
Validate before calling
const codex = args.includes("--codex");
const patchFlags = ["--auto-patch", "--no-patch"];
if (codex && patchFlags.some(f => args.includes(f))) throw new Error("patch-mode flags are not allowed with --codex"); Prevention
- 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
When it happens
Trigger: Running `rtk init --codex --auto-patch`. Fires whenever `codex` is true and `patch_mode` matches PatchMode::Auto, immediately after the --hook-only conflict check.
Common situations: 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.
Understand the failure class
Background: "mutually exclusive" flag errors: what "can't supply both nx and xx", "--raw is not compatible with -i" and "cannot be used with" mean, and how to fix them — this error's family across 29 libraries.
Related errors
- --codex cannot be combined with --no-patch
- --codex cannot be combined with --claude-md
- --codex cannot be combined with --hook-only
- is not a JSON file (detected ). Use `rtk read` for non-JSON…
- is not a JSON file (detected ). Use `rtk read` for non-JSON…
AI-assisted analysis of rtk-ai/rtk@0924356b4c (2026-09-19).
Data as JSON: /api/errors/31f0431c72e32362.
Report an issue: GitHub.
Appendix: source
Thrown at src/hooks/init.rs:407
hook_only: bool,
codex: bool,
patch_mode: PatchMode,
ctx: InitContext,
) -> Result<()> {
let InitContext { dry_run, .. } = ctx;
// Validation: Codex mode conflicts
if codex {
if install_opencode {
anyhow::bail!("--codex cannot be combined with --opencode");
}
if claude_md {
anyhow::bail!("--codex cannot be combined with --claude-md");
}
if hook_only {
anyhow::bail!("--codex cannot be combined with --hook-only");
}
if matches!(patch_mode, PatchMode::Auto) {
anyhow::bail!("--codex cannot be combined with --auto-patch");
}
if matches!(patch_mode, PatchMode::Skip) {
anyhow::bail!("--codex cannot be combined with --no-patch");
}
run_codex_mode(global, ctx)?;
} else {
// Validation: Global-only features
if install_opencode && !global {
anyhow::bail!("OpenCode plugin is global-only. Use: rtk init -g --opencode");
}
if install_cursor && !global {
anyhow::bail!("Cursor hooks are global-only. Use: rtk init -g --agent cursor");
}
if install_windsurf && !global {
anyhow::bail!("Windsurf support is global-only. Use: rtk init -g --agent windsurf");
}View on GitHub (pinned to 0924356b4c)