Get the FREE Ultimate OpenClaw Setup Guide →

Github Cli

Scanned
npx machina-cli add skill georgekhananaev/claude-skills-vault/github-cli --openclaw
Files (1)
SKILL.md
10.4 KB

GitHub CLI

Safety-first wrapper for GitHub CLI (gh). Every command is classified by risk level before execution.

When to Use

  • User asks to create, list, merge, or close PRs
  • User asks to manage issues, releases, or repos
  • User asks to check CI/CD status or workflow runs
  • User asks to call the GitHub API via gh api
  • User asks to manage GitHub Actions secrets or variables

Prerequisites

  1. Install: brew install gh or see https://cli.github.com
  2. Auth: gh auth login
  3. Verify: gh --version (requires v2.86+)
  4. Scopes: gh auth status — confirm repo, read:org scopes minimum

Safety Model

Every gh command falls into one of four risk tiers:

TierAction RequiredExamples
SafeExecute immediatelygh pr list, gh issue view, gh repo view
WriteInform user, then executegh pr create, gh issue create, gh release create
DestructiveAskUserQuestion BEFORE executinggh pr merge, gh pr close, gh release delete
ForbiddenMulti-step validation, NEVER auto-confirmgh repo delete, gh repo transfer, visibility changes

See references/safety-rules.md for the full classification and confirmation templates.

Decision Flow

Command received
  → Classify risk tier (see Quick Reference)
  → Safe?        Execute immediately
  → Write?       Inform user what will happen → execute
  → Destructive? AskUserQuestion with options → wait for answer → execute or cancel
  → Forbidden?   Warn → require typed confirmation → final confirm → execute or cancel

Quick Reference

Safe (read-only, execute immediately)

CommandDescription
gh pr listList pull requests
gh pr viewView PR details
gh pr checksView CI status
gh pr diffView PR diff
gh issue listList issues
gh issue viewView issue details
gh repo viewView repo info
gh repo listList repos
gh repo cloneClone a repo
gh release listList releases
gh release viewView release details
gh run listList workflow runs
gh run viewView run details
gh run view --logView run logs
gh workflow listList workflows
gh workflow viewView workflow details
gh run downloadDownload workflow artifacts
gh api (GET)Read-only API calls
gh auth statusCheck auth
gh browseOpen repo in browser
gh statusCheck your GitHub dashboard
gh gist listList your gists
gh gist viewView gist details
gh label listList labels
gh search reposSearch repos
gh search issuesSearch issues
gh search prsSearch PRs
gh search codeSearch code

Write (inform, then execute)

CommandDescription
gh pr createCreate PR
gh pr editEdit PR metadata
gh pr commentComment on PR
gh pr reviewSubmit review
gh pr readyMark PR as ready
gh pr checkoutCheck out a PR branch locally
gh issue createCreate issue
gh issue editEdit issue
gh issue commentComment on issue
gh issue reopenReopen a closed issue
gh issue pinPin an issue
gh issue unpinUnpin an issue
gh label createCreate label
gh label editEdit label
gh release createCreate release
gh repo createCreate new repo
gh repo editEdit repo settings (non-visibility)
gh repo forkFork a repo
gh repo renameRename a repository
gh gist createCreate a new gist
gh gist editEdit an existing gist
gh run rerunRe-run workflow
gh workflow enableEnable workflow
gh workflow disableDisable workflow
gh workflow runManually trigger a workflow
gh secret setSet secret
gh variable setSet variable
gh api -X POST/PUT/PATCHWrite API calls

Destructive (AskUserQuestion required)

CommandDescription
gh pr mergeMerge PR (irreversible in most workflows)
gh pr closeClose PR
gh issue closeClose issue
gh issue deleteDelete issue (permanent)
gh issue transferTransfer issue to another repo
gh release deleteDelete release
gh label deleteDelete label
gh repo archiveArchive repo
gh secret deleteDelete secret
gh variable deleteDelete variable
gh auth logoutLog out of GitHub CLI
gh run cancelCancel running workflow
gh api -X DELETEDelete API calls

Forbidden (multi-step validation)

CommandDescription
gh repo deleteDelete repository (PERMANENT)
gh repo transferTransfer repo ownership
gh repo edit --visibilityChange repo visibility
Bulk destructive loopsAny loop running delete/close/merge

Workflow Patterns

Pull Requests

# List open PRs
gh pr list

# Create PR (Write — inform user first)
gh pr create --title "feat: add auth" --body "$(cat <<'EOF'
## Summary
- Add JWT authentication middleware

## Test plan
- [ ] Unit tests pass
- [ ] Manual login flow verified
EOF
)"

# View PR with checks
gh pr view 42
gh pr checks 42

# Merge PR (Destructive — AskUserQuestion first)
gh pr merge 42 --squash --delete-branch

Issues

# List issues with filters
gh issue list --label bug --assignee @me
gh issue list --state closed --limit 10

# Create issue (Write)
gh issue create --title "Bug: login fails" --body "Steps to reproduce..." --label bug

# View issue
gh issue view 123

# Close issue (Destructive — confirm first)
gh issue close 123 --reason completed

Releases

# List releases
gh release list

# Create release (Write — inform user)
gh release create v1.2.0 --generate-notes --title "v1.2.0"

