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 authenticatedgh auth statushttps://cli.github.com/User must be authenticated with appropriate permissionsgh auth loginFetch comprehensive PR metadatagh pr view [PR_NUMBER] --repo [owner]/[repo] --json number,title,author,state,body,url,headRefName,baseRefName,files,additions,deletions,changedFilesJSON.roo/temp/pr-[PR_NUMBER]/pr-metadata.jsonGet the full diff of PR changesgh pr diff [PR_NUMBER] --repo [owner]/[repo].roo/temp/pr-[PR_NUMBER]/pr.diffList all files changed in the PRgh pr view [PR_NUMBER] --repo [owner]/[repo] --json files --jq '.files[].path'Line-separated file pathsGet all comments on the PRgh pr view [PR_NUMBER] --repo [owner]/[repo] --json comments --jq '.comments'JSON array of commentsGet all reviews on the PRgh pr view [PR_NUMBER] --repo [owner]/[repo] --json reviews --jq '.reviews'JSON array of reviewsCheck out PR branch locally for analysisgh pr checkout [PR_NUMBER] --repo [owner]/[repo]This switches the current branch to the PR branchPost a comment on the PRgh 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 commentsgh 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,stateJSON
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 filesPreserve data for analysis and recoveryUse jq for JSON parsing when available
gh pr view --json files --jq '.files[].path'
For PRs with many files, save outputs to files firstMore than 50 filesSave to file, then process in chunksAlways validate JSON before parsingjq 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 locallygh pr diff [number]: View PR diffgh pr comment [number] --body "[text]": Add commentgh pr review [number]: Create reviewgh pr close [number]: Close PRgh pr reopen [number]: Reopen PRgh issue view [number]
number, title, body, author, state,
labels, assignees, milestone, comments
gh repo view --json [fields]: Get repo infogh repo clone [owner]/[repo]: Clone repositoryAlways specify --repo to avoid ambiguityUse --json for structured data that needs parsingSave command outputs to temp files for reliabilityCheck gh auth status before starting operationsHandle both personal repos and organization reposUse meaningful file names when saving outputsInclude error handling for all commandsDocument the expected format of saved filesFetch all PR data for analysisgh pr view 123 --repo owner/repo --json number,title,author,state,body,url,headRefName,baseRefName,files,additions,deletions,changedFiles > .roo/temp/pr-123/metadata.jsongh pr view 123 --repo owner/repo --json comments > .roo/temp/pr-123/comments.jsongh pr view 123 --repo owner/repo --json reviews > .roo/temp/pr-123/reviews.jsongh pr diff 123 --repo owner/repo > .roo/temp/pr-123/pr.diffPost a comprehensive reviewCreate review content in .roo/temp/pr-123/review.mdgh pr review 123 --repo owner/repo --comment --body-file .roo/temp/pr-123/review.md