← ClaudeAtlas

ghlisted

Patterns for invoking the GitHub CLI (gh) from agents. Covers structured output, pagination, repo targeting, search vs list, gh api fallback.
RIJUDEVx/agent-skills · ★ 1 · AI & Automation · score 74
Install: claude install-skill RIJUDEVx/agent-skills
# Reference ## Interactivity policy `gh` already does the right thing in non-TTY contexts: it skips the pager, strips ANSI color, and errors out fast with a helpful message instead of prompting (e.g. `must provide --title and --body when not running interactively`). You don't need to defensively set `GH_PAGER` or pass `--no-pager` (no such flag exists). ## Parsing JSON Human output from `gh` is column-formatted. If you want structured data: - Add `--json field1,field2,...` for structured output. - Run a command with `--json` and **no field list** to print the full set of available fields, then pick what you need. - Use `--jq '<expr>'` for filtering without piping through a separate `jq`. - Use `--template '<go-template>'` (alongside `--json`) when you want shaped text output. Note that `--template`/`-T` collides with a body-template flag on a few commands (e.g. `gh pr create -T`, `gh issue create -T`); always check `--help` before assuming which one you're hitting. ## Pagination and silent truncation List commands cap results. - `gh issue list`, `gh pr list`, `gh search ...`: pass `-L N` (`--limit N`). The default is usually 30. - `gh issue list` / `gh pr list` do not expose aggregate totals like `totalCount` via `--json`. If you need a true total, use `gh api graphql` to query `totalCount`; otherwise, treat `-L` as the cap for the current call. - For raw API calls use `gh api --paginate <path>`. Combine with `--jq` and (optionally) `--slurp` to assemb