affaan-m/ECC · error · Error
requires a value
Error message
${flagName} requires a value What it means
readValue in scripts/loop-status.js extracts the value following a flag. If the flag is the last argument or the next token starts with '--' (i.e. looks like another flag), it throws, because the flag was given without an actual value.
Solutions
- Supply the value directly after the flag: --interval 30.
- Check that any shell variable used for the value is actually set and non-empty.
- Do not place another flag where a value is expected; reorder arguments.
- Run with --help to see which flags require values.
Example fix
// before node scripts/loop-status.js --interval // after node scripts/loop-status.js --interval 30
Defensive patterns
Strategy: try-catch
Validate before calling
function flagHasValue(argv, flag) {
const i = argv.indexOf(flag);
if (i === -1) return true;
const next = argv[i + 1];
return typeof next === 'string' && next !== '' && !next.startsWith('--');
}
// usage: if (!flagHasValue(args, '--interval')) exit with usage error Try / catch
try {
parseArgs(args);
} catch (err) {
if (String(err.message).endsWith('requires a value')) {
console.error(`${err.message}\nExample: node scripts/loop-status.js --interval 30`);
process.exitCode = 1;
return;
}
throw err;
} Prevention
- Always place the value immediately after its flag
- Use "${VAR:-default}" for shell variables feeding flag values
- Quote values and avoid empty expansions
- Verify against --help which flags take values
When it happens
Trigger: Running loop-status with a value-taking flag at the end of the command line (e.g. 'node scripts/loop-status.js --interval') or immediately followed by another flag ('--interval --watch').
Common situations: Forgetting the value after a flag; copying a boolean-style invocation onto a value flag; shell variable expansion to empty ('--interval $MY_INTERVAL' with unset variable) leaving nothing after the flag.
Understand the failure class
Background: "--flag is required" and "must specify" CLI errors: how missing-required-flag validation works and how to fix it — this error's family across 20 libraries.
Related errors
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/e0f90b4e410695f6.
Report an issue: GitHub.
Appendix: 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 8321021c54)