Hooks worker

From oimiragieo/agent-studio · View interactive version

Hooks worker is an AI agent skill from the GitHub repository oimiragieo/agent-studio. Hook system optimization — async conversion, consolidation, deduplication, new hook events

How to use this skill

Skill file

Hooks Worker

NOTE: Startup and cleanup are handled by worker-base. This skill defines the WORK PROCEDURE.

When to Use This Skill

Features that modify .claude/settings.json hook registrations, create new hook scripts, consolidate existing hooks, or add new hook event categories.

Work Procedure

  1. Read the feature description carefully. Understand exactly which hooks to modify, what safety classification to respect, and what the expected settings.json structure should be.
  1. Baseline snapshot. Before ANY changes, read .claude/settings.json and record:
  1. Write tests first (red). Create test file at tests/hooks/<descriptive-name>.test.cjs. Tests should verify:

Run tests — they should FAIL (red).

  1. Implement changes.
  1. Run tests (green). All tests pass. Fix any failures.
  1. Validate settings.json.

```

node -e "JSON.parse(require('fs').readFileSync('.claude/settings.json','utf8'))"

```

  1. Run lint and format.

```

pnpm lint

pnpm format:check

```

  1. Manual verification. For new hooks, run them manually with sample input to verify behavior. For settings.json changes, diff against baseline to confirm only intended changes were made.

Example Handoff

{
  "salientSummary": "Converted 22 advisory hooks to async:true in settings.json. Zero security hooks affected. Added timeout_ms to 40 hooks that were missing it. settings.json valid JSON with all 7 event categories preserved. Created tests/hooks/hook-async-classification.test.cjs (15 tests).",
  "whatWasImplemented": "Parsed settings.json, classified each hook by reading its source (exit 2 = blocking/sync, exit 0 = advisory/async candidate). Added async:true to 22 advisory hooks across UserPromptSubmit, PostToolUse, PostToolUseFailure. Left all 18 security/blocking hooks as sync. Added timeout_ms to 40 hooks: 5000ms for simple advisory, 10000ms for monitoring, 15000ms for file-scanning, 30000ms for cleanup.",
  "whatWasLeftUndone": "",
  "verification": {
    "commandsRun": [
      {
        "command": "node --test tests/hooks/hook-async-classification.test.cjs",
        "exitCode": 0,
        "observation": "15 tests passing"
      },
      {
        "command": "node -e \"JSON.parse(require('fs').readFileSync('.claude/settings.json','utf8'))\"",
        "exitCode": 0,
        "observation": "Valid JSON"
      },
      {
        "command": "pnpm lint",
        "exitCode": 0,
        "observation": "0 errors"
      }
    ]
  },
  "tests": {
    "added": [
      {
        "file": "tests/hooks/hook-async-classification.test.cjs",
        "cases": [
          { "name": "advisory hooks have async:true", "verifies": "VAL-HO-003" },
          { "name": "security hooks do NOT have async:true", "verifies": "VAL-HO-002" },
          { "name": "all hooks have timeout_ms", "verifies": "VAL-HO-004" }
        ]
      }
    ]
  },
  "discoveredIssues": []
}

When to Return to Orchestrator

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.