git:attach-review-to-pr

neolabhq/context-engineering-kit · updated Apr 8, 2026

MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.

$npx skills add https://github.com/neolabhq/context-engineering-kit --skill git:attach-review-to-pr
0 commentsdiscussion
summary

This guide explains how to add line-specific review comments to pull requests using the GitHub CLI (gh) API or mcp__github_inline_comment__create_inline_comment if it not available, similar to how the GitHub UI allows commenting on specific lines of code.

skill.md

How to Attach Line-Specific Review Comments to Pull Requests

This guide explains how to add line-specific review comments to pull requests using the GitHub CLI (gh) API or mcp__github_inline_comment__create_inline_comment if it not available, similar to how the GitHub UI allows commenting on specific lines of code.

Preferred Approach: Using MCP GitHub Tools

If available, use the mcp__github_inline_comment__create_inline_comment MCP tool for posting line-specific inline comments on pull requests. This approach provides better integration with GitHub's UI and is the recommended method.

Fallback: If the MCP tool is not available, use the GitHub CLI (gh) API methods described below:

Overview

While gh pr review provides basic review functionality (approve, request changes, general comments), it does not support line-specific comments directly. To add comments on specific lines of code, you must use the lower-level gh api command to call GitHub's REST API directly.

Prerequisites

  1. GitHub CLI installed and authenticated:

    gh auth status
    
  2. Access to the repository and pull request you want to review

Understanding GitHub's Review Comment System

GitHub has two types of PR comments:

  1. Issue Comments - General comments on the PR conversation
  2. Review Comments - Line-specific comments on code changes

Review comments can be added in two ways:

  • Single comment - Using the /pulls/{pr}/comments endpoint
  • Review with multiple comments - Using the /pulls/{pr}/reviews endpoint

Adding a Single Line-Specific Comment

Basic Syntax

gh api repos/{owner}/{repo}/pulls/{pr_number}/comments \
  -f body='Your comment text here' \
  -f commit_id='<commit-sha>' \
  -f path='path/to/file.js' \
  -F line=42 \
  -f side='RIGHT'

Parameters Explained

Parameter Type Required Description
body string Yes The text of the review comment (supports Markdown)
commit_id string Yes The SHA of the commit to comment on
path string Yes Relative path to the file being commented on
line integer Yes The line number in the diff (use -F for integers)
side string Yes RIGHT for new/modified lines, LEFT for deleted lines
start_line integer No For multi-line comments, the starting line
start_side string No For multi-line comments, the starting side

Parameter Flags

  • -f (--field) - For string values
  • -F (--field) - For integer values (note the capital F)

Complete Example

# First, get the latest commit SHA for the PR
gh api repos/NeoLabHQ/learning-platform-app/pulls/4 --jq '.head.sha'

# Then add your comment
gh api repos/NeoLabHQ/learning-platform-app/pulls/4/comments \
  -f body='Consider adding error handling here. Should we confirm the lesson was successfully marked as completed before navigating away?' \
  -f commit_id='e152d0dd6cf498467eadbeb638bf05abe11c64d4' \
  -f path='src/components/LessonNavigationButtons.tsx' \
  -F line=26 \
  -f side='RIGHT'

Understanding Line Numbers

The line parameter refers to the position in the diff, not the absolute line number in the file:

  • For new files: Line numbers match the file's line numbers
  • For modified files: Use the line number as it appears in the "Files changed" tab
  • For multi-line comments: Use start_line and line to specify the range

Response

On success, returns a JSON object with comment details:

{
  "id": 2532291222,
  "pull_request_review_id": 3470545909,
  "path": "src/components/LessonNavigationButtons.tsx",
  "line": 26,
  "body": "Consider adding error handling here...",
  "html_url": "https://github.com/NeoLabHQ/learning-platform-app/pull/4#discussion_r2532291222",
  "created_at": "2025-11-16T22:40:46Z"
}

Adding Multiple Line-Specific Comments Together

To add multiple comments across different files in a single review, use the /reviews endpoint with JSON input.

Why Use Reviews for Multiple Comments?

  • Atomic operation - All comments are added together
  • Single notification - Doesn't spam with multiple notifications
  • Better UX - Appears as one cohesive review
  • Same mechanism as GitHub UI - "Start a review" → "Finish review"

Basic Syntax

cat <<'EOF' | gh api repos/{owner}/{repo}/pulls/{pr_number}/reviews --input -
{
  "event": "COMMENT",
  "body": "Overall review summary (optional)",
  "comments": [
    {
      "path": "file1.tsx",
      "body": "Comment on file 1",
      "side": "RIGHT",
      "line": 15
    },
    {
      "path": "file2.tsx",
      "body": "Comment on file 2",
      "side": "RIGHT",
      "line": 30
    }
  ]
}
EOF

