← Back to list

watch-dir
by prichodko
⭐ 0🍴 0📅 Jan 19, 2026
SKILL.md
name: watch-dir description: Watch directories for file changes using Node.js fs.watch. Use when monitoring files, detecting changes, or building watch-based workflows.
Watch Directory
Watch directory and subdirectories for changes using fs.watch.
CLI
.claude/skills/watch-dir/watch.ts [dir]
Watches dir (default: current) recursively. Outputs event: path on changes. Ctrl-C to stop.
Code Examples
Basic (recursive)
import { watch } from "fs";
const watcher = watch("./src", { recursive: true }, (event, path) => {
console.log(`${event}: ${path}`);
});
Async iterator
import { watch } from "fs/promises";
const watcher = watch("./src", { recursive: true });
for await (const { eventType, filename } of watcher) {
console.log(`${eventType}: ${filename}`);
}
Cleanup on SIGINT
import { watch } from "fs";
const watcher = watch("./src", { recursive: true }, (event, path) => {
console.log(`${event}: ${path}`);
});
process.on("SIGINT", () => {
watcher.close();
process.exit(0);
});
Events
rename: file created, deleted, or renamedchange: file content modified
Notes
recursive: truerequired for subdirectoriesimport.meta.dir= current file's directory (bun only)- call
watcher.close()to stop watching
Score
Total Score
50/100
Based on repository quality metrics
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
Reviews
💬
Reviews coming soon