Hmbown/CodeWhale · error
must be placed before `exec`. Use: codewhale exec
Error message
{flag} must be placed before `exec`.
Use:
codewhale {flag} <value> exec "<prompt>" What it means
Codewhale's exec subcommand validates that global-only flags (like --model, --provider) are not passed after the `exec` keyword. Args are scanned up to `--` and any recognized global flag placed in the exec position causes a bail with usage guidance. This keeps argument parsing unambiguous between the global CLI layer and the exec subcommand.
Solutions
- Move the flag before `exec`: `codewhale --model <value> exec "<prompt>"`
- If the value must stay inline, place `--` before it or remove the flag if a subcommand equivalent exists
Example fix
// before codewhale exec "refactor this" --model gpt-5 // after codewhale --model gpt-5 exec "refactor this"
Defensive patterns
Strategy: validation
Validate before calling
const GLOBAL_ONLY = ['--model', '--provider'];
const i = argv.indexOf('exec');
if (i !== -1 && argv.slice(0, i).some(a => GLOBAL_ONLY.includes(a.split('=')[0]) === false)) throw new Error('move global flags before exec'); Prevention
- Always order CLI args as `codewhale <global flags> exec "<prompt>"`
- Wrap complex invocations in shell functions with flags fixed in the global position
When it happens
Trigger: Running `codewhale exec "<prompt>" --model <value>` (or any flag in GLOBAL_ONLY_FLAGS) after `exec`, before any `--` separator.
Common situations: Users copying global invocations from docs/examples and appending exec at the end; scripts built by reordering an existing working command; muscle memory from other CLIs that accept subcommand-level model overrides.
Understand the failure class
Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.
Related errors
- Choose exactly one server mode: --mcp…
- `codewhale --continue` resumes the interactive TUI. Use…
- `codewhale --resume ` resumes the interactive TUI. Use…
- --continue/--resume/--session-id apply to the interactive…
- Fleet tool authority cannot be combined with exec --resume…
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/deb57f124ba54232.
Report an issue: GitHub.
Appendix: source
Thrown at crates/cli/src/lib.rs:2516
forwarded.push(command.to_string());
forwarded.extend(args.args);
forwarded
}
fn setup_is_status_report(args: &TuiPassthroughArgs) -> bool {
args.args.iter().any(|arg| arg == "--status")
}
fn reject_exec_global_flags(args: &[String]) -> Result<()> {
const GLOBAL_ONLY_FLAGS: &[&str] = &["--provider", "--model", "--api-key", "--base-url"];
for arg in args {
if arg == "--" {
break;
}
let flag = arg.split_once('=').map_or(arg.as_str(), |(flag, _)| flag);
if GLOBAL_ONLY_FLAGS.contains(&flag) {
bail!(
"{flag} must be placed before `exec`.\n\nUse:\n codewhale {flag} <value> exec \"<prompt>\""
);
}
}
Ok(())
}
/// `codewhale login` used to configure provider API keys; that surface moved
/// to `auth set --provider`. The hidden legacy flags stay parseable so the
/// redirect below can name the replacement instead of an unknown-flag error.
fn reject_legacy_login_provider_args(args: &LoginArgs) -> Result<()> {
if args.api_key.is_none() && args.provider.is_none() {
return Ok(());
}
bail!(
"`codewhale login` now signs in to your Codewhale account via the browser device flow. \
To configure a provider key, run `codewhale auth set --provider <provider>` (hidden prompt) \View on GitHub (pinned to 73e0f67d83)