Gh

From markerikson/opencode-config-example · View interactive version

Gh is an AI agent skill from the GitHub repository markerikson/opencode-config-example. This skill should be used when working with GitHub CLI (gh) for pull requests, issues, releases, and GitHub automation. Use when users mention gh commands, GitHub workflows, PR operations, issue management, or GitHub API access. Essential for understanding gh's mental model, command structure, and i

How to use this skill

Skill file

GitHub CLI (gh)

Overview

GitHub CLI (gh) is the official command-line tool for GitHub that brings pull requests, issues, releases, and other GitHub concepts to the terminal. This skill provides comprehensive guidance for using gh to streamline GitHub workflows, including PR management, issue tracking, repository operations, and API access.

When to Use This Skill

Invoke this skill when users:

Core Concepts

Before providing guidance, understand these key concepts:

Three-Layer Architecture:

  1. High-Level Commands (porcelain): gh pr, gh issue, gh repo - user-friendly workflows
  2. API Access: gh api - direct REST/GraphQL access with built-in auth
  3. Git Integration: Smart repo detection from git remotes and current branch

Context Resolution:

Mental Model:

Think of gh as "GitHub workflows made CLI-native" - each command maps to a common GitHub workflow optimized for terminal use.

Using the Reference Documentation

When providing gh guidance, load the comprehensive reference documentation:

references/gh.md

This reference contains:

Loading Strategy:

Common Operations

When users ask for help with gh, guide them using these patterns:

First-Time Setup

  1. Check if gh is installed: gh --version
  2. Authenticate: gh auth login (interactive) or gh auth status (check current)
  3. Configure defaults: gh config set <key> <value>
  4. Test connection: gh repo view (in a git repo)

Pull Request Operations

Load references/gh.md and search for "gh pr" section to provide:

Issue Management

Load references/gh.md and search for "gh issue" section to provide:

Repository Operations

Load references/gh.md and search for "gh repo" section to provide:

API Access

Load references/gh.md and search for "gh api" section to provide:

For advanced GraphQL use cases, load references/graphql.md:

Release Management

Load references/gh.md and search for "gh release" section to provide:

Workflow Guidance

When users describe their workflow needs, map them to patterns in the reference:

Pattern 1: Daily PR Workflow - Create, review, merge PRs

Pattern 2: Issue Triage - List, filter, and manage issues

Pattern 3: Release Automation - Script release creation and asset management

Pattern 4: PR Checks and Status - Monitor CI/CD and review status

Pattern 5: Multi-Repo Operations - Work across multiple repositories

Pattern 6: GitHub API Scripting - Automate complex GitHub workflows

Pattern 7: Code Review Workflow - Review PRs from command line

Load the appropriate pattern sections from references/gh.md based on user needs.

Output Formatting

When users need to parse or format gh output:

  1. Load the Output Formatting section from references/gh.md
  2. Explain format options: --json, --jq, --template
  3. Show JSON field selection: gh pr list --json number,title,state
  4. Demonstrate jq filtering: gh api /repos/{owner}/{repo}/pulls | jq '.[] | select(.draft==false)'
  5. Provide template examples for custom output

Authentication and Configuration

When users need auth or config help:

  1. Load the Authentication & Configuration section from references/gh.md
  2. Distinguish between:
  1. Explain authentication methods: browser, token, SSH
  2. Show common config settings: git_protocol, editor, pager
  3. Handle multiple accounts and enterprise instances

Integration Guidance

Workstack Integration

When users mention workstack or worktree workflows:

Git Integration

When users need to understand gh + git workflows:

CI/CD Integration

When users want to integrate gh with CI/CD:

Scripting and Automation

When users want to script GitHub workflows:

  1. Load the Scripting section from references/gh.md
  2. Show how to use gh in shell scripts
  3. Demonstrate error handling: --jq, exit codes
  4. Explain pagination for large datasets
  5. Provide examples of common automation patterns:

Advanced Features

When users need advanced capabilities:

  1. Aliases: Custom commands via gh alias set
  2. Extensions: Third-party gh extensions
  3. GraphQL: Complex queries beyond REST API (see GraphQL API Reference)
  4. Webhooks: Trigger workflows (via API)
  5. GitHub Actions: Interact with workflows via gh workflow

Load the relevant sections from references/gh.md for each advanced feature.

GraphQL API Reference

When standard gh commands are insufficient, use GraphQL via gh api graphql. Load references/graphql.md for comprehensive GraphQL guidance.

When to Use GraphQL:

Use GraphQL when the porcelain commands (gh pr, gh issue, etc.) cannot accomplish the task:

GraphQL Resources:

Loading Strategy:

  1. Start with references/graphql.md for use cases and patterns
  2. Load references/graphql-schema-core.md only when detailed schema info is needed
  3. Use grep patterns to find specific sections:

Troubleshooting

When users encounter issues:

  1. Check authentication: gh auth status
  2. Verify repository detection: gh repo view
  3. Test API access: gh api user
  4. Review configuration: gh config list
  5. Check rate limits: gh api rate_limit
  6. Enable debug mode: GH_DEBUG=api gh <command>

Load the Troubleshooting section from references/gh.md for specific error patterns.

Command Discovery

When users ask "what can gh do?":

Resources

references/

These references should be loaded as needed to ensure accurate, detailed information. Use progressive disclosure: start with the main reference, then load specialized GraphQL docs when needed.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.