{"record":{"id":"663a19fbbe1e561f","repo":"yamadashy/repomix","slug":"when-using-stdin-do-not-specify-directory-argum","errorCode":null,"errorMessage":"When using --stdin, do not specify directory arguments. File paths will be read from stdin.","messagePattern":"When using --stdin, do not specify directory arguments\\. File paths will be read from stdin\\.","errorType":"exception","errorClass":"RepomixError","httpStatus":null,"severity":"error","filePath":"src/cli/actions/defaultAction.ts","lineNumber":137,"sourceCode":"\n    // Determine skill directory\n    if (cliOptions.skillOutput && !cliOptions.skillDir) {\n      // Non-interactive mode: use provided path directly\n      cliOptions.skillDir = await resolveAndPrepareSkillDir(cliOptions.skillOutput, cwd, cliOptions.force ?? false);\n    } else if (!cliOptions.skillDir) {\n      // Interactive mode: prompt for skill location\n      const promptResult = await promptSkillLocation(cliOptions.skillName, cwd);\n      cliOptions.skillDir = promptResult.skillDir;\n    }\n  }\n\n  // Handle stdin processing\n  let stdinFilePaths: string[] | undefined;\n  if (cliOptions.stdin) {\n    // Validate directory arguments for stdin mode\n    const firstDir = directories[0] ?? '.';\n    if (directories.length > 1 || firstDir !== '.') {\n      throw new RepomixError(\n        'When using --stdin, do not specify directory arguments. File paths will be read from stdin.',\n      );\n    }\n\n    const stdinResult = await readFilePathsFromStdin(cwd);\n    stdinFilePaths = stdinResult.filePaths;\n    logger.trace(`Read ${stdinFilePaths.length} file paths from stdin`);\n  }\n\n  // Run pack() directly in the main process instead of spawning a child process.\n  // The child process startup cost (~250ms for Node.js init + module re-loading) was\n  // pure overhead since the spinner and pack ran in the same child process anyway.\n  const spinner = new Spinner('Initializing...', cliOptions);\n  spinner.start();\n\n  let packResult: PackResult;\n\n  try {","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/yamadashy/repomix/blob/f465ad909315a22120636baf03fa5e28701a50cb/src/cli/actions/defaultAction.ts#L119-L155","documentation":"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).","triggerScenarios":"`repomix --stdin src` or `repomix --stdin src tests`; any call where directories.length > 1 or directories[0] !== '.' while cliOptions.stdin is true.","commonSituations":"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.","solutions":["Remove the directory arguments and pipe file paths in: `git ls-files | repomix --stdin`.","If you intended to pack a directory, drop --stdin: `repomix src`.","If you need to constrain scope, filter the stdin path list (e.g. `git ls-files src | repomix --stdin`)."],"exampleFix":"# before\ngit ls-files | repomix --stdin src\n# after\ngit ls-files src | repomix --stdin","handlingStrategy":"validation","validationCode":"if (args.includes('--stdin') && args.filter(a => !a.startsWith('-') && !['--stdin'].includes(a)).some(a => a !== '.')) {\n  throw new Error('--stdin does not accept directory arguments; pipe paths via stdin');\n}","typeGuard":"const stdinArgsValid = (args: string[]): boolean =>\n  !args.includes('--stdin') || args.filter(a => !a.startsWith('-') && a !== '--stdin').every(a => a === '.');","tryCatchPattern":"try {\n  await repomixRun(args, { input: filePaths });\n} catch (e) {\n  if (String(e.message).includes('When using --stdin, do not specify directory arguments')) {\n    throw new Error('Remove positional directories; filter the stdin path list instead');\n  }\n  throw e;\n}","preventionTips":["Remember: --stdin means the path list comes from stdin only.","Filter the piped list (git ls-files <dir>) to scope output instead of passing directories.","Keep separate command templates for stdin mode and directory mode."],"tags":["cli","stdin","argument-validation","repomix"],"backgroundTag":"mutually-exclusive-cli-options","analyzedSha":"f465ad909315a22120636baf03fa5e28701a50cb","analyzedAt":"2026-08-29T01:27:42.024Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}