Loading...
Loading...
Chokidar-based file watcher that triggers `claude -p` on changes. Useful for automated AI reactions to file changes — design sync, code validation, config regeneration, etc.
npx skill4agent add qdhenry/claude-command-suite file-watcher{{file}}# Watch src/ and analyze any changed file
node scripts/watch-files.mjs ./src 'Analyze {{file}} for issues'
# Watch only .tsx files with 1s debounce
node scripts/watch-files.mjs ./src 'Review {{file}} for React best practices' --glob '*.tsx' --debounce 1000
# Via package.json script (pass args after --)
bun run watch:files -- ./src 'Check {{file}}'node scripts/watch-files.mjs <path> <prompt> [--glob '<pattern>'] [--debounce <ms>]| Arg | Required | Description |
|---|---|---|
| Yes | File or directory to watch |
| Yes | Claude prompt. Use |
| No | Glob filter (e.g. |
| No | Debounce delay in milliseconds (default: 500) |
addchange{{file}}claude -p '<prompt>' --printchild_process.execSync| Use Case | Prompt |
|---|---|
| Code review | |
| Type checking | |
| Design sync | |
| Test generation | |
| Documentation | |
--glob '*.tsx' # Only TypeScript React files
--glob '*.css' # Only CSS files
--glob '*.{ts,tsx}' # TypeScript files (not supported by chokidar glob — use without braces)--debounce 200 # Fast (200ms) — good for single-file saves
--debounce 1000 # Slow (1s) — good for batch operations
--debounce 5000 # Very slow (5s) — good for build output directories| Issue | Solution |
|---|---|
| Install Claude Code: |
| Watcher not detecting changes | Check the path exists and you have read permissions |
| Too many invocations | Increase |
| Prompt with special characters | Wrap prompt in single quotes; |
| Permission denied | Ensure the watched directory is readable |
chokidarclaude