file-watcher

GitHub

基于Chokidar的文件监听工具,检测到文件变更时自动触发Claude AI进行代码审查、测试生成或文档更新等自动化处理。

.claude/skills/file-watcher/SKILL.md qdhenry/Claude-Command-Suite

Trigger Scenarios

需要自动化代码审查 文件变更后自动生成测试 配置或设计同步 批量代码验证

Install

npx skills add qdhenry/Claude-Command-Suite --skill file-watcher -g -y
More Options

Non-standard path

npx skills add https://github.com/qdhenry/Claude-Command-Suite/tree/main/.claude/skills/file-watcher -g -y

Use without installing

npx skills use qdhenry/Claude-Command-Suite@file-watcher

指定 Agent (Claude Code)

npx skills add qdhenry/Claude-Command-Suite --skill file-watcher -a claude-code -g -y

安装 repo 全部 skill

npx skills add qdhenry/Claude-Command-Suite --all -g -y

预览 repo 内 skill

npx skills add qdhenry/Claude-Command-Suite --list

SKILL.md

Frontmatter
{
    "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."
}

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

  1. Chokidar watches the target path for add and change events
  2. Changes are debounced (default 500ms) to batch rapid saves
  3. For each changed file, the {{file}} placeholder in the prompt is replaced with the actual file path
  4. claude -p '<prompt>' --print is executed via child_process.execSync
  5. 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 watcher
  • claude CLI — must be installed globally and authenticated

Version History

  • e89b2f0 Current 2026-08-20 06:58

Same Skill Collection

.claude/skills/audit-env-variables/SKILL.md
.claude/skills/bigcommerce-api/SKILL.md
.claude/skills/elevenlabs-transcribe/SKILL.md
.claude/skills/extract-video-frames/SKILL.md
.claude/skills/remove-dead-code/SKILL.md
.claude/skills/setup-agent-tail/SKILL.md
.claude/skills/setup-portless/SKILL.md
.claude/skills/webmcp/SKILL.md

Metadata

Files
0
Version
e89b2f0
Hash
14106e69
Indexed
2026-08-20 06:58

inicio - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-22 03:53
浙ICP备14020137号-1 $mapa de visitantes$