affaan-m/ECC · error · Error

Unknown command: ${options.command}

Error message

Unknown command: ${options.command}

What it means

Thrown at the end of the command dispatch chain when options.command is not one of list, show, upsert, close, claim, or sync-github. parseArgs treats the first non-dash argv token as the command, so any typo or stray word becomes an unknown command rather than a silent default to list.

Source

Thrown at scripts/work-items.js:514

        console.log('No unassigned open work items to claim.');
      } else {
        console.log(`Claimed by ${result.item.owner}:`);
        printWorkItem(result.item);
      }
      return;
    }

    if (options.command === 'sync-github') {
      const payload = syncGithubWorkItems(store, options);
      if (options.json) {
        console.log(JSON.stringify(payload, null, 2));
      } else {
        printGithubSyncResult(payload);
      }
      return;
    }

    throw new Error(`Unknown command: ${options.command}`);
  } catch (error) {
    console.error(`Error: ${error.message}`);
    process.exit(1);
  } finally {
    if (store) {
      store.close();
    }
  }
}

if (require.main === module) {
  main();
}

module.exports = {
  buildUpsertPayload,
  buildGithubIssueWorkItem,
  buildGithubPrWorkItem,

View on GitHub (pinned to 01e15490f0)

Solutions

  1. Run `node scripts/work-items.js --help` to see the supported commands.
  2. Correct the command word: list, show, upsert, close, claim, sync-github.
  3. Make sure no leading positional (e.g. an env var expansion) is being consumed as the command.

Example fix

// before
node scripts/work-items.js clsoe refactor-state-store

// after
node scripts/work-items.js close refactor-state-store
Defensive patterns

Strategy: validation

Validate before calling

const WORK_ITEM_COMMANDS = new Set(['list', 'show', 'upsert', 'close', 'claim', 'sync-github']);
function ensureKnownCommand(cmd) {
  if (!WORK_ITEM_COMMANDS.has(cmd)) {
    throw new Error(`Unknown command: ${cmd}. Valid: ${[...WORK_ITEM_COMMANDS].join(', ')}`);
  }
  return cmd;
}

Type guard

function isWorkItemCommand(cmd) {
  return typeof cmd === 'string'
    && ['list', 'show', 'upsert', 'close', 'claim', 'sync-github'].includes(cmd);
}

Prevention

When it happens

Trigger: Typing a subcommand wrong: `node scripts/work-items.js clsoe <id>`, `node scripts/work-items.js upsertt ...`, or passing a flag-like positional. The default command is 'list', so running the script with no command word does not hit this.

Common situations: Typos; using an old command name after a rename; shell alias inserting an extra token that becomes the command; copy-paste from docs that use a placeholder like `<command>`.

Related errors


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