Github cli

From carbon-language/carbon-lang · View interactive version

Github cli is an AI agent skill from the GitHub repository carbon-language/carbon-lang. Instructions for using the `gh` command to query and inspect GitHub state safely.

How to use this skill

Skill file

GitHub CLI usage

<!--

Part of the Carbon Language project, under the Apache License v2.0 with LLVM

Exceptions. See /LICENSE for license information.

SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

-->

This skill provides instructions for using the GitHub CLI (gh) to query,

inspect, and search GitHub state (issues, pull requests, repositories) for the

Carbon project.

Safety First: Read-Only Usage

[!IMPORTANT] AI assistants MUST NOT use the gh tool to modify any GitHub

project state. Do NOT run commands that create, edit, delete, label, comment

on, or merge issues, pull requests, releases, or any other resources.

Allowed Verbs

Prohibited Verbs

Repository Configuration

The gh tool interacts with a default repository when run within a local check

out. For this project, the default repository is expected to be

carbon-language/carbon-lang.

Verifying Default Repository

To verify the current default repository configuration:

gh repo view

The output should indicate the repository is carbon-language/carbon-lang.

Correcting Misconfigurations

If the default repository is misconfigured (for example, pointing to a personal

fork or a different repository), the human operator must correct it.

[!IMPORTANT] AI Assistants MUST NOT attempt to mutate gh configuration or

run commands that change the default repository (such as

gh repository set-default).

Instruct the human operator to run the following command to select the correct

default repository:

gh repo set-default

The operator will be prompted to select the correct repository (e.g.,

carbon-language/carbon-lang) from the available remotes.

Common Query Commands

Issues

Pull Requests

Search

Advanced Usage: GitHub API

For queries that are not supported by standard gh commands, you can use the

gh api command to query the GitHub REST or GraphQL APIs.

REST API

Query the REST API using paths relative to the API root.

```bash

gh api repos/carbon-language/carbon-lang/contributors

```

```bash

gh api repos/carbon-language/carbon-lang/issues/<issue_number>/comments

```

GraphQL API

For complex queries, use GraphQL to fetch exactly the data needed.

```bash

gh api graphql -f query='

query {

repository(owner: "carbon-language", name: "carbon-lang") {

description

stargazerCount

}

}

'

```

Pagination

Use the --paginate flag to automatically fetch all pages of results.

gh api --paginate repos/carbon-language/carbon-lang/issues

Filtering and Formatting

Use --json to request JSON output, and --jq or --template to filter or

format the results.

```bash

gh pr list --json title,author --jq '.[] | "\(.title) by \(.author.login)"'

```

```bash

gh issue list --template '{{range .}}{{.number}} - {{.title}}{{"\n"}}{{end}}'

```

Documentation References

cli.github.com/manual

docs.github.com/en/rest

docs.github.com/en/graphql

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.