Address code review comments

From blockscout/mcp-server · View interactive version

Address code review comments is an AI agent skill from the GitHub repository blockscout/mcp-server. Enter the worktree of a GitHub PR, validate the code-review comments raised on it against what the code actually does and the repo rules, fix the valid ones directly in the PR's source/tests, and report in chat — a brief note per closed comment and a detailed plain-language explanation of every comm

How to use this skill

Skill file

Address Code Review Comments

A reviewer (a human, or a tool like CodeRabbit) left a set of comments on a pull request — each a claimed bug, omission, style violation, or risk in the diff. Your job is to judge each comment on its merits against the actual code in the PR, fix the ones that are genuinely valid by editing the PR's own source and tests, and then report your decisions in chat.

Two things make this skill what it is, and you must hold both:

Inputs

If the PR or the comments are missing, ask — do not invent comments or guess the PR.

Workflow

0. Enter the PR's worktree (do this first)

The whole point of this step is to get onto the exact code the reviewer saw, locally, so the rest of the work reads files straight from disk instead of round-tripping through the GitHub API.

  1. Read the PR's branch, head, and closing issue (<pr> is the number or URL from the invocation — with a bare number, run this from inside the target repo so gh resolves it):

```bash

gh pr view <pr> --json number,title,headRefName,headRefOid,url,closingIssuesReferences

```

Note the closingIssuesReferences — the issue this PR is meant to close. It carries the real intent and acceptance criteria, which is often what decides whether a comment is valid (a "fix" that fights the issue's goal is not a fix). Read that issue when a comment's validity turns on original intent; don't read it just to read it.

  1. Find the local worktree for headRefName:

```bash

git worktree list

```

Pick the worktree whose checked-out branch equals the PR's headRefName.

  1. Switch into it with the EnterWorktree tool, passing that worktree's path (path: <worktree dir>).
  1. Double-check you are on the PR's head. Compare the worktree's HEAD to the PR's headRefOid:

```bash

git rev-parse HEAD

```

It must equal headRefOid from step 1. Once it matches, trust the working tree: every file the PR changed is present locally, so read and edit it directly with Read/Edit — do not pull diffs or file contents through gh/the git API. That round-tripping is the waste this step exists to avoid.

If something doesn't line up, stop and ask instead of guessing:

1. Resolve the comments into concrete claims

For comments pasted as text, take them as-is. For links to specific review comments, fetch the body via the GitHub API so you act on the reviewer's actual words rather than the URL — the numeric id in a comment link's anchor is the comment id. For an inline review comment:

```bash

gh api repos/{owner}/{repo}/pulls/comments/<ID> --jq '{path, line, body}'

```

gh fills {owner}/{repo} from the repo you're in (the PR's worktree, after step 0). Other link kinds resolve through their matching endpoint; if a link won't resolve, ask rather than guess what it said.

Extract the concrete claim from each: the file/symbol/line it names, what it asserts is wrong, and the change it recommends. Treat each as a hypothesis to confirm.

2. Validate each comment independently

Confirm or refute each comment against the real code and the repo's own conventions:

3. Fix the valid comments

Edit the code on the PR's branch to close every valid (or partially-valid) comment:

4. Verify your changes

Don't hand back edits you haven't checked. For the files you touched, run the project's own lint/format and the relevant tests, using its standard tooling and environment (its virtualenv, task runner, or scripts) rather than global interpreters. If a fix breaks something, fix it or reconsider whether the comment was really valid. Report honestly if something still fails.

5. Report in chat

Reply in the chat (no file is written). Keep the two halves deliberately asymmetric — the diff already shows what you changed, but a rejection leaves no trace, so it needs your full reasoning:

Key each bullet to the comment (its file:line or a short quote) so the mapping is unambiguous. If every comment was valid, say so under Not closed (- None — every comment was valid and addressed.); if none were, say so under Closed.

End by stating that you have not committed or pushed — the edits sit in the worktree for the user to review — unless they explicitly ask you to commit.

Notes

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.