affaan-m/ECC · error · Error

Missing value for --target

Error message

Missing value for --target

What it means

In consult.js parseArgs(), when --target is encountered, the parser checks argv[index + 1]. If the next token is falsy (undefined, meaning --target is last) or starts with '-' (looks like another flag), it throws. This prevents silently consuming a flag name as the target value.

Source

Thrown at scripts/consult.js:214

    target: DEFAULT_TARGET,
    limit: DEFAULT_LIMIT,
    json: false,
    help: false,
  };

  if (args.includes('--help') || args.includes('-h')) {
    parsed.help = true;
    return parsed;
  }

  for (let index = 0; index < args.length; index += 1) {
    const arg = args[index];

    if (arg === '--json') {
      parsed.json = true;
    } else if (arg === '--target') {
      if (!args[index + 1] || args[index + 1].startsWith('-')) {
        throw new Error('Missing value for --target');
      }
      parsed.target = args[index + 1];
      index += 1;
    } else if (arg === '--limit') {
      if (!args[index + 1]) {
        throw new Error('Missing value for --limit');
      }
      parsed.limit = Math.min(parsePositiveInteger(args[index + 1], '--limit'), MAX_LIMIT);
      index += 1;
    } else if (arg.startsWith('-')) {
      throw new Error(`Unknown argument: ${arg}`);
    } else {
      parsed.queryParts.push(arg);
    }
  }

  if (!SUPPORTED_INSTALL_TARGETS.includes(parsed.target)) {
    throw new Error(

View on GitHub (pinned to 01e15490f0)

Solutions

  1. Provide a valid target name immediately after --target, e.g. --target claude
  2. Check the SUPPORTED_INSTALL_TARGETS list for valid values: claude, claude-project, cursor, antigravity, codex, gemini, opencode, codebuddy, joycode, qwen, zed, hermes, openclaw, kimi
  3. If building commands dynamically, ensure the target variable is non-empty before appending --target

Example fix

// before
node scripts/consult.js --target --json security
// after
node scripts/consult.js --target claude security
Defensive patterns

Strategy: validation

Validate before calling

// Verify --target has a non-flag value before invoking consult.js
const argv = process.argv.slice(2);
const targetIdx = argv.indexOf('--target');
if (targetIdx !== -1 && (!argv[targetIdx + 1] || argv[targetIdx + 1].startsWith('-'))) {
  console.error('Missing value for --target. Expected one of: claude, cursor, codex, gemini, opencode, ...');
  process.exit(1);
}

Try / catch

try {
  const options = parseArgs(process.argv);
} catch (error) {
  if (error.message === 'Missing value for --target') {
    console.error('Provide a target harness after --target, e.g. --target claude');
    process.exit(2);
  }
  throw error;
}

Prevention

When it happens

Trigger: Passing --target as the last argument; passing --target immediately followed by --limit or --json; or a dynamic command builder that appends --target but not its value.

Common situations: CI or wrapper scripts that conditionally append --target from a variable that is empty; copy-paste errors that drop the target name.

Related errors


AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13). Data as JSON: /api/errors/3e506523c31edbca. Report an issue: GitHub.