gh

Retrieve GitHub CLI issue, pull request, and workflow data as structured JSON with bounded pagination.

3|1|Updated Apr 12, 2026
One-click install
npx skills add https://github.com/Cogni-AI-OU/cogni-ai-agent-skills --skill gh-cogni-ai-ou
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gh
Source: https://github.com/Cogni-AI-OU/cogni-ai-agent-skills/tree/main/gh
Command: npx skills add https://github.com/Cogni-AI-OU/cogni-ai-agent-skills --skill gh-cogni-ai-ou

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It helps you use the GitHub CLI in restricted or non-interactive shells without brittle parsing, interactive hangs, or runaway pagination.

Core Features & Use Cases

  • Structured GitHub queries: Prefer gh subcommands with --json/--jq/--template to extract the exact fields you need for issues, pull requests, workflow runs, and API-derived metadata.
  • Safe command routing for PRs and issues: Use the right gh issue ... vs gh pr ... surfaces, and pivot to broader API calls only when native subcommands cannot provide a clean field.
  • Reliability and safety guardrails: Avoid endless pagination, fragile shell pipelines, and interactive editor prompts by validating outputs and selecting bounded fallbacks.

Quick Start

Use the gh skill to fetch pull request metadata in JSON form for a given PR number, for example: "Get PR #123 data (title, state, commits, and review decision) using GitHub CLI structured output."

Frequently Asked Questions about gh

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

FAQPage Schema
How do I extract specific fields from GitHub issues using the CLI without shell filtering?

To extract specific fields from GitHub issues safely, use the gh CLI with structured output flags like --json, --jq, and --template instead of shell filtering. This approach retrieves exact data such as title, state, and review decisions while avoiding brittle parsing pipelines.

What is the best way to query GitHub pull requests in a CI/Codespaces environment?

The best way to query GitHub pull requests in CI/Codespaces is using native gh subcommands with structured JSON output. This prevents interactive editor hangs and ensures reliable data retrieval in non-interactive shells by prioritizing bounded pagination and precise field extraction.

Why does my GitHub CLI command hang in non-interactive shells?

Your GitHub CLI command hangs in non-interactive shells because it likely triggers an interactive editor prompt. You can avoid this by using gh subcommands designed for structured output, such as those utilizing --json or --template, which bypass interactive inputs entirely.

How do I prevent runaway pagination when fetching GitHub workflow run data?

To prevent runaway pagination when fetching GitHub workflow run data, apply bounded fallbacks and validate outputs using the gh CLI. Structured querying with --json and --jq helps limit requests to precise fields, avoiding endless pagination loops during data extraction.

When should I pivot from native gh subcommands to broader GitHub API calls?

You should pivot from native gh subcommands to broader GitHub API calls only when native subcommands cannot provide a clean field for your required issues or pull requests. Always validate structured output first and pivot strategy after semantic failures to maintain safety.