-
Notifications
You must be signed in to change notification settings - Fork 30
feat: add Claude Code PostToolUse hook for review integration #179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: add Claude Code PostToolUse hook for review integration #179
Conversation
cbb2572 to
157fb2e
Compare
Adds a hook that fires after git commit commands in Claude Code, reminding the agent to wait for and check roborev reviews. This follows the existing skills structure in internal/skills/ but for hooks. Implementation notes in the README explain what's needed to fully integrate this (embedding, installation command). Discussion/feedback welcome on the best way to structure this.
157fb2e to
9a95a30
Compare
|
Interesting proposal. I'll have to set this up and see what the ergonomics look like. Personally I don't want finished reviews randomly hijacking my interactive sessions -- if I want to use an interactive session to address, I prefer to use the TUI to paste multiple reviews (with So if users want what you are doing, we can give them a way to have it, but I'm unlikely to adopt this workflow myself. |
|
Thanks for the very quick reply! several questions/thoughts I guess it really depends on developer and especially git workflow. I tend to iterate on an idea and only commit when I am confident something has been achieved and isn't wrong so a review after each commit is rarely noise and in general keeps the main agent from diverging. I guess for users that commit every often that might not work as well. My workflow was already asking the main agent to spawn a sub-agent and then address the review. So for your workflow, I still don't understand the wow! |
I feel very strongly that this is the wrong way to work now and rooted in the old human way of working on something until it's "ready" and then committing. After working on this project for a month, I've concluded that you want other agents looking at the code that is being generated right away, not after you've iterated and it's "done" (because it's not done -- it has lots of bugs!)
I dunno, the copy pasting seems intuitive to me? here is a screencast of me doing it trimmed_clip.mov
Yeah starting to think about it! all in good time |
|
Oh I see! Just to show the workflow in action: ⏺ Bash(git add .github/workflows/automated-release.yml CHANGELOG.md CLAUDE.md tests/test_submission.py
vertex_cli/submission.py && git commit -m "feat: output console…)
⎿ [main 67e2d20] feat: output console URL after submission, fix release workflow skip
5 files changed, 79 insertions(+), 6 deletions(-)
ruff.....................................................................Passed
ty.......................................................................Passed
⎿ PostToolUse:Bash hook returned blocking error
⏺ Bash(sleep 25 && roborev show 67e2d20c4965e796da24ac5e3d46561945c258c8)
⎿ Review for 67e2d20 (job 49, by claude-code)
------------------------------------------------------------
## Summary
… +58 lines (ctrl+o to expand)
⏺ Good catches. Let me fix all three:Also, I guess, just to note, I still commit very often, and 99% of commits are done by claude code, I still have it commit in "logical units of work" though that may as well be outdated. |
|
My codex reviews typically take anywhere from 15s to 5 minutes, so it doesn’t make sense for the agent to stop and wait for review when it could be doing other things while waiting on the review. The asynchronous model is simply more productive in my experience, it sounds like you want a synchronous workflow but I’m quite confident this is slow. |
In my experience so far (> 3000 reviews processed), this isn't really an issue. If the reviews raise an issue that has already been addressed, the agents ignore it. They always look at the current state of the codebase and so changes that have occurred since the review was run does not appear to affect their performance either |
|
I think the review hooks system in #181 is the way to go and keep the focus on asynchronous reviews. If someone wants their interactive Claude sessions to block and wait for a review, we should document the approach for that in https://github.com/roborev-dev/roborev-docs |
|
To be honest, I tried to implement an async notification hook where Claude would launch the I was using Your workflow sounds fascinating though. I still can't imagine what using agents fully non interactively looks like, I can't trust them to not diverge very quickly and waste a bunch of time after. Also you saying your average review can be up to 5 mins made me reconsider whether I'm not being ambitious enough with my agents tasks (averaging 1-3 mins reviews after serious project use) either way, I don't want to clutter a PR with a discussion! please feel free to close the PR if it doesn't go with the intended use/design philosophy of the project. I'll keep iterating and finding ways the tool fits my workflow, thanks @wesm! |
|
All good, I'm very curious about what works well for different people! I'll investigate how to create some kind of a "review inbox" for Claude since I don't think that blocking the interactive session makes sense as a design. Here are some statistics on runtimes for the reviews in my environment: I think some of the longer reviews were scenarios when I was connected to my mobile hotspot or on an airplane, but this should give an idea why the synchronous review concept is problematic |
FWIW, when I'm not using |
Hi @wesm, as we discussed briefly in #151, there's currently no way for the main agent to know that a
roborevreview is happening in the background.I had been using the
roborevTUI, but I wanted to remove myself from the loop and make the agent aware - something close to a notification system. The Claude Code team hasn't released SDK support for this or a way to tap into their notification system (which seems to work for background tasks), so this is my attempt.The hook at
internal/hooks/claude/roborev-post-commit/hook.shtriggers after git commits, queues a review, and outputs a reminder for the agent to address findings.A few tricks worth noting:
Hooks with exit code 0 don't pass context to the agent (useful for linting, not for our use case here). Exit code 2 passes the hook output to the main context. A bit of a magic number, but it works. (see https://code.claude.com/docs/en/hooks#simple:-exit-code)
Hook matchers can't use argument patterns like the permissions system can -
Bash(git commit*)doesn't work, onlyBash. So the hook fires on every Bash call and exits early (with 0) when it's not a git command. I raised anthropics/claude-code#21540 about this limitation but I don't think it'll be addressed.The pattern matches "git commit" anywhere in the command to catch chained commands like
git add && git commit. Tradeoff: occasional false positives from heredocs or string arguments containing "git commit".The hook output is kept lean to avoid polluting the agent's context.
Go code changes are still needed to embed and install it to
~/.claude/hooks/.Question
How should installation work?
roborev hooks installroborev skills install --hooks