Review Event Types

Event Description When to Use
COMMENT General review comment Just leaving feedback without approval
APPROVE Approve the PR Changes look good, ready to merge
REQUEST_CHANGES Request changes Issues that must be fixed before merge

Complete Example

cat <<'EOF' | gh api repos/NeoLabHQ/learning-platform-app/pulls/4/reviews --input -
{
  "event": "COMMENT",
  "body": "Testing multiple line-specific comments via gh api",
  "comments": [
    {
      "path": "src/components/CourseCard.tsx",
      "body": "Test comment generated by Claude",
      "side": "RIGHT",
      "line": 15
    },
    {
      "path": "src/components/CourseProgressWidget.tsx",
      "body": "Test comment generated by Claude",
      "side": "RIGHT",
      "line": 30
    },
    {
      "path": "src/components/LessonProgressTracker.tsx",
      "body": "Test comment generated by Claude",
      "side": "RIGHT",
      "line": 20
    }
  ]
}
EOF

Response

{
  "id": 3470546747,
  "state": "COMMENTED",
  "html_url": "https://github.com/NeoLabHQ/learning-platform-app/pull/4#pullrequestreview-3470546747",
  "submitted_at": "2025-11-16T22:42:43Z",
  "commit_id": "e152d0dd6cf498467eadbeb638bf05abe11c64d4"
}

Common Issues and Solutions

Issue 1: "user_id can only have one pending review per pull request"

Error Message:

gh: Validation Failed (HTTP 422)
{"message":"Validation Failed","errors":[{"resource":"PullRequestReview","code":"custom","field":"user_id","message":"user_id can only have one pending review per pull request"}]}

Cause: GitHub only allows one pending (unsubmitted) review per user per PR. If you previously started a review through the UI or API and didn't submit it, it blocks new review creation.

Solution 1: Submit the pending review

# Check for pending reviews
gh api repos/{owner}/{repo}/pulls/{pr_number}/reviews | jq '.[] | select(.state=="PENDING")'

# Submit it through the UI or ask the user to submit it

Solution 2: Use the single comment endpoint instead

# Add individual comments without creating a review
gh api repos/{owner}/{repo}/pulls/{pr_number}/comments \
  -f body='Comment text' \
  -f commit_id='<sha>' \
  -f path='file.tsx' \
  -F line=26 \
  -f side='RIGHT'

Issue 2: Array syntax not working with --raw-field

Failed Attempt:

# This does NOT work - GitHub API receives an object, not an array
gh api repos/{owner}/{repo}/pulls/{pr}/reviews \
  --raw-field 'comments[0][path]=file1.tsx' \
  --raw-field 'comments[0][line]=15' \
  --raw-field 'comments[1][path]=file2.tsx' \
  --raw-field 'comments[1][line]=30'

Error:

Invalid request. For 'properties/comments', {"0" => {...}, "1" => {...}} is not an array.

Solution: Use JSON input via heredoc:

cat <<'EOF' | gh api repos/{owner}/{repo}/pulls/{pr}/reviews --input -
{
  "comments": [...]
}
EOF

Issue 3: Invalid line number

Error Message:

Pull request review thread line must be part of the diff

Cause: The line number doesn't exist in the diff for this file.

Solutions:

  • Verify the file was actually changed in this PR
  • Check the "Files changed" tab to see actual line numbers in the diff
  • Ensure you're using the correct commit_id (the latest commit in the PR)

Issue 4: Wrong commit_id

Error Message:

commit_sha is not part of the pull request

Solution: Get the latest commit SHA:

how to use git:attach-review-to-pr

How to use git:attach-review-to-pr on Cursor

AI-first code editor with Composer

1

Prerequisites

Before installing skills in Cursor, ensure your development environment meets these requirements:

  • Cursor installed and configured on your development machine
  • Node.js version 16.0+ with npm package manager (verify with node --version)
  • Active project directory or workspace where you want to add git:attach-review-to-pr
2

Execute installation command

Execute the skills CLI command in your project's root directory to begin installation:

$npx skills add https://github.com/neolabhq/context-engineering-kit --skill git:attach-review-to-pr

The skills CLI fetches git:attach-review-to-pr from GitHub repository neolabhq/context-engineering-kit and configures it for Cursor.

3

Select Cursor when prompted

The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:

◆ Which agents do you want to install to?
│ ── Universal (.agents/skills) ── always included ────
│ • Amp
│ • Antigravity
│ • Cline
│ • Codex
│ ●Cursor(selected)
│ • Cursor
│ • Windsurf
4

Verify installation

Confirm successful installation by checking the skill directory location:

.cursor/skills/git:attach-review-to-pr

Reload or restart Cursor to activate git:attach-review-to-pr. Access the skill through slash commands (e.g., /git:attach-review-to-pr) or your agent's skill management interface.

