Aident AI

Claude Code Keeps Replying to Its Own PR Comments? Stop the Loop
If Claude Code's pull-request monitor keeps treating its own replies as new review feedback, stop the loop before it creates another comment or commit. Add a rule that fetches the exact GitHub comment and ignores any body ending with Claude Code's automated-reply marker. Then inspect the pull request read-only before resuming the monitor.
This is a containment workaround for an open Claude Code issue, not an upstream fix. The check happens after the event reaches the session, so it can prevent another reply and code change but cannot recover the turn already spent on the false dispatch.
Confirm the Failure Before Changing Anything
The August 7 report describes a specific cycle:
Claude Code watches a pull request for review feedback.
A real review comment arrives.
Claude addresses it and posts a reply through the user's GitHub account.
The monitor surfaces that reply as another new review comment.
Claude tries to address its own reply, posts again, and repeats.
The reporter observed this four times in one session across two pull requests. The visible GitHub author is not enough to break the cycle because Claude Code's reply is posted through the user's credentials. A human comment and the automated reply can therefore have the same user.login value.
Use this guide when the new feedback is a reply Claude Code just posted and the reply carries the documented automated label. Do not use it to suppress a human review merely because the author matches the pull-request owner.
Stop the Current Loop Safely
Interrupt the active session or disable Auto-fix for the affected pull request. Do not delete comments, force-push, or manufacture a code change to satisfy the generic instruction to address feedback.
Before resuming, record:
the pull-request URL;
the latest dispatched comment ID and URL;
whether the comment is top-level or attached to a diff line;
whether its body ends with the Claude Code marker;
whether a code change or reply was already pushed for that dispatch.
Run git status --short and inspect the latest commit before reverting anything. The loop may have posted comment noise without changing code, or it may have produced a real fix on the first pass and unnecessary changes later. Review each result separately.
Add an Exact Marker Guard
Add this rule to ~/.claude/CLAUDE.md if you want it to apply across repositories, or to the repository's CLAUDE.md if the workaround should stay project-scoped:
Match the complete marker, including the link and trailing emphasis. A loose check for Claude Code could discard a real review that merely mentions the product.
This rule follows the upstream issue's working workaround. It consumes the signal Claude Code already appends to automated replies instead of trying to infer authorship from the GitHub username.
Fetch the Right Kind of GitHub Comment
GitHub exposes top-level pull-request comments and inline review comments through different endpoints. Use the endpoint that matches the URL or event payload.
For a top-level pull-request comment:
For an inline review comment on a diff:
Expected output for Claude Code's own reply includes "automated": true. When it is false, read the exact comment in context before deciding whether any action is warranted.
Do not fetch every repository comment and filter by author. The useful evidence is the body of the exact event that triggered the session.
Why the Username Check Fails
Claude Code's Auto-fix documentation says replies are posted using the user's GitHub account and labeled as coming from Claude Code. That makes the marker the stronger discriminator:
Signal | Human review | Claude Code reply | Safe discriminator? |
|---|---|---|---|
| Possible | Possible | No |
Comment appeared after a push | Possible | Possible | No |
Body ends with the full marker | Unlikely | Expected | Yes, for this bug |
The marker check should run before code edits, replies, commits, or pushes. Checking only after a change prevents neither noise nor duplicate work.
Verify the Guard Without Posting a Comment
Test the rule with saved, non-sensitive fixtures instead of creating another live reply:
Expected results:
the automated fixture returns
true;the human-review fixture returns
false;neither command touches GitHub;
no code, commit, or reply is created.
Then ask Claude Code to explain what it would do for each fixture without taking action. The marker fixture should stop. The human fixture should evaluate the request instead of assuming every comment requires a patch.
Do Not Confuse Auto-fix With Code Review
Claude Code has adjacent pull-request features with different behavior:
Auto-fix watches a pull request and can respond to CI failures and review comments.
Code Review analyzes a pull request and posts findings as inline comments.
A custom GitHub Action can also react to issue or review-comment events.
The reported loop concerns the monitor handling replies, not proof that every Claude Code review mode loops. Check which feature or workflow subscribed to the pull request before changing organization-wide settings.
Official Auto-fix guidance also warns that Claude's replies can trigger comment-driven automation. Review workflows that react to issue_comment, review-comment, or pull-request events, especially when a comment can deploy infrastructure or run a privileged job. Disable the watcher until the feedback path is idempotent.
Clean Up After the Loop
Once the guard is in place:
List the comments created during the incident.
Identify automated replies by the exact trailing marker.
Review the branch diff and commits created after the first valid human comment.
Keep legitimate fixes and report uncertain changes for human review.
Do not delete GitHub comments or rewrite branch history automatically.
Re-enable the monitor on one low-risk pull request first.
Success means one human comment causes at most one bounded response, an automated marker comment causes no code or reply, and a no-change observation does not produce a manufactured commit.
Check the Loop Read-Only With Aident Loadout
Start with the canonical setup instruction:
Follow https://aident.ai/SETUP.md
Then give your agent a read-only audit:
Check Aident Loadout authentication and Vault status. Discover the current GitHub Action that lists review comments on one pull request, inspect its input schema, and preflight the request for OWNER/REPO pull request NUMBER. If the input is valid and the estimate is free, execute it. Return the total comment count, the count whose bodies end with the exact Claude Code automated marker, and the count without that marker. Do not return full comment bodies. Do not post, edit, react to, resolve, or delete comments, and do not change the pull request or branch.
Set up Aident Loadout and audit one review loop without GitHub writes.
The measurable result is a typed, read-only inventory and three counts. A zero-marker result means this exact signature loop was not found; it does not prove that every review automation path is healthy.
Sources
Refresh this guide when issue 84761 is fixed or closed, when Claude Code changes the automated-reply marker, or when the monitor documents a server-side self-reply filter.



The one tool
for every tool
your agent needs.
Give any AI agent real capabilities in seconds. Connect 1,000+ tools once, skip the setup headache, and let your agents execute.
