Skip to content

Add project hooks guarding invariants, main, and hotRun contention - #43

Merged
solcott merged 1 commit into
mainfrom
feature/claude-hooks
Sep 30, 2026
Merged

solcott merged 1 commit into
mainfrom
feature/claude-hooks

Conversation

@solcott

@solcott solcott commented Sep 30, 2026

Copy link
Copy Markdown
Owner

Summary

Four hooks in .claude/settings.json, each backed by a script in .claude/hooks/. The existing ktfmt and /verify-reminder hooks are unchanged. Hook messages point at the .claude/rules/ files from #42.

Hook When What it does
guard-invariants.sh Before Write/Edit Asks before an edit adds fallbackToDestructiveMigration(, rememberSaveableBackStack(, an iosX64 target, or kotlin-parcelize. The prompt gives the reason and the rule file.
guard-main-branch.sh Before Bash Denies git commit/git push while on main, or a push targeting main from any branch.
warn-hotrun-race.sh Before Bash Warns when a ./gradlew run starts while :desktopApp:hotRun --auto is running. That continuous build makes concurrent builds fail with errors in untouched modules.
check-build-credentials.sh Session start Warns if MEALDB_API_KEY or gpr.user/gpr.key (or GITHUB_ACTOR/GITHUB_TOKEN) is missing. It checks presence only and never prints a value.

Notes:

  • The invariant check asks rather than denies, so a deliberate change to one of these rules is still possible.
  • It matches call and plugin syntax, not names. The KDoc in BrowserHistoryEffect.web.kt that mentions rememberSaveableBackStack passes.
  • The credential check mirrors the build's own lookup: ProjectExt.kt for the API key, settings.gradle.kts for GitHub Packages.
  • hotMcpServer, which compiles nothing, does not trigger the hotRun warning.
  • A forced "route every Gradle call through the runner agent" hook was left out, because it would also fire inside that agent.

Test plan

  • Invariant check: fed every tracked .kt/.kts/.toml file through it, and none were flagged; synthetic Room and iosX64 edits prompt as expected
  • Main-branch guard: denies on main, origin main, HEAD:main, -C dir … main and compound commands; allows feature branches, maintenance, and commit messages that mention main (a false positive during development, now fixed)
  • hotRun warning: fires in a live session against a decoy hotRun --auto process; silent without one and for hotRun/reload themselves
  • Credential check: silent with credentials configured; lists both missing items with an empty HOME
  • Start a new session on this branch and confirm no credential warning appears on a configured machine

🤖 Generated with Claude Code

- guard-invariants (PreToolUse Write|Edit): asks before an edit adds
  fallbackToDestructiveMigration, rememberSaveableBackStack, an iosX64
  target, or kotlin-parcelize. Matches call syntax only, so KDoc that
  names them passes.
- guard-main-branch (PreToolUse Bash): denies git commit/push on main or
  a push targeting main. Only a real push's own arguments count, so a
  commit message that mentions main does not trip it.
- warn-hotrun-race (PreToolUse Bash): warns when a Gradle build starts
  while `:desktopApp:hotRun --auto` is running, since its continuous
  build makes concurrent builds fail in untouched modules.
- check-build-credentials (SessionStart): warns when MEALDB_API_KEY or
  gpr.user/gpr.key (or GITHUB_ACTOR/GITHUB_TOKEN) are missing. Checks
  presence only and never prints a value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@solcott
solcott merged commit 3f19174 into main Sep 30, 2026
1 check passed
@solcott
solcott deleted the feature/claude-hooks branch September 30, 2026 19:13
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