affaan-m/ECC · error · Error
At least one --target is required for handoffs.
Error message
At least one --target is required for handoffs.
What it means
Thrown by runWriteCommand in scripts/memory.js when the `handoff` subcommand is called with no `--target` values. Handoffs are addressed to one or more target harnesses, so an empty target list is rejected before writing. This is checked after the `--from` guard, so a handoff missing both flags fails on `--from` first.
Source
Thrown at scripts/memory.js:419
}
}
function runInitCommand({ command, options, positionals, roots }) {
requireNoPositionals(positionals, command);
return printInit(
initializeVault({ roots, scopes: options.scopes || undefined }),
options.json
);
}
function runWriteCommand({ command, options, positionals, roots }) {
requireNoPositionals(positionals, command);
if (!options.title) throw new Error('--title is required.');
if (command === 'handoff' && !options.from) {
throw new Error('--from is required for handoffs.');
}
if (command === 'handoff' && (!options.targets || options.targets.length === 0)) {
throw new Error('At least one --target is required for handoffs.');
}
return printWrite(
saveMemory(saveInput(options, command === 'handoff' ? 'handoff' : null), { roots }),
options.json
);
}
function runSearchCommand({ options, positionals, roots }) {
const query = positionals.join(' ');
return printSearch(query, searchMemories(query, {
roots,
scopes: options.scopes,
kinds: options.kinds,
targetHarness: options.targetHarness,
limit: options.limit,
}), options.json);
}
View on GitHub (pinned to 01e15490f0)
Solutions
- Add at least one `--target <harness>` (e.g. `--target claude --target cursor`) to the handoff.
- If you want the 'address all harnesses' behavior, use the `save` subcommand instead of `handoff`.
- In scripts, fail fast if the computed target list is empty rather than letting the CLI reject it.
Example fix
// before node scripts/memory.js handoff --from claude --title "Hand off work" // after node scripts/memory.js handoff --from claude --target cursor --title "Hand off work"
Defensive patterns
Strategy: validation
Validate before calling
function buildTargets(targets) {
const list = (Array.isArray(targets) ? targets : [targets]).filter(t => typeof t === 'string' && t.length > 0);
if (list.length === 0) throw new Error('handoff needs at least one non-empty --target');
return list.flatMap(t => ['--target', t]);
} Type guard
function hasTargets(value) {
return Array.isArray(value) && value.length > 0 && value.every(t => typeof t === 'string' && t.length > 0);
} Prevention
- Default to the `save` command only if 'all harnesses' is truly intended; otherwise require explicit targets.
- Filter empty strings out of target lists before invoking the CLI so a stray empty does not silently pass the array-length check.
- Unit-test the argument builder against the empty-list edge case.
When it happens
Trigger: Running `node scripts/memory.js handoff --from claude --title "X"` with no `--target`. Passing `--target` with no following value, or an options.targets array that is undefined or zero-length. Note the defaulting in saveInput (`options.targets || ['all']`) only applies to the `save` command path, not this handoff guard.
Common situations: Assuming handoffs default to all harnesses (they do not — only `save` does); a wrapper script that conditionally appends `--target` and skips it when the list is empty; copy-pasting a `save` invocation and changing the verb to `handoff` without adding target flags.
Related errors
- --from is required for handoffs.
- read requires exactly one memory ID.
- Unknown memory command: ${command}
- Unknown argument: ${arg}
- Unknown argument: ${arg}
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/e0b2832cce0e5df2.
Report an issue: GitHub.