GitHub CLI usage

Query and inspect GitHub issues, pull requests, and repositories using read-only gh commands.

33.9k|1.7k|Updated Apr 27, 2020
One-click install
npx skills add https://github.com/carbon-language/carbon-lang --skill github-cli-usage
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: GitHub CLI usage
Source: https://github.com/carbon-language/carbon-lang/tree/main/.agents/skills/github_cli
Command: npx skills add https://github.com/carbon-language/carbon-lang --skill github-cli-usage

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

AI assistants working on the Carbon project need a safe, consistent way to inspect GitHub state such as issues, pull requests, and repository metadata without risking accidental modification of project resources.

Core Features & Use Cases

  • Read-Only Safety Guardrails: Explicitly restricts usage to read-only verbs (list, view, search, status, GET-only api calls) and prohibits any state-changing commands like create, edit, merge, or comment.
  • Repository Configuration Verification: Checks that the default repository is carbon-language/carbon-lang and directs human operators to fix misconfigurations.
  • Advanced Querying: Covers REST and GraphQL API queries via gh api, pagination with --paginate, and output filtering with --json, --jq, and --template.
  • Use Case: An AI assistant investigating a reported compiler bug can run gh issue view and gh pr diff to gather context on the issue and its linked pull request without any risk of altering project state.

Quick Start

Ask the assistant to list open issues mentioning crashes in the carbon-language/carbon-lang repository using the GitHub CLI.

Frequently Asked Questions about GitHub CLI usage

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

FAQPage Schema
How do I search GitHub issues with the gh CLI?

Use gh issue search followed by a quoted query string, such as gh issue search "crash" --state open. You can also use gh issue list to browse issues or gh issue view <number> to inspect a specific one.

How do I view a pull request diff using GitHub CLI?

Run gh pr diff <number> to display the diff of a specific pull request. Other useful read-only commands include gh pr list, gh pr view <number>, and gh pr status.

Can the gh CLI modify GitHub issues or pull requests?

The gh CLI supports mutating commands like create, edit, merge, and comment, but this skill strictly prohibits them for AI assistants. Only read-only verbs (list, view, search, status, and GET api requests) are permitted.

How do I query the GitHub GraphQL API with gh?

Use gh api graphql with the -f query flag containing your GraphQL query string. This allows fetching exactly the fields needed, such as repository description and stargazer count, in a single request.

What should I do if gh points to the wrong default repository?

Verify the default with gh repo view; it should show carbon-language/carbon-lang. If misconfigured, a human operator must run gh repo set-default, since AI assistants must not change gh configuration.