AgentSkillsCN

Github

GitHub

SKILL.md

GitHub CLI Skill

Purpose

Automate GitHub workflows using the official GitHub CLI (gh). This skill enables creating repositories, managing issues/PRs, triggering workflows, and interacting with GitHub's API without leaving the terminal.

Capabilities

  • Create and manage repositories
  • View, create, and edit issues and pull requests
  • Manage GitHub Actions workflows
  • Review and merge PRs
  • Manage releases and deployments
  • Clone, fork, and manage repositories
  • Search code, issues, and users

Dependencies

  • GitHub CLI (gh)

    bash
    # macOS
    brew install gh
    
    # Ubuntu/Debian
    sudo apt install gh
    
    # Arch Linux
    sudo pacman -S github-cli
    
    # Other: https://github.com/cli/cli#installation
    
  • Authentication (run once):

    bash
    gh auth login
    

Usage Examples

Repository Management

bash
# Create a new repository
gh repo create my-project --public --description "My new project"

# Clone a repository
gh repo clone owner/repo

# Fork a repository
gh repo fork owner/repo

# View repository info
gh repo view owner/repo --web

Issues

bash
# List open issues
gh issue list --repo owner/repo --state open

# Create a new issue
gh issue create --title "Bug found" --body "Description of the bug" --label bug

# View issue details
gh issue view 123 --repo owner/repo

# Comment on an issue
gh issue comment 123 --body "Working on this now"

# Close an issue
gh issue close 123 --comment "Fixed in commit abc123"

Pull Requests

bash
# List open PRs
gh pr list --state open

# Create a PR
gh pr create --title "Fix: resolve null pointer" --body "This PR fixes..."

# Checkout a PR locally for review
gh pr checkout 456

# View PR details
gh pr view 456 --web

# Review a PR
gh pr review 456 --approve --body "LGTM!"

# Merge a PR
gh pr merge 456 --squash --delete-branch

GitHub Actions

bash
# List workflow runs
gh run list --workflow ci.yml

# View run details
gh run view 1234567890

# Watch a run in real-time
gh run watch 1234567890

# Trigger a workflow manually
gh workflow run deploy.yml --ref main

Releases

bash
# List releases
gh release list

# Create a release
gh release create v1.0.0 --title "Version 1.0.0" --notes "First stable release"

# Upload assets to a release
gh release upload v1.0.0 ./build/app.zip

Searching

bash
# Search repositories
gh search repos "machine learning" --stars ">1000" --sort stars

# Search code
gh search code "function main" --language go

# Search issues
gh search issues "bug" --repo owner/repo --state open

Configuration

Set default editor for interactive operations:

bash
gh config set editor vim        # or nano, code, etc.
gh config set browser firefox   # default browser for --web flag

View current configuration:

bash
gh config list

Environment Variables

  • GH_TOKEN / GITHUB_TOKEN: API authentication token
  • GH_HOST: GitHub Enterprise Server hostname
  • GH_REPO: Default repository for commands
  • NO_COLOR: Disable colored output

Tips

  • Use --jq for JSON filtering: gh pr list --json number,title --jq '.[]'
  • Use --template for custom output formatting
  • Most commands support -R, --repo to specify a different repository
  • Use gh alias set to create command shortcuts:
    bash
    gh alias set co "pr checkout"
    gh alias set pv "pr view --web"
    

Resources