jackwener/OpenCLI · error · ArgumentError

prompt is required

Error message

prompt is required

What it means

The send command requires a positional prompt; the value is stringified and trimmed, and if the result is empty an ArgumentError('prompt', 'is required') is thrown. Empty prompts cannot be submitted to Grok, so the command fails fast before touching the browser.

Source

Thrown at clis/grok/send.js:30

cli({
    site: 'grok',
    name: 'send',
    access: 'write',
    description: 'Fire-and-forget: send a prompt to Grok without waiting for the reply',
    domain: GROK_DOMAIN,
    strategy: Strategy.COOKIE,
    browser: true,
    siteSession: 'persistent',
    navigateBefore: false,
    args: [
        { name: 'prompt', required: true, positional: true, help: 'Prompt to send to Grok' },
        { name: 'new', type: 'boolean', default: false, help: 'Start a new chat before sending' },
    ],
    columns: ['Status', 'Prompt'],
    func: async (page, kwargs) => {
        const prompt = String(kwargs.prompt || '').trim();
        if (!prompt) throw new ArgumentError('prompt', 'is required');
        const startFresh = normalizeBooleanFlag(kwargs.new, false);

        await ensureOnGrok(page);
        if (startFresh) {
            await startNewChat(page);
        }

        const send = await sendMessage(page, prompt);
        if (!send?.ok) {
            // If the composer is missing, the most likely cause is that the
            // signed-in session expired (Grok then renders a sign-in CTA in
            // place of the composer). Surface that as AuthRequiredError so
            // agents can prompt for re-auth instead of treating it as a
            // generic execution failure.
            if (!(await isLoggedIn(page))) throw authRequired();
            throw new CommandExecutionError(send?.reason || 'Failed to send Grok prompt');
        }
        return [{ Status: 'sent', Prompt: prompt }];

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Pass a non-empty prompt as the positional argument.
  2. Check that the shell variable feeding the prompt is set and non-blank.
  3. Quote the prompt to preserve spaces and avoid shell word-splitting.

Example fix

// before
cli send "$PROMPT"   # PROMPT is empty
// after
cli send "Explain event loops"   # or: : "${PROMPT:?PROMPT must be set}"
Defensive patterns

Strategy: validation

Validate before calling

const prompt = (process.argv[2] ?? '').trim();
if (!prompt) {
  console.error('usage: cli send <non-empty prompt>');
  process.exit(2);
}

Type guard

function isNonEmptyString(v) {
  return typeof v === 'string' && v.trim().length > 0;
}

Try / catch

try {
  await cli.send({ prompt });
} catch (e) {
  if (e instanceof ArgumentError && e.message === 'prompt is required') {
    console.error('Provide a non-empty prompt as the positional argument.');
    process.exitCode = 2;
  } else throw e;
}

Prevention

When it happens

Trigger: Running the send command with no positional argument, --prompt '', --prompt ' ' (whitespace only), or kwargs.prompt being undefined/null.

Common situations: Shell variable holding the prompt was empty/unset, quoting mistake dropping the argument, or a script piping an empty string into the CLI.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/d4f94d3812246f49. Report an issue: GitHub.