pr-review-comments

bởi microsoft

Hướng dẫn gửi/đăng nhận xét đánh giá PR nội tuyến lên GitHub. Sử dụng khi bạn cần đăng nhận xét đánh giá mã trên các dòng cụ thể của một Pull Request.

npx skills add https://github.com/microsoft/semantic-link-labs --skill pr-review-comments

Posting Inline PR Review Comments to GitHub

This skill documents how to post inline review comments to GitHub Pull Requests using the GitHub CLI (gh) and GitHub API. Inline comments appear directly on specific lines of code in the PR diff, making it easier for PR authors to identify and address issues.

When to Use This Skill

Use this skill when you need to:

  • Post inline review comments on specific lines of a PR
  • Automate code review feedback with targeted comments
  • Submit batch review comments via the GitHub API

Prerequisites

  1. GitHub CLI installed: Check with gh --version

    • If not installed on Linux:
      curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
      sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg
      echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
      sudo apt update && sudo apt install gh -y
      
  2. GitHub CLI authenticated: Check with gh auth status

    • If not authenticated: gh auth login -h github.com -p https --web
    • Follow the device code flow to complete authentication

Method: Using GitHub API with JSON Payload

Step 1: Get the PR's Head Commit SHA

COMMIT_SHA=$(gh api repos/{OWNER}/{REPO}/pulls/{PR_NUMBER} --jq '.head.sha')
echo "Commit SHA: $COMMIT_SHA"

Step 2: Create the Review JSON Payload

Create a JSON file with the review comments. Each comment needs:

  • path: The file path relative to repository root
  • line: The line number in the new version of the file (right side of diff)
  • body: The comment content (supports Markdown)
cat > /tmp/review.json << 'EOF'
{
  "commit_id": "YOUR_COMMIT_SHA_HERE",
  "event": "COMMENT",
  "comments": [
    {
      "path": "src/path/to/file.py",
      "line": 40,
      "body": "🔴 **Critical:** Description of the issue.\n\n**Suggested fix:**\n```python\n# your code here\n```"
    },
    {
      "path": "src/path/to/another_file.py",
      "line": 21,
      "body": "🟡 **Minor:** Another issue description."
    }
  ]
}
EOF

Step 3: Post the Review

gh api repos/{OWNER}/{REPO}/pulls/{PR_NUMBER}/reviews --method POST --input /tmp/review.json

Important Notes

Line Numbers

  • The line field refers to the line number in the new version of the file (right side of the diff)
  • For deleted lines, use side: "LEFT" and the line number from the old version
  • Make sure the line number exists in the diff, otherwise the API will reject the comment

Event Types

EventDescription
"COMMENT"Just add comments without approving/requesting changes
"APPROVE"Approve the PR with comments
"REQUEST_CHANGES"Request changes with comments

Comment Body Formatting

  • Supports full GitHub Markdown
  • Use \n for newlines in JSON
  • Escape special characters properly
  • Use emoji prefixes for severity: 🔴 Critical/High, 🟡 Medium/Minor, 🟢 Suggestion

Multi-line Comments

For commenting on a range of lines:

{
  "path": "src/file.py",
  "start_line": 10,
  "line": 15,
  "body": "This comment spans lines 10-15"
}

Troubleshooting

IssueSolution
"Validation Failed" errorCheck that the line number exists in the PR diff; verify the file path is correct
"Resource not accessible" errorEnsure you have write access to the repository; re-authenticate with gh auth login
Comments not appearing on specific linesThe line must be part of the diff (added, modified, or within context lines)

Alternative: Using gh pr review Command

For simpler reviews without inline comments:

gh pr review {PR_NUMBER} --repo {OWNER}/{REPO} --comment --body "Your review comment here"

This posts a general review comment but does not support inline comments on specific lines.


Repository-Specific Information

  • Repository: microsoft/semantic-link-labs
  • Common file paths:
    • src/sempy_labs/{module}/_items.py
    • src/sempy_labs/{module}/__init__.py
  • Review comment conventions:
    • Use severity emojis: 🔴 Critical, 🟡 Medium, 🟢 Minor
    • Include "Suggested fix" with code blocks
    • Reference specific line numbers

Examples

See the examples/ folder for complete working scripts:

Thêm skills từ microsoft