# Create release with assets
gh release create v1.2.0 ./dist/*.tar.gz --title "v1.2.0" --notes "Release notes here"

# Delete release (Destructive — confirm first)
gh release delete v1.2.0

CI/CD & Actions

# List recent runs
gh run list --limit 10

# View specific run
gh run view 12345

# View logs for failed run
gh run view 12345 --log-failed

# Re-run failed jobs (Write)
gh run rerun 12345 --failed

# Cancel running workflow (Destructive — confirm)
gh run cancel 12345

# Manage secrets (Write for set, Destructive for delete)
gh secret set API_KEY --body "sk-..."
gh secret list

Repository

# View repo info
gh repo view

# Create repo (Write)
gh repo create my-app --public --clone

# Clone
gh repo clone owner/repo

# Fork (Write)
gh repo fork owner/repo --clone

# Archive (Destructive — confirm first)
gh repo archive owner/repo

API

# GET (Safe)
gh api repos/owner/repo/pulls
gh api repos/owner/repo/issues/123/comments

# POST (Write)
gh api repos/owner/repo/issues -f title="Bug" -f body="Description"

# DELETE (Destructive — confirm first)
gh api repos/owner/repo/issues/123/labels/bug -X DELETE

AskUserQuestion Integration

For Destructive operations, use AskUserQuestion with tailored options:

PR Merge Example

Question: "How should PR #42 'feat: add auth' be merged?"
Options:
  - "Squash and merge" — Combine all commits into one
  - "Create merge commit" — Preserve commit history
  - "Rebase and merge" — Rebase onto base branch
  - "Cancel" — Do not merge

PR/Issue Close Example

Question: "Close PR #42 'feat: add auth'?"
Options:
  - "Close only" — Close without deleting branch
  - "Close and delete branch" — Close PR and remove source branch
  - "Cancel" — Keep open

Delete Example

Question: "Delete release v1.2.0?"
Options:
  - "Delete release only" — Keep the git tag
  - "Delete release and tag" — Remove both release and git tag
  - "Cancel" — Keep release

For Forbidden operations, follow the triple-confirmation protocol in references/safety-rules.md.

Error Handling

ErrorCauseFix
gh: command not foundNot installedbrew install gh
authentication requiredNot logged ingh auth login
HTTP 403Insufficient scopesgh auth refresh -s scope
HTTP 404Repo not found or no accessCheck repo name and permissions
HTTP 422Validation failedCheck required fields, branch exists
HTTP 409Merge conflictResolve conflicts first
HTTP 429Rate limitedWait, or use --limit to reduce calls
GraphQL: ...API query errorCheck field names and types

CLI Flags Reference

FlagDescription
--json fieldsOutput specific JSON fields
--jq exprFilter JSON with jq expressions
--template tmplFormat output with Go templates
-R owner/repoTarget a different repo
--limit NLimit results
--state open|closed|allFilter by state
--label nameFilter by label
--assignee userFilter by assignee
--author userFilter by author
--webOpen in browser

Shell Safety

  • No interactive mode: Never use -i or --interactive flags
  • No pagers: Always pipe to cat if output may trigger a pager: gh pr list | cat
  • Timeouts: Set reasonable timeouts for commands that could hang
  • Quote arguments: Always quote multi-word arguments and heredoc bodies
  • Never pass --yes to forbidden operations — always require explicit confirmation

Integration

Pairs with:

  • code-quality — Review code before PR creation
  • brainstorm — Design features before opening issues
  • codex-cli — Second-opinion audit before merging PRs
  • gemini-cli — Alternative AI review for PR changes

Source

git clone https://github.com/georgekhananaev/claude-skills-vault/blob/main/.claude/skills/github-cli/SKILL.mdView on GitHub

Overview

A safety-first wrapper for the GitHub CLI (gh) that classifies every command by risk before execution. It covers PRs, issues, releases, repos, Actions, and API calls, enforcing mandatory confirmation for destructive or forbidden actions. This helps prevent accidental data loss and unintended changes.

How This Skill Works

On command receipt, the skill classifies the risk tier (Safe, Write, Destructive, Forbidden) and follows a decision flow: Safe commands execute immediately, Write commands inform the user before executing, Destructive commands prompt for confirmation, and Forbidden commands require multi-step validation and final confirmation. This risk-aware pipeline mirrors the provided safety model and quick reference.

When to Use It

  • User asks to create, list, merge, or close PRs
  • User asks to manage issues, releases, or repos
  • User asks to check CI/CD status or workflow runs
  • User asks to call the GitHub API via gh api
  • User asks to manage GitHub Actions secrets or variables

Quick Start

  1. Step 1: Install and authenticate gh (brew install gh; gh auth login; gh --version >= v2.86+)
  2. Step 2: State the GitHub operation you want (PRs, issues, releases, repos, Actions, API)
  3. Step 3: Follow prompts; destructive/forbidden actions require explicit confirmation before execution

Best Practices

  • Always classify risk before executing any gh command
  • Begin with Safe, read-only commands to verify context
  • For Write actions, inform the user what will happen before executing
  • Destructive actions trigger an explicit confirmation flow
  • Forbidden actions require multi-step validation and final confirmation

Example Use Cases

  • gh pr list (Safe) to review open PRs without changing state
  • gh pr create (Write) to open a new PR after user confirmation
  • gh pr merge (Destructive) prompts for confirmation before merging
  • gh repo delete (Forbidden) requires explicit multi-step confirmation
  • gh api (GET) calls to read repository data without side effects

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers