Agent Skillsrohitg00/pro-workflow › file-watcher

file-watcher

GitHub

配置文件监听钩子以自动响应配置、环境变量和依赖变更。通过注册watchPaths触发FileChanged事件,实现自动重载、依赖检测及环境注入等响应式开发工作流。

skills/file-watcher/SKILL.md rohitg00/pro-workflow

Trigger Scenarios

设置配置文件更改的自动重载 监控依赖更新 监视构建输出 创建响应式开发工作流

Install

npx skills add rohitg00/pro-workflow --skill file-watcher -g -y
More Options

Use without installing

npx skills use rohitg00/pro-workflow@file-watcher

指定 Agent (Claude Code)

npx skills add rohitg00/pro-workflow --skill file-watcher -a claude-code -g -y

安装 repo 全部 skill

npx skills add rohitg00/pro-workflow --all -g -y

预览 repo 内 skill

npx skills add rohitg00/pro-workflow --list

SKILL.md

Frontmatter
{
    "name": "file-watcher",
    "description": "Configure file watching hooks to auto-react to config changes, env file updates, and dependency modifications. Use to set up reactive workflows.",
    "user-invocable": true
}

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:

{
  "hookSpecificOutput": {
    "hookEventName": "SessionStart",
    "watchPaths": [
      "/absolute/path/to/.env",
      "/absolute/path/to/package.json"
    ]
  }
}

When watched files change, the FileChanged hook fires with:

{
  "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:

echo "export PROJECT_TYPE=node" >> "$CLAUDE_ENV_FILE"
echo "export TEST_CMD='npm test'" >> "$CLAUDE_ENV_FILE"

Common Watch Patterns

Watch .env for Changes

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:

{
  "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 export

Version History

  • 7f7209d Current 2026-07-24 11:40

Same Skill Collection

skills/agent-teams/SKILL.md
skills/auto-setup/SKILL.md
skills/batch-orchestration/SKILL.md
skills/bug-capture/SKILL.md
skills/compact-guard/SKILL.md
skills/context-engineering/SKILL.md
skills/context-optimizer/SKILL.md
skills/cost-tracker/SKILL.md
skills/design-engineering/SKILL.md
skills/deslop/SKILL.md
skills/domain-modeling/SKILL.md
skills/improve-architecture/SKILL.md
skills/insights/SKILL.md
skills/learn-rule/SKILL.md
skills/llm-council/SKILL.md
skills/llm-gate/SKILL.md
skills/mcp-audit/SKILL.md
skills/orchestrate/SKILL.md
skills/parallel-worktrees/SKILL.md
skills/permission-tuner/SKILL.md
skills/plan-interrogate/SKILL.md
skills/replay-learnings/SKILL.md
skills/safe-mode/SKILL.md
skills/session-handoff/SKILL.md
skills/skill-router/SKILL.md
skills/smart-commit/SKILL.md
skills/sprint-status/SKILL.md
skills/tdd/SKILL.md
skills/thoroughness-scoring/SKILL.md
skills/token-efficiency/SKILL.md
skills/wiki-builder/SKILL.md
skills/wiki-query/SKILL.md
skills/wiki-research-loop/SKILL.md
skills/wiki-viewer/SKILL.md
skills/wrap-up/SKILL.md
skills/writing-guidelines/SKILL.md
skills/pro-workflow/SKILL.md
skills/skill-optimizer/SKILL.md
skills/survey-generator/SKILL.md

Metadata

Files
0
Version
7f7209d
Hash
09ec688f
Indexed
2026-07-24 11:40

Главная - Вики-сайт
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-07 14:32
浙ICP备14020137号-1 $Гость$