add-review-comment
Add a review comment to a GitHub pull request.
When & Why to Use This Skill
The 'add-review-comment' Claude skill enables seamless integration with GitHub's review system, allowing the AI to post precise, line-specific feedback on pull requests. By leveraging the GitHub CLI and API, it supports both single and multi-line comments and can provide one-click code suggestions, significantly streamlining the collaborative development workflow and enhancing code quality through automated insights.
Use Cases
- Automated Code Auditing: Use Claude to identify potential bugs or security vulnerabilities and post them as comments directly on the affected lines of code.
- Interactive Code Suggestions: Provide maintainers with ready-to-apply code fixes using GitHub's suggestion blocks, reducing manual editing time for contributors.
- Style and Standard Enforcement: Automatically flag deviations from project-specific style guides or best practices during the PR phase.
- Collaborative Feedback: Facilitate clearer communication between developers by adding context-aware explanations or documentation links to complex code changes.
| name | add-review-comment |
|---|---|
| description | Add a review comment to a GitHub pull request. |
| - Bash(gh api | *) |
| - Bash(gh pr view | *) |
Add Review Comment
Adds a review comment to a specific line in a GitHub pull request.
Usage
Single-line comment:
gh api repos/<owner>/<repo>/pulls/<pr_number>/comments \
# Body must end with "🤖 Generated with Claude" on a separate line
-f body=<comment> \
-f path=<file_path> \
-F line=<line_number> \
-f side=<side> \
-f commit_id="$(gh pr view <pr_number> --repo <owner>/<repo> --json headRefOid -q .headRefOid)" \
--jq '.html_url'
Multi-line comment:
gh api repos/<owner>/<repo>/pulls/<pr_number>/comments \
# Body must end with "🤖 Generated with Claude" on a separate line
-f body=<comment> \
-f path=<file_path> \
-F start_line=<first_line> \
-f start_side=<side> \
-F line=<last_line> \
-f side=<side> \
-f commit_id="$(gh pr view <pr_number> --repo <owner>/<repo> --json headRefOid -q .headRefOid)" \
--jq '.html_url'
Parameters
line: Line number in the file (for multi-line, the last line)side:RIGHTfor added/modified lines (+),LEFTfor deleted lines (-)start_line/start_side: For multi-line comments, the first line of the range
Best Practices
Use suggestion blocks (three backticks + "suggestion") for simple fixes that maintainers can apply with one click
```suggestion <suggested code here> ```Note: Preserve original indentation exactly in suggestion blocks
For repetitive issues, leave one representative comment instead of flagging every instance
For bugs, explain the potential problem and suggested fix clearly