Skip to content

[ef-38] feat: add 9 missing hook event types + daily sync workflow#38

Merged
NiveditJain merged 3 commits into
mainfrom
ef-38
Apr 7, 2026
Merged

[ef-38] feat: add 9 missing hook event types + daily sync workflow#38
NiveditJain merged 3 commits into
mainfrom
ef-38

Conversation

@NiveditJain

@NiveditJain NiveditJain commented Apr 7, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds 9 hook event types missing from HOOK_EVENT_TYPES (17 → 26 total): PermissionDenied, TaskCreated, StopFailure, InstructionsLoaded, CwdChanged, FileChanged, PostCompact, Elicitation, ElicitationResult
  • Updates hardcoded counts in __tests__/hooks/manager.test.ts (all passing)
  • Adds .github/workflows/sync-hook-events.yml: daily (08:07 UTC) + workflow_dispatch job that runs Claude Code (Sonnet) to fetch the Anthropic hooks docs, diff coverage against src/hooks/types.ts, and auto-open a PR when events are added or removed upstream
  • Adds scripts/sync-hook-events-prompt.md: the checked-in prompt the workflow feeds to Claude Code

Sandbox design

The sync workflow only exposes ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN, and the auto-generated scoped GITHUB_TOKEN to the Claude Code process — no other project secrets.

Test plan

  • bun run test:run — 723 tests pass
  • bunx tsc --noEmit — clean
  • gh workflow run sync-hook-events.yml after merge to confirm "up to date" output
  • Manually remove an event from types.ts on a test branch and re-trigger to verify PR creation

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Expanded hook event types from 17 to 26, adding permission, task, instruction, config, file-change, and elicitation events.
  • Chores

    • Added a scheduled/manual automation to keep hook event types synchronized with the official docs, plus an accompanying prompt script and ignored workflow output file.
    • Bumped package version to 0.0.1-beta.12.
  • Tests

    • Updated test expectations to reflect the new total of 26 hook event types.

- Add PermissionDenied, TaskCreated, StopFailure, InstructionsLoaded,
  CwdChanged, FileChanged, PostCompact, Elicitation, ElicitationResult
  to HOOK_EVENT_TYPES (17 → 26 total)
- Update manager.test.ts counts accordingly
- Add .github/workflows/sync-hook-events.yml: daily + manual job that
  runs Claude Code (sonnet) to fetch the Anthropic hooks docs, diff
  coverage, and auto-open a PR when new/removed events are detected
- Add scripts/sync-hook-events-prompt.md: the checked-in prompt

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Free

Run ID: 11da1da5-514c-47b2-a66d-d6993a9f7f41

📥 Commits

Reviewing files that changed from the base of the PR and between 8843fd2 and 0ca1b9e.

📒 Files selected for processing (3)
  • .github/workflows/sync-hook-events.yml
  • .gitignore
  • scripts/sync-hook-events-prompt.md
✅ Files skipped from review due to trivial changes (2)
  • .gitignore
  • scripts/sync-hook-events-prompt.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/sync-hook-events.yml

📝 Walkthrough

Walkthrough

Adds a scheduled/manual GitHub Actions workflow and prompt to sync HOOK_EVENT_TYPES from Claude docs, updates src/hooks/types.ts to 26 event types, adjusts two test expectations, bumps package version, and ignores the workflow output file.

Changes

Cohort / File(s) Summary
GitHub Actions Workflow
/.github/workflows/sync-hook-events.yml
New scheduled + manual workflow that runs the Claude Code CLI, computes diffs, and opens a PR when hook event types change.
Automation Prompt
scripts/sync-hook-events-prompt.md
New prompt script used by the workflow: fetches docs, extracts event types, diffs with code, writes .sync-hook-events-output.json, and emits PR metadata.
Hook Event Types
src/hooks/types.ts
Expanded and reordered HOOK_EVENT_TYPES to include 26 entries (added: PermissionRequest, PermissionDenied, TaskCreated, TaskCompleted, StopFailure, InstructionsLoaded, ConfigChange, CwdChanged, FileChanged, PostCompact, Elicitation, ElicitationResult); HookEventType updated accordingly.
Test Expectations
__tests__/hooks/manager.test.ts
Updated test description text and two toHaveLength(...) assertions to expect 26 event types (was 17).
Package Manifest
package.json
Bumped version from 0.0.1-beta.11 to 0.0.1-beta.12.
Ignore CI Output
.gitignore
Added .sync-hook-events-output.json to .gitignore.

Sequence Diagram

sequenceDiagram
    participant GHA as GitHub Actions (scheduler)
    participant CLI as Claude Code CLI
    participant Doc as Docs (hooks pages)
    participant Repo as Repository (src/hooks/types.ts, tests)
    participant API as GitHub API

    GHA->>CLI: invoke sync (cron or manual)
    CLI->>Doc: fetch reference & guide pages
    Doc-->>CLI: return event tables
    CLI->>Repo: read current HOOK_EVENT_TYPES and tests
    CLI-->>CLI: compute added/removed diffs
    alt differences found
        CLI->>Repo: update `src/hooks/types.ts` and tests
        CLI->>Repo: write `.sync-hook-events-output.json`, commit & push branch
        CLI->>API: open PR with added/removed lists and sources
        API-->>CLI: PR created
    else no differences
        CLI-->>Repo: write `.sync-hook-events-output.json` (changed: false) and exit
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hopped through docs at dawn so bright,

I counted hooks and set them right,
Twenty-six names now lined in cheer,
A neat little branch and PR appear,
—from the rabbit who syncs with delight.


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands and usage tips.

NiveditJain and others added 2 commits April 7, 2026 20:39
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Claude Code step now only receives ANTHROPIC_BASE_URL + ANTHROPIC_AUTH_TOKEN
- Claude writes analysis result to .sync-hook-events-output.json (no Bash tool needed)
- A separate shell step reads the output file and handles all git/gh operations
- Add .sync-hook-events-output.json to .gitignore

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@NiveditJain NiveditJain merged commit 799025a into main Apr 7, 2026
8 checks passed
@NiveditJain NiveditJain deleted the ef-38 branch April 21, 2026 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant