一键导入
gh-cli
GitHub CLI patterns for PR reviews, comments, and API operations. Use when working with gh api commands, especially for review threads and comments.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
GitHub CLI patterns for PR reviews, comments, and API operations. Use when working with gh api commands, especially for review threads and comments.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when working with git operations including commits, branches, worktrees, and PRs. Covers the full git workflow from feature isolation to PR submission.
Complete PR submission pipeline with local sub-agent review before pushing, CI verification, and automated review integration. Always dispatches code-reviewer and code-simplifier for code changes, plus conditional reviewers (security, performance, dependency, accessibility, i18n, type-design, etc.) based on change type. Waits for CI with `gh pr checks --watch`. Integrates CodeRabbit and Greptile feedback.
Use when following a written plan or task list. Checkpoint verification at each step. Triggers - execute plan, follow plan, implement plan, next step, continue, proceed.
Use for parallel branch development with workspace isolation.
Use when implementing analytics, event tracking, or setting up dashboards. Covers privacy-first tracking, event patterns, and common analytics tools.
REST/GraphQL API design patterns, error handling, and versioning. Use when designing APIs, handling errors, or making API architecture decisions.
| name | gh-cli |
| description | GitHub CLI patterns for PR reviews, comments, and API operations. Use when working with gh api commands, especially for review threads and comments. |
Common gh CLI patterns for PR operations, especially review comments and thread resolution.
gh api or gh api graphql operationCorrect endpoint: /repos/{owner}/{repo}/pulls/{pr}/comments/{comment_id}/replies
# Reply to a specific review comment
gh api repos/OWNER/REPO/pulls/PR_NUMBER/comments/COMMENT_ID/replies \
-X POST \
-f body="Your reply message here"
Example:
gh api repos/erikpr1994/myrepo/pulls/123/comments/2705458190/replies \
-X POST \
-f body="Fixed in commit abc123"
# WRONG - This creates a NEW comment, not a reply
gh api repos/OWNER/REPO/pulls/PR_NUMBER/comments \
-X POST \
-f body="..." \
-f in_reply_to=COMMENT_ID # This field doesn't work here!
# CORRECT - Use the /replies sub-endpoint
gh api repos/OWNER/REPO/pulls/PR_NUMBER/comments/COMMENT_ID/replies \
-X POST \
-f body="..."
# Get all review comments on a PR
gh api repos/OWNER/REPO/pulls/PR_NUMBER/comments \
--jq '.[] | {id: .id, user: .user.login, body: .body[:80], path: .path}'
# List all review threads with resolution status
gh api graphql -f query='
query {
repository(owner: "OWNER", name: "REPO") {
pullRequest(number: PR_NUMBER) {
reviewThreads(first: 100) {
nodes {
id
isResolved
comments(first: 1) {
nodes {
body
author { login }
}
}
}
}
}
}
}'
# Count unresolved threads
gh api graphql -f query='
query {
repository(owner: "OWNER", name: "REPO") {
pullRequest(number: PR_NUMBER) {
reviewThreads(first: 100) {
nodes {
id
isResolved
}
}
}
}
}' | jq '[.data.repository.pullRequest.reviewThreads.nodes[] | select(.isResolved == false)] | length'
# Resolve a thread by its ID
gh api graphql -f query='
mutation {
resolveReviewThread(input: {threadId: "THREAD_ID"}) {
thread {
isResolved
}
}
}'
Example with actual thread ID:
gh api graphql -f query='
mutation {
resolveReviewThread(input: {threadId: "PRRT_kwDONAi3wc6XYZABC"}) {
thread {
isResolved
}
}
}'
GraphQL uses $ for variables, but bash also interprets $. This causes issues:
# BROKEN - bash interprets $owner as a shell variable
gh api graphql -f query='query($owner: String!) { ... }'
# Error: Expected VAR_SIGN, actual: UNKNOWN_CHAR ("")
# Works - no variables to escape
gh api graphql -f query='
query {
repository(owner: "erikpr1994", name: "myrepo") {
pullRequest(number: 123) {
title
}
}
}'
# Works - use -F (uppercase) for typed parameters
gh api graphql \
-F owner="erikpr1994" \
-F repo="myrepo" \
-F pr=123 \
-f query='
query($owner: String!, $repo: String!, $pr: Int!) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $pr) {
title
}
}
}'
Note: -F (uppercase) passes typed values. -f (lowercase) passes strings.
# Works - escape $ with backslash
gh api graphql -f query='
query(\$owner: String!, \$repo: String!, \$pr: Int!) {
repository(owner: \$owner, name: \$repo) {
pullRequest(number: \$pr) {
title
}
}
}' -F owner="erikpr1994" -F repo="myrepo" -F pr=123
Use hardcoded values when possible (Solution 1). It's simpler and avoids escaping issues. Only use variables when you need dynamic values.
# Get thread IDs and first comment
gh api graphql -f query='
query {
repository(owner: "OWNER", name: "REPO") {
pullRequest(number: PR_NUMBER) {
reviewThreads(first: 100) {
nodes {
id
isResolved
comments(first: 1) {
nodes {
id
body
author { login }
}
}
}
}
}
}
}' | jq '.data.repository.pullRequest.reviewThreads.nodes[] | select(.isResolved == false)'
# For each unresolved thread, reply to its comment
gh api repos/OWNER/REPO/pulls/PR_NUMBER/comments/COMMENT_ID/replies \
-X POST \
-f body="Fixed in commit abc123"
# Resolve the thread
gh api graphql -f query='
mutation {
resolveReviewThread(input: {threadId: "THREAD_ID_HERE"}) {
thread { isResolved }
}
}'
# Should return 0
gh api graphql -f query='
query {
repository(owner: "OWNER", name: "REPO") {
pullRequest(number: PR_NUMBER) {
reviewThreads(first: 100) {
nodes { isResolved }
}
}
}
}' | jq '[.data.repository.pullRequest.reviewThreads.nodes[] | select(.isResolved == false)] | length'
gh pr view PR_NUMBER --json number,title,state,reviewDecision,statusCheckRollup
gh pr checks PR_NUMBER
gh pr checks PR_NUMBER --watch # Wait for completion
gh pr edit PR_NUMBER --add-reviewer username1,username2
gh pr create --title "feat: my feature" --body "Description here"
gh pr merge PR_NUMBER --squash --delete-branch
| Operation | Command |
|---|---|
| Reply to comment | gh api repos/O/R/pulls/N/comments/ID/replies -X POST -f body="..." |
| Resolve thread | gh api graphql -f query='mutation { resolveReviewThread(input: {threadId: "ID"}) { thread { isResolved } } }' |
| List threads | gh api graphql -f query='query { repository(...) { pullRequest(...) { reviewThreads(...) } } }' |
| Count unresolved | ... | jq '[... | select(.isResolved == false)] | length' |
| PR checks | gh pr checks N --watch |
| Request review | gh pr edit N --add-reviewer user |
| Error | Cause | Fix |
|---|---|---|
Expected VAR_SIGN, actual: UNKNOWN_CHAR | Bash ate the $ in GraphQL | Use hardcoded values or escape \$ |
"in_reply_to" is not a permitted key | Wrong endpoint for replies | Use /comments/{id}/replies endpoint |
No subschema in "oneOf" matched | Missing required fields | Check API docs for required params |
InputObject doesn't accept argument | Wrong GraphQL mutation | Verify mutation field names |
Used by:
Related: