{"record":{"id":"06a20a2ac047712d","repo":"yamadashy/repomix","slug":"watch-cannot-be-used-with-stdout-output-watch-m","errorCode":null,"errorMessage":"--watch cannot be used with stdout output. Watch mode writes to a file.","messagePattern":"--watch cannot be used with stdout output\\. Watch mode writes to a file\\.","errorType":"exception","errorClass":"RepomixError","httpStatus":null,"severity":"error","filePath":"src/cli/actions/watchAction.ts","lineNumber":90,"sourceCode":"\n  logger.trace('Watch mode: loaded CLI options:', redactOptionsForLog(cliOptions));\n\n  const config = await buildMergedConfig(cwd, cliOptions);\n\n  // Watch-specific incompatibilities. Each of these is independently incompatible with\n  // --watch and can also be set via the config file (which validateWatchOptions in cliRun,\n  // CLI-flags-only, does not see), so re-check them on the merged config here. They are\n  // checked individually rather than via the shared validateConflictingOptions so the error\n  // always names --watch instead of a (potentially confusing) pairwise conflict.\n  if (config.output.splitOutput !== undefined) {\n    // Split output would create numbered files that the watcher then picks up, looping.\n    throw new RepomixError(\n      '--watch cannot be used with split output. Watch mode does not yet support split output files.',\n    );\n  }\n  // `output: \"-\"` resolves to stdout mode via filePath === '-', the same as --stdout.\n  if (config.output.stdout || config.output.filePath === '-') {\n    throw new RepomixError('--watch cannot be used with stdout output. Watch mode writes to a file.');\n  }\n  if (config.skillGenerate !== undefined) {\n    throw new RepomixError(\n      '--watch cannot be used with --skill-generate. Watch mode does not support skill generation.',\n    );\n  }\n  if (config.output.copyToClipboard) {\n    throw new RepomixError(\n      '--watch cannot be used with --copy. Watch mode re-packs on every change, which would repeatedly overwrite the clipboard.',\n    );\n  }\n\n  const targetPaths = directories.map((directory) => path.resolve(cwd, directory));\n\n  // Run initial pack\n  const packResult = await runPack(targetPaths, config, cliOptions);\n  reportResults(cwd, packResult, config, cliOptions);\n  logger.log(pc.dim(`\\nWatching ${packResult.safeFilePaths.length} files for changes... (Ctrl+C to stop)\\n`));","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/yamadashy/repomix/blob/f465ad909315a22120636baf03fa5e28701a50cb/src/cli/actions/watchAction.ts#L72-L108","documentation":"Watch mode must write its output to a file so it can re-pack and detect changes; stdout mode (`--stdout` or `output.filePath === '-'`) cannot be watched. `runWatchAction` rejects this combination on the merged config.","triggerScenarios":"Running `repomix --watch --stdout`, or `repomix --watch` with `output.stdout: true` or `output.filePath: \"-\"` set in the config file.","commonSituations":"A user who normally pipes repomix output to another tool (`repomix --stdout | llm ...`) tries adding `--watch` to refresh the piped output automatically.","solutions":["Drop `--stdout` when using `--watch`","Remove `stdout: true` or `filePath: \"-\"` from the config file for watch runs","Write to a real file with `--watch` and `tail -f`/re-read the file instead of piping stdout"],"exampleFix":"// before\nrepomix --watch --stdout | ai-tool\n// after\nrepomix --watch   # writes repomix-output.xml\nai-tool < repomix-output.xml","handlingStrategy":"validation","validationCode":"if (watch && (stdout || filePath === '-')) {\n  throw new Error('--watch requires a real output file, not stdout');\n}","typeGuard":"null","tryCatchPattern":"try {\n  await runRepomix({ watch: true });\n} catch (e) {\n  if (e instanceof RepomixError && e.message.includes('--watch cannot be used with stdout')) {\n    console.error('Drop --stdout (or filePath \"-\") when watching.');\n  }\n  throw e;\n}","preventionTips":["Never pair --watch with --stdout; write to a file and tail it instead","Check config for output.stdout: true or filePath: '-' before watch runs"],"tags":["cli","watch-mode","conflicting-options"],"backgroundTag":"incompatible-cli-options","analyzedSha":"f465ad909315a22120636baf03fa5e28701a50cb","analyzedAt":"2026-08-29T01:27:42.024Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}