learning-opportunities-auto: make post-commit nudge more robust#9
Open
larssn wants to merge 1 commit into
Open
learning-opportunities-auto: make post-commit nudge more robust#9larssn wants to merge 1 commit into
larssn wants to merge 1 commit into
Conversation
Three small changes to `hooks/post-tool-use.sh`. Trigger gate and nudge phrasing are unchanged. - Fix offer counter: previously incremented on every hook fire, which silently burned the 2/session quota even when a nudge didn't land (e.g. on non-commit Bash calls whose command text matched the loose grep, or commits Claude decided not to act on). Now the counter increments only at the point a nudge is actually emitted, and is de-duped per commit SHA so a single commit can't consume multiple offers if the hook is invoked more than once for it. - Guard against failed commits: if `git commit` was rejected (e.g. by a pre-commit hook), HEAD is still the previous commit. Checking HEAD's commit timestamp and exiting silently if it isn't very recent avoids nudging about stale work that wasn't actually just committed. - Include short commit context in the nudge: add the short SHA and the commit subject to additionalContext so the skill has a concrete topic handle when asking the user.
ABDtmx
approved these changes
May 1, 2026
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.
Three small changes to
post-tool-use.sh. Trigger gate and nudge phrasing unchanged.offerspreviously bumped on every hook fire, burning the 2/session cap even when no nudge landed. Now increments only on emit, de-duped per commit SHA.git commitwas rejected, HEAD is the previous commit. Skip silently unless HEAD's timestamp is within ~30s.(${SHA}: ${SUBJECT})so the skill has a concrete topic. Subject sanitized + truncated for safe JSON embedding.No new dependencies.
Happy to split into three commits if you'd prefer cherry-pickability.