yamadashy/repomix · error · RepomixError
Invalid number for --top-files-len: '${v}'. Must be a non-ne
Error message
Invalid number for --top-files-len: '${v}'. Must be a non-negative integer. What it means
`--top-files-len` sets how many largest files appear in the summary. The CLI parses it with a strict `/^\d+$/` check; anything else throws this RepomixError during argument parsing.
Source
Thrown at src/cli/cliRun.ts:96
.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')
.option('-o, --output <file>', 'Output file path (default: repomix-output.xml, use "-" for stdout)')
.option('--style <type>', 'Output format: xml, markdown, json, or plain (default: xml)')
.addOption(
new Option(
'--output-file-path-style <style>',
'How file paths are shown in output: target-relative or cwd-relative (default: target-relative)',
).choices(['target-relative', 'cwd-relative']),
)
.option(
'--parsable-style',
'Escape special characters to ensure valid XML/Markdown (needed when output contains code that breaks formatting)',
)View on GitHub (pinned to f465ad9093)
Solutions
- Pass a non-negative integer: `--top-files-len 20`
- Ensure the value immediately follows the flag and is not empty
- Check variables used in scripts expand to valid integers
Example fix
// before repomix --top-files-len -1 // after repomix --top-files-len 20
Defensive patterns
Strategy: validation
Validate before calling
const i = process.argv.indexOf('--top-files-len');
const v = i !== -1 ? process.argv[i + 1] : undefined;
if (v !== undefined && !/^\d+$/.test(v)) {
throw new Error(`--top-files-len needs a non-negative integer, got: ${v}`);
} 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('--top-files-len')) {
console.error('Usage: --top-files-len 20 (non-negative integer)');
}
process.exitCode = 1;
} Prevention
- Always provide an explicit integer right after the flag
- Validate script variables before interpolating into CLI args
When it happens
Trigger: Passing `--top-files-len` with a non-integer value: negative (`-1`), decimal (`2.5`), empty, or a stray token swallowed by the option (e.g. `--top-files-len --include` patterns where commander consumes the next flag).
Common situations: Typos (`--top-files-len 2O` with letter O), forgetting the value so it eats the next flag, or scripting with unquoted/unexpanded variables that resolve empty.
Related errors
- Invalid token count threshold: '${value}'. Must be a non-neg
- 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/a7b0d1ceafb57d74.
Report an issue: GitHub.