Hmbown/CodeWhale · error
{flag} must be placed before `exec`. Use: codewhale {flag
Error message
{flag} must be placed before `exec`.
Use:
codewhale {flag} exec "<prompt>" What it means
`reject_exec_global_flags` scans the arguments before a `--` separator and rejects the global-only flags `--provider`, `--model`, `--api-key`, and `--base-url` when they appear after the `exec` subcommand. These flags configure the runtime globally and must precede `exec`; the message shows the corrected invocation with `{flag} <value>` moved in front.
Source
Thrown at crates/cli/src/lib.rs:2183
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(())
}
fn run_login_command(store: &mut ConfigStore, args: LoginArgs) -> Result<()> {
run_login_command_with_secrets(store, args, &Secrets::auto_detect())
}
fn run_login_command_with_secrets(
store: &mut ConfigStore,
args: LoginArgs,
secrets: &Secrets,
) -> Result<()> {
let provider: ProviderKind = args.provider.unwrap_or(ProviderArg::Deepseek).into();View on GitHub (pinned to 0c42157ee5)
Solutions
- Move the flag before the subcommand: `codewhale --provider <value> exec "<prompt>"`
- For `=`-style flags, likewise hoist them: `codewhale --model=deepseek-v4-pro exec ...`
- If you truly need to pass a literal `--provider` token to the prompt, place it after `--`
Example fix
# before $ codewhale exec --provider deepseek "review this diff" # after $ codewhale --provider deepseek exec "review this diff"
Defensive patterns
Strategy: validation
Validate before calling
#!/usr/bin/env bash # hoist global flags in front of exec before invoking provider="deepseek"; model="deepseek-v4-pro"; prompt="review this diff" exec codewhale --provider "$provider" --model "$model" exec -- "$prompt"
Prevention
- Adopt the habit: global flags (`--provider`, `--model`, `--api-key`, `--base-url`) always before the subcommand
- Use `--` before the prompt so literal flag-looking words are not parsed as flags
- Wrap codewhale in a small arg-ordering helper if team members keep tripping on this
When it happens
Trigger: `codewhale exec --provider deepseek "..."`, `codewhale exec --model auto ...`, or any exec invocation carrying one of the four global flags (with or without `=`) before the `--` separator; also triggered by flags after `exec` but intended for the outer CLI.
Common situations: Muscle memory from CLIs where flags can go anywhere; scripts migrated from tools with per-subcommand provider flags; copy-pasting a provider flag into the prompt-adjacent position.
Related errors
- `codewhale --continue` resumes the interactive TUI. Use `cod
- invalid value '{provider}' for '--provider <PROVIDER>': expe
- --worktree-repo and --branch must be provided together
- No saved sessions found for workspace {}. Use `codewhale ses
- The Codewhale service returned an unexpectedly large respons
AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20).
Data as JSON: /api/errors/2673cfe8c9f55391.
Report an issue: GitHub.