oss-growth
microsoft
Cá tính tăng trưởng OSS
official
microsoft-foundry
microsoft
Triển khai, đánh giá và quản lý các agent Foundry từ đầu đến cuối: xây dựng Docker, đẩy lên ACR, tạo agent lưu trữ/agent nhắc nhở, khởi động container, đánh giá hàng loạt, đánh giá liên tục, quy trình tối ưu hóa nhắc nhở, agent.yaml, quản lý bộ dữ liệu từ dấu vết. SỬ DỤNG CHO: triển khai agent lên Foundry, agent lưu trữ, tạo agent, gọi agent, đánh giá agent, chạy đánh giá hàng loạt, đánh giá liên tục, giám sát liên tục, trạng thái đánh giá liên tục, tối ưu hóa nhắc nhở, cải thiện nhắc nhở, trình tối
officialdevelopmentdevops
azure-ai
microsoft
Sử dụng cho Azure AI: Tìm kiếm, Giọng nói, OpenAI, Xử lý tài liệu. Hỗ trợ tìm kiếm, tìm kiếm vector/kết hợp, chuyển giọng nói thành văn bản, chuyển văn bản thành giọng nói, phiên âm, OCR. KHI: AI Search, truy vấn tìm kiếm, tìm kiếm vector, tìm kiếm kết hợp, tìm kiếm ngữ nghĩa, chuyển giọng nói thành văn bản, chuyển văn bản thành giọng nói, phiên âm, OCR, chuyển đổi văn bản thành giọng nói.
officialdevelopmentapi
azure-deploy
microsoft
Thực thi triển khai Azure cho các ứng dụng ĐÃ ĐƯỢC CHUẨN BỊ có sẵn tệp .azure/deployment-plan.md và tệp cơ sở hạ tầng. KHÔNG sử dụng kỹ năng này khi người dùng yêu cầu TẠO ứng dụng mới — hãy sử dụng azure-prepare thay thế. Kỹ năng này chạy các lệnh azd up, azd deploy, terraform apply và az deployment với khả năng phục hồi lỗi tích hợp. Yêu cầu .azure/deployment-plan.md từ azure-prepare và trạng thái đã xác thực từ azure-validate. KHI: "chạy azd up", "chạy azd deploy", "thực thi triển khai",...
officialdevopsaws
azure-storage
microsoft
Dịch vụ Lưu trữ Azure bao gồm Blob Storage, File Shares, Queue Storage, Table Storage và Data Lake. Trả lời các câu hỏi về các tầng truy cập lưu trữ (hot, cool, cold, archive), thời điểm sử dụng từng tầng và so sánh các tầng. Cung cấp lưu trữ đối tượng, chia sẻ tệp SMB, nhắn tin không đồng bộ, NoSQL key-value và phân tích dữ liệu lớn. Bao gồm quản lý vòng đời. SỬ DỤNG CHO: blob storage, file shares, queue storage, table storage, data lake, tải lên tệp, tải xuống blob, tài khoản lưu trữ, các tầng truy cập,...
officialdevelopmentdatabase
azure-diagnostics
microsoft
Gỡ lỗi các vấn đề sản xuất trên Azure bằng AppLens, Azure Monitor, tình trạng tài nguyên và phân loại an toàn. KHI: gỡ lỗi vấn đề sản xuất, khắc phục sự cố app service, app service CPU cao, lỗi triển khai app service, khắc phục sự cố container apps, khắc phục sự cố functions, khắc phục sự cố AKS, kubectl không kết nối được, lỗi kube-system/CoreDNS, pod đang chờ, crashloop, node chưa sẵn sàng, lỗi nâng cấp, phân tích nhật ký, KQL, thông tin chi tiết, lỗi kéo image, vấn đề khởi động nguội, lỗi health probe,...
officialdevopsdevelopment
azure-prepare
microsoft
Chuẩn bị ứng dụng Azure để triển khai (hạ tầng Bicep/Terraform, azure.yaml, Dockerfiles). Sử dụng để tạo/hiện đại hóa hoặc tạo+triển khai; không dùng cho di chuyển đa đám mây (sử dụng azure-cloud-migrate). KHÔNG DÙNG CHO: ứng dụng copilot-sdk (sử dụng azure-hosted-copilot-sdk). KHI: "tạo ứng dụng", "xây dựng ứng dụng web", "tạo API", "tạo HTTP API serverless", "tạo frontend", "tạo backend", "xây dựng dịch vụ", "hiện đại hóa ứng dụng", "cập nhật ứng dụng", "thêm xác thực", "thêm bộ nhớ đệm", "lưu trữ trên Azure", "tạo và...
officialdevelopmentdevops
azure-validate
microsoft
Kiểm tra trước khi triển khai để đảm bảo sẵn sàng trên Azure. Chạy kiểm tra sâu về cấu hình, hạ tầng (Bicep hoặc Terraform), phân công vai trò RBAC, quyền của managed identity và các điều kiện tiên quyết trước khi triển khai. KHI NÀO: xác thực ứng dụng của tôi, kiểm tra mức độ sẵn sàng triển khai, chạy kiểm tra trước khi triển khai, xác minh cấu hình, kiểm tra xem đã sẵn sàng triển khai chưa, xác thực azure.yaml, xác thực Bicep, kiểm tra trước khi triển khai, khắc phục lỗi triển khai, xác thực Azure Functions, xác thực function app, xác th
officialdevopstesting