Mastering GitHub CLI

VerifiedSafe

Complete GitHub CLI (gh) command reference for repository search, CI/CD monitoring, resource creation, and workflow automation.

Sby Skills Guide Bot
DevOpsIntermediate
7/26/2026
Claude CodeCursor
#github-cli#ci-cd#workflow-automation#repository-search

Recommended for

Automated summary

This skill covers mastering the GitHub CLI (gh) for code search, CI/CD monitoring, resource creation, and workflow automation.

Strengths

  • Quick repository and file search using simple command-line syntax.
  • Real-time monitoring of GitHub Actions workflows and PR checks.
  • Ability to create and manage PRs, issues, forks, and trigger workflows from the terminal.

Limitations

  • Requires gh installed and authenticated with a token.
  • Subject to GitHub API rate limits, especially for code search.
  • Learning curve for advanced JSON queries and API usage.
When to use it

Use this skill when you need to interact with GitHub from the command line frequently, automate CI/CD tasks, or search for code across repositories.

When not to use it

Avoid this skill if the GitHub web interface is sufficient or if you need operations that require fine-grained permissions not available through the API.

Security analysis

Safe
Quality score90/100

The skill provides reference and examples for standard GitHub CLI operations and workflow authoring. No destructive, exfiltrating, or obfuscated commands are present; all actions are legitimate and safe when used as intended.

No concerns found

How this analysis is made

Examples

Search repositories for a file
Find all GitHub repositories that contain a SKILL.md file using the GitHub CLI.
Monitor CI status of a PR
Check and watch the CI status of PR #123 in the current repository.
Create a new issue with labels
Create a GitHub issue titled 'Fix bug in login' with labels 'bug' and 'urgent' assigned to me.

name: mastering-github-cli description: | GitHub CLI (gh) command reference for repository search, code discovery, CI/CD monitoring, workflow authoring, and automation. Triggers on "gh" commands, "github cli", searching repos for files/directories (.skilz, .cursor, .codex, Dockerfile), monitoring GitHub Actions workflows, checking PR CI status, downloading artifacts, creating PRs/issues/repos from command line, triggering workflows, forking repos, batch operations, "write a workflow", "github actions", "CI/CD pipeline", "workflow yaml", and "matrix builds". Use for gh search, gh run, gh pr, gh issue, gh repo, gh workflow, gh api, workflow authoring, and automating GitHub operations. license: MIT allowed-tools:

  • Bash
  • Read
  • Write
  • Glob
  • Grep

Mastering GitHub CLI

Command-line interface for GitHub operations: search, monitoring, resource creation, workflow authoring, and automation.

Contents


Quick Start

Find repos with specific files/directories

gh search code "path:.skilz" --json repository --jq '.[].repository.fullName'
gh search code --filename SKILL.md
gh search code --filename Dockerfile --language python

Monitor CI/CD

gh run list --workflow=CI --status=failure --limit 10
gh run watch 12345 --exit-status      # Block until complete
gh run view 12345 --log-failed        # Failed logs only
gh pr checks 123 --watch              # PR CI status

Create resources

gh pr create --title "Feature" --body "Description" --reviewer @user
gh issue create --title "Bug" --label bug,urgent --assignee @me
gh repo fork owner/repo --clone

Trigger and monitor workflow

gh workflow run deploy.yml -f environment=staging
sleep 5
RUN_ID=$(gh run list --workflow=deploy.yml --limit 1 --json databaseId --jq '.[0].databaseId')
gh run watch "$RUN_ID" --exit-status

Command Reference

| Task | Command | Reference | |------|---------|-----------| | Find repos with file | gh search code --filename FILE | search.md | | Find repos with directory | gh search code "path:DIR" | search.md | | List failed runs | gh run list --status=failure | monitoring.md | | Watch run | gh run watch ID --exit-status | monitoring.md | | Download artifacts | gh run download ID -n NAME | monitoring.md | | Create PR | gh pr create --fill | resources.md | | Check PR CI | gh pr checks --watch | monitoring.md | | Trigger workflow | gh workflow run NAME.yml | automation.md | | Fork repo | gh repo fork REPO --clone | resources.md | | REST/GraphQL API | gh api repos/{owner}/{repo} | api.md |

JSON Output

gh pr list --json                              # Discover fields
gh pr list --json number,title,author,labels   # Select fields
gh run list --json status --jq '.[] | select(.status=="completed")'

Environment & Auth

| Variable | Purpose | |----------|---------| | GH_TOKEN | Authentication token | | GH_REPO | Default owner/repo | | GH_HOST | GitHub Enterprise host | | GH_PROMPT_DISABLED=1 | Disable prompts (CI) |

Rate Limits

| Endpoint | Limit | Notes | |----------|-------|-------| | REST API | 5,000/hour | Per authenticated user | | Search API | 30/minute | All search endpoints | | Code Search | 10/minute | More restrictive | | Search results | 1,000 max | Use date partitioning for more |


