file-watcher
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.
- License 许可
- MIT
- 最近更新
- 2026-05-18
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- file-watcher
- description
- 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.
03 SKILL.md 正文
File Watcher Skill
Overview
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.
Quick Start
# 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}}'
CLI Reference
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) |
How It Works
- Chokidar watches the target path for
addandchangeevents - Changes are debounced (default 500ms) to batch rapid saves
- For each changed file, the
{{file}}placeholder in the prompt is replaced with the actual file path claude -p '<prompt>' --printis executed viachild_process.execSync- Claude's output is logged to stdout
Example Prompts
| 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}}' |
Configuration
Glob Patterns
Filter which files trigger the watcher:
--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
Control how long to wait after the last change before triggering:
--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
Troubleshooting
| 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 |
Dependencies
chokidar(devDependency) — file system watcherclaudeCLI — must be installed globally and authenticated
04 同仓库更多 Skills
webapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
web-design-guidelines
Review UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "check accessibility", "audit design", "review UX", or "check my site against best practices".
vercel-react-view-transitions
Guide for implementing smooth, native-feeling animations using React's View Transition API (`<ViewTransition>` component, `addTransitionType`, and CSS view transition pseudo-elements). Use this skill whenever the user wants to add page transitions, animate route changes, create shared element animations, animate enter/exit of components, animate list reorder, implement directional (forward/back) navigation animations, or integrate view transitions in Next.js. Also use when the user mentions view transitions, `startViewTransition`, `ViewTransition`, transition types, or asks about animating between UI states in React without third-party animation libraries.
vercel-react-best-practices
React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.
vercel-composition-patterns
React composition patterns that scale. Use when refactoring components with boolean prop proliferation, building flexible component libraries, or designing reusable APIs. Triggers on tasks involving compound components, render props, context providers, or component architecture. Includes React 19 API changes.
vercel-cli-with-tokens
Deploy and manage projects on Vercel using token-based authentication. Use when working with Vercel CLI using access tokens rather than interactive login — e.g. "deploy to vercel", "set up vercel", "add environment variables to vercel".