file-watcher
Configure file watching hooks to auto-react to config changes, env file updates, and dependency modifications. Use to set up reactive workflows.
Best use case
file-watcher is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Configure file watching hooks to auto-react to config changes, env file updates, and dependency modifications. Use to set up reactive workflows.
Teams using file-watcher should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/file-watcher/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How file-watcher Compares
| Feature / Agent | file-watcher | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Configure file watching hooks to auto-react to config changes, env file updates, and dependency modifications. Use to set up reactive workflows.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# File Watcher
Use Claude Code's `FileChanged` and `CwdChanged` hooks to create reactive workflows that respond to file system changes.
## Trigger
Use when:
- Setting up auto-reload for config changes
- Watching for dependency updates
- Monitoring build output
- Creating reactive development workflows
## How File Watching Works
Claude Code's `SessionStart` and `CwdChanged` hooks support returning `watchPaths` to register file watchers. The current `cwd-changed.js` script focuses on env injection; to add watch registration, your hook script must output this JSON structure:
```json
{
"hookSpecificOutput": {
"hookEventName": "SessionStart",
"watchPaths": [
"/absolute/path/to/.env",
"/absolute/path/to/package.json"
]
}
}
```
When watched files change, the `FileChanged` hook fires with:
```json
{
"hook_event_name": "FileChanged",
"file_path": "/path/to/changed/file",
"event": "change"
}
```
## Environment Injection
`CwdChanged` and `FileChanged` hooks can write to `CLAUDE_ENV_FILE` to inject environment variables into subsequent Bash commands:
```bash
echo "export PROJECT_TYPE=node" >> "$CLAUDE_ENV_FILE"
echo "export TEST_CMD='npm test'" >> "$CLAUDE_ENV_FILE"
```
## Common Watch Patterns
### Watch .env for Changes
```javascript
const envFile = path.join(projectRoot, '.env');
if (fs.existsSync(envFile)) {
output.hookSpecificOutput = {
hookEventName: 'SessionStart',
watchPaths: [envFile]
};
}
```
### Watch package.json for Dependency Changes
Detect when dependencies change and remind to run `npm install`.
### Watch tsconfig.json for Config Changes
Remind to restart TypeScript checks when config changes.
## Setup
Add to hooks.json:
```json
{
"FileChanged": [{
"matcher": ".env|package.json|tsconfig.json",
"hooks": [{
"type": "command",
"command": "node scripts/file-changed.js"
}]
}]
}
```
## Rules
- Use absolute paths for watchPaths (required by Claude Code)
- Matcher uses pipe-separated filenames
- Watcher uses 500ms stability threshold and 200ms poll interval
- Keep file-changed handlers fast (<5s) to avoid blocking
- Use `CLAUDE_ENV_FILE` for injecting env vars, not direct exportRelated Skills
wrap-up
End-of-session ritual that audits changes, runs quality checks, captures learnings, and produces a session summary. Use when saying "wrap up", "done for the day", "finish coding", or ending a coding session.
thoroughness-scoring
Score every decision point with a Thoroughness Rating (1-10). AI makes the marginal cost of doing things properly near-zero — pick the higher-rated option every time. Includes scope checks to distinguish contained vs unbounded work.
sprint-status
Track parallel work sessions and prevent confusion across multiple Claude Code instances. Every major step ends with a status line. Every question re-states project, branch, and task.
smart-commit
Run quality gates, review staged changes for issues, and create a well-crafted conventional commit. Use when saying "commit", "git commit", "save my changes", or ready to commit after making changes.
session-handoff
Generate a structured handoff document capturing current progress, open tasks, key decisions, and context needed to resume work. Use when ending a session, saying "continue later", "save progress", "session summary", or "pick up where I left off".
safe-mode
Prevent destructive operations using Claude Code hooks. Three modes — cautious (warn on dangerous commands), lockdown (restrict edits to one directory), and clear (remove restrictions). Uses PreToolUse matchers for Bash, Edit, and Write.
replay-learnings
Surface past learnings relevant to the current task before starting work. Searches correction history, recalls past mistakes, and applies prior patterns. Use when starting a task, saying "what do I know about", "previous mistakes", "lessons learned", or "remind me about".
pro-workflow
Complete AI coding workflow system. Orchestration patterns, 18 hook events, 5 agents, cross-agent support, reference guides, and searchable learnings. Works with Claude Code, Cursor, and 32+ agents.
permission-tuner
Analyze permission denial patterns and generate optimized alwaysAllow and alwaysDeny rules. Use when permission prompts are slowing you down or after sessions with many denials.
parallel-worktrees
Create and manage git worktrees for parallel coding sessions with zero dead time. Use when blocked on tests, builds, wanting to work on multiple branches, context switching, or exploring multiple approaches simultaneously.
orchestrate
Wire Commands, Agents, and Skills together for complex features. Use when building features that need research, planning, and implementation phases.
mcp-audit
Audit connected MCP servers for token overhead, redundancy, and security. Use when sessions feel slow or before adding new MCPs.