Skip to content

Instantly share code, notes, and snippets.

@mmornati
Created April 27, 2026 19:14
Show Gist options
  • Select an option

  • Save mmornati/2bba07f11d6e80075cb54f2cf10fa0fb to your computer and use it in GitHub Desktop.

Select an option

Save mmornati/2bba07f11d6e80075cb54f2cf10fa0fb to your computer and use it in GitHub Desktop.

Skill: GitHub CLI (gh) Operations

Use this skill when performing GitHub operations via the gh CLI. Follow the commands exactly to avoid re-running --help lookups.

Authentication

gh auth status   # Check if authenticated

Repository Operations

# Create a public repository
gh repo create <repo-name> --public

# Create a private repository
gh repo create <repo-name> --private

# View repo info
gh repo view <owner>/<repo>

Issue Operations

# List open issues (plain table)
gh issue list -R <owner>/<repo>

# List issues as JSON (for structured data)
gh issue list -R <owner>/<repo> --json number,title,body,state,comments

# Create an issue
gh issue create -R <owner>/<repo> --title "<title>" --body "<body>"

# View a specific issue
gh issue view <issue-number> -R <owner>/<repo>

# Add a comment to an issue
gh issue comment <issue-number> -R <owner>/<repo> --body "<comment>"

# Search for an issue by text
gh issue list -R <owner>/<repo> --search "<query>" --json number,title,state

Pull Request Operations

# List open PRs
gh pr list -R <owner>/<repo>

# List PRs as JSON
gh pr list -R <owner>/<repo> --json number,title,state,author

# Create a PR
gh pr create -R <owner>/<repo> --title "<title>" --body "<body>" --head <branch> --base main

Output Format Tips

  • Always prefer --json flags to get structured output instead of human-readable tables.
  • Fields available for --json on issues: number, title, body, state, labels, author, comments, createdAt, updatedAt, url
  • Fields available for --json on PRs: number, title, state, author, headRefName, baseRefName, url, isDraft

Error Handling

  • If OWNER/REPO not found: verify with gh repo view <owner>/<repo>
  • If auth fails: run gh auth login
  • Never run gh --help or discover flags at runtime — all needed flags are listed above.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment