affaan-m/ECC · error · Error
Unknown argument: ${arg}
Error message
Unknown argument: ${arg} What it means
Thrown at the end of platform-audit's parseArgs loop when a token matched no recognized flag. The parser handles --help, --format(+==), --json, --markdown, --root(+==), --repo(+==), --skip-github, --allow-untracked(+==), --write(+==), the three --max-* integer flags(+==), --use-env-github-token, and --exit-code; anything else is rejected outright rather than silently ignored.
Source
Thrown at scripts/platform-audit.js:202
continue;
}
if (arg.startsWith('--max-dirty-files=')) {
parsed.thresholds.maxDirtyFiles = parseIntegerFlag(arg.slice('--max-dirty-files='.length), '--max-dirty-files');
continue;
}
if (arg === '--use-env-github-token') {
parsed.useEnvGithubToken = true;
continue;
}
if (arg === '--exit-code') {
parsed.exitCode = true;
continue;
}
throw new Error(`Unknown argument: ${arg}`);
}
if (!['text', 'json', 'markdown'].includes(parsed.format)) {
throw new Error(`Invalid format: ${parsed.format}. Use text, json, or markdown.`);
}
if (parsed.writePath && parsed.format === 'text') {
throw new Error('--write requires --json, --markdown, or --format json|markdown');
}
parsed.allowUntracked = parsed.allowUntracked.map(normalizeRelativePrefix);
return parsed;
}
function normalizeRelativePrefix(value) {
return String(value || '')
.replace(/\\/g, '/')View on GitHub (pinned to 01e15490f0)
Solutions
- Run `--help` to list every accepted flag for this installed version.
- Quote shell arguments and check glob expansion if a path was intended.
- Use the `=` form for value flags to reduce ordering mistakes that masquerade as unknown args.
Example fix
# before node scripts/platform-audit.js --alllow-untracked src/ --repo owner/repo # after node scripts/platform-audit.js --allow-untracked src/ --repo owner/repo
Defensive patterns
Strategy: validation
Validate before calling
const ACCEPTED_PLATFORM_AUDIT_FLAGS = new Set([
'--help','-h','--format','--json','--markdown','--root','--repo',
'--skip-github','--allow-untracked','--write','--max-open-prs',
'--max-open-issues','--max-dirty-files','--use-env-github-token','--exit-code'
]);
function isAcceptedFlag(token) {
const base = token.split('=')[0];
return ACCEPTED_PLATFORM_AUDIT_FLAGS.has(base);
} Type guard
function isKnownPlatformAuditFlag(token) {
const base = token.startsWith('--') ? token.split('=')[0] : token;
return ACCEPTED_PLATFORM_AUDIT_FLAGS.has(base);
} Try / catch
try {
parseArgs(process.argv);
} catch (err) {
if (err.message.startsWith('Unknown argument')) {
console.error(`${err.message}. Run --help for the accepted flag list.`);
process.exit(2);
}
throw err;
} Prevention
- Run --help for the authoritative flag list of the installed version.
- Quote path arguments and check shell glob expansion.
- Use `--flag=value` form to reduce ordering-related typos.
When it happens
Trigger: A typo like `--jsom` or `--alllow-untracked`; passing a positional repo path instead of `--repo`; using a flag from a newer/older version; an unintended shell expansion injecting a stray token.
Common situations: Version drift between the docs the user read and the installed script; copy-pasting flags from a different tool; shell glob expanding to multiple words the parser sees as flags.
Related errors
- ${flagName} requires a value
- Invalid ${flagName}: ${value}
- Invalid format: ${parsed.format}. Use text, json, or markdow
- --write requires --json, --markdown, or --format json|markdo
- Unknown argument: ${arg}
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/4e31f22d11b425d7.
Report an issue: GitHub.