rtk-ai/rtk · error · anyhow::Error
--codex cannot be combined with --auto-patch
Error message
--codex cannot be combined with --auto-patch
What it means
`rtk init --codex` runs its own fixed setup and never consults the patch machinery; the validation at src/hooks/init.rs:289 rejects PatchMode::Auto (--auto-patch) alongside it because patch mode only applies to the non-codex branch that --codex skips entirely.
Source
Thrown at src/hooks/init.rs:289
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 d977e1c316)
Solutions
- Run `rtk init --codex` without patch flags — codex mode has no patching step to auto-approve
- If --auto-patch was for Claude Code patching, run it separately: `rtk init --auto-patch`
- Trim init invocations to one mode's flags at a time
Example fix
# before rtk init --codex --auto-patch # --codex cannot be combined with --auto-patch # after rtk init --codex rtk init --auto-patch # if patching for Claude Code was the goal
Defensive patterns
Strategy: validation
Validate before calling
bash: if [[ "$*" == *--codex* && "$*" == *--auto-patch* ]]; then echo "--codex and --auto-patch are mutually exclusive" >&2 exit 2 fi rtk init "$@"
Type guard
rust:
enum PatchMode { Ask, Auto, Skip }
fn codex_patch_conflict(codex: bool, pm: PatchMode) -> bool {
codex && matches!(pm, PatchMode::Auto)
} Try / catch
rust:
// clap-level: #[arg(long, conflicts_with = "auto_patch")] codex: bool,
if let Err(e) = init::run(...) {
if e.to_string().contains("--codex cannot be combined with --auto-patch") { exit(2); }
} Prevention
- Patch-mode flags only apply to the non-codex branch — don't pass them with --codex
- Split team init scripts per integration instead of one mega-command
- Surface patch flag rules in your project's setup docs
When it happens
Trigger: `rtk init --codex --auto-patch`. The flags parse; init's validation matches patch_mode against PatchMode::Auto and bails with the conflict named.
Common situations: Users copying a full-featured init line from team docs (`rtk init --auto-patch --codex ...`); scripted bootstrap accumulating every 'yes' flag; upgrades where --auto-patch was previously harmless to combine.
Related errors
- --codex cannot be combined with --opencode
- --codex cannot be combined with --claude-md
- --codex cannot be combined with --hook-only
- --codex cannot be combined with --no-patch
- dotnet: no subcommand specified
AI-assisted analysis of rtk-ai/rtk@d977e1c316 (2026-08-16).
Data as JSON: /api/errors/31f0431c72e32362.
Report an issue: GitHub.