Skip to content

🔨 Rework hooks for Claude Code#6872

Merged
dubzzz merged 2 commits into
mainfrom
dubzzz-patch-4
Apr 16, 2026
Merged

🔨 Rework hooks for Claude Code#6872
dubzzz merged 2 commits into
mainfrom
dubzzz-patch-4

Conversation

@dubzzz

@dubzzz dubzzz commented Apr 16, 2026

Copy link
Copy Markdown
Owner

Description

Rework Claude Code hook commands to use absolute paths via $CLAUDE_PROJECT_DIR instead of relative paths with explicit bash invocation. This ensures hooks resolve to the correct script path regardless of the current working directory.

Also makes .claude/npm-to-pnpm.sh executable so it can be invoked directly without an explicit bash prefix.

Checklist

Don't delete this checklist and make sure you do the following before opening the PR

  • I have a full understanding of every line in this PR — whether the code was hand-written, AI-generated, copied from external sources or produced by any other tool
  • I flagged the impact of my change (minor / patch / major) either by running pnpm run bump or by following the instructions from the changeset bot
  • I kept this PR focused on a single concern and did not bundle unrelated changes
  • I followed the gitmoji specification for the name of the PR, including the package scope (e.g. 🐛(vitest) Something...) when the change targets a package other than fast-check
  • I added relevant tests and they would have failed without my PR (when applicable)

@changeset-bot

changeset-bot Bot commented Apr 16, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 2fae278

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dubzzz

dubzzz commented Apr 16, 2026

Copy link
Copy Markdown
Owner Author

@claude is it correct. maybe you can confirm by reading https://code.claude.com/docs/en/hooks#hooks-reference

@claude

claude Bot commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Claude finished @dubzzz's task in 1m 54s —— View job


Verifying hooks configuration against official docs

  • Read the PR changes to .claude/settings.json
  • Fetch the official Claude Code hooks documentation
  • Compare and verify correctness

Verdict

The change from bash .claude/script.sh to "$CLAUDE_PROJECT_DIR"/.claude/script.sh is correct and recommended. The hooks documentation confirms that $CLAUDE_PROJECT_DIR is a supported environment variable for hooks, and using it ensures scripts resolve to the right path regardless of the current working directory.

The overall hooks structure in your settings.json is valid per the docs:

  • Hook event types (SessionStart, PreToolUse, PostToolUse, Stop) — all valid
  • Matcher values (Bash, Edit|Write) — correct syntax (pipe-separated exact matches)
  • Hook handler schema (type: "command" + command: "...") — matches the documented schema

One potential issue

.claude/npm-to-pnpm.sh is not executable (-rw-r--r--), while the other three scripts are (-rwxr-xr-x):

-rwxr-xr-x  check-code.sh
-rwxr-xr-x  format-file.sh
-rw-r--r--  npm-to-pnpm.sh    ← missing +x
-rwxr-xr-x  session-start.sh

Previously this didn't matter because bash .claude/npm-to-pnpm.sh explicitly invokes bash to interpret the file (no execute permission needed). After this PR, "$CLAUDE_PROJECT_DIR"/.claude/npm-to-pnpm.sh tries to execute the file directly, which requires the execute bit. Since hooks run commands through bash -c "..." by default, the shell will attempt to exec the script, and it will fail with a permission denied error.

You'll want to add chmod +x .claude/npm-to-pnpm.sh as part of this PR. Fix this →


@pkg-pr-new

pkg-pr-new Bot commented Apr 16, 2026

Copy link
Copy Markdown
@fast-check/ava

npm i https://pkg.pr.new/@fast-check/ava@6872

fast-check

npm i https://pkg.pr.new/fast-check@6872

@fast-check/jest

npm i https://pkg.pr.new/@fast-check/jest@6872

@fast-check/packaged

npm i https://pkg.pr.new/@fast-check/packaged@6872

@fast-check/poisoning

npm i https://pkg.pr.new/@fast-check/poisoning@6872

@fast-check/vitest

npm i https://pkg.pr.new/@fast-check/vitest@6872

@fast-check/worker

npm i https://pkg.pr.new/@fast-check/worker@6872

commit: 2fae278

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Claude Code hook configuration to invoke hook scripts using an absolute project-root-based path via $CLAUDE_PROJECT_DIR, instead of calling them via bash with a relative path.

Changes:

  • Updated all Claude hook command entries to use "$CLAUDE_PROJECT_DIR"/.claude/*.sh
  • Removed explicit bash invocation from hook commands (now relying on direct script execution)

Comment thread .claude/settings.json
{
"type": "command",
"command": "bash .claude/session-start.sh"
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/session-start.sh"
Comment thread .claude/settings.json
{
"type": "command",
"command": "bash .claude/npm-to-pnpm.sh"
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/npm-to-pnpm.sh"
Comment thread .claude/settings.json
{
"type": "command",
"command": "bash .claude/format-file.sh"
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/format-file.sh"
Comment thread .claude/settings.json
{
"type": "command",
"command": "bash .claude/check-code.sh"
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/check-code.sh"
@dubzzz

dubzzz commented Apr 16, 2026

Copy link
Copy Markdown
Owner Author

@claude edit pr description following pr template

@claude

claude Bot commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Claude finished @dubzzz's task in 56s —— View job


Updating PR description to follow template

  • Read PR template
  • Read PR changes to understand the scope
  • Update PR description

Updated the PR description to follow the template from .github/PULL_REQUEST_TEMPLATE.md:

  • Added a Description section explaining the change: hook commands now use $CLAUDE_PROJECT_DIR for absolute paths instead of relative paths with explicit bash, and .claude/npm-to-pnpm.sh was made executable.
  • Kept all Checklist items from the template. Checked the applicable boxes — left "tests" unchecked since this is a tooling/config change with no associated tests.

@dubzzz
dubzzz enabled auto-merge (squash) April 16, 2026 23:22
@dubzzz
dubzzz merged commit 01b7f28 into main Apr 16, 2026
49 checks passed
@dubzzz
dubzzz deleted the dubzzz-patch-4 branch April 16, 2026 23:26
@codecov

codecov Bot commented Apr 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.75%. Comparing base (6661a31) to head (2fae278).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6872   +/-   ##
=======================================
  Coverage   94.75%   94.75%           
=======================================
  Files         211      211           
  Lines        5778     5778           
  Branches     1527     1527           
=======================================
  Hits         5475     5475           
  Misses        295      295           
  Partials        8        8           
Flag Coverage Δ
tests 94.75% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

3 participants