Install any skill in seconds. Free to start, no credit card required.
Get Started Free →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.
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-15 | ✗→✓ | ▲ Improved | -50% | 0% |
| case-16 | ✗→✓ | ▲ Improved | -56% | 0% |
| case-01 | ✗→✓ | ▲ Improved | -50% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 5% | 0% |
| case-03 | ✗→✓ | ▲ Improved | -20% | 0% |
Sets up a file watcher using chokidar that monitors a path for changes and runs a Claude prompt against every changed file. The prompt supports a {{file}} placeholder that gets replaced with the changed file path.
bash# 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 | |-----|----------|-------------| | <path> | Yes | File or directory to watch | | <prompt> | Yes | Claude prompt. Use {{file}} for the changed file path | | --glob | No | Glob filter (e.g. *.tsx, *.css) | | --debounce | No | Debounce delay in milliseconds (default: 500) |
add and change events{{file}} placeholder in the prompt is replaced with the actual file pathclaude -p '<prompt>' --print is executed via child_process.execSync| Use Case | Prompt | |----------|--------| | Code review | 'Review {{file}} for bugs and suggest fixes' | | Type checking | 'Check {{file}} for TypeScript type issues' | | Design sync | 'The design file {{file}} changed. Update the corresponding React component' | | Test generation | 'Generate unit tests for {{file}}' | | Documentation | 'Update documentation for changes in {{file}}' |
Filter which files trigger the watcher:
bash--glob '*.tsx' # Only TypeScript React files --glob '*.css' # Only CSS files --glob '*.{ts,tsx}' # TypeScript files (not supported by chokidar glob — use without braces)
Control how long to wait after the last change before triggering:
bash--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 | |-------|----------| | claude CLI not found | Install Claude Code: npm install -g @anthropic-ai/claude-code | | Watcher not detecting changes | Check the path exists and you have read permissions | | Too many invocations | Increase --debounce value | | Prompt with special characters | Wrap prompt in single quotes; {{file}} is the only placeholder | | Permission denied | Ensure the watched directory is readable |
chokidar (devDependency) — file system watcherclaude CLI — must be installed globally and authenticatedOther measured skills in the registry, with their headline benchmark lift.