| name | github-operations |
| license | MIT |
| compatibility | Claude Code 2.1.183+. Requires gh CLI. |
| author | OrchestKit |
| description | GitHub CLI operations for issues, PRs, milestones, and Projects v2. Covers gh commands, REST API patterns, and automation scripts. Use when managing GitHub issues, PRs, milestones, or Projects with gh. |
| context | fork |
| version | 1.1.0 |
| tags | ["github","gh","cli","issues","pr","milestones","projects","api"] |
| user-invocable | false |
| complexity | medium |
| persuasion-type | guidance |
| metadata | {"category":"workflow-automation"} |
| allowed-tools | ["Read","Glob","Grep","Bash","Write","Edit","TaskCreate","TaskUpdate","TaskList"] |
GitHub Operations
Comprehensive GitHub CLI (gh) operations for project management, from basic issue creation to advanced Projects v2 integration and milestone tracking via REST API.
Overview
- Creating and managing GitHub issues and PRs
- Working with GitHub Projects v2 custom fields
- Managing milestones (sprints, releases) via REST API
- Automating bulk operations with
gh
- Running GraphQL queries for complex operations
CRITICAL: Task Management is MANDATORY (CC 2.1.16)
BEFORE doing ANYTHING else, create tasks to track progress:
TaskCreate(
subject="GitHub Operations: {target}",
description="Managing GitHub issues, PRs, milestones, or Projects",
activeForm="Managing GitHub resources"
)
TaskCreate(subject="Issue management", activeForm="Creating/updating issues")
TaskCreate(subject="PR management", activeForm="Managing pull requests")
TaskCreate(subject="Milestone tracking", activeForm="Updating milestones")
TaskUpdate(taskId="3", addBlockedBy=["2"])
TaskUpdate(taskId="4", addBlockedBy=["3"])
task = TaskGet(taskId="2")
TaskUpdate(taskId="2", status="in_progress")
TaskUpdate(taskId="2", status="completed")
Quick Reference
Issue Operations
gh issue create --title "Bug: API returns 500" --body "..." --label "bug" --milestone "Sprint 5"
gh issue list --state open --label "backend" --assignee @me
gh issue edit 123 --add-label "high" --milestone "v2.0"
PR Operations
gh pr create --title "feat: Add search" --body "..." --base dev --reviewer @teammate
gh pr checks 456 --watch
gh pr merge 456 --auto --squash --delete-branch
claude --from-pr 456
claude --from-pr https://github.com/org/repo/pull/456
Tip (CC 2.1.27): Sessions created via gh pr create are automatically linked to the PR. Use --from-pr to resume with full PR context.
Milestone Operations (REST API)
Footgun: gh issue edit --milestone takes a NAME (string), not a number. The REST API uses a NUMBER (integer). Never pass a number to --milestone. Load Read("${CLAUDE_SKILL_DIR}/references/cli-vs-api-identifiers.md").
gh api repos/:owner/:repo/milestones --jq '.[] | "\(.title): \(.closed_issues)/\(.open_issues + .closed_issues)"'
gh api -X POST repos/:owner/:repo/milestones \
-f title="Sprint 8" -f due_on="2026-02-15T00:00:00Z"
MILESTONE_NUM=$(gh api repos/:owner/:repo/milestones --jq '.[] | select(.title=="Sprint 8") | .number')
gh api -X PATCH repos/:owner/:repo/milestones/$MILESTONE_NUM -f state=closed
gh issue edit 123 124 125 --milestone "Sprint 8"
Projects v2 Operations
gh project item-add 1 --owner @me --url https://github.com/org/repo/issues/123
gh api graphql -f query='mutation {...}' -f projectId="..." -f itemId="..."
JSON Output Patterns
gh issue list --json number,labels --jq '[.[] | select(.labels[].name == "bug")] | .[].number'
gh pr list --json number,title,author --jq '.[] | "\(.number): \(.title) by \(.author.login)"'
gh pr list --json number,reviewDecision,statusCheckRollupState \
--jq '[.[] | select(.reviewDecision == "APPROVED" and .statusCheckRollupState == "SUCCESS")]'
Key Concepts
Milestone vs Epic
| Milestones | Epics |
|---|
| Time-based (sprints, releases) | Topic-based (features) |
| Has due date | No due date |
| Progress bar | Task list checkbox |
| Native REST API | Needs workarounds |
Rule: Use milestones for "when", use parent issues for "what".
Projects v2 Custom Fields
Projects v2 uses GraphQL for setting custom fields (Status, Priority, Domain). Basic gh project commands work for listing and adding items, but field updates require GraphQL mutations.
Rules Quick Reference
| Rule | Impact | What It Covers |
|---|
issue-tracking-automation (load ${CLAUDE_SKILL_DIR}/rules/issue-tracking-automation.md) | HIGH | Auto-progress from commits, sub-task completion, session summaries |
issue-branch-linking (load ${CLAUDE_SKILL_DIR}/rules/issue-branch-linking.md) | MEDIUM | Branch naming, commit references, PR linking patterns |
Batch Issue Creation
When creating multiple issues at once (e.g., seeding a sprint), use an array-driven loop:
SPRINT="Sprint 9"
ISSUES=(
"feat: Add user auth|enhancement,backend|$SPRINT"
"fix: Login redirect loop|bug,high|$SPRINT"
"chore: Update dependencies|maintenance|$SPRINT"
)
for entry in "${ISSUES[@]}"; do
IFS='|' read -r title labels milestone <<< "$entry"
NUM=$(gh issue create \
--title "$title" \
--label "$labels" \
--milestone "$milestone" \
--body "" \
--json number --jq '.number')
echo "Created #$NUM: $title"
done
Tip: Capture the created issue number with --json number --jq '.number' so you can reference it immediately (e.g., add to Projects v2, link in PRs).
Best Practices
- Always use
--json for scripting - Parse with --jq for reliability
- Non-interactive mode for automation - Use
--title, --body flags
- Check rate limits before bulk operations -
gh api rate_limit. On CC ≥ 2.1.116, the Bash tool surfaces a rate-limit hint in the transcript when gh hits 403 — treat that hint as authoritative and back off, don't blind-retry. Before 2.1.116, agents had no signal and would burn all retry attempts in ~13 s.
- Use heredocs for multi-line content -
--body "$(cat <<'EOF'...EOF)"
- Link issues in PRs -
Closes #123, Fixes #456 — GitHub auto-closes on merge
- Use ISO 8601 dates -
YYYY-MM-DDTHH:MM:SSZ for milestone due_on
- Close milestones, don't delete - Preserve history
--milestone takes NAME, not number - Load Read("${CLAUDE_SKILL_DIR}/references/cli-vs-api-identifiers.md")
- Never
gh issue close directly - Comment progress with gh issue comment; issues close only when their linked PR merges to the default branch
2026 CLI changes — what to know
gh-copilot extension is retired
GitHub retired the gh-copilot extension in October 2025. Copilot is now a standalone binary:
gh extension install github/gh-copilot
gh copilot suggest "revert last commit"
copilot suggest "revert last commit"
copilot explain "git rebase -i HEAD~5"
Install from cli.github.com/copilot or via Homebrew (brew install github/gh/copilot). Authentication is shared with gh auth when both are installed.
gh agent-task (2026)
New subcommand for managing Copilot coding-agent tasks:
gh agent-task create --repo owner/repo --title "Fix flaky login test"
gh agent-task list --state open
gh agent-task view 42 --log
gh agent-task watch 42
gh agent-task cancel 42
Pairs with the REST endpoint POST /repos/{owner}/{repo}/agent-tasks for CI-driven task creation.
Sub-issues (native, 2026)
Sub-issues are now a native GitHub concept — no extension required:
gh api repos/{owner}/{repo}/issues/123/sub_issues
gh api -X POST repos/{owner}/{repo}/issues/123/sub_issues \
-f sub_issue_id=$(gh api repos/{owner}/{repo}/issues/456 --jq .node_id)
gh api -X DELETE repos/{owner}/{repo}/issues/123/sub_issue \
-F sub_issue_id=<id>
The old gh-sub-issue third-party extension still works but is superseded. GraphQL sub-issue mutations still require the issue node_id (see references/cli-vs-api-identifiers.md).
Related Skills
ork:create-pr - Create pull requests with proper formatting and review assignments
ork:review-pr - Comprehensive PR review with specialized agents
ork:release-management - GitHub release workflow with semantic versioning and changelogs
stacked-prs - Manage dependent PRs with rebase coordination
ork:issue-progress-tracking - Automatic issue progress updates from commits
Key Decisions
| Decision | Choice | Rationale |
|---|
| CLI vs API | gh CLI preferred | Simpler auth, better UX, handles pagination automatically |
| Output format | --json with --jq | Reliable parsing for automation, no regex parsing needed |
| Milestones vs Epics | Milestones for time | Milestones have due dates and progress bars, epics for topic grouping |
| Projects v2 fields | GraphQL mutations | gh project commands limited, GraphQL required for custom fields |
| Milestone lifecycle | Close, don't delete | Preserves history and progress tracking |
References
Load on demand with Read("${CLAUDE_SKILL_DIR}/references/<file>"):
| File | Content |
|---|
issue-management.md | Bulk operations, templates, sub-issues |
pr-workflows.md | Reviews, merge strategies, auto-merge |
milestone-api.md | REST API patterns for milestone CRUD |
projects-v2.md | Custom fields, GraphQL mutations |
graphql-api.md | Complex queries, pagination, bulk operations |
cli-vs-api-identifiers.md | NAME vs NUMBER footguns, milestone/project ID mapping |
Examples
Load: Read("${CLAUDE_SKILL_DIR}/examples/automation-scripts.md") - Ready-to-use scripts for bulk operations, PR automation, milestone management