pr-review-comments

Panduan untuk mengirimkan/memposting komentar ulasan PR inline ke GitHub. Gunakan ini saat Anda perlu memposting komentar ulasan kode pada baris tertentu dari sebuah 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:

Lebih banyak skill dari microsoft

oss-growth
microsoft
Persona peretas pertumbuhan OSS
official
microsoft-foundry
microsoft
Menyebarkan, mengevaluasi, dan mengelola agen Foundry secara menyeluruh: pembuatan Docker, push ACR, pembuatan agen yang dihosting/dengan prompt, memulai kontainer, evaluasi batch, evaluasi berkelanjutan, alur kerja pengoptimal prompt, agent.yaml, kurasi kumpulan data dari jejak. GUNAKAN UNTUK: menyebarkan agen ke Foundry, agen yang dihosting, membuat agen, memanggil agen, mengevaluasi agen, menjalankan evaluasi batch, evaluasi berkelanjutan, pemantauan berkelanjutan, status evaluasi berkelanjutan, mengoptimalkan prompt, meningkatkan prompt, pengoptimal prompt, mengoptimalkan instruksi agen, meningkatkan agen...
officialdevelopmentdevops
azure-ai
microsoft
Gunakan untuk Azure AI: Search, Speech, OpenAI, Document Intelligence. Membantu pencarian, pencarian vektor/hibrida, ucapan-ke-teks, teks-ke-ucapan, transkripsi, OCR. KAPAN: AI Search, pencarian kueri, pencarian vektor, pencarian hibrida, pencarian semantik, ucapan-ke-teks, teks-ke-ucapan, transkripsi, OCR, konversi teks ke ucapan.
officialdevelopmentapi
azure-deploy
microsoft
Jalankan deployment Azure untuk aplikasi yang SUDAH DISIAPKAN dan memiliki file .azure/deployment-plan.md serta infrastruktur yang sudah ada. JANGAN gunakan skill ini saat pengguna meminta untuk MEMBUAT aplikasi baru — gunakan azure-prepare sebagai gantinya. Skill ini menjalankan perintah azd up, azd deploy, terraform apply, dan az deployment dengan pemulihan kesalahan bawaan. Membutuhkan .azure/deployment-plan.md dari azure-prepare dan status tervalidasi dari azure-validate. KAPAN: "jalankan azd up", "jalankan azd deploy", "jalankan deployment",...
officialdevopsaws
azure-storage
microsoft
Layanan Azure Storage termasuk Blob Storage, File Shares, Queue Storage, Table Storage, dan Data Lake. Menjawab pertanyaan tentang tingkat akses penyimpanan (hot, cool, cold, archive), kapan menggunakan setiap tingkat, dan perbandingan tingkat. Menyediakan penyimpanan objek, berbagi file SMB, pengiriman pesan asinkron, NoSQL key-value, dan analitik big data. Termasuk manajemen siklus hidup. GUNAKAN UNTUK: blob storage, file shares, queue storage, table storage, data lake, unggah file, unduh blob, akun penyimpanan, tingkat akses,...
officialdevelopmentdatabase
azure-diagnostics
microsoft
Debug masalah produksi Azure menggunakan AppLens, Azure Monitor, resource health, dan triase aman. KAPAN: debug masalah produksi, troubleshoot app service, CPU tinggi app service, kegagalan deployment app service, troubleshoot container apps, troubleshoot functions, troubleshoot AKS, kubectl tidak bisa terhubung, kegagalan kube-system/CoreDNS, pod pending, crashloop, node tidak siap, kegagalan upgrade, analisis log, KQL, insights, kegagalan image pull, masalah cold start, kegagalan health probe,...
officialdevopsdevelopment
azure-prepare
microsoft
Siapkan aplikasi Azure untuk deployment (infra Bicep/Terraform, azure.yaml, Dockerfiles). Gunakan untuk membuat/memodernisasi atau membuat+men-deploy; bukan untuk migrasi lintas-cloud (gunakan azure-cloud-migrate). JANGAN GUNAKAN UNTUK: aplikasi copilot-sdk (gunakan azure-hosted-copilot-sdk). KAPAN: "membuat aplikasi", "membangun aplikasi web", "membuat API", "membuat API HTTP serverless", "membuat frontend", "membuat backend", "membangun layanan", "memodernisasi aplikasi", "memperbarui aplikasi", "menambahkan autentikasi", "menambahkan caching", "hosting di Azure", "membuat dan...
officialdevelopmentdevops
azure-validate
microsoft
Validasi pra-penyebaran untuk kesiapan Azure. Lakukan pemeriksaan mendalam pada konfigurasi, infrastruktur (Bicep atau Terraform), penetapan peran RBAC, izin identitas terkelola, dan prasyarat sebelum menyebarkan. KAPAN: validasi aplikasi saya, periksa kesiapan penyebaran, jalankan pemeriksaan awal, verifikasi konfigurasi, periksa apakah siap untuk menyebarkan, validasi azure.yaml, validasi Bicep, uji sebelum menyebarkan, pecahkan kesalahan penyebaran, validasi Azure Functions, validasi function app, validasi serverless...
officialdevopstesting