affaan-m/ECC · warning

${flagName} requires a value

Error message

${flagName} requires a value

What it means

readValue is the helper that consumes the token after a value-taking flag in loop-status.js. It throws when args[index+1] is missing or itself starts with '--' (i.e. looks like the next flag rather than a value). The guard prevents silently treating a flag as a value. Affects --home, --transcript, --limit, --bash-timeout-seconds, --wake-grace-multiplier, --now, --watch-count, --watch-interval-seconds, --write-dir.

Source

Thrown at scripts/loop-status.js:43

    '  --bash-timeout-seconds <n>     Age before a pending Bash call is stale (default: 1800)',
    '  --wake-grace-multiplier <n>    ScheduleWakeup grace multiplier (default: 2)',
    '  --now <time>                   Override current time (ISO, epoch ms, or "now")',
    '  --exit-code                    Exit 2 on attention signals, 1 on scan errors',
    '  --watch                        Refresh status until interrupted',
    '  --watch-count <n>              Stop after n watch refreshes',
    '  --watch-interval-seconds <n>   Seconds between watch refreshes (default: 5)',
    '  --write-dir <dir>              Write index.json and per-session status snapshots',
    '',
    'Examples:',
    '  node scripts/loop-status.js --json',
    '  node scripts/loop-status.js --transcript ~/.claude/projects/-repo/session.jsonl'
  ].join('\n'));
}

function readValue(args, index, flagName) {
  const value = args[index + 1];
  if (!value || value.startsWith('--')) {
    throw new Error(`${flagName} requires a value`);
  }
  return value;
}

function readPositiveNumber(value, flagName) {
  const number = Number(value);
  if (!Number.isFinite(number) || number <= 0) {
    throw new Error(`${flagName} must be a positive number`);
  }
  return number;
}

function readPositiveInteger(value, flagName) {
  const number = readPositiveNumber(value, flagName);
  if (!Number.isInteger(number)) {
    throw new Error(`${flagName} must be a positive integer`);
  }
  return number;

View on GitHub (pinned to 01e15490f0)

Solutions

  1. Supply an explicit value after every value-taking flag.
  2. If you wanted the default, remove the flag entirely rather than leaving it valueless.
  3. Quote multi-word values: `--write-dir '/some path'`.
  4. Re-check with `--help`; only boolean flags (no value) are --json, --exit-code, --watch.

Example fix

# before
node scripts/loop-status.js --home --json

# after
node scripts/loop-status.js --home "$HOME/.claude" --json
Defensive patterns

Strategy: validation

Validate before calling

// Ensure every value-taking flag has a non-flag value before running.
const VALUE_FLAGS = new Set(['--home','--transcript','--limit','--bash-timeout-seconds','--wake-grace-multiplier','--now','--watch-count','--watch-interval-seconds','--write-dir']);
function assertValuesPresent(argv) {
  for (let i = 0; i < argv.length; i++) {
    if (VALUE_FLAGS.has(argv[i])) {
      const next = argv[i + 1];
      if (!next || next.startsWith('--')) throw new Error(`${argv[i]} requires a value`);
    }
  }
}

Try / catch

try { parseArgs(process.argv); }
catch (err) { if (/requires a value/.test(err.message)) { console.error(err.message); printHelp(2); } else throw err; }

Prevention

When it happens

Trigger: Putting a flag last with no following token: `loop-status.js --home`. Following a value flag immediately with another flag: `loop-status.js --home --json`. A copy-paste that dropped the value.

Common situations: Editing a long command and deleting the value. Wrapping flags across lines so the value lands in a different shell token. Assuming a flag has a default so omitting its value is fine — it is not, the value is mandatory.

Related errors


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