Reuse existing Claude Code comment instead of creating a new comment when commits are pushed to PRs
Currently, when we configure claude code action using the auto review example, a new comment will be created by the claude code action when new commits are pushed to a PR. We will see many comments made by Claude Code instead of always updating the same comment when we push changes to a PR. It would be super helpful to add an option of always updating the same comment instead of creating new ones.
I was just coming here to create the same request!
What I think is happening is that claude will always create an initial tracking comment. Then for a review, it creates a github review which will be posted as a new comment.
I found that the tracking comment will then later get updated and repeat a lot of information from the review as well. As a workaround I added:
disallowed_tools: "mcp__github_file_ops__update_claude_comment"
that way claude isn't allowed to update the tracking comment, but what would be ideal for me is that it wouldn't post it in the first place or perhaps so that it deletes it after. I can already see the status of the github action at the bottom of the PR page and can click there for more info if I need.
One idea is to expose this as an input option, so it's configurable?
I had initially thought this is what the use_sticky_comment parameter is for, but notice that enabling the parameter doesn't effect behavior. I don't actually see where this parameter (which gets passed as an env variable to the entrypoint scripts) gets used directly.
I agree though, this is something that is desperately needed, as comments tend to be very long and quickly clutter up a PR.
This is indeed what use_sticky_comment is for. Are you not seeing that behavior?
Ah it looks like there was a bug in the previous PR (#211). I have a fix out here: https://github.com/anthropics/claude-code-action/pull/226
No, I'm not seeing it. Looking through the PR that added the parameter a few days ago, I think I see the issue:
useStickyComment: process.env.STICKY_COMMENT === "true",
should be:
useStickyComment: process.env.USE_STICKY_COMMENT === "true",
This is indeed what
use_sticky_commentis for. Are you not seeing that behavior?
@ashwin-ant
In: src/github/operations/comments/create-initial.ts, I see:
if (
context.inputs.useStickyComment &&
context.isPR &&
!isPullRequestEvent(context)
)
Would !isPullRequestEvent prevent auto PR review workflows from reusing the initial comment? Not sure if I'm reading the code correctly
I updated that PR and tested it just now to make sure it works as expected. Will work on getting it into today's release.
I'm not sure if useStickyComment fully solves what I'm hoping for though. My understanding is that useStickyComment will still create an initial comment and then claude will keep updating that one. However, I've instructed claude to use mcp__github__create_pending_pull_request_review and mcp__github__submit_pending_pull_request_review which would then post a separate review comment as well.
What I would like is a way to not have that initial comment posted at all.
if i do understand i see the the sticky_comment works only for claude[bot] Will it be possible to make it work for the GitHub [bot] also?
I just ran into this mildly confusing behaviour myself :)
https://github.com/anthropics/claude-code-action/blob/main/src/github/operations/comments/create-initial.ts#L41-L49
It definitely looks like it'll re-use the comment IF:
- the specific user ID matches the claude bot
- or the user is a Bot with "claude" in its name
- or the exact body matches
I would love if this turned into two overridable parameters:
- bot_user_id (so for folks who do not use the official claude bot, they can use their own custom user id, or use the github actions user id .. or whatever they want) default: 209825114, the official claude user id
- bot_user_name_fragment (ie the substring to match for the bot user) default: claude
This would not change the default behaviour, but it would open up a lot of flexibility with custom setups for this.
Thoughts?
I just ran into this mildly confusing behaviour myself :)
https://github.com/anthropics/claude-code-action/blob/main/src/github/operations/comments/create-initial.ts#L41-L49
It definitely looks like it'll re-use the comment IF:
- the specific user ID matches the claude bot
- or the user is a Bot with "claude" in its name
- or the exact body matches
I would love if this turned into two overridable parameters:
- bot_user_id (so for folks who do not use the official claude bot, they can use their own custom user id, or use the github actions user id .. or whatever they want) default: 209825114, the official claude user id
- bot_user_name_fragment (ie the substring to match for the bot user) default: claude
This would not change the default behaviour, but it would open up a lot of flexibility with custom setups for this.
Thoughts?
yup, this is the main issue, i saw it too, i think that @valorkin could elaborate and solve this because he is the one who added it ?
I think I'm going to try a workaround of making a new private App with claude in its name .. this should make it match the second condition .. having config options would still be nice ;)
@ashwin-ant i think the best use-case is to refer to the @trigger_pharse as the user who is performing the commeting.. @piotrb what do you think of that ?
@ashwin-ant i think the best use-case is to refer to the @trigger_pharse as the user who is performing the commeting.. @piotrb what do you think of that ?
I'm not sure what you mean by @trigger_parse
Oh as an update here, if you just create a new github app in your org and name it with claude in its name, that seems to work perfectly well to make the sticky comment behaviour work as expected
not ideal if you're internally planning to call your app something that doesn't contain Claude in its name ;) .. but a valid workaround .. I would still really appreciate this being configurable
I opened a simple PR to make those two hardcoded values not so hardcoded :)
I'm hoping this can get merged quickly, since I don't really want to maintain this fork :)
still waiting for the merge :)