# CLI reference

Every `cafe` command, grouped by area. Run `cafe <command> --help` for all of a
command's options. To install the CLI and sign in, see
[install the CLI](https://staging.git.cafe/docs/getting-started/cli.md).

## Global options

| Option                            | Effect                                               |
| --------------------------------- | ---------------------------------------------------- |
| `--repo <owner/name>`             | Repository to act on (default: the current clone)    |
| `--host <url>`                    | GitCafe API address (default `https://git.cafe/api`) |
| `--json`                          | Print structured JSON on stdout                      |
| `--format pretty\|markdown\|json` | Choose the output format                             |
| `--yes`                           | Confirm destructive actions without asking           |
| `--no-input`                      | Fail instead of prompting                            |
| `--no-browser`                    | Never open a browser                                 |
| `--no-update-check`               | Do not check for a newer release                     |

| Environment variable   | Effect                                     |
| ---------------------- | ------------------------------------------ |
| `CAFE_HOST`            | Same as `--host`                           |
| `CAFE_REPO`            | Same as `--repo`                           |
| `CAFE_TOKEN`           | A token to use instead of the stored login |
| `CAFE_NO_UPDATE_CHECK` | Same as `--no-update-check`                |

## Authentication

| Command                                              | Does                                                                               |
| ---------------------------------------------------- | ---------------------------------------------------------------------------------- |
| `cafe auth login`                                    | Sign in through the browser ([device sign-in](https://staging.git.cafe/docs/account/device-authorization.md)) |
| `cafe auth status`                                   | Show who you are signed in as                                                      |
| `cafe auth logout`                                   | Remove the stored login (`--all` for every server)                                 |
| `cafe auth http setup`                               | Let Git use your login for HTTPS remotes                                           |
| `cafe auth http status`                              | Check the Git credential setup                                                     |
| `cafe auth ssh setup`                                | Find and register your SSH key, optionally set up signing                          |
| `cafe auth ssh list\|add\|remove`                    | Manage SSH authentication keys                                                     |
| `cafe auth setup`                                    | Configure HTTPS and SSH in one step, without prompts                               |
| `cafe auth token list\|create\|view\|rotate\|revoke` | Manage [personal access tokens](https://staging.git.cafe/docs/account/personal-access-tokens.md)              |
| `cafe signing ssh list\|add\|remove`                 | Manage SSH signing keys                                                            |
| `cafe signing gpg list\|add\|remove`                 | Manage [GPG keys](https://staging.git.cafe/docs/account/gpg-keys.md)                                          |

Managing tokens and keys needs the optional credential-management permission
when you sign in.

## Repositories

| Command                                              | Does                                                                                             |
| ---------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| `cafe repo list`                                     | List repositories you can access                                                                 |
| `cafe repo create <name>`                            | Create a repository (`--private`, `--org`, `--clone`)                                            |
| `cafe repo view [owner/name]`                        | Show a repository                                                                                |
| `cafe repo clone <owner/name> [dir]`                 | Clone a repository                                                                               |
| `cafe repo edit`                                     | Change description, topics, visibility, default branch                                           |
| `cafe repo fork [owner/name]`                        | Fork a repository                                                                                |
| `cafe repo sync`                                     | Update a fork's default branch from its parent                                                   |
| `cafe repo compare-upstream`                         | Show how far a fork is ahead or behind                                                           |
| `cafe repo forks`                                    | List a repository's forks                                                                        |
| `cafe repo transfer <owner/name> <new-owner>`        | Transfer a repository                                                                            |
| `cafe repo delete <owner/name>`                      | Delete a repository                                                                              |
| `cafe repo star\|unstar\|stargazers\|starred`        | Manage and list stars                                                                            |
| `cafe repo archive <branch\|tag\|commit> <ref>`      | Write a tar.gz snapshot to stdout                                                                |
| `cafe repo collaborator list\|add\|remove`           | Manage [collaborators](https://staging.git.cafe/docs/repositories/repository-access.md)                                     |
| `cafe repo ruleset list\|view\|create\|edit\|delete` | Manage [rulesets](https://staging.git.cafe/docs/repositories/repository-rulesets.md) (`--org`, `--team` for inherited ones) |
| `cafe repo ruleset effective <branch>`               | Show the rules that apply to a branch                                                            |
| `cafe repo branch-role list\|assign\|revoke`         | Manage per-branch roles                                                                          |

### Code

| Command                                 | Does                                          |
| --------------------------------------- | --------------------------------------------- |
| `cafe repo code tree [path]`            | List files                                    |
| `cafe repo code blob <path>`            | Print a file (`--raw` for the bytes)          |
| `cafe repo code commits`                | List commits                                  |
| `cafe repo code commit <sha>`           | Show a commit and its diff                    |
| `cafe repo code compare <base>..<head>` | Compare two revisions (`--patch`)             |
| `cafe repo code refs`                   | List branches and tags                        |
| `cafe repo code search <pattern>`       | [Search code](https://staging.git.cafe/docs/repositories/code-search.md) |
| `cafe repo code status <sha>`           | Show a commit's combined check status         |

### Branches and tags

| Command                                      | Does                                         |
| -------------------------------------------- | -------------------------------------------- |
| `cafe branch list`                           | List branches (`--deleted` for deleted ones) |
| `cafe branch delete <name>`                  | Delete a branch                              |
| `cafe branch restore <name>`                 | Restore a deleted branch                     |
| `cafe tag list`                              | List tags                                    |
| `cafe tag view <name>`                       | Show a tag                                   |
| `cafe tag delete <name>`                     | Delete a tag                                 |
| `cafe repo ref-deletion list\|view\|inspect` | Check the result of branch and tag deletions |

## Pull requests

| Command                                  | Does                                                                                  |
| ---------------------------------------- | ------------------------------------------------------------------------------------- |
| `cafe pr list`                           | List pull requests (`--state`)                                                        |
| `cafe pr create`                         | [Open a pull request](https://staging.git.cafe/docs/pull-requests/open.md) from the current branch               |
| `cafe pr view <number>`                  | Show a pull request                                                                   |
| `cafe pr checkout <number>`              | Check out a pull request's branch                                                     |
| `cafe pr edit <number>`                  | Change the title, description or target (`--base`)                                    |
| `cafe pr diff <number>`                  | List changed files (`--patch`, `--path`)                                              |
| `cafe pr commits <number>`               | List the commits                                                                      |
| `cafe pr status [number]`                | Show reviews, checks and mergeability                                                 |
| `cafe pr ready <number>`                 | Check merge readiness against rulesets                                                |
| `cafe pr merge <number>`                 | [Merge](https://staging.git.cafe/docs/pull-requests/merge.md) (`--strategy merge\|squash\|rebase\|fast-forward`) |
| `cafe pr close <number>`                 | Close without merging                                                                 |
| `cafe pr review <number>`                | Submit a review (`--approve`, `--request-changes`, `--comment`)                       |
| `cafe pr reviews <number>`               | List reviews                                                                          |
| `cafe pr review-view\|review-dismiss`    | Show or dismiss a review                                                              |
| `cafe pr reviewer list\|add\|remove`     | Manage requested reviewers                                                            |
| `cafe pr comments <number>`              | List comments                                                                         |
| `cafe pr comment <number>`               | Comment, or comment on a line with `--path` and `--line`                              |
| `cafe pr comment-edit\|comment-delete`   | Edit or delete a comment                                                              |
| `cafe pr resolve\|unresolve`             | Resolve or reopen a review thread                                                     |
| `cafe pr milestone <number> [milestone]` | Set or clear the milestone                                                            |
| `cafe pr lock\|unlock <number>`          | Lock or unlock the conversation                                                       |
| `cafe pr links\|link\|unlink`            | Manage linked issues                                                                  |

## Stacks

See [stacked pull requests](https://staging.git.cafe/docs/pull-requests/stacks.md).

| Command                    | Does                                                                             |
| -------------------------- | -------------------------------------------------------------------------------- |
| `cafe stack submit`        | Push local commits as a stack of pull requests (`--name`, `--base`, `--dry-run`) |
| `cafe stack link <pulls…>` | Link existing pull requests into a stack, bottom first                           |
| `cafe stack list`          | List stacks                                                                      |
| `cafe stack status [pull]` | Show the stack containing a pull request                                         |
| `cafe stack merge [pull]`  | Land the stack up to a pull request (`--stack` for all)                          |
| `cafe stack restack`       | Rebase the stack onto its updated base                                           |
| `cafe stack close [pull]`  | Close the stack and its open pull requests                                       |

## Issues and milestones

| Command                                                          | Does                                                  |
| ---------------------------------------------------------------- | ----------------------------------------------------- |
| `cafe issue list`                                                | List issues (`--state`, `--label`, `--assignee`)      |
| `cafe issue create`                                              | Create an issue                                       |
| `cafe issue view <number>`                                       | Show an issue                                         |
| `cafe issue edit <number>`                                       | Change title, body, state, priority or due date       |
| `cafe issue close <number>`                                      | Close an issue as completed                           |
| `cafe issue comments\|comment`                                   | List or add comments                                  |
| `cafe issue comment-edit\|comment-delete`                        | Edit or delete a comment                              |
| `cafe issue assign\|unassign`                                    | Manage assignees                                      |
| `cafe issue label list\|create\|edit\|delete`                    | Manage the repository's [labels](https://staging.git.cafe/docs/issues/labels.md) |
| `cafe issue label add\|remove`                                   | Label or unlabel an issue                             |
| `cafe issue milestone <number> [milestone]`                      | Set or clear the milestone                            |
| `cafe issue pin\|unpin`                                          | [Pin](https://staging.git.cafe/docs/issues/pin-and-lock.md) an issue             |
| `cafe issue lock\|unlock`                                        | Lock or unlock the conversation                       |
| `cafe issue links\|link\|unlink`                                 | Manage linked pull requests                           |
| `cafe milestone list\|view\|create\|edit\|close\|reopen\|delete` | Manage [milestones](https://staging.git.cafe/docs/issues/milestones.md)          |

## CI

| Command                                                   | Does                                                     |
| --------------------------------------------------------- | -------------------------------------------------------- |
| `cafe ci list`                                            | List runs (`--pr`, `--branch`, `--commit`)               |
| `cafe ci view <run>`                                      | Show a run                                               |
| `cafe ci status`                                          | Show runs for a pull request, branch or the latest       |
| `cafe ci watch <run>`                                     | Wait until a run finishes                                |
| `cafe ci jobs <run>`                                      | List a run's jobs                                        |
| `cafe ci logs <run> --job <job>`                          | Print or save a job log (`--full`, `--tail`, `--output`) |
| `cafe ci binding list\|view\|create\|edit\|delete`        | Connect pipelines to a repository                        |
| `cafe integration list\|view\|create\|edit\|delete <org>` | Manage [Buildkite integrations](https://staging.git.cafe/docs/ci/buildkite.md)      |

## Webhooks

The target is an organization slug or `owner/repo`. See
[webhooks](https://staging.git.cafe/docs/integrations/webhooks.md).

| Command                                           | Does                                 |
| ------------------------------------------------- | ------------------------------------ |
| `cafe webhook list\|view <target>`                | List or show webhooks                |
| `cafe webhook create\|edit\|delete <target>`      | Manage webhooks                      |
| `cafe webhook rotate-secret <target> <id>`        | Replace the signing secret           |
| `cafe webhook ping <target> <id>`                 | Send a signed test ping              |
| `cafe webhook capabilities\|readiness`            | Check supported events and readiness |
| `cafe webhook deliveries\|dead-letter\|attempts`  | Inspect delivery history             |
| `cafe webhook redeliver <target> <id> <delivery>` | Send a failed event again            |

## Organizations and teams

| Command                                                      | Does                                                       |
| ------------------------------------------------------------ | ---------------------------------------------------------- |
| `cafe org list\|view\|create\|edit\|delete`                  | Manage [organizations](https://staging.git.cafe/docs/organizations/organizations.md)  |
| `cafe org member list\|set\|remove <org>`                    | Manage [members](https://staging.git.cafe/docs/organizations/organization-members.md) |
| `cafe org invitation list\|create\|delete <org>`             | Manage invitations                                         |
| `cafe org invitation accept <org>`                           | Accept an invitation                                       |
| `cafe team list\|create\|view\|edit\|reparent\|delete <org>` | Manage [teams](https://staging.git.cafe/docs/organizations/teams.md)                  |
| `cafe team member list\|set\|remove <org> <team>`            | Manage team members                                        |
| `cafe team repos <org> <team>`                               | List a team's repositories                                 |
| `cafe team repo create <org> <team> <name>`                  | Create a repository for a team                             |

## Profile

| Command                      | Does                                       |
| ---------------------------- | ------------------------------------------ |
| `cafe profile view [handle]` | Show a public profile                      |
| `cafe profile edit`          | Edit your [profile](https://staging.git.cafe/docs/account/profile.md) |
| `cafe profile pins`          | List your pinned repositories              |
| `cafe profile pin <repos…>`  | Replace your pinned repositories           |

## Other commands

| Command                             | Does                                        |
| ----------------------------------- | ------------------------------------------- |
| `cafe api <path>`                   | Send an authenticated [API](https://staging.git.cafe/docs/reference/api.md) request |
| `cafe config get\|set\|unset\|list` | Read and write settings such as `stack.vcs` |
| `cafe skills list\|show\|install`   | Install `cafe` skills for coding agents     |
| `cafe completion <shell>`           | Print a shell completion script             |
| `cafe version`                      | Show the version (`--check` for the latest) |
