github-cli

Automate GitHub operations with the gh CLI using token-aware, least-privilege scripting patterns.

Updated Apr 11, 2026
One-click install
npx skills add https://github.com/lurodrisilva/personal-skills --skill github-cli-lurodrisilva
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: github-cli
Source: https://github.com/lurodrisilva/personal-skills/tree/main/platform-engineering/github-cli
Command: npx skills add https://github.com/lurodrisilva/personal-skills --skill github-cli-lurodrisilva

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve? Teams calling the GitHub CLI (gh) from scripts, Makefiles, and CI pipelines hit recurring failures: hung runs from unresolved repo context, leaked tokens from echoed credentials, brittle table-scraping instead of structured output, and over-privileged GITHUB_TOKEN permissions in Actions. This Skill encodes the full gh contract so every invocation is reproducible, least-privilege, and machine-parseable. ## Core Features & Use Cases - Authentication & token precedence: Covers gh auth login flows, the GH_TOKEN > GITHUB_TOKEN > keyring precedence model, GHES enterprise tokens, and fine-grained PAT selection over classic PATs. - Scripting & the gh api escape hatch: Teaches the --json/--jq/--template machine-output trio, -f vs -F field typing, pagination with --paginate/--slurp, and repo-context determinism via -R/GH_REPO. - CI/CD hardening & triage tooling: Encodes the step-level GH_TOKEN + least-privilege permissions: pattern, exit codes 0/1/2/4, extension supply-chain hygiene, and ships three read-only triage scripts (gh-auth-check.sh, gh-config-audit.sh, gh-api-inventory.sh). - Use Case: A GitHub Actions step runs gh release create and hangs in CI. The Skill diagnoses the missing -R flag and interactive prompt, then rewrites the step with GH_TOKEN env, a minimal permissions: block, and --verify-tag. ## Quick Start Ask the AI to review your shell script or workflow step that calls gh and rewrite it to use explicit repo context, --json with --jq output, and least-privilege token handling.

Frequently Asked Questions about github-cli

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

FAQPage Schema
How do I authenticate the GitHub CLI in CI pipelines?▼

Set GH_TOKEN to the ephemeral secrets.GITHUB_TOKEN as step-level env in GitHub Actions, paired with a least-privilege permissions block. For cross-repo writes or CI outside Actions, use a fine-grained PAT or GitHub App token stored in a secret manager.

What is the difference between -f and -F in gh api?▼

The -f/--raw-field flag always sends the value as a literal string, while -F/--field coerces types: true/false/null become JSON values, integers become numbers, and @file reads file contents. Adding any field flips the request from GET to POST, so force -X GET for query-string requests.

Why does my gh command hang in a CI script?▼

The hang usually comes from unresolved repo context in a multi-remote clone, where gh prompts interactively to pick a remote. Pass -R OWNER/REPO explicitly or export GH_REPO, and set GH_PROMPT_DISABLED to fail fast instead of prompting.

Does the GitHub CLI work with GitHub Enterprise Server?▼

Yes, gh supports GHES hosts via gh auth login --hostname or the GH_HOST environment variable. Authentication requires GH_ENTERPRISE_TOKEN or GITHUB_ENTERPRISE_TOKEN, since plain GH_TOKEN does not apply to enterprise hosts.

How do I parse gh command output in shell scripts?▼

Use --json with comma-separated field names, then filter with the built-in --jq flag or format with --template Go templates. Running --json with no argument lists the available fields, and no external jq binary is required.

When should I use the GitHub MCP Server instead of the gh CLI?▼

Use the GitHub MCP Server when an agent needs a typed, read-only-guardrailed tool surface with toolsets and --read-only mode. Use the gh CLI for deterministic scripting, pagination control, and CI steps where exact command behavior matters.