affaan-m/ECC · error · Error

Unknown command

Error message

Unknown command: ${options.command}

What it means

The work-items CLI dispatches on options.command and throws this error when the command name matches none of its known subcommands (create, list, get, close, sync, etc.). The unknown-command check is the fall-through at the end of the dispatch chain, meaning argv parsing itself succeeded but the verb was unrecognized.

Solutions

  1. Run the script with no arguments or with --help to print the supported command list.
  2. Correct the command spelling (e.g. `close` not `clos`).
  3. Check whether the intended operation exists under a different verb (e.g. `remove` may be `close`, `sync` for GitHub sync).
  4. If the command was recently renamed in the repo, update your scripts/aliases to the new name.

Example fix

// before
node scripts/work-items.js delete wi-0042
// Error: Unknown command: delete

// after
node scripts/work-items.js close wi-0042
Defensive patterns

Strategy: validation

Validate before calling

const VALID = ['create','list','get','close','sync'];
const cmd = process.argv[2];
if (!VALID.includes(cmd)) { console.error(`Unsupported command: ${cmd}. Valid: ${VALID.join(', ')}`); process.exit(2); }

Try / catch

try {
  execSync(`node scripts/work-items.js ${cmd} ${args}`);
} catch (e) {
  if (String(e.stderr).startsWith('Error: Unknown command')) {
    execSync('node scripts/work-items.js --help', { stdio: 'inherit' });
  }
}

Prevention

When it happens

Trigger: Calling the script with an unsupported verb, e.g. `node scripts/work-items.js delete <id>` or `remove`, or an empty command (`node scripts/work-items.js` with no subcommand), or a misspelled command like `clos`.

Common situations: Typo in the command; guessing a command that does not exist (e.g. expecting `delete`); outdated docs referencing a renamed subcommand; forgetting the subcommand entirely so options.command is undefined.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/97ef12a4a6b9f4af. Report an issue: GitHub.

Appendix: 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 8321021c54)