Security & Verification Notice

We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.

Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.

List & Monetize Your Skill

Submit your Claude Code skill and start earning

GET_STARTED →

Use Cases

User Story & Requirements Generation

Create detailed user stories, acceptance criteria, and feature specs

Example

Generate user stories for 'password reset feature' with acceptance criteria, edge cases, and test scenarios

Reduce spec writing time by 50%, ensure comprehensive coverage

Competitive Analysis

Research competitors, compare features, identify gaps

Example

Analyze 5 competitor products, create feature comparison matrix, suggest differentiation opportunities

Complete competitive research in 2 hours instead of 2 days

Roadmap Prioritization

Evaluate features using frameworks (RICE, ICE, Kano) and create prioritized backlogs

Example

Score 20 feature ideas using RICE framework, generate prioritized roadmap with rationale

Make data-driven prioritization decisions faster

Stakeholder Communication

Draft PRDs, status updates, and stakeholder presentations

Example

Create executive summary of Q3 roadmap, monthly progress report, feature launch announcement

Save 3-5 hours/week on communication overhead

Implementation Guide

Prerequisites

  • Claude Desktop or compatible AI client
  • Access to product documentation and roadmap tools (Jira, Notion, etc.)
  • Understanding of product management frameworks (RICE, Jobs-to-be-Done, etc.)
  • Stakeholder contact information and communication channels

Time Estimate

30-60 minutes to see productivity improvements

Installation Steps

  1. 1.Install product management skill
  2. 2.Start with user story generation for known feature
  3. 3.Progress to competitive analysis: research 2-3 competitors
  4. 4.Use for roadmap prioritization: apply RICE/ICE scoring
  5. 5.Draft stakeholder communications and refine based on feedback
  6. 6.Build template library for recurring PM tasks
  7. 7.Share effective prompts with product team

Common Pitfalls

  • Not validating competitive research—verify facts before sharing
  • Accepting user stories without involving engineering team
  • Over-relying on frameworks without qualitative judgment
  • Not customizing outputs to company culture and communication style
  • Skipping stakeholder validation of generated requirements

Best Practices

✓ Do

  • +Validate research and competitive analysis with real data
  • +Collaborate with engineering when generating technical requirements
  • +Customize frameworks and templates to your company context
  • +Use skill for first drafts, refine with stakeholder input
  • +Document successful prompt patterns for PM tasks
  • +Combine AI efficiency with human judgment and intuition

✗ Don't

  • Don't publish competitive analysis without fact-checking
  • Don't finalize user stories without engineering review
  • Don't make prioritization decisions solely on AI scoring
  • Don't skip customer validation of generated requirements
  • Don't ignore company-specific context and culture

💡 Pro Tips

  • Provide context: company goals, constraints, customer feedback
  • Ask for alternatives: 'Show 3 ways to prioritize this roadmap'
  • Request stakeholder-specific formatting: 'Executive summary vs. engineering spec'
  • Use skill for 70% generation + 30% customization to company needs

When to Use This

✓ Use When

Use for user story writing, competitive research, roadmap prioritization, stakeholder communication, and PRD drafting. Best for reducing repetitive documentation and research work.

✗ Avoid When

Avoid for strategic product vision (requires deep customer empathy), pricing decisions (needs market and financial expertise), or when face-to-face customer discovery is more valuable than speed.

Learning Path

  1. 1Basic: user stories, feature specs, status updates
  2. 2Intermediate: competitive analysis, prioritization frameworks, PRDs
  3. 3Advanced: product strategy, go-to-market planning, OKR setting
  4. 4Expert: product vision, market positioning, business model innovation

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.767 reviews
  • Yuki Sanchez· Dec 28, 2024

    Registry listing for git:attach-review-to-pr matched our evaluation — installs cleanly and behaves as described in the markdown.

  • Pratham Ware· Dec 24, 2024

    Keeps context tight: git:attach-review-to-pr is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Emma Okafor· Dec 24, 2024

    git:attach-review-to-pr has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Mei Dixit· Dec 16, 2024

    I recommend git:attach-review-to-pr for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Chaitanya Patil· Dec 12, 2024

    git:attach-review-to-pr reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Kaira Bansal· Dec 12, 2024

    Solid pick for teams standardizing on skills: git:attach-review-to-pr is focused, and the summary matches what you get after install.

  • Camila Johnson· Dec 12, 2024

    git:attach-review-to-pr reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Isabella Choi· Dec 8, 2024

    Keeps context tight: git:attach-review-to-pr is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Noor Reddy· Dec 8, 2024

    git:attach-review-to-pr fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Noor Harris· Nov 27, 2024

    git:attach-review-to-pr has been reliable in day-to-day use. Documentation quality is above average for community skills.

showing 1-10 of 67

1 / 7