{"record":{"id":"49f9cf476b0598f5","repo":"yamadashy/repomix","slug":"watch-cannot-be-used-with-copy-watch-mode-re","errorCode":null,"errorMessage":"--watch cannot be used with --copy. Watch mode re-packs on every change, which would repeatedly overwrite the clipboard.","messagePattern":"--watch cannot be used with --copy\\. Watch mode re-packs on every change, which would repeatedly overwrite the clipboard\\.","errorType":"exception","errorClass":"RepomixError","httpStatus":null,"severity":"error","filePath":"src/cli/actions/watchAction.ts","lineNumber":98,"sourceCode":"  // 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`));\n\n  // Watch target directories instead of individual files so new files are detected.\n  // The ignore predicate mirrors the packer so chokidar stays out of node_modules/.git\n  // and gitignored trees (prevents EMFILE on large projects) and avoids wasted rebuilds.\n  const buildIgnoreFilter = resolvedDeps.buildIgnoreFilter ?? buildWatchIgnoreFilter;\n  const watchIgnoreFilter = await buildIgnoreFilter(targetPaths, config);\n  const watcher = resolvedDeps.watch(targetPaths, {\n    ignoreInitial: true,","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/yamadashy/repomix/blob/f465ad909315a22120636baf03fa5e28701a50cb/src/cli/actions/watchAction.ts#L80-L116","documentation":"Watch mode re-packs on every file change; with `--copy` (copyToClipboard) each re-pack would overwrite the clipboard repeatedly. `runWatchAction` rejects this combination.","triggerScenarios":"Running `repomix --watch --copy`, or `--watch` with `output.copyToClipboard: true` in the config file.","commonSituations":"A user whose config enables `copyToClipboard: true` by default adds `--watch` and hits the conflict even without passing `--copy` explicitly.","solutions":["Drop `--copy` when using `--watch`","Set `output.copyToClipboard: false` in repomix.config.json for watch runs","Run a one-shot `repomix --copy` when you actually want the clipboard content"],"exampleFix":"// before\nrepomix --watch --copy\n// after\nrepomix --watch\n# when needed: repomix --copy","handlingStrategy":"validation","validationCode":"if (watch && (argv.includes('--copy') || cfg.output?.copyToClipboard === true)) {\n  throw new Error('Disable clipboard copy when using --watch');\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 --copy')) {\n    console.error('Remove --copy (and copyToClipboard from config) for watch mode.');\n  }\n  throw e;\n}","preventionTips":["Check config for output.copyToClipboard: true before running with --watch","Use a one-shot `repomix --copy` when clipboard content is needed"],"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"}