> **github-labels-query** — skill 38 of 54 in [github/gh-aw](https://skillsdocs.com/github/gh-aw).
>
> Book (all skills, one file): https://skillsdocs.com/github/gh-aw.md
> Machine manifest: https://skillsdocs.com/github/gh-aw/.well-known/agent-skills/index.json
> Origin: credited — this skill is installed into this repository and in use here, not published from it, so there is no install command.
> Upstream: https://github.com/github/gh-aw/blob/main/.github/skills/github-labels-query/SKILL.md @ `main`
> Raw bytes, no header: https://raw.githubusercontent.com/github/gh-aw/main/.github/skills/github-labels-query/SKILL.md
> Base for relative paths: https://raw.githubusercontent.com/github/gh-aw/main/.github/skills/github-labels-query/
> Licence: MIT — https://spdx.org/licenses/MIT.html
>
> Bundled files (1), referenced from this skill's directory:
>   - `query-labels.sh` — https://raw.githubusercontent.com/github/gh-aw/main/.github/skills/github-labels-query/query-labels.sh
>
> Content © its authors, served unmodified. Takedown: https://github.com/DreambaseAI/skillsdocs/issues/new?labels=takedown&title=Takedown+request

<!-- Verbatim upstream SKILL.md follows, YAML frontmatter included. -->

---
name: github-labels-query
description: List GitHub repository labels with per_page pagination and name filtering support.
---

# GitHub Labels Query Skill

List GitHub repository labels with efficient pagination using the `--per-page` flag.

## Usage

Use this script to list labels from any repository with controlled page sizes.

### Basic Usage

```bash
./query-labels.sh --owner github --repo gh-aw
# Returns 10 labels (default per_page=10)
```

### Pagination

```bash
# Get the first label only
./query-labels.sh --owner github --repo gh-aw --per-page 1

# Get 25 labels starting from page 2
./query-labels.sh --owner github --repo gh-aw --per-page 25 --page 2
```

### Filtering by name

```bash
# Only labels whose name contains "bug" (case-insensitive)
./query-labels.sh --owner github --repo gh-aw --name-filter bug
```

When `--name-filter` is set, all labels are fetched and filtered, then
`--per-page`/`--page` are applied to the filtered results.

## Parameters

| Parameter | Required | Default | Description |
|-----------|----------|---------|-------------|
| `--owner` | Yes | - | Repository owner (username or organization) |
| `--repo` | Yes | - | Repository name |
| `--per-page` | No | 10 | Results per page (1–100) |
| `--page` | No | 1 | Page number |
| `--name-filter` | No | - | Case-insensitive substring filter on the label name |

## Output

Returns JSON with the following fields:

```json
{
  "labels": [
    {
      "id": 12345,
      "node_id": "LA_...",
      "url": "https://api.github.com/repos/owner/repo/labels/bug",
      "name": "bug",
      "color": "d73a4a",
      "default": true,
      "description": "Something isn't working"
    }
  ],
  "item_count": 10,
  "per_page": 10,
  "page": 1
}
```

## Source

Calls the GitHub REST API:
`GET /repos/{owner}/{repo}/labels?per_page={n}&page={n}`

When `--name-filter` is used, the script pages through all labels
(`--paginate`) before filtering and slicing locally.
