From openhands-skills
Posts structured PR review comments to GitHub via API using GitHub CLI, with inline comments on lines, code suggestions, multi-line ranges, and priority labels like critical or nit. Ideal after code analysis.
npx claudepluginhub openhands/extensionsThis skill uses the workspace's default tool permissions.
Post structured code review feedback using the GitHub API with inline comments on specific lines.
Resolves GitHub PR review comments: fetches via GitHub CLI and API, classifies by severity, filters new feedback, applies fixes with confirmation, commits changes, and replies to threads.
Posts friendly review comments to GitHub PRs: prepare locally via conversation, preview drafts, confirm, then submit atomically. For code reviews, PR feedback, inline suggestions.
Guides GitHub PR comment workflows: drafts responses, creates pending reviews via gh CLI, resolves feedback by fixing code or replying per strict style rules.
Share bugs, ideas, or general feedback.
Post structured code review feedback using the GitHub API with inline comments on specific lines.
Bundle ALL comments into a single review API call. Do not post comments individually.
Use the GitHub CLI (gh) with a JSON input file. The GITHUB_TOKEN is automatically available.
Important: Always use --input with a JSON file instead of -F flags. This avoids shell quoting issues with special characters in comment bodies (quotes, backticks, newlines, etc.) and eliminates the need for complex heredoc scripts.
cat > /tmp/review.json << 'EOF'
{
"commit_id": "{commit_sha}",
"event": "COMMENT",
"body": "Brief 1-3 sentence summary.",
"comments": [
{
"path": "path/to/file.py",
"line": 42,
"side": "RIGHT",
"body": "๐ Important: Your comment here."
},
{
"path": "another/file.js",
"line": 15,
"side": "RIGHT",
"body": "๐ก Suggestion: Another comment."
}
]
}
EOF
gh api -X POST repos/{owner}/{repo}/pulls/{pr_number}/reviews --input /tmp/review.json
| Parameter | Description |
|---|---|
commit_id | Commit SHA to comment on (use git rev-parse HEAD) |
event | COMMENT, APPROVE, or REQUEST_CHANGES |
path | File path as shown in the diff |
line | Line number in the NEW version (right side of diff) |
side | RIGHT for new/added lines, LEFT for deleted lines |
body | Comment text with priority label |
For comments spanning multiple lines, add start_line to specify the range:
{
"path": "path/to/file.py",
"start_line": 10,
"line": 12,
"side": "RIGHT",
"body": "๐ก Suggestion: Refactor this block:\n\n```suggestion\nline_one = \"new\"\nline_two = \"code\"\nline_three = \"here\"\n```"
}
Important: The suggestion must have the same number of lines as the range (e.g., lines 10-12 = 3 lines).
Start each comment with a priority label. Minimize nits - leave minor style issues to linters.
| Label | When to Use |
|---|---|
| ๐ด Critical | Must fix: security vulnerabilities, bugs, data loss risks |
| ๐ Important | Should fix: logic errors, performance issues, missing error handling |
| ๐ก Suggestion | Worth considering: significant improvements to clarity or maintainability |
| ๐ข Nit | Optional: minor style preferences (use sparingly) |
| ๐ข Acceptable | Pragmatic choice: acknowledged trade-off that is reasonable given constraints or out of scope for this PR |
Example:
๐ Important: This function doesn't handle None, which could cause an AttributeError.
```suggestion
if user is None:
raise ValueError("User cannot be None")
## GitHub Suggestions
For small code changes, use the suggestion syntax for one-click apply:
~~~
```suggestion
improved_code_here()
Use suggestions for: renaming, typos, small refactors (1-5 lines), type hints, docstrings.
Avoid for: large refactors, architectural changes, ambiguous improvements.
## Finding Line Numbers
```bash
# From diff header: @@ -old_start,old_count +new_start,new_count @@
# Count from new_start for added/modified lines
grep -n "pattern" filename # Find line number
head -n 42 filename | tail -1 # Verify line content
```
## Fallback: curl
If `gh` is unavailable, use curl with the JSON file:
```bash
curl -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/{owner}/{repo}/pulls/{pr_number}/reviews" \
-d @/tmp/review.json
```
## Summary
1. Analyze the code and identify important issues (minimize nits)
2. Write review data to a JSON file (e.g., `/tmp/review.json`)
3. Post **ONE** review using `gh api --input /tmp/review.json`
4. Use priority labels (๐ด๐ ๐ก๐ข) on every comment
5. Mark pragmatic trade-offs as ๐ข **Acceptable** - don't block PRs for out-of-scope improvements
6. Use suggestion syntax for concrete code changes
7. Keep the review body brief (details go in inline comments)
8. If no issues: post a short message