# Use the GitHub CLI with your AI agent (/en/docs/gthb/usage)

You or your agent find the issue behind a question, see what is still open in a repository and read a README, from a
terminal or by a request in your own words. The agent runs the same commands, so every example here is also a request
you can make.

Issues, comments and READMEs come from a copy on your computer, so lists and search answer at once, even offline.
Pull requests, commits and releases are read from GitHub when you ask. You need a profile signed in with your token,
as [install](/llms.mdx/docs/gthb/installation/content.md) shows.

**On this page:**

1. [The profile comes first](#the-profile-comes-first)
2. [Choose repositories and copy them](#choose-repositories-and-copy-them)
3. [Find issues](#find-issues)
4. [Read one issue](#read-one-issue)
5. [READMEs](#readmes)
6. [Pull requests, commits and releases](#pull-requests-commits-and-releases)
7. [Output for scripts](#output-for-scripts)
8. [Agents](#agents)

## The profile comes first [#the-profile-comes-first]

A profile is a name you choose for one GitHub owner, such as `work`. It is the first word of every command that uses
an account:

```sh
gthb work issues list
```

`GTHB_PROFILE=work` does the same for one shell session. No profile is ever assumed, not even the only one: a command
without one stops with exit code 2 and lists the profiles on this computer.

One profile reads one owner, a user or an organization, because a fine-grained token reads one owner's repositories.
For your personal repositories and your company's, sign in two profiles.

## Choose repositories and copy them [#choose-repositories-and-copy-them]

`gthb` copies only the repositories you choose:

```sh
gthb work repos add octo-org/app
gthb work repos add octo-org/docs
gthb work repos list
gthb work sync
```

`repos add` checks with GitHub that the token can read the repository before it keeps it. `repos remove` stops copying
one: its issues leave lists and search, and come back when you add it again.

`sync` copies the issues with their comments, labels, milestones and assignees, and each repository's README. Then it
copies the pull requests with their reviews and comments, the commits, the branches, the tags and the releases. Pull
requests are read in full on the first sync. Commits start with the last 30 days, and each later sync reaches 30 days
further back, up to 90. Each later `sync` takes only what changed, and an unchanged README costs nothing from your
rate limit.

`gthb` sends at most 60 requests a minute, so your own `gh` and other tools keep a share of GitHub's limit. A large
first sync stops before its time limit and says so with `complete: false`. Run `sync` again, and it goes on from
where it stopped. A repository GitHub refuses is named under `gaps`, and the others are synced.

`gthb work status` shows the last sync and what is waiting.

## Find issues [#find-issues]

```sh
gthb work issues search login token                    # every word, in any order
gthb work issues search "why does the session expire?"
gthb work issues list type:unstarted                   # open issues
gthb work issues list type:completed label:bug
gthb work issues list assignee:none team:"octo-org/app"  # nobody assigned, one repository
```

`issues search` looks in the issues and comments of the copy. Every word must match, in any form, and words in quote
marks stay together as a phrase. After `sync --embed` it also finds issues by meaning, with an embedding model
already on your computer.

`issues list` narrows by fields. `gthb` uses the same fields as the other WireCat trackers, so some have
GitHub names:

| Field | On GitHub | Example |
| --- | --- | --- |
| `team:` | the repository, in quote marks | `team:"octo-org/app"` |
| `sprint:` | the milestone | `sprint:"v2.4"` |
| `type:` | open or closed | `type:unstarted` for open, `type:completed`, `type:canceled` (closed as not planned) or `type:duplicate` |
| `label:` | a label | `label:bug` |
| `assignee:` | the first assignee's login | `assignee:octocat` or `assignee:none` |

Lists show the newest change first, 50 rows a page. `--limit` and `--page` take you further. `labels list`,
`milestones list` and `users list` show the names the fields take. `states list` shows the four states each
repository has, and `projects list` is empty for GitHub.

Open issues assigned to you become your WireCat tasks at each `sync`, and close when the issue is closed or goes to
someone else. `issues assign octo-org/app#15` makes any issue your task. This changes nothing on GitHub.

## Read one issue [#read-one-issue]

```sh
gthb work issues show octo-org/app#12
gthb work issues context octo-org/app#12
```

`issues show` is the issue with its state, assignee and comments. `issues context` is what an agent needs to answer
about it: the issue, its newest comments, its milestone and labels, and a `missing` list of what the copy does not
hold, such as the pull requests that close the issue and its timeline.

## READMEs [#readmes]

```sh
gthb work repos show octo-org/app                      # description, topics, default branch and README
gthb work documents list
gthb work search "release checklist"                   # the READMEs, by words
```

Each chosen repository's README is a document in the copy, with the id `documents list` shows, such as `readme-101`.
`documents show readme-101` prints it, and `documents export readme-101 --output app-readme.md` writes it to a
Markdown file. You can tag a README, write notes about it and
keep what you learned from it, as `gthb commands` lists under `tags`, `notes` and `memories`.

## Pull requests, commits and releases [#pull-requests-commits-and-releases]

`sync` keeps pull requests, reviews, commits and releases in the WireCat store on your computer, but `gthb` has no
command that lists them from there. To read one, use the `api` group: it asks GitHub live, one command for each of
GitHub's read operations, and needs the network.

```sh
gthb work api list                                     # every operation, without calling GitHub
gthb skill show api                                    # the operations by group, with their commands
gthb work api pulls list --owner octo-org --repo app --state open
gthb work api repos list-releases --owner octo-org --repo app
```

`gthb work api list` and `gthb skill show api` name the command for pull requests, reviews, commits and releases, and
`--help` after a command shows its options, such as `--owner octo-org` and `--repo app`. The `api` group only reads,
and it leaves out everything that returns code or a secret, as [security](/llms.mdx/docs/gthb/security/content.md#what-the-api-group-leaves-out)
lists.

## Output for scripts [#output-for-scripts]

Every command except `mcp serve` on stdin and stdout takes `--json`, and prints one JSON value on stdout. Errors are
JSON on stderr, with a code to branch on. The [command reference](/llms.mdx/docs/gthb/commands/content.md#exit-codes) lists the codes.

## Agents [#agents]

`gthb skill install` puts the tool's skill where Claude Code, Codex, Gemini CLI and OpenClaw look for it. An agent
with a terminal then runs `gthb` itself. `gthb skill install --for hermes` also adds that folder to Hermes Agent's own
settings, so a bare `skill install` leaves Hermes out.

An app without a terminal, such as Claude Desktop or Cursor, connects over MCP. `mcp config` prints the entry to paste
into its settings, and `mcp add` sets up Claude Code or Codex the same way:

```sh
gthb work mcp config                                   # the entry for Claude Desktop, Cursor and others
gthb work mcp add claude-code --allow-writes           # or codex
gthb work mcp check                                    # the tools the agent gets
```

`gthb` only reads GitHub, so an agent over MCP can change nothing there. It can still write to the copy on your
computer, such as notes and tags, which is why `mcp add` asks for `--allow-writes`. To keep an agent away from the
live API, deny the group: `gthb work config set permissions.api deny`.

For ChatGPT and Claude in the browser, you need your own tunnel to this computer, such as Tailscale Funnel, and its
public address. `gthb work mcp server start --public-url` with that address serves the profile on `127.0.0.1` behind
the tunnel. A browser app logs in with a one-time code that the command
prints. `mcp server status` shows the address, the login code and the apps logged in, `mcp server stop` ends the
server and `gthb work mcp revoke` ends every login.
