yamadashy/repomix · error · RepomixError

When using --stdin, do not specify directory arguments. File

Error message

When using --stdin, do not specify directory arguments. File paths will be read from stdin.

What it means

In --stdin mode, repomix reads the list of file paths from standard input, so positional directory arguments are meaningless and would silently conflict with stdin input. runDefaultAction throws this when --stdin is combined with more than one directory or a directory other than the default '.' (src/cli/actions/defaultAction.ts:137).

Source

Thrown at src/cli/actions/defaultAction.ts:137

    // Determine skill directory
    if (cliOptions.skillOutput && !cliOptions.skillDir) {
      // Non-interactive mode: use provided path directly
      cliOptions.skillDir = await resolveAndPrepareSkillDir(cliOptions.skillOutput, cwd, cliOptions.force ?? false);
    } else if (!cliOptions.skillDir) {
      // Interactive mode: prompt for skill location
      const promptResult = await promptSkillLocation(cliOptions.skillName, cwd);
      cliOptions.skillDir = promptResult.skillDir;
    }
  }

  // Handle stdin processing
  let stdinFilePaths: string[] | undefined;
  if (cliOptions.stdin) {
    // Validate directory arguments for stdin mode
    const firstDir = directories[0] ?? '.';
    if (directories.length > 1 || firstDir !== '.') {
      throw new RepomixError(
        'When using --stdin, do not specify directory arguments. File paths will be read from stdin.',
      );
    }

    const stdinResult = await readFilePathsFromStdin(cwd);
    stdinFilePaths = stdinResult.filePaths;
    logger.trace(`Read ${stdinFilePaths.length} file paths from stdin`);
  }

  // Run pack() directly in the main process instead of spawning a child process.
  // The child process startup cost (~250ms for Node.js init + module re-loading) was
  // pure overhead since the spinner and pack ran in the same child process anyway.
  const spinner = new Spinner('Initializing...', cliOptions);
  spinner.start();

  let packResult: PackResult;

  try {

View on GitHub (pinned to f465ad9093)

Solutions

  1. Remove the directory arguments and pipe file paths in: `git ls-files | repomix --stdin`.
  2. If you intended to pack a directory, drop --stdin: `repomix src`.
  3. If you need to constrain scope, filter the stdin path list (e.g. `git ls-files src | repomix --stdin`).

Example fix

# before
git ls-files | repomix --stdin src
# after
git ls-files src | repomix --stdin
Defensive patterns

Strategy: validation

Validate before calling

if (args.includes('--stdin') && args.filter(a => !a.startsWith('-') && !['--stdin'].includes(a)).some(a => a !== '.')) {
  throw new Error('--stdin does not accept directory arguments; pipe paths via stdin');
}

Type guard

const stdinArgsValid = (args: string[]): boolean =>
  !args.includes('--stdin') || args.filter(a => !a.startsWith('-') && a !== '--stdin').every(a => a === '.');

Try / catch

try {
  await repomixRun(args, { input: filePaths });
} catch (e) {
  if (String(e.message).includes('When using --stdin, do not specify directory arguments')) {
    throw new Error('Remove positional directories; filter the stdin path list instead');
  }
  throw e;
}

Prevention

When it happens

Trigger: `repomix --stdin src` or `repomix --stdin src tests`; any call where directories.length > 1 or directories[0] !== '.' while cliOptions.stdin is true.

Common situations: Wrapping an existing `repomix <dir>` script and appending --stdin; aliases that inject --stdin for one use case then reused with explicit directories; misunderstanding that --stdin takes paths only from the piped stream.

Related errors


AI-assisted analysis of yamadashy/repomix@f465ad9093 (2026-08-29). Data as JSON: /api/errors/663a19fbbe1e561f. Report an issue: GitHub.