Guidelines for handling GitHub operations using the GitHub CLI (gh). This mode exclusively uses command-line operations for all GitHub interactions. GitHub CLI must be installed and authenticated gh auth status https://cli.github.com/ User must be authenticated with appropriate permissions gh auth login Fetch comprehensive PR metadata gh pr view [PR_NUMBER] --repo [owner]/[repo] --json number,title,author,state,body,url,headRefName,baseRefName,files,additions,deletions,changedFiles JSON .roo/temp/pr-[PR_NUMBER]/pr-metadata.json Get the full diff of PR changes gh pr diff [PR_NUMBER] --repo [owner]/[repo] .roo/temp/pr-[PR_NUMBER]/pr.diff List all files changed in the PR gh pr view [PR_NUMBER] --repo [owner]/[repo] --json files --jq '.files[].path' Line-separated file paths Get all comments on the PR gh pr view [PR_NUMBER] --repo [owner]/[repo] --json comments --jq '.comments' JSON array of comments Get all reviews on the PR gh pr view [PR_NUMBER] --repo [owner]/[repo] --json reviews --jq '.reviews' JSON array of reviews Check out PR branch locally for analysis gh pr checkout [PR_NUMBER] --repo [owner]/[repo] This switches the current branch to the PR branch Post a comment on the PR gh pr comment [PR_NUMBER] --repo [owner]/[repo] --body-file [file_path] gh pr comment [PR_NUMBER] --repo [owner]/[repo] --body "[comment_text]" Create a PR review with comments gh pr review [PR_NUMBER] --repo [owner]/[repo] --comment --body-file [review_file] Get issue details (for linked issues) gh issue view [issue_number] --repo [owner]/[repo] --json number,title,body,author,state JSON Error contains "authentication" or "not logged in" 1. Inform user about auth issue 2. Suggest running: gh auth login 3. Check status with: gh auth status Error contains "rate limit" or "API rate limit exceeded" 1. Wait 30-60 seconds before retry 2. Inform user about rate limiting 3. Consider reducing API calls Error contains "not found" or "could not find pull request" 1. Verify PR number and repository format 2. Check if repository is accessible 3. Ensure correct owner/repo format Error contains "permission denied" or "403" 1. Check repository permissions 2. Verify authentication scope 3. May need to re-authenticate with proper scopes Always save command outputs to temp files Preserve data for analysis and recovery Use jq for JSON parsing when available gh pr view --json files --jq '.files[].path' For PRs with many files, save outputs to files first More than 50 files Save to file, then process in chunks Always validate JSON before parsing jq empty < file.json || echo "Invalid JSON" gh pr view [number] number, title, author, state, body, url, headRefName, baseRefName, files, additions, deletions, changedFiles, comments, reviews, isDraft, mergeable, mergeStateStatus gh pr checkout [number]: Check out PR locally gh pr diff [number]: View PR diff gh pr comment [number] --body "[text]": Add comment gh pr review [number]: Create review gh pr close [number]: Close PR gh pr reopen [number]: Reopen PR gh issue view [number] number, title, body, author, state, labels, assignees, milestone, comments gh repo view --json [fields]: Get repo info gh repo clone [owner]/[repo]: Clone repository Always specify --repo to avoid ambiguity Use --json for structured data that needs parsing Save command outputs to temp files for reliability Check gh auth status before starting operations Handle both personal repos and organization repos Use meaningful file names when saving outputs Include error handling for all commands Document the expected format of saved files Fetch all PR data for analysis gh pr view 123 --repo owner/repo --json number,title,author,state,body,url,headRefName,baseRefName,files,additions,deletions,changedFiles > .roo/temp/pr-123/metadata.json gh pr view 123 --repo owner/repo --json comments > .roo/temp/pr-123/comments.json gh pr view 123 --repo owner/repo --json reviews > .roo/temp/pr-123/reviews.json gh pr diff 123 --repo owner/repo > .roo/temp/pr-123/pr.diff Post a comprehensive review Create review content in .roo/temp/pr-123/review.md gh pr review 123 --repo owner/repo --comment --body-file .roo/temp/pr-123/review.md