Skip to content

chore: resolve post-edit hook path via CLAUDE_PROJECT_DIR - #2362

Open
rahmanunver wants to merge 1 commit into
mainfrom
chore/claude-hook-project-dir
Open

chore: resolve post-edit hook path via CLAUDE_PROJECT_DIR#2362
rahmanunver wants to merge 1 commit into
mainfrom
chore/claude-hook-project-dir

Conversation

@rahmanunver

Copy link
Copy Markdown
Contributor

The PostToolUse hook command was a repo-root-relative path, so it only resolved when the shell's working directory happened to be the repo root.

Widget work follows docs/widget-scripts.md and runs from inside the package directory, where that path does not exist. The hook fails non-blocking, so the auto-format silently stops running and the loss is easy to miss.

$CLAUDE_PROJECT_DIR is set to the project root, so the path resolves regardless of working directory. Behaviour at the repo root is unchanged.

The hook command was a repo-root-relative path, so it only resolved when
the shell's working directory happened to be the repo root. Widget work
follows docs/widget-scripts.md and runs from inside the package directory,
where the path does not exist and the auto-format hook silently stops
running (it fails non-blocking, so the loss is easy to miss).
@rahmanunver
rahmanunver requested a review from a team as a code owner July 28, 2026 10:12
@github-actions

Copy link
Copy Markdown
Contributor

AI Code Review

⚠️ Approved with suggestions — low-severity items only, safe to merge


What was reviewed

File Change
.claude/settings.json Fix PostToolUse hook path to resolve via $CLAUDE_PROJECT_DIR instead of a repo-root-relative path

Skipped (out of scope): dist/, pnpm-lock.yaml

CI checks were not accessible in this run (gh pr checks required approval).


Findings

⚠️ Low — PreToolUse hook has the same relative-path problem

File: .claude/settings.json line 40
Note: The validate-openspec-path.sh hook on PreToolUse still uses the bare relative path .claude/hooks/validate-openspec-path.sh, which has the same working-directory sensitivity that this PR is fixing for post-edit.sh. Running from inside a widget package subdirectory will silently fail to execute the guard.
Fix:

"command": "\"$CLAUDE_PROJECT_DIR/.claude/hooks/validate-openspec-path.sh\""

Positives

  • The fix correctly uses $CLAUDE_PROJECT_DIR, which is the designated project-root variable, so the path resolves from any working directory without side-effects at the repo root.
  • The embedded-quoting convention ("\"$CLAUDE_PROJECT_DIR/...\"" ) is consistent and handles paths with spaces.
  • The PR description clearly explains the silent-failure mode and why it was easy to miss — good change documentation.

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.

2 participants