yamadashy/repomix · error · RepomixError
Invalid token count threshold: '${value}'. Must be a non-neg
Error message
Invalid token count threshold: '${value}'. Must be a non-negative integer. What it means
The `--token-count-tree` option accepts an optional numeric threshold for showing only files with ≥N tokens. Commander invokes this parser during CLI parsing, and any non-integer (or negative) string value throws immediately. Bare `--token-count-tree` (boolean) is allowed.
Source
Thrown at src/cli/cliRun.ts:84
)
.addOption(
new Option('--quiet', 'Suppress all console output except errors (useful for scripting)').conflicts('verbose'),
)
.addOption(
new Option(
'--stdout',
'Write packed output directly to stdout instead of a file (suppresses all logging)',
).conflicts('output'),
)
.option('--stdin', 'Read file paths from stdin, one per line (specified files are processed directly)')
.option('--copy', 'Copy the generated output to system clipboard after processing')
.option(
'--token-count-tree [threshold]',
'Show file tree with token counts; optional threshold to show only files with ≥N tokens (e.g., --token-count-tree 100)',
(value: string | boolean) => {
if (typeof value === 'string') {
if (!/^\d+$/.test(value)) {
throw new RepomixError(`Invalid token count threshold: '${value}'. Must be a non-negative integer.`);
}
return Number(value);
}
return value;
},
)
.option(
'--top-files-len <number>',
'Number of largest files to show in summary (default: 5, e.g., --top-files-len 20)',
(v: string) => {
if (!/^\d+$/.test(v)) {
throw new RepomixError(`Invalid number for --top-files-len: '${v}'. Must be a non-negative integer.`);
}
return Number(v);
},
)
// Repomix Output Options
.optionsGroup('Repomix Output Options')View on GitHub (pinned to f465ad9093)
Solutions
- Pass a plain non-negative integer: `--token-count-tree 100`
- Remove thousands separators/units (use 1000, not 1,000 or 1k)
- If you want the tree without a threshold, pass the flag with no value
Example fix
// before repomix --token-count-tree 1,000 // after repomix --token-count-tree 1000
Defensive patterns
Strategy: validation
Validate before calling
const t = process.argv[process.argv.indexOf('--token-count-tree') + 1];
if (typeof t === 'string' && !/^\d+$/.test(t)) {
throw new Error(`--token-count-tree needs a non-negative integer, got: ${t}`);
} Type guard
const isNonNegativeInt = (v: unknown): v is number => typeof v === 'number' && Number.isInteger(v) && v >= 0;
Try / catch
try {
parseArgv(argv);
} catch (e) {
if (e instanceof RepomixError && e.message.includes('Invalid token count threshold')) {
console.error('Usage: --token-count-tree 100 (plain non-negative integer)');
}
process.exitCode = 1;
} Prevention
- Always pass plain digits (no commas, decimals, units, or signs)
- Remember the optional value is greedy: insert `--` or order flags to avoid swallowing the next token
When it happens
Trigger: Passing a non-numeric or negative value such as `--token-count-tree 1,000`, `--token-count-tree 100.5`, `--token-count-tree -1`, or a flag-swallowing typo like `--token-count-tree auto`.
Common situations: Users writing thousands separators or units (`1000`, `1k`) out of habit, or accidentally passing the next flag's value because `--token-count-tree` greedily consumes the following token.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- Invalid number for --top-files-len: '${v}'. Must be a non-ne
- Invalid number for --include-logs-count: '${v}'. Must be a n
- --skill-output can only be used with --skill-generate
- --force can only be used with --skill-generate
- --skill-project-name can only be used with --skill-generate
AI-assisted analysis of yamadashy/repomix@f465ad9093 (2026-08-29).
Data as JSON: /api/errors/d9a2eec10e1b3e81.
Report an issue: GitHub.