jackwener/OpenCLI · error · ArgumentError

${commandName} prompt cannot be empty

Error message

${commandName} prompt cannot be empty

What it means

requireNonEmptyPrompt validates that the prompt argument for a Claude command is a non-empty, non-whitespace string. opencli throws this ArgumentError early rather than launching a browser session to send an empty message.

Source

Thrown at clis/claude/utils.js:72

    const state = await getPageState(page);
    if (!state.isLoggedIn) {
        throw new AuthRequiredError(CLAUDE_DOMAIN, message);
    }
    return state;
}

export async function ensureClaudeComposer(page, message = 'Claude composer is not available on the current page.') {
    const state = await ensureClaudeLogin(page, message);
    if (!state.hasComposer) {
        throw new CommandExecutionError(message);
    }
    return state;
}

export function requireNonEmptyPrompt(prompt, commandName) {
    const text = String(prompt ?? '').trim();
    if (!text) {
        throw new ArgumentError(
            `${commandName} prompt cannot be empty`,
            `Example: opencli ${commandName} "hello"`,
        );
    }
    return text;
}

export function requirePositiveInt(value, flagLabel, hint) {
    if (!Number.isInteger(value) || value < 1) {
        throw new ArgumentError(`${flagLabel} must be a positive integer`, hint);
    }
    return value;
}

export function requireConversationId(value) {
    const id = String(value ?? '').trim();
    if (!id) {
        throw new ArgumentError(

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Pass a non-empty quoted prompt as the command argument
  2. Check the variable/pipe feeding the prompt is populated before invoking
  3. In scripts, guard with a check like `[ -n "$PROMPT" ] || exit 1`

Example fix

// before
const prompt = process.env.PROMPT; // may be ''
await requireNonEmptyPrompt(prompt, 'ask');
// after
const prompt = process.env.PROMPT?.trim();
if (!prompt) throw new Error('PROMPT env var is required');
await requireNonEmptyPrompt(prompt, 'ask');
Defensive patterns

Strategy: validation

Validate before calling

const text = String(prompt ?? '').trim();
if (!text) {
  throw new Error('Prompt must be a non-empty string');
}
await requireNonEmptyPrompt(text, 'ask');

Type guard

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

Try / catch

try {
  await requireNonEmptyPrompt(prompt, 'ask');
} catch (e) {
  if (e instanceof ArgumentError && e.message.includes('prompt cannot be empty')) {
    console.error('Usage: opencli ask "hello"');
    process.exitCode = 2;
  } else throw e;
}

Prevention

When it happens

Trigger: Calling a claude command (ask/new/send) with an empty string, whitespace-only string, or null/undefined prompt, e.g. `opencli claude ask ""` or passing a shell variable that expanded to nothing.

Common situations: Shell variable not set (`opencli claude ask "$PROMPT"` with PROMPT empty), quoting mistakes in scripts, piping empty stdin, CI jobs with missing inputs.

Related errors


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