Add Claude Code hooks for the repo's never-do rules - #45
Merged
Merged
Conversation
Project hooks in .claude/settings.json, backed by scripts in .claude/hooks/ (now un-ignored): - pre-tool-guard.sh (PreToolUse): denies `git add -A`/`--all`/`.`, a force push without --force-with-lease, edits under build/ (Apollo generated code), and hand edits to the npm lockfiles. - pre-commit-ktfmt.sh (PreToolUse on `git commit`): when Kotlin is staged, runs ktfmtCheck (and build-logic's) and blocks the commit with the ktfmtFormat command to run. - post-edit-check.sh (PostToolUse): rejects vector drawables with ?attr/ or @android: references, which crash at runtime, and reminds that styles.css duplicates WebSkin's page colour. Co-Authored-By: Claude Opus 5.5 <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.
Summary
This repo's "never do X" rules were written down but nothing enforced them. These project hooks, in
.claude/settings.jsonwith scripts under.claude/hooks/, enforce them for every Claude Code session in the repo.pre-tool-guard.shgit add -A/--all/.(it sweeps up Xcodexcuserdata/), a force push without--force-with-lease, edits underbuild/(Apollo generated code), and hand edits tokotlin-js-store/*.lockpre-commit-ktfmt.shgit commitktfmtCheck, plusbuild-logic's check whenbuild-logicfiles are staged. Blocks the commit with thektfmtFormatcommand to run, instead of failing in CIpost-edit-check.sh?attr/or@android:, which builds clean and crashes at runtime. Reminds thatstyles.cssduplicatesWebSkin's page colour.gitignorenow un-ignores.claude/hooks/.Known limitation: the
git addcheck matches the text anywhere in a command, soecho git add -Ais also blocked. It's harmless, and the check stays a simple regex.Test plan
git add,--force-with-lease, ordinary pushes and normal edits were allowed.?attr/and passed a clean drawable.echo git add -Awas denied.pre-commit-ktfmt.sh.🤖 Generated with Claude Code