GitHub CLI: Extract PR Review Comments for Fixing Issues in Cursor

Use Case:

This snippet helps extract PR review comments and their associated files and line numbers. It can be used in Cursor (AI-powered code editor) to quickly identify issues and apply suggested fixes.

Explanation:

  1. gh api /repos/<organisation>/<repo-name>/pulls/627/comments – Fetches all comments on PR #627 from the specified repository.
  2. Pipes to jq – Extracts relevant fields for processing:
    • reviewer → Username of the commenter.
    • comment → The review comment text (suggested fix).
    • file → The file where the issue exists.
    • line → The exact line number of the issue.

Example output:

How to Use in Cursor:

  1. Run the command to extract PR comments.
  2. Use Cursor AI to apply suggested fixes to the identified files.
  3. Verify changes and commit the fixes efficiently.

Automate code review fixes and speed up your workflow! 🚀