Skip to content

fix: use absolute paths for all Claude Code hook commands#1434

Merged
jeremyeder merged 1 commit intomainfrom
fix/stop-hook-path
Apr 22, 2026
Merged

fix: use absolute paths for all Claude Code hook commands#1434
jeremyeder merged 1 commit intomainfrom
fix/stop-hook-path

Conversation

@jeremyeder
Copy link
Copy Markdown
Contributor

@jeremyeder jeremyeder commented Apr 22, 2026

Summary

  • All hook commands in .claude/settings.json used relative paths (scripts/hooks/...), which fail when the shell's cwd isn't the repo root
  • Prefix each with cd "$(git rev-parse --show-toplevel)" && so hooks resolve reliably regardless of working directory
  • Fixes the stop-review.sh: No such file or directory error seen at session end

Test plan

  • Verify all hooks fire correctly from a non-root cwd
  • Start a new Claude Code session and confirm stop hook runs without error

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Updated development tooling configuration to improve hook command execution reliability.

All hook commands in .claude/settings.json used relative paths, which
fail when the shell's working directory isn't the repo root. Prefix
each with cd "$(git rev-parse --show-toplevel)" to resolve reliably
regardless of cwd.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 22, 2026

Deploy Preview for cheerful-kitten-f556a0 canceled.

Name Link
🔨 Latest commit fbab93f
🔍 Latest deploy log https://app.netlify.com/projects/cheerful-kitten-f556a0/deploys/69e91bcfb4df8f0008f24091

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 22, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 44510463-75f2-444f-b4c8-e9302b06b63c

📥 Commits

Reviewing files that changed from the base of the PR and between 341747a and fbab93f.

📒 Files selected for processing (1)
  • .claude/settings.json

📝 Walkthrough

Walkthrough

Updated .claude/settings.json hook commands to explicitly set the working directory to the repository root before executing shell scripts, ensuring consistent command execution context across pr-review-gate.sh, convention-guard.sh, auto-format.sh, and stop-review.sh hooks.

Changes

Cohort / File(s) Summary
Hook Configuration
.claude/settings.json
Modified four hook command entries to prepend cd "$(git rev-parse --show-toplevel)" before executing scripts with bash, replacing direct script invocations. Ensures scripts run from repository root context.
🚥 Pre-merge checks | ✅ 8
✅ Passed checks (8 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Title follows Conventional Commits format (fix type), clearly describes the main change of adding absolute paths to hook commands via git rev-parse.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Performance And Algorithmic Complexity ✅ Passed PR modifies only static JSON configuration file with hook command strings. No algorithms, loops, data structures, or API operations. Git metadata lookup adds negligible overhead.
Security And Secret Handling ✅ Passed Pull request modifies only .claude/settings.json to prepend cd "$(git rev-parse --show-toplevel)" && to hook commands for path resolution. No secrets, tokens, API keys, or credentials are hardcoded.
Kubernetes Resource Safety ✅ Passed Kubernetes Resource Safety check not applicable; PR only modifies .claude/settings.json, a hook configuration file, not Kubernetes manifests.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/stop-hook-path
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/stop-hook-path

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

@jeremyeder jeremyeder merged commit e170db0 into main Apr 22, 2026
18 checks passed
@jeremyeder jeremyeder deleted the fix/stop-hook-path branch April 22, 2026 19:11
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