GitHub CLI Workflow Skill
Use gh for PR/issue workflows and gh api for operations not covered by built-in commands.
1) Write clean markdown bodies
Prefer inline multiline bodies (no temp files, no escaped \n) with heredoc:
gh pr edit --body "$(cat <<'EOF' ## Summary Line 1 Line 2 EOF )"
Important:
- •Keep the heredoc delimiter quoted (
<<'EOF') so backticks in markdown are treated as plain text. - •Do not put markdown with backticks directly inside a double-quoted
--body "..."string. - •
--body-fileis still fine for very long bodies, but inline heredoc is the default.
Avoid:
gh pr comment --body "Line 1\n\nLine 2"
2) Pull request workflow
Inspect the active PR:
gh pr view --json number,title,url,body gh pr view --comments
Create/update PRs:
gh pr create --title "..." --base main --head <branch> --body "$(cat <<'EOF' ## Summary - item EOF )" gh pr edit --body "$(cat <<'EOF' ## Updated summary - item EOF )" gh pr edit --body "" gh pr comment --body "$(cat <<'EOF' Short update - test 1 passed EOF )"
If PR title check fails:
- •Error pattern:
No release type found in pull request title. - •Fix with Conventional Commit title prefixes like
feat:,fix:,docs:,test:,build:,ci:,chore:,refactor:,perf:,revert:. - •Update title quickly:
gh pr edit <number> --title "fix(ci): short imperative summary"
3) Issue workflow
Inspect/update issues:
gh issue view <number> --json number,title,body,state,url gh issue view <number> --comments gh issue edit <number> --body 'Updated issue body Details' gh issue comment <number> --body 'Resolution summary - action 1'
Close or reopen:
gh issue close <number> --reason "completed" gh issue close <number> --reason "not planned" gh issue reopen <number>
4) Edit or delete malformed comments
gh does not provide a direct PR comment edit command; use issue-comment API endpoints.
gh api --method PATCH /repos/<owner>/<repo>/issues/comments/<comment_id> -f body='Updated markdown body' gh api --method DELETE /repos/<owner>/<repo>/issues/comments/<comment_id>
5) CI and workflow checks
gh pr checks 55 --repo owner/repo gh run list --repo owner/repo --limit 10 gh run view <run-id> --repo owner/repo gh run view <run-id> --repo owner/repo --log-failed
6) Review comments workflow (no jq)
Use these commands when you want to triage/reply/resolve review comments without jq parsing.
gh pr view <pr-number> --repo <owner>/<repo> --comments gh pr view <pr-number> --repo <owner>/<repo> --web
Notes:
- •
gh pr view --commentsis useful for PR conversation context, but not reliable for full inline review-thread management. - •For reply/resolve workflows, query
reviewThreadsvia GraphQL to get thread IDs.
List review threads (with IDs, path, unresolved flag):
gh api graphql -f query='query { repository(owner:"<owner>", name:"<repo>") { pullRequest(number:<pr-number>) { reviewThreads(first:100) { nodes { id isResolved path comments(last:1){nodes{url body author{login}}} } } } } }'
Quick unresolved check without jq:
gh api graphql -f query='query { repository(owner:"<owner>", name:"<repo>") { pullRequest(number:<pr-number>) { reviewThreads(first:100) { nodes { id isResolved } } } } }' | grep '"isResolved": false' || true
Reply to a review thread and resolve it (CLI):
gh api graphql -f query='mutation($threadId:ID!, $body:String!) { addPullRequestReviewThreadReply(input:{pullRequestReviewThreadId:$threadId, body:$body}) { comment { url } } }' -f threadId='<thread_id>' -f body='Addressed in <commit_sha>.'
gh api graphql -f query='mutation($threadId:ID!) { resolveReviewThread(input:{threadId:$threadId}) { thread { isResolved } } }' -f threadId='<thread_id>'
7) Advanced query patterns (optional jq)
Use JSON output for scripts; add --jq only when you want filtered one-liners.
gh api repos/owner/repo/pulls/55 --jq '.title, .state, .user.login' gh issue list --repo owner/repo --json number,title --jq '.[] | "\(.number): \(.title)"'