Workflow Authoring

GitHub Actions workflow YAML patterns for CI/CD pipelines.

Basic Structure

name: CI Pipeline
on:
  push:
    branches: [main]
  pull_request:
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: make build
      - run: make test

Caching Patterns

# Python/Poetry
- uses: actions/setup-python@v5
  with:
    python-version: '3.11'
- uses: actions/cache@v4
  with:
    path: .venv
    key: venv-${{ runner.os }}-${{ hashFiles('poetry.lock') }}

# Node.js
- uses: actions/setup-node@v4
  with:
    node-version: '20'
    cache: 'npm'

Matrix Builds

strategy:
  matrix:
    os: [ubuntu-latest, windows-latest]
    node: [18, 20]
  fail-fast: false

OIDC Authentication (AWS/GCP)

permissions:
  id-token: write
  contents: read

steps:
  - uses: aws-actions/configure-aws-credentials@v4
    with:
      role-to-assume: arn:aws:iam::123456789012:role/GitHubActionsRole
      aws-region: us-east-1

Full reference: references/workflow-authoring.md

Advanced Patterns

For enterprise CI/CD pipelines:

  • Ephemeral PR Environments - Auto-create/destroy per PR
  • Release Please - Automated semantic versioning
  • PR Cleanup - Resource cleanup on close
  • Testing Patterns - pytest, Gradle, Jest with coverage
  • Deployment Status Checks - Wait for stack readiness
  • Separate Build/Deploy Roles - Fine-grained OIDC permissions
  • Multi-Stack Ordering - Foundation → Schemas → Application

Additional References:

  • Workflow Summaries - Rich markdown output with $GITHUB_STEP_SUMMARY
  • Container Security - Multi-stage builds, Trivy scanning, image tagging
  • Security Scanning - CodeQL, Dependabot, IaC scanning (Checkov, tfsec)
  • Troubleshooting - Debug mode, flaky tests, common issues
  • Performance - Limits, runner specs, optimization tips

Scripts

Pre-built automation scripts with error handling and rate limit awareness.

| Script | Purpose | Usage | |--------|---------|-------| | find-repos-with-path.sh | Find repos containing specific paths | ./scripts/find-repos-with-path.sh .skilz [owner] | | wait-for-run.sh | Block until workflow completes | ./scripts/wait-for-run.sh RUN_ID [timeout] | | batch-search.sh | Search >1000 results via date partitioning | ./scripts/batch-search.sh "query" START END |

Exit Codes

| Script | 0 | 1 | 2 | 3 | |--------|---|---|---|---| | wait-for-run.sh | success | failure | cancelled | timeout | | find-repos-with-path.sh | success | error | - | - | | batch-search.sh | success | error | - | - |


Validation Checklist

Before completing a GitHub CLI task, verify:

- [ ] gh authenticated (`gh auth status`)
- [ ] Command syntax matches documentation
- [ ] Exit codes checked and handled appropriately
- [ ] Rate limits considered (code search: 10/min, repo search: 30/min)
- [ ] JSON output parsed correctly (if using --json)
- [ ] Artifacts downloaded to correct directory (if applicable)
- [ ] PR/Issue created with proper labels and assignees (if applicable)
- [ ] Workflow triggered and monitored to completion (if applicable)

When Not to Use

This skill covers gh CLI and GitHub Actions workflow authoring. Do not use for:

  • Git commands: git push, git commit, git pull (use git directly)
  • GitHub web UI: Questions about github.com interface navigation
  • GitHub Desktop: Different application entirely
  • Direct curl/HTTP: API calls without gh wrapper
  • GitHub mobile app: Mobile-specific features

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/mastering-github-cli-ms1aw3y3/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/mastering-github-cli-ms1aw3y3' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/mastering-github-cli-ms1aw3y3/download' --output '.skill-downloads/mastering-github-cli-ms1aw3y3/SKILL.md.part' && mv '.skill-downloads/mastering-github-cli-ms1aw3y3/SKILL.md.part' '.skill-downloads/mastering-github-cli-ms1aw3y3/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/mastering-github-cli-ms1aw3y3/SKILL.md' && test -s '.skill-downloads/mastering-github-cli-ms1aw3y3/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/mastering-github-cli' && cp -R '.skill-downloads/mastering-github-cli-ms1aw3y3' '.claude/skills/mastering-github-cli'

Cursor
test -f '.skill-downloads/mastering-github-cli-ms1aw3y3/SKILL.md' && test -s '.skill-downloads/mastering-github-cli-ms1aw3y3/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/mastering-github-cli' && cp -R '.skill-downloads/mastering-github-cli-ms1aw3y3' '.cursor/skills/mastering-github-cli'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/mastering-github-cli-ms1aw3y3'

openskills read 'mastering-github-cli-ms1aw3y3'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/mastering-github-cli-ms1aw3y3/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills