Make validate_brain_file hook portable across python/python3#3
Open
hema-sanam wants to merge 1 commit into
Open
Make validate_brain_file hook portable across python/python3#3hema-sanam wants to merge 1 commit into
hema-sanam wants to merge 1 commit into
Conversation
The PostToolUse hook in the scaffold's settings.json invoked bare `python`,
which doesn't exist on macOS (and many Linux distros), where only `python3`
is on PATH. A generated PM-brain workspace would then fail to run the
validator on Write/Edit.
Use a POSIX-shell launcher that prefers python3 and falls back to python:
sh -c 'if command -v python3 >/dev/null 2>&1; then \
python3 .claude/hooks/validate_brain_file.py; \
else python .claude/hooks/validate_brain_file.py; fi'
No logic change to the hook itself.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The scaffold's
.claude/settings.jsonwires thevalidate_brain_file.pyPostToolUse hook with a barepython:On macOS (and many modern Linux distros) only
python3is onPATH—pythondoesn't exist. So a PM-brain workspace generated on those systems fails to run the validator on everyWrite/Edit, silently losing the provenance/link checks the hook is meant to enforce.Fix
Use a POSIX-shell launcher that prefers
python3and falls back topython:validate_brain_file.pyitself — launcher only.sh).#!/usr/bin/env python3, so this just makes the invocation match that intent.Test plan
sh -carg, no inner double quotes to escape).Writeunderhypotheses/in a generated workspace and confirm the hook runs viapython3.🤖 Generated with Claude Code