github-cli

Automate GitHub pull requests, issues, CI runs, releases via gh CLI with JSON output.

2|1|Updated Feb 15, 2025
One-click install
npx skills add https://github.com/tomhoule/chezmoi-dotfiles --skill github-cli-tomhoule
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: github-cli
Source: https://github.com/tomhoule/chezmoi-dotfiles/tree/main/dot_config/agents/skills/github-cli
Command: npx skills add https://github.com/tomhoule/chezmoi-dotfiles --skill github-cli-tomhoule

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Reference for using the GitHub CLI (gh) to interact with GitHub. Use when working with pull requests, issues, CI runs, releases, or the GitHub API from the command line.

Core Features & Use Cases

  • Top-level commands are pr, issue, run, release, search, repo, and api; each has subcommands discoverable with --help.
  • Avoiding interactive prompts: Always pass --title and --body when creating PRs or issues, and use --no-pager or pipe through cat when output might be long, since interactive paging blocks automated flows.
  • Structured output: Many gh commands support --json <fields> for machine-readable output. Pass --json with no arguments to discover which fields are available. Once in JSON mode, chain --jq to filter or reshape. Prefer this over parsing the human-readable table output — it's stable across versions.
  • Investigating PRs and issues: When summarizing or investigating a PR, always fetch comments and reviews alongside metadata — the conversation is often where the real context lives.
  • Search: gh search prs, gh search issues, gh search code, gh search commits. Use --repo OWNER/REPO to scope, and -- before any query containing - to prevent flag parsing (e.g. gh search issues --repo OWNER/REPO -- "-label:bug").
  • The gh api escape hatch: gh api <endpoint> covers anything without a dedicated command. {owner} and {repo} placeholders auto-resolve from the current repo's git remote. Key flags: -X, -f, -F, --jq, --paginate, --slurp (combine paginated arrays), --cache <duration>, --verbose (dump full HTTP request/response).
  • Cross-repo targeting: -R OWNER/REPO on any command, or the GH_REPO env var, targets a repo other than the one in the current directory.
  • Environment variables worth knowing: GH_TOKEN / GITHUB_TOKEN, GH_DEBUG=api, NO_COLOR.

Quick Start

Authenticate with GitHub using gh auth status, then try gh pr view --help to discover available commands.

Frequently Asked Questions about github-cli

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I automate GitHub pull requests and issues from the command line?

To automate GitHub pull requests and issues from the command line, use the GitHub CLI to execute commands like pr and issue. Always pass --title and --body flags to create PRs or issues without triggering interactive prompts that block automated flows.

Can I get machine-readable JSON output from GitHub CLI commands?

Yes, you can get machine-readable JSON output from GitHub CLI commands by using the --json flag. Pass --json with no arguments to discover available fields, and chain --jq to filter or reshape the output for stable parsing across versions.

Do I need to authenticate before using the GitHub CLI to manage repositories?

Yes, you need to authenticate before using the GitHub CLI to manage repositories. Check your authentication status using gh auth status, and ensure environment variables like GH_TOKEN or GITHUB_TOKEN are set for non-interactive automation across projects.

What is the best way to search for specific code or commits across GitHub repos?

The best way to search for specific code or commits across GitHub repos is using the gh search command with subcommands like code or commits. Scope your search using --repo OWNER/REPO and place -- before queries containing dashes to prevent flag parsing errors.

How do I interact with the GitHub API directly when there is no dedicated command?

To interact with the GitHub API directly when there is no dedicated command, use the gh api escape hatch with your endpoint. It auto-resolves {owner} and {repo} placeholders from the current git remote and supports flags like -X, --paginate, and --cache.

How do I run GitHub CLI commands on a repository that is not in my current directory?

To run GitHub CLI commands on a repository that is not in your current directory, use the -R OWNER/REPO flag on any command or set the GH_REPO environment variable. This targets a specific repo for your cross-repo operations.