This is the full developer documentation for Bitbucket CLI
# Bitbucket CLI
> Clone repositories, manage pull requests, and automate workflows from your terminal. If you know GitHub's gh, you'll feel right at home.
## Install
[Section titled “Install”](#install)
Requires [Bun](https://bun.sh) 1.0+ runtime.
* npm
```bash
npm install -g @pilatos/bitbucket-cli
```
* pnpm
```bash
pnpm add -g @pilatos/bitbucket-cli
```
* Bun
```bash
bun install -g @pilatos/bitbucket-cli
```
```bash
bb auth login # authenticate
bb repo clone myworkspace/myrepo # clone a repository
bb pr create -t "My awesome feature" # create a PR
bb pr list # list open PRs
```
***
## What can you do?
[Section titled “What can you do?”](#what-can-you-do)
Repository management
Clone, create, list, view, and delete repositories.
```bash
bb repo clone workspace/repo
bb repo create my-new-project
bb repo list -w myworkspace
```
Pull requests
Full PR lifecycle — create, review, approve, merge.
```bash
bb pr create -t "Add feature"
bb pr approve 42
bb pr merge 42 --strategy squash
```
Code review
View diffs, checkout PR branches, inspect checks.
```bash
bb pr diff 42
bb pr checkout 42
bb pr checks 42
```
CI/CD pipelines
Trigger, inspect, and stop Bitbucket Pipelines.
```bash
bb pipeline run --branch main
bb pipeline list --status FAILED
bb pipeline logs 42
```
Workspaces and projects
Find the workspaces you belong to and the projects inside them.
```bash
bb workspace list
bb project list
bb project view PROJ
```
Issues, snippets, and commits
Track issues, share snippets, read history, and publish build statuses.
```bash
bb issue list --state open
bb snippet create -t notes -f a.txt
bb commit list --limit 10
bb status set abc1234 --key BB-DEPLOY --state SUCCESSFUL
```
See [Issue commands](/commands/issue/) and [Snippet commands](/commands/snippet/).
Jump to the web UI
Open Bitbucket pages — PRs, files, commits, settings — in your browser.
```bash
bb browse 42
bb browse src/cli.ts:20
bb browse --pipelines
```
Scripting and automation
Every command speaks JSON. `--json` projects to a field list, `--jq` filters in-process — no external `jq` binary, no shell pipe.
```bash
bb pr list --json id,title,author.display_name
bb pipeline run --branch main --json --jq '.build_number'
```
A field list returns a flat array of objects; dotted paths keep their full name as the key. See the [Scripting guide](/guides/scripting/).
Raw API access
Reach any Bitbucket 2.0 endpoint not yet wrapped by a typed command.
```bash
bb api /user
bb api /repositories/{workspace}/{repo}/pullrequests --paginate
bb api POST /repositories/ws/repo/issues -f title=Bug
```
***
## PR workflows
[Section titled “PR workflows”](#pr-workflows)
[Create, edit, and view](/commands/pr/create-and-edit/)Open a PR, change its title or description, list PRs, inspect one.
[Review and merge](/commands/pr/review-and-merge/)Approve, decline, mark drafts ready, and merge with explicit strategy control.
[Diff and checkout](/commands/pr/diff-and-checkout/)Review patch output, fetch PR branches locally, and open browser diffs.
[Activity and checks](/commands/pr/activity-and-checks/)Inspect activity history and CI/build status before approving or merging.
[Review comments](/commands/pr/comments/)List, add, view, edit, reply to, resolve, unresolve, and delete general or inline review comments.
[Reviewers](/commands/pr/reviewers/)Add and remove reviewers. Adding someone already assigned is a no-op, as is removing someone who is not.
[All PR commands](/commands/pr/)
***
## Explore
[Section titled “Explore”](#explore)
[Scripting guide](/guides/scripting/)JSON output, exit codes, shell patterns.
[CI/CD integration](/guides/cicd/)GitHub Actions, GitLab CI, Jenkins, and more.
[Recipes](/recipes/)Auto-merge on green CI, bulk reviewer assignment, fork sync, reporting, retry wrappers.
[AI agent integration](/guides/ai-agents/)Wire the CLI into coding agents and tool-calling loops.
[Troubleshooting](/help/troubleshooting/)Common issues and solutions.
***
## Community
[Section titled “Community”](#community)
This is an **unofficial**, community-maintained CLI. Not affiliated with Atlassian.
* [GitHub Repository](https://github.com/0pilatos0/bitbucket-cli)
* [Report Issues](https://github.com/0pilatos0/bitbucket-cli/issues)
* [Contribute](https://github.com/0pilatos0/bitbucket-cli/blob/main/CONTRIBUTING.md)
# API Command — Raw Authenticated Bitbucket API Access
> Call any Bitbucket Cloud 2.0 API endpoint through the CLI's authenticated stack — the escape hatch for endpoints not yet wrapped by a typed command. Mirrors gh api.
`bb api` sends an authenticated request to any Bitbucket Cloud 2.0 endpoint through the same stack as every other command: Basic/Bearer auth, automatic OAuth token refresh, rate-limit and transient-error retries, and secret redaction. Same shape as `gh api`.
Every global flag is inherited — see [Global Flags](/reference/global-flags/). The ones that matter here are `--json [fields]`, `--jq `, `-w/--workspace`, `-r/--repo`, and `--no-color`/`--no-unicode`, which style the error and `--paginate` warning lines. `--no-truncate` and `--locale` change nothing: `bb api` prints no tables and no dates.
## `bb api`
[Section titled “bb api”](#bb-api)
```bash
bb api [options] [method]
```
### Arguments
[Section titled “Arguments”](#arguments)
| Argument | Description |
| ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `method` | Optional HTTP verb (`GET`, `POST`, `PUT`, `PATCH`, `DELETE`, `HEAD`, `OPTIONS`), case-insensitive. When omitted, defaults to `GET`, or `POST` when fields/body are present. Both `bb api GET /user` and `bb api /user` work. |
| `endpoint` | The API path, relative to `https://api.bitbucket.org/2.0` (a leading `/` is optional). A redundant leading `/2.0` is stripped, so paths copied straight out of the Bitbucket REST docs (`/2.0/user`) work unchanged. `{workspace}` and `{repo}` placeholders are substituted from `--workspace`/`--repo` or the current repository. |
### Options
[Section titled “Options”](#options)
| Option | Description |
| ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `-X, --method ` | HTTP method. Overrides a positional verb. |
| `-f, --raw-field ` | Add a string parameter. Query param on `GET`/`HEAD`, JSON body field otherwise. Repeatable. |
| `-F, --field ` | Add a typed parameter: `true`/`false`/`null` and numbers are converted; `@file` reads a file and `@-` reads stdin. Repeatable. |
| `--input ` | Read the raw request body from a file, or `-` for stdin. Sent as `application/json` (override with `-H 'Content-Type: ...'`). Mutually exclusive with `-f`/`-F`. |
| `-H, --header ` | Add a request header. Repeatable. `Authorization` is managed automatically and cannot be set here. |
| `-i, --include` | Print the HTTP status line and response headers before the body (text mode only — suppressed under `--json`). |
| `--paginate` | Follow the cursor (`next`) across pages and merge every page into a single `{ "values": [...] }` result (`GET`/`HEAD` only). |
### Argument errors
[Section titled “Argument errors”](#argument-errors)
Positionals are strict: at most two, and with two the first must be an HTTP verb. Every case below exits `1` without sending a request.
```text
$ bb api
✗ An endpoint path is required (e.g. /user). Run `bb api --help` for usage.
$ bb api GET
✗ An endpoint path is required after the method (e.g. bb api GET /user). Run `bb api --help` for usage.
$ bb api GTE /user
✗ 'GTE' is not a valid HTTP method. Expected one of: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS. Run `bb api --help` for usage.
(Did you mean GET?)
$ bb api -X GTE /user
✗ --method must be one of: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS
(Did you mean GET?)
$ bb api GET /user /extra
error: too many arguments for 'api'. Expected 2 arguments but got 3: GET, /user, /extra.
```
### Examples
[Section titled “Examples”](#examples)
```bash
# Current user
bb api /user
# Explicit method (equivalent to the above)
bb api GET /user
# List every pull request, following pagination, using the current repository
bb api /repositories/{workspace}/{repo}/pullrequests --paginate
# Create an issue (method inferred as POST because fields are present)
bb api /repositories/my-ws/my-repo/issues -f title=Bug -f priority=major
# -F applies gh-style magic typing: true/false/null and numbers become JSON literals
bb api PUT /repositories/my-ws/my-repo -F is_private=true
# Send a JSON body from a file
bb api PUT /repositories/my-ws/my-repo/pullrequests/42 --input body.json
# Pipe a body in from stdin
cat body.json | bb api POST /repositories/my-ws/my-repo/pullrequests/42/comments --input -
# Force a GET with query parameters (fields normally infer POST)
bb api GET /repositories/my-ws/my-repo/pullrequests -f state=MERGED
# Filter the response with jq (no --json needed — bb api output is already JSON)
bb api /repositories/my-ws --jq '.values[].name'
# Inspect the status line and response headers
bb api -i /user
```
### How fields are sent
[Section titled “How fields are sent”](#how-fields-are-sent)
* **`GET` / `HEAD`** — `-f`/`-F` are appended as a URL query string (`?key=value&...`).
* **Every other method** — `-f`/`-F` are assembled into a JSON request body.
* Repeating the same key turns it into an array, matching `gh`.
### Placeholders
[Section titled “Placeholders”](#placeholders)
`{workspace}` and `{repo}` are resolved only when they actually appear in the path, so `bb api /user` works outside a checkout.
```bash
# Inside a Bitbucket checkout, these resolve automatically:
bb api /repositories/{workspace}/{repo}/commits
# Or override explicitly:
bb api -w my-ws -r my-repo /repositories/{workspace}/{repo}/commits
```
### Output
[Section titled “Output”](#output)
The response body is printed to stdout. JSON responses are pretty-printed and respect the global `--json [fields]` projection and `--jq` filtering. Non-JSON responses (e.g. raw diffs) are printed verbatim, and `--json`/`--jq` are inert on them. An empty response body (e.g. a `HEAD` or `204`) prints nothing in text mode, and `{}` under `--json`, so a downstream `jq` never sees zero bytes.
```bash
bb api /user
```
```json
{
"type": "user",
"username": "my-user",
"display_name": "My User",
"account_id": "557058:..."
}
```
`bb api` is the only command where `--jq` works without `--json`; everywhere else a bare `--jq` fails with `✗ --jq requires --json`.
On a paginated endpoint, `--json ` unwraps the `values` array and drops the envelope (`pagelen`, `size`, `next`), returning a bare array of projected objects. Projection runs before `--jq`, so once you pass `--json ` the expression sees that flat array — use `.[]`, not `.values[]`.
```bash
# Envelope intact
bb api /repositories/my-ws --jq '.values[].name'
# Projected and unwrapped
bb api /repositories/my-ws --json name --jq '.[].name'
```
### Notes
[Section titled “Notes”](#notes)
* **Authentication is automatic.** The same credentials as the rest of the CLI are attached to every request; you cannot (and need not) set `Authorization` yourself.
* **Only the Bitbucket API host is allowed.** Absolute URLs are accepted only when they point at `api.bitbucket.org`. This prevents the CLI from sending your token to a foreign host. Pagination cursors (which are absolute `api.bitbucket.org` URLs) are followed safely.
* **`--paginate` degrades instead of erroring.** On a non-`GET`/`HEAD` request it prints `--paginate only applies to GET/HEAD requests; ignoring it.` on stderr and sends the request unpaginated. If the first response has no `values` array — a single resource rather than a collection — it prints `--paginate: response has no "values" array; returning the first page only.` and returns page 1. Both warnings are suppressed under `--json`. Combined with `-i`, the status line and headers printed are the first page’s.
* **Errors surface the API response.** On a non-2xx status, the API’s error body is printed and the command exits non-zero. With `--json`, the error payload (including `statusCode` and `response`) is emitted as structured JSON. A `401` or `403` also carries a `hint` with the next step to take. The generic `404` hint is deliberately suppressed here — you supplied the URL yourself, so advice about `--workspace`/`--repo` would not apply. Note the API error body prints to **stdout** while the error line and its hint go to **stderr**, so in a terminal the hint appears after the body.
* **Retries and redaction are inherited** from the shared API client — rate limits (`429`) and the transient gateway errors `502`/`503`/`504` are retried with backoff, and sensitive values are redacted from `DEBUG` logs.
### Related
[Section titled “Related”](#related)
* [Scripting & Automation](/guides/scripting/) — combine `bb api` with `--jq` to build pipelines over endpoints without a typed command.
* [JSON Output](/reference/json-output/) — how `--json` projection and `--jq` filtering work across the CLI.
* [Authentication](/getting-started/authentication/) — the auth methods that `bb api` reuses.
# Auth Commands
> Authentication commands reference
Manage authentication with Bitbucket.
Global options available on all auth commands: `--json [fields]`, `--jq `, `--no-color`, `--no-unicode`, `--locale `. See [Global flags](/reference/global-flags/) for the full list.
## `bb auth login`
[Section titled “bb auth login”](#bb-auth-login)
Authenticate with Bitbucket using OAuth (default) or an API token.
```bash
bb auth login [options]
```
### Options
[Section titled “Options”](#options)
| Option | Description |
| -------------------------------- | ----------------------------------------------------------------------------------------------------------- |
| `-u, --username ` | Bitbucket username (implies API token auth) |
| `-p, --password ` | Bitbucket API token (implies API token auth) |
| `--with-token` | Read the API token from stdin so it never appears in shell history or process args (implies API token auth) |
| `--app-password` | Use API token authentication instead of OAuth (see the note below) |
| `--client-id ` | Custom OAuth consumer client ID |
| `--client-secret ` | Custom OAuth consumer client secret |
### Examples
[Section titled “Examples”](#examples)
```bash
# Login with OAuth (opens browser)
bb auth login
# Login with a custom OAuth consumer
bb auth login --client-id YOUR_KEY --client-secret YOUR_SECRET
# Login with API token
bb auth login -u myuser -p your-api-token
# Login by piping the token via stdin (keeps it out of shell history and `ps`)
echo "$BB_API_TOKEN" | bb auth login -u myuser --with-token
# Login using environment variables (API token)
export BB_USERNAME=myuser
export BB_API_TOKEN=your-api-token
bb auth login
```
Tip
`--with-token` is the safest way to pass a token. Unlike `-p`, the token is read from stdin, so it never lands in your shell history or in process-listing tools like `ps`. It pairs well with secret managers, e.g. `my-secret-tool get bb-token | bb auth login -u myuser --with-token`.
Two rules: `--with-token` cannot be combined with `-p/--password` (hard error, `VALIDATION_INVALID`), and it reads all of stdin and trims it, so an empty stdin fails instead of prompting — `bb auth login -u me --with-token < /dev/null` errors with `No API token found on stdin.`
### How it works
[Section titled “How it works”](#how-it-works)
OAuth is used unless any of `--app-password`, `--with-token`, `-u`, `-p`, or the `BB_API_TOKEN` environment variable is present.
**OAuth flow (default):**
1. The CLI starts a local callback server and opens your browser
2. You authorize the CLI on Bitbucket’s consent screen
3. Bitbucket redirects back to the CLI with an authorization code
4. The CLI exchanges the code for access and refresh tokens
5. Tokens are stored in your config file
6. Access tokens expire after 2 hours and are refreshed automatically
Note
The OAuth flow needs a browser that can reach a loopback callback server on `http://localhost:19872/callback`. There is **no device-code flow**, so on headless hosts (SSH sessions, containers, CI) use API token auth — ideally `--with-token` — instead.
**API token flow:**
1. You provide your Bitbucket username and API token (token via `-p`, piped to stdin with `--with-token`, or the `BB_API_TOKEN` environment variable)
2. The CLI stores the credentials in your config file
3. The CLI verifies the credentials by fetching your user information
4. If verification fails, credentials are not saved
Note
The `--app-password` flag is a legacy name. It triggers API token authentication, not Bitbucket app passwords (which are deprecated). Prefer `-u`/`-p`, `--with-token`, or the environment variables.
### Required scopes (API token)
[Section titled “Required scopes (API token)”](#required-scopes-api-token)
`bb auth login` and `bb auth status` need `read:user:bitbucket` to verify your identity, and so does `bb pr list --mine` (it resolves your account UUID).
Repository and pull request commands need `read:repository:bitbucket` and `read:pullrequest:bitbucket`, plus the matching `write:` scopes to create, edit, merge, approve, or decline. Creating a repository needs the admin scope (legacy `repository:admin`) and deleting one needs the delete scope (legacy `repository:delete`); Atlassian publishes these as `admin:repository:bitbucket` and `delete:repository:bitbucket`.
Everything else — pipelines, issues, snippets, projects — needs its own scope. See [Token scopes](/reference/token-scopes/) for the per-command table.
OAuth logins request a fixed scope set: `account repository repository:admin pullrequest pullrequest:write`. Commands outside repositories and pull requests (`bb pipeline`, `bb issue`, `bb snippet`, `bb project`) are not covered, and neither is `bb repo delete`. Use an API token with the matching scopes for those.
See the [Authentication guide](/getting-started/authentication/) for setup instructions.
***
## `bb auth logout`
[Section titled “bb auth logout”](#bb-auth-logout)
Log out of Bitbucket and remove stored credentials.
```bash
bb auth logout [options]
```
### Examples
[Section titled “Examples”](#examples-1)
```bash
bb auth logout
# Machine-readable result
bb auth logout --json
```
### What gets removed
[Section titled “What gets removed”](#what-gets-removed)
* **OAuth**: Revokes the token on Bitbucket’s side, then removes `oauthAccessToken`, `oauthRefreshToken`, `oauthExpiresAt`, `authMethod`, and custom OAuth consumer credentials from the config file.
* **API Token**: Removes `username` and `apiToken` from the config file.
Other settings like `defaultWorkspace`, `skipVersionCheck`, and `versionCheckInterval` are preserved.
If revocation fails, the CLI still clears local credentials and warns you to revoke the token manually (`revokeFailed: true` in `--json`).
***
## `bb auth status`
[Section titled “bb auth status”](#bb-auth-status)
Show current authentication status and account information.
```bash
bb auth status [options]
```
### Examples
[Section titled “Examples”](#examples-2)
```bash
# Check authentication status
bb auth status
# Get status as JSON
bb auth status --json
```
### Output
[Section titled “Output”](#output)
When authenticated with OAuth:
```plaintext
✓ Logged in to Bitbucket
Authentication: OAuth
Username: myuser
Display name: My Name
Account ID: 712020:3cfed7e0-0ed6-49fc-bb35-410a00ccee6f
Token expires: in 1h 42m
Default workspace: myworkspace
```
When authenticated with API token:
```plaintext
✓ Logged in to Bitbucket
Authentication: API Token
Username: myuser
Display name: My Name
Account ID: 712020:3cfed7e0-0ed6-49fc-bb35-410a00ccee6f
Default workspace: myworkspace
```
The `Default workspace:` line appears only when `defaultWorkspace` is set. On an OAuth login with a stale token, `Token expires:` reads `expired (will refresh automatically)`.
When not authenticated:
```plaintext
ℹ Not logged in
Run bb auth login to authenticate.
```
Caution
`bb auth status --json` reports `method: "basic"` for API-token logins, while `bb auth login --json` reports `method: "api_token"` for the same credentials. In scripts, match on `!== "oauth"` rather than on either literal. See [JSON output](/reference/json-output/) for the full payloads.
***
## `bb auth token`
[Section titled “bb auth token”](#bb-auth-token)
Print the current access token.
```bash
bb auth token [options]
```
### Examples
[Section titled “Examples”](#examples-3)
```bash
# Print the token
bb auth token
# Copy it to the clipboard
bb auth token | pbcopy
# Use it against the raw API (OAuth login — bearer token)
curl -H "Authorization: Bearer $(bb auth token)" https://api.bitbucket.org/2.0/user
# Use it against the raw API (API token login — base64 basic credentials)
curl -H "Authorization: Basic $(bb auth token)" https://api.bitbucket.org/2.0/user
# Get token as JSON
bb auth token --json
```
### Output
[Section titled “Output”](#output-1)
* **OAuth**: Prints the bearer access token (automatically refreshes if expired). `--json` reports `type: "bearer"`.
* **API Token**: Prints a base64-encoded `username:apiToken` string suitable for HTTP Basic auth headers. `--json` reports `type: "basic"`.
Caution
Anyone holding this token has your Bitbucket access, within the scopes you granted. Don’t paste it into logs, CI output, or issue reports.
# Browse Command — Open Bitbucket Pages from the Terminal
> Open Bitbucket Cloud web pages — repo home, files, branches, commits, pull requests, pipelines, settings — directly from the CLI, or print the URL for scripts.
`bb browse` opens Bitbucket Cloud web pages — repository home, files, branches, commits, pull requests, pipelines, settings, and more — in your default browser. Mirrors `gh browse`.
It also doubles as a script-friendly URL builder: pass `--no-browser` to print the URL instead, or `--json url` for machine-readable output.
It accepts the [global flags](/reference/global-flags/), including `--json [fields]`, `--jq `, `-w, --workspace`, and `-r, --repo`.
## `bb browse`
[Section titled “bb browse”](#bb-browse)
```bash
bb browse [target] [options]
```
### Arguments
[Section titled “Arguments”](#arguments)
| Argument | Description |
| -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `target` | Optional positional. Resolved by shape: pure digits → PR id, 7–40 hex chars → commit SHA, anything else → file/dir path. Append `:` to a path for a line anchor (e.g. `src/cli.ts:42`). |
### Resource flags
[Section titled “Resource flags”](#resource-flags)
Resource flags are mutually exclusive — pick at most one. They cannot be combined with a positional `target` (except `--branch`, which is a modifier that pairs with a path target).
| Option | Opens |
| ----------------- | --------------------------------------------------------------------- |
| `--pr ` | A specific pull request |
| `--prs` | The pull-requests list |
| `--pull-requests` | Alias for `--prs` |
| `--branch ` | The branch source tree (or, with ``, that path on the branch) |
| `--branches` | The branches list |
| `--commit [sha]` | A specific commit (defaults to current HEAD when no SHA is given) |
| `--commits` | The commits list |
| `--pipelines` | The pipelines page |
| `--pipeline ` | A specific pipeline run |
| `--downloads` | The downloads page |
| `--issue ` | A specific issue |
| `--issues` | The issue tracker |
| `--wiki` | The wiki |
| `--settings` | Repository admin / settings |
### Behavior flags
[Section titled “Behavior flags”](#behavior-flags)
| Option | Description |
| ------------------ | --------------------------------------------------- |
| `-n, --no-browser` | Print the URL to stdout instead of opening it |
| `--json [fields]` | Emit `{ "url": "..." }` (does not open the browser) |
### Examples
[Section titled “Examples”](#examples)
```bash
# Repo home
bb browse
# A file at the current branch
bb browse src/cli.ts
# A file at a specific line
bb browse src/cli.ts:42
# A file on a specific branch
bb browse --branch release/2.0 src/cli.ts
# Just the branch tree
bb browse --branch release/2.0
# Pull request #217 (positional shorthand)
bb browse 217
# Pull request #217 (explicit)
bb browse --pr 217
# Pull-request list
bb browse --prs
# A commit by SHA
bb browse abc1234
# Current HEAD commit
bb browse --commit
# Pipelines tab
bb browse --pipelines
# Repo settings
bb browse --settings
# Print the URL only — useful in scripts and pipes
bb browse --pr 217 --no-browser
# Script-friendly URL retrieval
bb browse --pr 217 --json url
```
### Notes
[Section titled “Notes”](#notes)
* **Positional disambiguation.** A bare `` is treated as a pull request id (the most common case). Use `--issue ` to open an issue with the same number.
* **Branch defaulting.** When you give a path target without `--branch`, the CLI uses your current git branch (`git rev-parse --abbrev-ref HEAD`). Outside a git checkout (when using `--workspace`/`--repo` overrides), it falls back to the literal `HEAD` segment, which Bitbucket resolves server-side to the repository’s default branch.
* **URL encoding.** Workspace and repository slugs, branch names, and path segments are URL-encoded individually, so branches with slashes (`feature/foo`) and paths or names with spaces still produce valid URLs. Path separators (`/` between segments) are preserved.
* **No API calls.** `bb browse` never talks to the Bitbucket API — it only builds URLs. It does shell out to git: to resolve workspace and repository from your remote (skipped only when you pass both `-w` and `-r`), and to resolve a ref — `git rev-parse --abbrev-ref HEAD` for a path target without `--branch`, `git rev-parse HEAD` for `--commit` with no SHA. `--branch `, an explicit SHA, and the resource flags need no extra git call.
* **`--json` does not open the browser.** Either output mode (JSON or `--no-browser`) suppresses the open action, so scripts can capture the URL deterministically.
### Output
[Section titled “Output”](#output)
In default mode, `bb browse` prints a short status line and shells out to the [`open`](https://www.npmjs.com/package/open) helper to launch the URL.
With `--no-browser`:
```text
https://bitbucket.org/myworkspace/myrepo/pull-requests/217
```
With `--json`:
```json
{
"url": "https://bitbucket.org/myworkspace/myrepo/pull-requests/217"
}
```
`--jq` output is JSON-quoted (the embedded jq has no `-r`), so for a bare, pipe-ready URL use `--no-browser` as shown above. Reach for `--jq` when you are feeding a JSON consumer:
```bash
bb browse --pr 217 --json url --jq '.url'
```
### Related
[Section titled “Related”](#related)
* [`bb pr diff --web`](/commands/pr/diff-and-checkout/) — open the PR diff page directly in the browser.
* [Repository Context](/guides/repository-context/) — how the CLI infers workspace and repository from your current directory.
* [Scripting & Automation](/guides/scripting/) — capture URLs from `bb browse` to feed other tools.
# Commit Commands - Inspect Repository History
> Reference for Bitbucket CLI commit commands. List commit history for a branch, tag, or revision and view full commit details from the command line.
Inspect commits in a Bitbucket repository — list the history of a branch, tag, or revision, and view the full details of a single commit.
Commit commands operate at **repository** scope. Run them inside a cloned Bitbucket repository, or pass `-w, --workspace ` and `-r, --repo ` explicitly.
Global options available on all commit commands: `--json [fields]`, `--jq `, `--no-color`, `--no-unicode`, `--no-truncate`, `--locale `, `-w, --workspace`, `-r, --repo`.
A `` is a full 40-character hash or any abbreviated prefix (`abc1234`). `--json` output is wrapped in an envelope keyed by `workspace` and `repoSlug`; the `# →` comments below show each shape.
***
## `bb commit list`
[Section titled “bb commit list”](#bb-commit-list)
List commits, newest first.
```bash
bb commit list [options]
```
### Options
[Section titled “Options”](#options)
| Option | Description |
| ------------------ | ---------------------------------------------------------------------------- |
| `--ref [` | Branch, tag, or commit SHA to list history for (default: current git branch) |
| `--limit ` | Maximum number of commits (default: 25) |
| `--all` | List all commits (overrides `--limit`) |
### Examples
[Section titled “Examples”](#examples)
```bash
# Inside a git repository: history of the current branch
bb commit list
bb commit list --ref main
bb commit list --ref v1.0.0 --limit 50
# → { workspace, repoSlug, [ref], count, commits }
bb commit list --json
# Hashes only, via built-in --jq
bb commit list --json --jq '.commits[].hash'
```
### Notes
[Section titled “Notes”](#notes)
* **Default ref:** with no `--ref`, the CLI uses the current git branch when run inside a git repository. When branch detection fails (outside a git repository, detached HEAD), it falls back to the repository’s default commit listing instead of erroring.
* Columns: short hash (7 characters), first line of the commit message (truncated to 60 characters; disable with `--no-truncate`), author (Bitbucket display name, or the name parsed from the raw git author), and commit date.
* `--limit` is enforced across paginated responses. When results are capped the CLI prints `Showing 25 commits. Use --limit or --all to see more.` (suppressed with `--json`).
* An unknown `--ref` returns `Ref 'no-such-branch' not found in acme/api. Pass --ref to choose a different ref.`
***
## `bb commit view`
[Section titled “bb commit view”](#bb-commit-view)
View the full details of a single commit. `` is a full or abbreviated hash.
```bash
bb commit view [options]
```
### Examples
[Section titled “Examples”](#examples-1)
```bash
bb commit view abc1234
# → { workspace, repoSlug, commit }
bb commit view abc1234 --json
# Raw author string of the commit
bb commit view abc1234 --json --jq '.commit.author.raw'
```
### Notes
[Section titled “Notes”](#notes-1)
* The human view shows the full hash, author (raw `Name ` when available), date, parent commits (short hashes), and the complete commit message including the body.
* In `--json` mode, `commit` is the raw commit resource as returned by the Bitbucket API (hash, author, parents, message, links, …).
* An unknown sha returns `Commit abc1234 not found in acme/api.`
***
## See also
[Section titled “See also”](#see-also)
* [Status Commands](/commands/status/) — read and report build statuses on commits.
* [Scripting & Automation](/guides/scripting/) — JSON envelopes, `--jq`, exit codes.
# Completion Commands
> Install or remove bb tab completion for bash, zsh, and fish, and see exactly what the completer suggests.
Tab completion for bash, zsh, and fish.
Global options: every global flag is accepted here (see [Global Flags](/reference/global-flags/)). Only `--json`, `--no-color` and `--no-unicode` change anything — `--jq` needs `--json`, and `--no-truncate`/`--locale`/`-w`/`-r` have no output to affect.
## `bb completion install`
[Section titled “bb completion install”](#bb-completion-install)
```bash
bb completion install [options]
```
This command is interactive. It asks two questions:
1. **“Which Shell do you use ?”** — pick `bash`, `zsh`, or `fish`. The default is `bash`; the prompt does **not** preselect your current shell.
2. **“We will install completion to ``, is it ok ?”** — confirm, or decline and supply an absolute path of your own.
It then appends a source line to that file and writes the completion script under `~/.config/tabtab/`.
| Shell | Config file offered |
| ----- | ---------------------------- |
| bash | `~/.bashrc` |
| zsh | `~/.zshrc` |
| fish | `~/.config/fish/config.fish` |
Because it prompts, `bb completion install` is not scriptable. It blocks on the shell question in CI, `--json` included.
A failure throws error code `9001` ([`COMPLETION_INSTALL_FAILED`](/reference/error-codes/)) with the message `Failed to install completions: `, and the command exits `1`.
### After installing
[Section titled “After installing”](#after-installing)
Restart your shell, or source the file you chose:
```bash
source ~/.bashrc # bash
source ~/.zshrc # zsh
source ~/.config/fish/config.fish # fish
```
Then check it works:
```bash
bb # every top-level command (the root flags are offered too)
bb repo # clone, create, list, view, delete, default-reviewers
```
### JSON output
[Section titled “JSON output”](#json-output)
`--json` replaces both the success line and the “Restart your shell…” follow-up with a single object:
```json
{
"success": true,
"shellCompletion": {
"command": "bb",
"installed": true
}
}
```
## `bb completion uninstall`
[Section titled “bb completion uninstall”](#bb-completion-uninstall)
```bash
bb completion uninstall [options]
```
No prompt. It deletes `~/.config/tabtab/bb.`, removes the `bb` lines from `~/.config/tabtab/__tabtab.`, and drops the source line from your shell config once no other package is left in that file. Both `` and that config file come from `$SHELL` — your login shell, not the shell you happen to be typing in, and not the shell you picked at the install prompt. If they disagree, the source line is left behind and you have to delete it by hand. On success it prints `✓ Shell completions uninstalled successfully!`; with `--json` you get the same envelope as install, with `"installed": false`.
Most uninstall failures are swallowed by tabtab: it prints `ERROR while uninstalling ` and resolves anyway, so the command still reports success and exits `0`. Error code `9002` ([`COMPLETION_UNINSTALL_FAILED`](/reference/error-codes/)) only fires for failures thrown outside that handler.
## What gets completed
[Section titled “What gets completed”](#what-gets-completed)
Completions are generated from the live command tree, so they always match the commands and flags the CLI actually ships.
* **Commands and subcommands** — every command in the tree, at every depth.
* **Options** — every flag on the command plus the inherited globals (`--json`, `--jq`, `--no-color`, `--no-unicode`, `--no-truncate`, `--locale`, `--workspace`, `--repo`, `--help`), plus `--version` on the bare `bb`. Only long forms are suggested; short aliases like `-w` still work but are never offered.
* **Flag values** for options with a fixed set of choices.
Commands and flags carry their help text as a completion description. zsh and fish display it alongside the name; bash shows bare names. Enum **values** never carry a description, so they are bare in every shell.
### Flag-value completion
[Section titled “Flag-value completion”](#flag-value-completion)
Completing right after a flag that takes a fixed set of values suggests those values, and nothing else:
```bash
$ bb pr merge 42 --strategy
merge_commit squash fast_forward
squash_fast_forward rebase_fast_forward rebase_merge
$ bb pr list --state
OPEN MERGED DECLINED SUPERSEDED
$ bb snippet list --role
owner contributor member
$ bb pr diff --color
auto always never
$ bb api -X
GET POST PUT PATCH
HEAD OPTIONS DELETE
```
### Example session
[Section titled “Example session”](#example-session)
```bash
$ bb pr
pr
$ bb pr
activity approve checks checkout comments create decline
diff edit list merge ready reviewers view
$ bb pr create --
# the command's own flags, plus inherited global flags:
--title --body --source --destination
--close-source-branch --draft --reviewer --default-reviewers
--no-default-reviewers
--json --jq --no-color --no-unicode
--no-truncate --locale --workspace --repo --help
```
### Related
[Section titled “Related”](#related)
* [Global Flags](/reference/global-flags/) — the flags the completer offers on every command.
* [Error Codes](/reference/error-codes/) — `9001` and `9002` in context.
* [Scripting & Automation](/guides/scripting/) — `--json` envelopes and exit codes for the non-interactive commands.
# Config Commands
> Configuration commands reference
Manage CLI configuration settings.
Global options available on all config commands: `--json [fields]`, `--jq `, `--no-color`, `--no-unicode`, `--locale `. See [Global flags](/reference/global-flags/) for the full list.
## Configuration file
[Section titled “Configuration file”](#configuration-file)
Configuration is stored in a JSON file at:
* **Linux/macOS**: `~/.config/bb/config.json` (fixed path — `XDG_CONFIG_HOME` is not read)
* **Windows**: `%APPDATA%\bb\config.json`, falling back to `%USERPROFILE%\AppData\Roaming\bb\config.json`
On Linux and macOS the CLI creates the directory `0700` and the file `0600`, and refuses to run if either grants group or other access. See [Configuration file](/reference/configuration/) for the permission rules and how to fix them.
## Available settings
[Section titled “Available settings”](#available-settings)
| Key | `bb config get` | `bb config set` | Description |
| --------------------------------- | ------------------------ | ------------------------ | ------------------------------------------------------------------------------------------------------------------ |
| `defaultWorkspace` | yes | yes | Default workspace for commands |
| `skipVersionCheck` | yes | yes | Disable update notifications (default: false) |
| `versionCheckInterval` | yes | yes | Days between update checks (default: 1) |
| `prCreateIncludeDefaultReviewers` | yes | yes | Auto-add the repository’s default reviewers on `bb pr create` (default: false) |
| `username` | yes | no — use `bb auth login` | Bitbucket username |
| `apiToken` | no — use `bb auth token` | no — use `bb auth login` | Bitbucket API token (masked in `bb config list`) |
| `lastVersionCheck` | no | no | Timestamp of the last update check. Auto-managed; `bb config get lastVersionCheck` fails with `Unknown config key` |
`bb auth login` also writes `authMethod` — `basic` for API tokens, `oauth` for OAuth — and, after an OAuth login, the `oauth*` keys (`oauthAccessToken`, `oauthRefreshToken`, `oauthExpiresAt`, and custom consumer credentials). Only `bb auth login` and `bb auth logout` touch those keys; see [Configuration file](/reference/configuration/) for the full schema.
### Configuration file format
[Section titled “Configuration file format”](#configuration-file-format)
```json
{
"authMethod": "basic",
"username": "myuser",
"apiToken": "ATBB_xxxxxxxxxxxxxxxxxxxx",
"defaultWorkspace": "myworkspace",
"skipVersionCheck": false,
"versionCheckInterval": 1,
"prCreateIncludeDefaultReviewers": false
}
```
Don’t edit this file by hand. Use `bb config set` for settings and `bb auth login` for credentials.
## `bb config get`
[Section titled “bb config get”](#bb-config-get)
Print a configuration value.
```bash
bb config get
```
Readable keys: `username`, `defaultWorkspace`, `skipVersionCheck`, `versionCheckInterval`, `prCreateIncludeDefaultReviewers`. Any other key exits `1` with `Unknown config key ''`, except `apiToken`, which points you at `bb auth token`.
### Examples
[Section titled “Examples”](#examples)
```bash
# Get default workspace
bb config get defaultWorkspace
# Get username
bb config get username
# Get output as JSON
bb config get defaultWorkspace --json
```
***
## `bb config set`
[Section titled “bb config set”](#bb-config-set)
Set a configuration value.
```bash
bb config set
```
Settable keys, and the values each accepts:
| Key | Accepted values | Stored type |
| --------------------------------- | ---------------------------------- | ----------- |
| `defaultWorkspace` | Any string | string |
| `skipVersionCheck` | `true` or `false` | boolean |
| `versionCheckInterval` | Positive integer (`>= 1`), in days | number |
| `prCreateIncludeDefaultReviewers` | `true` or `false` | boolean |
### Examples
[Section titled “Examples”](#examples-1)
```bash
# Set default workspace
bb config set defaultWorkspace myworkspace
# Disable update notifications
bb config set skipVersionCheck true
# Check for updates weekly instead of daily
bb config set versionCheckInterval 7
# Get output as JSON
bb config set defaultWorkspace myworkspace --json
```
Values that don’t match the key’s type are rejected and exit `1`:
```bash
bb config set skipVersionCheck maybe
```
```plaintext
✗ Invalid value for 'skipVersionCheck'. Expected 'true' or 'false'.
```
JSON output for typed keys:
```json
{ "success": true, "key": "skipVersionCheck", "value": true }
```
Caution
`bb config set username …` and `bb config set apiToken …` are rejected outright:
```plaintext
✗ Cannot set 'username' directly. Use 'bb auth login' to configure authentication.
```
Use `bb auth login` for credentials.
***
## `bb config list`
[Section titled “bb config list”](#bb-config-list)
List all configuration values.
```bash
bb config list [options]
```
### Examples
[Section titled “Examples”](#examples-2)
```bash
# List all config
bb config list
# List as JSON for scripting
bb config list --json
# Read one value out of the JSON
bb config list --json --jq '.config.defaultWorkspace'
```
### Output
[Section titled “Output”](#output)
```plaintext
Config file: /Users/you/.config/bb/config.json
KEY VALUE
---------------- -----------
username myuser
defaultWorkspace myworkspace
apiToken ********
skipVersionCheck false
Settable keys: defaultWorkspace, skipVersionCheck, versionCheckInterval, prCreateIncludeDefaultReviewers. Run 'bb config set --help' for details.
```
With an empty config file the table is replaced by `ℹ No configuration set`; the `Config file:` line and the `Settable keys:` footer still print.
`apiToken` is always masked. OAuth credentials are omitted from `bb config list` entirely — after an OAuth login the listing shows no auth rows at all.
# Issue Commands - Manage the Bitbucket Issue Tracker
> Reference for Bitbucket CLI issue commands. List, view, create, edit, close, and comment on Bitbucket Cloud issues from the command line, mirroring gh issue.
Manage issues in a repository’s built-in issue tracker — list, view, create, edit, close, and comment, mirroring the ergonomics of `gh issue`.
Issue commands operate at **repository** scope. Run them inside a cloned Bitbucket repository, or pass `-w, --workspace ` and `-r, --repo ` explicitly.
Global options available on all issue commands: `--json [fields]`, `--jq `, `--no-color`, `--no-unicode`, `--no-truncate`, `--locale `, `-w, --workspace`, `-r, --repo`. See [Global flags](/reference/global-flags/) for the full list. The per-command tables below list only command-specific options.
Caution
Bitbucket’s issue tracker is **opt-in per repository** and disabled by default. When it is off, every issues endpoint answers `404` and `bb issue list` / `bb issue create` report: *“This repository’s issue tracker is disabled (or the repo was not found). Enable it under Repository settings → Issue tracker on Bitbucket, or check `--workspace`/`--repo`. Many teams use Jira instead — see the docs.”*
***
## `bb issue list`
[Section titled “bb issue list”](#bb-issue-list)
List issues. By default only “open-ish” issues are shown (states `new` and `open`), sorted most recently updated first.
```bash
bb issue list [options]
```
### Options
[Section titled “Options”](#options)
| Option | Description |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `--state ` | Filter by exact state: `submitted`, `new`, `open`, `resolved`, `on-hold`, `invalid`, `duplicate`, `wontfix`, or `closed` |
| `--kind ` | Filter by kind: `bug`, `enhancement`, `proposal`, or `task` |
| `--assignee ` | Filter by assignee username |
| `--reporter ` | Filter by reporter username |
| `--query ]` | Raw Bitbucket `q` filter expression (escape hatch) |
| `--limit ` | Maximum number of issues (default: 25) |
| `--all` | List all issues (overrides `--limit`) |
### Examples
[Section titled “Examples”](#examples)
```bash
bb issue list
bb issue list --state resolved
bb issue list --kind bug --assignee some.user
bb issue list --limit 50
# Raw q escape hatch (replaces the default state filter)
bb issue list --query 'priority="blocker" AND state!="closed"'
# Project to specific fields (returns a flat array)
bb issue list --json id,title,state
# Filter with built-in --jq — ids of critical issues
bb issue list --json --jq '.issues[] | select(.priority == "critical") | .id'
```
### Notes
[Section titled “Notes”](#notes)
* **Filter composition:** without `--state` or `--query` the command filters on `(state="new" OR state="open")`. An explicit `--state` matches exactly (the CLI’s `on-hold` maps to the API’s `"on hold"`). `--kind`, `--assignee`, and `--reporter` clauses are AND-ed on.
* **`--query` grouping:** the expression replaces the default state filter. It is wrapped in parentheses and placed first in the AND-ed clause list, so a top-level `OR` inside it stays correctly grouped against `--kind`/`--assignee`/`--reporter`. The composed expression comes back as `filters.q` in `--json` output.
* **JSON envelope:** `{ workspace, repoSlug, filters, count, issues }`, where `filters` echoes the active flags plus the effective `q` expression.
* TITLE is truncated to 50 characters in the table; pass the global `--no-truncate` for full titles (`--json` always carries the full value). UPDATED is formatted with `--locale`/`BB_LOCALE`, falling back to the system locale and then `en-US`.
* `--limit` is enforced across paginated responses; a hint shows when results were capped (suppressed with `--json`).
***
## `bb issue view`
[Section titled “bb issue view”](#bb-issue-view)
View the full details of a single issue.
```bash
bb issue view [options]
```
### Arguments
[Section titled “Arguments”](#arguments)
| Argument | Description |
| -------- | -------------------- |
| `id` | Issue ID (e.g. `42`) |
### Examples
[Section titled “Examples”](#examples-1)
```bash
bb issue view 42
# Print just the state, for a CI guard
bb issue view 42 --json --jq '.issue.state'
```
### Notes
[Section titled “Notes”](#notes-1)
* Human output shows the id, title, state, kind, priority, reporter, assignee, created/updated dates, votes, the issue body, and the web URL.
* **JSON envelope:** `{ workspace, repoSlug, issue }`.
* A `404` is reported as `Issue # not found in /.`, with a reminder that a disabled issue tracker 404s identically.
***
## `bb issue create`
[Section titled “bb issue create”](#bb-issue-create)
Create an issue.
```bash
bb issue create --title [options]
```
### Options
[Section titled “Options”](#options-1)
| Option | Description |
| ------------------------ | ------------------------------------------------------------------- |
| `-t, --title ` | Issue title (**required**) |
| `-b, --body ` | Issue description (Markdown) |
| `-F, --body-file ` | Read the description from a file (mutually exclusive with `--body`) |
| `--kind ` | `bug`, `enhancement`, `proposal`, or `task` |
| `--priority ` | `trivial`, `minor`, `major`, `critical`, or `blocker` |
| `--assignee ` | Assign the issue to a user |
### Examples
[Section titled “Examples”](#examples-2)
```bash
bb issue create --title "Crash on login"
bb issue create --title "Crash on login" --kind bug --priority major --assignee some.user
bb issue create --title "RFC: new API" --body-file ./rfc.md
# Capture the new issue id in a script
bb issue create --title "Crash on login" --json --jq '.issue.id'
```
### Notes
[Section titled “Notes”](#notes-2)
* On success the new issue number and its web URL are printed.
* **JSON envelope:** `{ workspace, repoSlug, issue }` with the created issue.
* A `404` here means the issue tracker is disabled (see the note at the top of this page).
***
## `bb issue edit`
[Section titled “bb issue edit”](#bb-issue-edit)
Edit an issue. At least one change flag is required.
```bash
bb issue edit [options]
```
### Arguments
[Section titled “Arguments”](#arguments-1)
| Argument | Description |
| -------- | -------------------- |
| `id` | Issue ID (e.g. `42`) |
### Options
[Section titled “Options”](#options-2)
| Option | Description |
| ----------------------- | ----------------------------------------------- |
| `-t, --title ` | New title |
| `-b, --body ` | New description (replaces the existing body) |
| `--kind ` | New kind |
| `--priority ` | New priority |
| `--assignee ` | Reassign to a user |
| `--state ` | New state (`on-hold` for the API’s `"on hold"`) |
### Examples
[Section titled “Examples”](#examples-3)
```bash
bb issue edit 42 --title "Crash on login (Safari only)"
bb issue edit 42 --state on-hold --priority critical
# Confirm the reassignment landed
bb issue edit 42 --assignee some.user --json --jq '.issue.assignee.display_name'
```
### Notes
[Section titled “Notes”](#notes-3)
* Only the flags you pass are changed; everything else is left untouched.
* **JSON envelope:** `{ workspace, repoSlug, issue }` with the updated issue.
***
## `bb issue close`
[Section titled “bb issue close”](#bb-issue-close)
Close an issue — sugar for `bb issue edit --state closed`, optionally posting a comment first.
```bash
bb issue close [options]
```
### Arguments
[Section titled “Arguments”](#arguments-2)
| Argument | Description |
| -------- | -------------------- |
| `id` | Issue ID (e.g. `42`) |
### Options
[Section titled “Options”](#options-3)
| Option | Description |
| ---------------------- | -------------------------------- |
| `-c, --comment ` | Post this comment before closing |
### Examples
[Section titled “Examples”](#examples-4)
```bash
bb issue close 42
bb issue close 42 --comment "Fixed in 1.4.2"
# Verify the new state
bb issue close 42 --json --jq '.issue.state'
```
### Notes
[Section titled “Notes”](#notes-4)
* With `--comment`, the comment is posted **before** the state change so it lands while the issue is still open.
* **JSON envelope:** `{ workspace, repoSlug, issue }` with the closed issue.
***
## `bb issue comment`
[Section titled “bb issue comment”](#bb-issue-comment)
Add a comment to an issue.
```bash
bb issue comment --body
```
### Arguments
[Section titled “Arguments”](#arguments-3)
| Argument | Description |
| -------- | -------------------- |
| `id` | Issue ID (e.g. `42`) |
### Options
[Section titled “Options”](#options-4)
| Option | Description |
| ------------------- | --------------------------------------- |
| `-b, --body ` | Comment text in Markdown (**required**) |
### Examples
[Section titled “Examples”](#examples-5)
```bash
bb issue comment 42 --body "Reproduced on main"
# Capture the new comment id
bb issue comment 42 --body "Reproduced on main" --json --jq '.comment.id'
```
### Notes
[Section titled “Notes”](#notes-5)
* **JSON envelope:** `{ workspace, repoSlug, comment }` with the created comment.
# Pipeline Commands - Run and Inspect Bitbucket Pipelines
> Reference for Bitbucket CLI pipeline commands. List, view, trigger, stop, and read logs of Bitbucket Pipelines builds from the command line.
Manage Bitbucket Pipelines (CI/CD) — list runs, inspect a run and its steps, trigger and stop runs, and read step logs.
Pipeline commands operate at **repository** scope. Run them inside a cloned Bitbucket repository, or pass `-w, --workspace ` and `-r, --repo ` explicitly.
Global options available on all pipeline commands: `--json [fields]`, `--jq `, `--no-color`, `--no-unicode`, `--no-truncate`, `--locale `, `-w, --workspace`, `-r, --repo`.
An `` is either the build number from the UI (`42`) or the pipeline UUID with braces (`{a1b2c3d4-...}`). `--json` output is wrapped in an envelope keyed by `workspace` and `repoSlug`; the `# →` comments below show each shape.
***
## `bb pipeline list`
[Section titled “bb pipeline list”](#bb-pipeline-list)
List pipeline runs, newest first.
```bash
bb pipeline list [options]
```
### Options
[Section titled “Options”](#options)
| Option | Description |
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| `--status ` | Filter by status: `PARSING`, `PENDING`, `PAUSED`, `HALTED`, `BUILDING`, `ERROR`, `PASSED`, `FAILED`, `STOPPED`, `UNKNOWN` (case-insensitive) |
| `--branch ` | Filter by target branch |
| `--sort ` | Sort attribute: `created_on`, `run_creation_date`, `creator.uuid`; prefix with `-` for descending (default: `-created_on`) |
| `--limit ` | Maximum number of runs (default: 25) |
| `--all` | List all runs (overrides `--limit`) |
### Examples
[Section titled “Examples”](#examples)
```bash
bb pipeline list
bb pipeline list --status FAILED
bb pipeline list --branch main --limit 50
# → { workspace, repoSlug, [status], [branch], sort, count, pipelines }
bb pipeline list --json
# Build numbers of recent failures, via built-in --jq
bb pipeline list --status FAILED --json --jq '.pipelines[].build_number'
```
### Notes
[Section titled “Notes”](#notes)
* Columns: build number, status (colored), ref (truncated to 40 characters; disable with `--no-truncate`), trigger, created date, and duration for completed runs.
* `--limit` is enforced across paginated responses. When results are capped the CLI prints `Showing 25 pipelines. Use --limit or --all to see more.` (suppressed with `--json`).
* `--status` is upper-cased before validation, so `failed` and `FAILED` both work. `--sort` is matched case-sensitively.
* An invalid value lists the allowed ones and, when the input is close to a valid one, suggests it:
```text
--status must be one of: PARSING, PENDING, PAUSED, HALTED, BUILDING, ERROR, PASSED, FAILED, STOPPED, UNKNOWN
(Did you mean FAILED?)
```
A `--sort` value that differs only in case gets `(Values are case-sensitive — use created_on.)` instead of a suggestion.
***
## `bb pipeline view`
[Section titled “bb pipeline view”](#bb-pipeline-view)
View run details and a per-step summary. `` is a build number or UUID.
```bash
bb pipeline view [options]
```
### Examples
[Section titled “Examples”](#examples-1)
```bash
bb pipeline view 42
bb pipeline view {a1b2c3d4-0000-0000-0000-000000000000}
# → { workspace, repoSlug, pipeline, steps }
bb pipeline view 42 --json
# Status name of the run
bb pipeline view 42 --json --jq '.pipeline.state.result.name // .pipeline.state.name'
```
### Notes
[Section titled “Notes”](#notes-1)
* The human view shows number, UUID, status, ref, the custom pipeline selector when the run used one (`Pipeline:`), trigger, creator, created/completed timestamps, duration, and a step table (index, name, status, duration).
* The step index is the value you pass to `bb pipeline logs --step`.
* The step table and the JSON `steps` array are complete even on large runs — the CLI follows the steps endpoint’s pagination.
* An unknown id returns `Pipeline 42 not found in acme/api.`
***
## `bb pipeline run`
[Section titled “bb pipeline run”](#bb-pipeline-run)
Trigger a pipeline run on a branch.
```bash
bb pipeline run [options]
```
### Options
[Section titled “Options”](#options-1)
| Option | Description |
| ----------------------- | --------------------------------------------------------- |
| `-b, --branch ` | Branch to run on (default: current git branch) |
| `--commit ` | Run against a specific commit on the branch |
| `-p, --pipeline ` | Custom pipeline definition from `bitbucket-pipelines.yml` |
| `--var ` | Pipeline variable; repeatable, value may contain `=` |
### Examples
[Section titled “Examples”](#examples-2)
```bash
# Run the default pipeline for the current branch
bb pipeline run
bb pipeline run --branch main
bb pipeline run --pipeline deploy-prod --var ENV=prod --var DRY_RUN=false
bb pipeline run --branch main --commit abc123def456
# → { workspace, repoSlug, pipeline }; grab the build number
bb pipeline run --branch main --json --jq '.pipeline.build_number'
```
### Notes
[Section titled “Notes”](#notes-2)
* Outside a git repository, `--branch` is required (the error tells you so).
* `--pipeline ` selects a `custom:` pipeline defined in `bitbucket-pipelines.yml`.
* Variables are sent unsecured; secured variables must be configured in repository settings.
* On success the CLI prints the build number plus ready-to-paste `bb pipeline view` / `bb pipeline logs` commands.
***
## `bb pipeline stop`
[Section titled “bb pipeline stop”](#bb-pipeline-stop)
Stop a running pipeline. `` is a build number or UUID.
```bash
bb pipeline stop [options]
```
### Examples
[Section titled “Examples”](#examples-3)
```bash
bb pipeline stop 42
# → { workspace, repoSlug, pipelineId, stopped }
bb pipeline stop 42 --json --jq '.stopped'
```
### Notes
[Section titled “Notes”](#notes-3)
* No `--yes` confirmation is required: stopping CI is reversible — rerun with `bb pipeline run`.
***
## `bb pipeline logs`
[Section titled “bb pipeline logs”](#bb-pipeline-logs)
Print the raw log of a pipeline step. `` is a build number or UUID.
```bash
bb pipeline logs [options]
```
### Options
[Section titled “Options”](#options-2)
| Option | Description |
| ---------------------------- | --------------------------------------------------------------- |
| `-s, --step ` | Step to fetch: a step UUID (braces optional) or a 1-based index |
### Examples
[Section titled “Examples”](#examples-4)
```bash
# Single-step runs need no --step
bb pipeline logs 42
bb pipeline logs 42 --step 2
bb pipeline logs 42 --step {a1b2c3d4-0000-0000-0000-000000000000}
bb pipeline logs 42 --step a1b2c3d4-0000-0000-0000-000000000000
# → { workspace, repoSlug, pipelineId, stepUuid, log }
bb pipeline logs 42 --json --jq '.log'
```
### Notes
[Section titled “Notes”](#notes-4)
* With exactly one step, it is selected automatically.
* With several steps and no `--step`, the CLI lists the steps (index, name, status, UUID) instead of guessing. With `--json` it returns `{ workspace, repoSlug, pipelineId, count, steps }` so scripts and agents can pick a step UUID and call again.
* Every step is selectable even on large runs — the CLI follows the steps endpoint’s pagination, so indexes and UUIDs beyond the API’s default page size of 10 work.
* The log is printed verbatim to stdout, so it pipes cleanly into `grep`, `less`, or a file.
* Four failure modes — a queued run with no steps yet, an out-of-range `--step` index, a `--step` UUID that matches nothing, and a step that has produced no log yet — each get their own message, in that order:
```text
Pipeline 42 has no steps yet. It may still be queued — check with `bb pipeline view 42`.
--step index 9 is out of range; the pipeline has 3 steps.
No step matching 'abc' found. Available steps: 1 ({uuid-1}), 2 ({uuid-2}).
No log found for step {uuid-2} of pipeline 42. The step may not have started yet.
```
***
## See also
[Section titled “See also”](#see-also)
* [Scripting & Automation](/guides/scripting/) — JSON envelopes, `--jq`, exit codes.
* [CI/CD Integration](/guides/cicd/) — using `bb` inside pipelines.
# PR Commands
> Task-based reference for creating, reviewing, and merging pull requests
Manage pull requests (PRs) in Bitbucket repositories. New here? Start with [Create, edit, and view](/commands/pr/create-and-edit/).
Global options work on every PR command: `--json [fields]`, `--jq `, `--no-color`, `--no-unicode`, `--no-truncate`, `--locale `, `-w, --workspace`, `-r, --repo` — see [Global Flags](/reference/global-flags/).
## Command groups
[Section titled “Command groups”](#command-groups)
[Create, edit, and view](/commands/pr/create-and-edit/)Open a PR, change its title or description, list PRs, inspect one.
[Activity and checks](/commands/pr/activity-and-checks/)Read the activity timeline and CI build statuses before approving or merging.
[Diff and checkout](/commands/pr/diff-and-checkout/)Print the patch or diffstat, fetch the PR branch locally, open the diff in a browser.
[Review and merge](/commands/pr/review-and-merge/)Approve, decline, mark a draft ready, and merge with an explicit strategy.
[Comments](/commands/pr/comments/)List, add, view, edit, reply to, resolve, unresolve, and delete general or inline review comments.
[Reviewers](/commands/pr/reviewers/)Add and remove reviewers. Adding someone already assigned is a no-op, as is removing someone who is not.
## Most-used commands
[Section titled “Most-used commands”](#most-used-commands)
| Task | Command |
| --------------------------------------------------- | --------------------------------------------------- |
| Create a PR | `bb pr create -t "Add feature"` |
| Create a PR with the repository’s default reviewers | `bb pr create -t "Add feature" --default-reviewers` |
| List open PRs | `bb pr list` |
| List all PRs (ignore the default limit) | `bb pr list --all` |
| List PRs where you are a reviewer | `bb pr list --mine` |
| View PR details | `bb pr view 42` |
| View checks | `bb pr checks 42` |
| Review diff | `bb pr diff 42 --stat` |
| Checkout PR locally | `bb pr checkout 42` |
| Approve PR | `bb pr approve 42` |
| Merge PR | `bb pr merge 42 --strategy squash` |
## JSON for automation
[Section titled “JSON for automation”](#json-for-automation)
List commands wrap their results in an envelope. Bare `bb pr list --json` returns `{workspace, repoSlug, state, filters, count, pullRequests}`, so a `--jq` filter starts at `.pullRequests[]`. Adding a field list (`--json id,title`) drops the envelope and returns a flat array, so the filter starts at `.[]` instead. Single-PR commands like `bb pr view` return the PR object itself, with no envelope.
```bash
# Project to specific fields (returns a flat array)
bb pr list --json id,title,author.display_name
# Filter with built-in --jq
bb pr list --json --jq '.pullRequests[] | select(.state == "OPEN") | .title'
# Combine projection + filter (jq runs after projection)
bb pr list --json id,title,state --jq '.[] | select(.state == "OPEN") | .title'
# Grab a PR URL from view output
bb pr view 42 --json --jq '.links.html.href'
# Capture diffstat totals
bb pr diff 42 --stat --json --jq '{filesChanged, totalAdditions, totalDeletions}'
```
`--json ` misfires on `bb pr create`, `bb pr edit` and `bb pr view` — see [Create, Edit, and View PRs](/commands/pr/create-and-edit/) for why, and [JSON Output](/reference/json-output/) for the full reference.
# Activity and Checks
> Inspect pull request activity history and CI/CD check status
Inspect pull request activity and build checks.
Global options available on all PR commands: `--json [fields]`, `--jq `, `--no-color`, `-w, --workspace`, `-r, --repo`.
## `bb pr activity`
[Section titled “bb pr activity”](#bb-pr-activity)
Show a pull request activity log.
```bash
bb pr activity [options]
```
### Arguments
[Section titled “Arguments”](#arguments)
| Argument | Description |
| -------- | --------------- |
| `id` | Pull request ID |
### Options
[Section titled “Options”](#options)
| Option | Description | Default |
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ------- |
| `--limit ` | Maximum number of activity entries | `25` |
| `--all` | Show all activity entries (overrides `--limit`) | |
| `--type ` | Filter by activity type (comma-separated): `comment`, `approval`, `changes_requested`, `merge`, `decline`, `commit`, `update` | |
| `--no-truncate` | Global flag. Show full details without truncation | |
| `-w, --workspace ` | Workspace | |
| `-r, --repo ` | Repository | |
| `--json` | Output as JSON | |
### Examples
[Section titled “Examples”](#examples)
```bash
# View activity for PR #42
bb pr activity 42
# Filter to comment and approval events
bb pr activity 42 --type comment,approval
# Limit results
bb pr activity 42 --limit 10
# Show the full activity history
bb pr activity 42 --all
# Get activity as JSON
bb pr activity 42 --json
```
Output:
```text
TYPE ACTOR DATE DETAILS
-------- -------- ------------------------ --------------------------------
UPDATE Sam Ali Jul 29, 2026 at 01:20 PM state: OPEN
COMMENT Jane Doe Jul 29, 2026 at 10:41 AM #486513002 Why was this removed?
APPROVAL Lee Park Jul 28, 2026 at 06:05 PM approved
COMMIT Sam Ali Jul 28, 2026 at 05:58 PM commit a1b2c3d
```
### Notes
[Section titled “Notes”](#notes)
* Comment snippets and change-request reasons are truncated to 80 characters, and `title:` change details to 60. Use `--no-truncate` for the full text
* An unrecognized `--type` token fails with `--type must be one of: comment, approval, changes_requested, merge, decline, commit, update`. Each bad token that is close to a valid one adds a `(Did you mean ...?)` line; tokens with no close match add nothing
* `--limit` is enforced across paginated activity responses
* When the result is capped by `--limit`, a hint shows how many were listed; use a higher `--limit` or `--all` to see the rest (suppressed with `--json`)
***
## `bb pr checks`
[Section titled “bb pr checks”](#bb-pr-checks)
Show CI/CD checks and build status for a pull request.
```bash
bb pr checks [options]
```
### Arguments
[Section titled “Arguments”](#arguments-1)
| Argument | Description |
| -------- | --------------- |
| `id` | Pull request ID |
### Options
[Section titled “Options”](#options-1)
| Option | Description |
| ----------------------------- | ------------------------------------------------------------ |
| `--no-truncate` | Global flag. Show full check descriptions without truncation |
| `-w, --workspace ` | Workspace |
| `-r, --repo ` | Repository |
| `--json` | Output as JSON |
### Examples
[Section titled “Examples”](#examples-1)
```bash
# View checks for PR #42
bb pr checks 42
# View checks in a specific repository
bb pr checks 42 -w myworkspace -r myrepo
# Get checks as JSON
bb pr checks 42 --json
```
Output:
```text
Pull Request #42 - 3 checks
────────────────────────────────────────────────────────────
STATUS NAME DESCRIPTION UPDATED
----------- -------------- ----------------------------- ------------------------
OK passed build Build succeeded in 2m 11s Jul 29, 2026 at 01:31 PM
FAIL failed unit-tests 3 of 412 tests failed Jul 29, 2026 at 01:34 PM
RUN running deploy-preview Deploying preview environment Jul 29, 2026 at 01:36 PM
OK 1 successful, FAIL 1 failed, RUN 1 pending
```
### Notes
[Section titled “Notes”](#notes-1)
* The `STATUS` cell is an icon plus a label: `OK passed`, `FAIL failed`, `RUN running`, `STOP stopped`, or `?` plus the raw state for anything else
* The summary line counts only successful, failed, and running checks, so it can total fewer than the header count
* Check descriptions are truncated to 40 characters in the table view. Use `--no-truncate` for the full text
* `bb pr checks` is not paginated — it makes a single request and has no `--limit` or `--all`
* `--json` returns `{ pullRequestId, workspace, repoSlug, summary, statuses }`. Unlike list commands, there is no `count` key — use the length of `statuses`
* With no checks, the command prints `No CI/CD checks found for this pull request`; with `--json` it returns an empty `statuses` array
# Comments
> List, add, view, edit, reply to, resolve, unresolve, and delete pull request comments
Manage pull request comments.
Global options available on all PR commands: `--json [fields]`, `--jq `, `--no-color`, `-w, --workspace`, `-r, --repo`.
Every `bb pr comments` subcommand accepts those globals. They work the same everywhere, so the per-command examples below leave them out:
```bash
# Target a repository other than the one you are standing in
bb pr comments list 42 -w myworkspace -r myrepo
# Machine-readable output
bb pr comments list 42 --json
```
`view`, `edit`, `reply`, `resolve`, and `unresolve` have no options of their own — only the globals.
## `bb pr comments`
[Section titled “bb pr comments”](#bb-pr-comments)
### Subcommands
[Section titled “Subcommands”](#subcommands)
| Subcommand | Description |
| -------------------------------------- | -------------------------------------------------- |
| `list ` | List comments on a pull request |
| `add ` | Add a comment to a pull request |
| `view ` | View a single comment on a pull request |
| `edit ` | Edit a comment on a pull request |
| `reply ` | Reply to a comment on a pull request |
| `resolve ` | Resolve a comment thread on a pull request |
| `unresolve ` | Reopen a resolved comment thread on a pull request |
| `delete ` | Delete a comment on a pull request |
***
## `bb pr comments list`
[Section titled “bb pr comments list”](#bb-pr-comments-list)
List comments on a pull request.
```bash
bb pr comments list [options]
```
### Arguments
[Section titled “Arguments”](#arguments)
| Argument | Description |
| -------- | --------------- |
| `id` | Pull request ID |
### Options
[Section titled “Options”](#options)
| Option | Description | Default |
| ------------------ | --------------------------------------------------------- | ------- |
| `--limit ` | Maximum number of comments | `25` |
| `--all` | List all comments (overrides `--limit`) | |
| `--resolved` | Only show resolved comments | |
| `--unresolved` | Only show unresolved comments | |
| `--no-truncate` | Global flag. Show full comment content without truncation | |
### Examples
[Section titled “Examples”](#examples)
```bash
# List comments on PR #42
bb pr comments list 42
# Only comments that still need attention
bb pr comments list 42 --unresolved
# List more comments
bb pr comments list 42 --limit 50
# List every comment
bb pr comments list 42 --all
# Show full comment content (not truncated)
bb pr comments list 42 --no-truncate
```
Output:
```text
ID Author Content Status Date
--------- -------- ------------------------------- -------- ------------------------
486512301 Jane Doe Consider renaming this variable resolved Jul 28, 2026 at 11:14 AM
486512477 Sam Ali Good catch, fixed. open Jul 28, 2026 at 12:02 PM
486513002 Jane Doe Why was this removed? open Jul 29, 2026 at 10:41 AM
```
### Notes
[Section titled “Notes”](#notes)
* Comment content is truncated to 60 characters in the table view. Use `--no-truncate` for the full text
* The `Status` column shows `resolved`, `pending`, or `open`. Bitbucket records resolution on the comment that was resolved, so a reply inside a resolved thread shows `open` (or `pending` if it is an unpublished draft)
* `--resolved` and `--unresolved` filter on the same resolution state and cannot be combined
* With `--resolved`/`--unresolved` the filter is applied client-side after each page is fetched, so `--limit` counts comments that survive the filter — `--unresolved --limit 25` keeps fetching pages until 25 unresolved comments are found or the list is exhausted
* When the result is capped by `--limit`, a hint shows how many were listed; use a higher `--limit` or `--all` to see the rest (suppressed with `--json`)
***
## `bb pr comments add`
[Section titled “bb pr comments add”](#bb-pr-comments-add)
Add a general comment, or an inline comment anchored to a file line.
```bash
bb pr comments add [options]
```
### Arguments
[Section titled “Arguments”](#arguments-1)
| Argument | Description |
| --------- | --------------- |
| `id` | Pull request ID |
| `message` | Comment message |
### Options
[Section titled “Options”](#options-1)
| Option | Description |
| ---------------------- | --------------------------------------------------------------------------- |
| `--file ` | File path for an inline comment (requires `--line-to` and/or `--line-from`) |
| `--line-to ` | Line number in the new version of the file (requires `--file`) |
| `--line-from ` | Line number in the old version of the file (requires `--file`) |
### Examples
[Section titled “Examples”](#examples-1)
```bash
# Add a general comment to PR #42
bb pr comments add 42 "LGTM! This looks great."
# Inline comment on a line in the new file
bb pr comments add 42 "Consider renaming this variable" --file src/index.ts --line-to 15
# Inline comment on a line in the old (removed) version of the file
bb pr comments add 42 "Why was this removed?" --file src/utils.ts --line-from 10
# Inline comment spanning old and new lines
bb pr comments add 42 "This logic changed" --file src/app.ts --line-from 5 --line-to 8
```
### Notes
[Section titled “Notes”](#notes-1)
* `--file` is required when using `--line-to` or `--line-from`
* At least one of `--line-to` or `--line-from` is required when using `--file`
* Line numbers must be positive integers
***
## `bb pr comments view`
[Section titled “bb pr comments view”](#bb-pr-comments-view)
View a single comment, including whether it is resolved.
```bash
bb pr comments view
```
### Arguments
[Section titled “Arguments”](#arguments-2)
| Argument | Description |
| ------------ | --------------- |
| `pr-id` | Pull request ID |
| `comment-id` | Comment ID |
### Examples
[Section titled “Examples”](#examples-2)
```bash
# View comment #486512301 on PR #42
bb pr comments view 42 486512301
```
### Notes
[Section titled “Notes”](#notes-2)
* The header shows `[resolved]` or `[unresolved]` for that specific comment. Bitbucket records the resolution on the comment that was resolved, so a reply inside a resolved thread still shows `[unresolved]`
* Unpublished draft review comments show `[pending]` instead
* Deleted comments render their content as `[deleted]`
* `--json` prints the raw comment object returned by the API
***
## `bb pr comments edit`
[Section titled “bb pr comments edit”](#bb-pr-comments-edit)
Edit a comment on a pull request.
```bash
bb pr comments edit
```
### Arguments
[Section titled “Arguments”](#arguments-3)
| Argument | Description |
| ------------ | ------------------- |
| `pr-id` | Pull request ID |
| `comment-id` | Comment ID |
| `message` | New comment message |
### Examples
[Section titled “Examples”](#examples-3)
```bash
# Replace the body of comment #486512301 on PR #42
bb pr comments edit 42 486512301 "Updated: I noticed something else..."
```
***
## `bb pr comments reply`
[Section titled “bb pr comments reply”](#bb-pr-comments-reply)
Reply to an existing comment. The reply is attached to the parent comment, so it lands in the same thread.
```bash
bb pr comments reply
```
### Arguments
[Section titled “Arguments”](#arguments-4)
| Argument | Description |
| ------------ | ----------------------------- |
| `pr-id` | Pull request ID |
| `comment-id` | ID of the comment to reply to |
| `message` | Reply message |
### Examples
[Section titled “Examples”](#examples-4)
```bash
# Reply to comment #486512301 on PR #42
bb pr comments reply 42 486512301 "Good catch, fixed."
```
### Notes
[Section titled “Notes”](#notes-3)
* Use `bb pr comments list ` to find the comment ID to reply to
* How Bitbucket anchors a reply to an inline comment is decided server-side
***
## `bb pr comments resolve`
[Section titled “bb pr comments resolve”](#bb-pr-comments-resolve)
Resolve a comment thread on a pull request.
```bash
bb pr comments resolve
```
### Arguments
[Section titled “Arguments”](#arguments-5)
| Argument | Description |
| ------------ | --------------- |
| `pr-id` | Pull request ID |
| `comment-id` | Comment ID |
### Examples
[Section titled “Examples”](#examples-5)
```bash
# Resolve comment thread #486512301 on PR #42
bb pr comments resolve 42 486512301
```
### Notes
[Section titled “Notes”](#notes-4)
* Resolving is reversible with `bb pr comments unresolve`
* `--json` returns `{ success, pullRequestId, commentId, resolution }`; the API returns the resolution record, not the full comment — use `bb pr comments view` to read the comment back
***
## `bb pr comments unresolve`
[Section titled “bb pr comments unresolve”](#bb-pr-comments-unresolve)
Reopen a resolved comment thread on a pull request.
```bash
bb pr comments unresolve
```
### Arguments
[Section titled “Arguments”](#arguments-6)
| Argument | Description |
| ------------ | --------------- |
| `pr-id` | Pull request ID |
| `comment-id` | Comment ID |
### Examples
[Section titled “Examples”](#examples-6)
```bash
# Reopen comment thread #486512301 on PR #42
bb pr comments unresolve 42 486512301
```
### Notes
[Section titled “Notes”](#notes-5)
* The API returns no body, so `--json` reports only `{ success, pullRequestId, commentId }`
***
## `bb pr comments delete`
[Section titled “bb pr comments delete”](#bb-pr-comments-delete)
Delete a comment from a pull request. `--yes` is required.
```bash
bb pr comments delete [options]
```
### Arguments
[Section titled “Arguments”](#arguments-7)
| Argument | Description |
| ------------ | --------------- |
| `pr-id` | Pull request ID |
| `comment-id` | Comment ID |
### Options
[Section titled “Options”](#options-2)
| Option | Description |
| ----------- | --------------------------- |
| `-y, --yes` | Confirm deletion (required) |
### Examples
[Section titled “Examples”](#examples-7)
```bash
# Delete comment #486512301 from PR #42
bb pr comments delete 42 486512301 --yes
```
### Notes
[Section titled “Notes”](#notes-6)
* `bb pr comments delete` never prompts. Without `--yes` it exits with a validation error ending in `Use --yes to confirm.`
* Deleting a comment is permanent and cannot be undone
# Create, Edit, and View PRs
> Create pull requests, edit metadata, and inspect PR details
Create and inspect pull requests (PRs).
Global options work on every PR command: `--json [fields]`, `--jq `, `--no-color`, `--no-unicode`, `--no-truncate`, `--locale `, `-w, --workspace`, `-r, --repo` — see [Global Flags](/reference/global-flags/).
Field projection (`--json id,title`) works on list commands such as `bb pr list`. It does not work on `bb pr create`, `bb pr edit` or `bb pr view`. The payload there is a single PR carrying a `reviewers` array, and the projector unwraps that array instead — you get the reviewers back, or `[]` when there are none. Use `--json --jq '{...}'` on those three.
## `bb pr create`
[Section titled “bb pr create”](#bb-pr-create)
Create a pull request.
```bash
bb pr create [options]
```
### Options
[Section titled “Options”](#options)
| Option | Description |
| ---------------------------- | ------------------------------------------------------------ |
| `-t, --title ` | PR title (required) |
| `-b, --body ` | PR description |
| `-s, --source ` | Source branch (default: current branch) |
| `-d, --destination ` | Destination branch (default: main) |
| `--close-source-branch` | Close source branch after merge |
| `--draft` | Create the PR as draft |
| `--reviewer ` | Add a reviewer by account ID or `{uuid}` (repeatable) |
| `--default-reviewers` | Include the repository’s default reviewers (opt-in) |
| `--no-default-reviewers` | Skip default reviewers even when the config key enables them |
### Examples
[Section titled “Examples”](#examples)
```bash
# Create a PR from current branch to main
bb pr create -t "Add new feature"
# Create a PR with full details
bb pr create -t "Add login page" -b "Implements user login functionality" -d develop
# Create a PR that will close the source branch after merging
bb pr create -t "Hotfix: Critical bug" --close-source-branch
# Create a draft PR
bb pr create -t "WIP: Add feature" --draft
# Auto-add the repository's default reviewers (matches the Bitbucket web UI)
bb pr create -t "Add new feature" --default-reviewers
# Add specific reviewers (repeatable; accepts account ID or {uuid})
bb pr create -t "Add new feature" \
--reviewer "712020:3cfed7e0-0ed6-49fc-bb35-410a00ccee6f" \
--reviewer "{c1cb1bb5-2e32-456e-a373-43978dc12aa1}"
# Combine defaults + explicit additions (duplicates are de-duped)
bb pr create -t "Add new feature" --default-reviewers \
--reviewer "712020:3cfed7e0-0ed6-49fc-bb35-410a00ccee6f"
# Capture the new PR's URL from JSON output for scripting
bb pr create -t "Add new feature" --json --jq '.links.html.href'
```
### Reviewers
[Section titled “Reviewers”](#reviewers)
By default `bb pr create` does **not** attach reviewers to the PR — this differs from the Bitbucket web UI, which auto-populates the repository’s default reviewers.
* `--default-reviewers` opts in per-invocation. The command fetches the repository’s *effective* default reviewers (repo-level + project-inherited) and attaches them.
* `--reviewer ` adds specific reviewers regardless of the defaults and can be passed multiple times. Accepts an **account ID** (e.g. `712020:3cfed7e0-...`) or a **UUID** in curly braces (e.g. `{c1cb1bb5-...}`). Bitbucket Cloud’s GDPR changes retired username lookups, so nicknames are not accepted.
* The PR author is automatically excluded from the reviewer list — Bitbucket rejects PRs that list the author as a reviewer.
* To make `--default-reviewers` the default behavior, set the config key:
```bash
bb config set prCreateIncludeDefaultReviewers true
```
Pass `--no-default-reviewers` to skip defaults for a single invocation when this is enabled.
* If the default-reviewer fetch fails (network error, permission issue, etc.) the CLI prints `Could not fetch default reviewers: … Continuing without them.` and creates the PR anyway. Only the *defaults* are dropped — reviewers you passed with `--reviewer` are still attached. A failed `--reviewer` lookup, by contrast, aborts the create.
See [`bb repo default-reviewers`](/commands/repo/#bb-repo-default-reviewers) to inspect or manage the underlying default reviewer list.
***
## `bb pr edit`
[Section titled “bb pr edit”](#bb-pr-edit)
Edit an existing pull request’s title or description.
```bash
bb pr edit [id] [options]
```
`[id]` is the PR number. Omit it to auto-detect the open PR whose source branch matches your current git branch.
### Options
[Section titled “Options”](#options-1)
| Option | Description |
| ------------------------ | -------------------------- |
| `-t, --title ` | New PR title |
| `-b, --body ` | New PR description |
| `-F, --body-file ` | Read description from file |
### Examples
[Section titled “Examples”](#examples-1)
```bash
# Edit the title by ID
bb pr edit 42 -t "Updated: Add new feature"
# Edit the description
bb pr edit 42 -b "This PR implements the new login flow"
# Edit both title and description
bb pr edit 42 -t "New title" -b "New description"
# Auto-detect the PR from the current branch and update the title
bb pr edit -t "Updated title"
# Read the description from a file
bb pr edit 42 -F description.md
# Get the updated PR as JSON
bb pr edit 42 -t "New title" --json
```
### Notes
[Section titled “Notes”](#notes)
* When no ID is provided, the command searches for an open PR where the source branch matches your current git branch
* At least one of `--title`, `--body`, or `--body-file` must be provided
* If both `-b/--body` and `-F/--body-file` are given, the file wins and no error is raised. This differs from `bb issue create`, which rejects the combination
* An unreadable path fails with `Failed to read file '': `
***
## `bb pr list`
[Section titled “bb pr list”](#bb-pr-list)
List pull requests.
```bash
bb pr list [options]
```
### Options
[Section titled “Options”](#options-2)
| Option | Description |
| --------------------- | ------------------------------------------------------------------- |
| `-s, --state ` | Filter by state: OPEN, MERGED, DECLINED, SUPERSEDED (default: OPEN) |
| `--limit ` | Maximum number of PRs (default: 25) |
| `--all` | List all PRs (overrides `--limit`) |
| `--mine` | Show only PRs where you are a reviewer |
### Examples
[Section titled “Examples”](#examples-2)
```bash
# List open PRs in current repository
bb pr list
# List merged PRs
bb pr list -s MERGED
# List declined PRs
bb pr list -s DECLINED
# List PRs in specific repository
bb pr list -w myworkspace -r myrepo
# List with JSON output for scripting
bb pr list --json
# Project to specific fields (returns a flat array)
bb pr list --json id,title,author.display_name
# Filter with built-in --jq (no external jq binary needed)
bb pr list --json --jq '.pullRequests[] | select(.state == "OPEN") | .title'
# List more results
bb pr list --limit 50
# Fetch every open PR, ignoring the default limit of 25
bb pr list --all
# Show only PRs assigned to you for review
bb pr list --mine
```
### Notes
[Section titled “Notes”](#notes-1)
* Draft PRs are shown with a `[DRAFT]` prefix in the title
* `--limit` is enforced across paginated API responses
* The TITLE column is truncated to 50 characters, and the `[DRAFT] `prefix counts against that budget. Pass `--no-truncate` for full titles; `--json` output is never truncated
`--mine` does not mean “my PRs”
`--mine` filters PRs where you are assigned as a **reviewer**, not PRs you authored. It uses the Bitbucket API’s `reviewers.uuid` filter. To find PRs you created, filter the JSON yourself:
```bash
bb pr list --json --jq '.pullRequests[] | select((.author.nickname // .author.display_name) == "your-username")'
```
***
## `bb pr view`
[Section titled “bb pr view”](#bb-pr-view)
View pull request details.
```bash
bb pr view [options]
```
`` is the PR number.
### Examples
[Section titled “Examples”](#examples-3)
```bash
# View PR #42 in current repository
bb pr view 42
# View PR in specific repository
bb pr view 42 -w myworkspace -r myrepo
# Get PR details as JSON
bb pr view 42 --json
# Pick out fields with built-in --jq
bb pr view 42 --json --jq '{id, title, state, author: .author.display_name}'
# Extract just the web URL
bb pr view 42 --json --jq '.links.html.href'
```
# Diff and Checkout
> Checkout pull request branches locally and inspect diff output
Review pull request changes with local checkout and diff tooling.
Global options available on all PR commands: `--json [fields]`, `--jq `, `--no-color`, `-w, --workspace`, `-r, --repo`.
## `bb pr checkout`
[Section titled “bb pr checkout”](#bb-pr-checkout)
Check out a pull request’s source branch locally.
```bash
bb pr checkout [options]
```
### Arguments
[Section titled “Arguments”](#arguments)
| Argument | Description |
| -------- | --------------- |
| `id` | Pull request ID |
### Options
[Section titled “Options”](#options)
| Option | Description |
| ----------------------------- | -------------- |
| `-w, --workspace ` | Workspace |
| `-r, --repo ` | Repository |
| `--json` | Output as JSON |
### Examples
[Section titled “Examples”](#examples)
```bash
# Checkout PR #42 to review locally
bb pr checkout 42
# Checkout PR from specific repository
bb pr checkout 42 -w myworkspace -r myrepo
```
### Notes
[Section titled “Notes”](#notes)
The command, in order:
1. Fetches the latest changes from the remote
2. Checks out the pull request’s source branch
3. If that checkout fails, creates a local branch `pr-` tracking `origin/`
`--json` returns `{ success, pullRequestId, branch, pullRequest }`, where `branch` is whichever of the two names was checked out.
***
## `bb pr diff`
[Section titled “bb pr diff”](#bb-pr-diff)
View the diff of a pull request in unified diff format.
```bash
bb pr diff [id] [options]
```
### Arguments
[Section titled “Arguments”](#arguments-1)
| Argument | Description |
| -------- | ------------------------------------------------------------- |
| `id` | Pull request ID (optional - auto-detects from current branch) |
### Options
[Section titled “Options”](#options-1)
| Option | Description |
| ----------------------------- | ---------------------------------------------------------- |
| `-w, --workspace ` | Workspace |
| `-r, --repo ` | Repository |
| `--color ` | Colorize output: `auto`, `always`, `never` (default: auto) |
| `--name-only` | Show only names of changed files |
| `--stat` | Show diffstat (files changed, insertions, deletions) |
| `--web` | Open diff in web browser |
| `--json` | Output as JSON |
### Examples
[Section titled “Examples”](#examples-1)
```bash
# View diff for PR #42
bb pr diff 42
# Auto-detect PR from current branch
bb pr diff
# Show only changed file names
bb pr diff 42 --name-only
# Show statistics (like git diff --stat)
bb pr diff 42 --stat
# Open diff in browser
bb pr diff 42 --web
# Return browser URL as JSON
bb pr diff 42 --web --json
# Disable colors for piping to file or other commands
bb pr diff 42 --color never > pr-42.patch
# Get diffstat as JSON for scripting
bb pr diff 42 --stat --json
```
`--stat` output:
```text
src/index.ts | +12 -3
src/utils.ts | +4
docs/README.md | -8
3 files changed, 16 insertions(+), 11 deletions(-)
```
### Notes
[Section titled “Notes”](#notes-1)
* When no ID is provided, the command searches for an open pull request whose source branch matches your current git branch
* `--color auto` colors the diff only when stdout is a terminal: green for additions, red for deletions, cyan for hunk headers. Whole lines are colored by their leading marker — there is no language-aware highlighting
* `--color never` forces plain text, which is what you want when redirecting to a file or piping into another command. The global `--no-color` flag does the same for every command
* The value is validated before the request. A typo fails with `--color must be one of: auto, always, never` plus a `(Did you mean never?)` suggestion, rather than silently falling back
* Passing `--color ` at all turns the *global* color setting on, because the CLI resolves color by scanning raw argv for a `--color` token. `bb pr diff 42 --color never` still leaves the diff body uncolored, but it overrides `--no-color` and `NO_COLOR` for everything else that invocation prints. See [Global Flags → Precedence summary](/reference/global-flags/#precedence-summary)
* `-w` is the global short alias for `--workspace`. To open the diff in a browser you must spell out `--web`
* For opening other Bitbucket pages (PR detail, files, commits, pipelines, settings) in the browser, see [`bb browse`](/commands/browse/)
# Review and Merge
> Approve, decline, mark ready, and merge pull requests
The four commands that change a pull request’s state: `bb pr approve`, `bb pr decline`, `bb pr ready`, `bb pr merge`.
Global options work on every PR command: `--json [fields]`, `--jq `, `--no-color`, `--no-unicode`, `--no-truncate`, `--locale `, `-w, --workspace`, `-r, --repo` — see [Global Flags](/reference/global-flags/).
`--json` accepts an optional comma-separated field list and `--jq` filters the JSON in-process — see [JSON Output](/reference/json-output/) for the full reference. On these four commands the field list is matched against the result envelope shown under [JSON output](#json-output), not against the PR, so `--json title` returns `{"title": null}`. Use a dotted path (`--json pullRequest.state`) or `--jq` instead.
## `bb pr merge`
[Section titled “bb pr merge”](#bb-pr-merge)
```bash
bb pr merge [options]
```
`` is the pull request ID.
### Options
[Section titled “Options”](#options)
| Option | Description |
| ------------------------- | -------------------------------------- |
| `-m, --message ` | Merge commit message |
| `--close-source-branch` | Delete the source branch after merging |
| `--strategy ` | Merge strategy (see below) |
### Merge strategies
[Section titled “Merge strategies”](#merge-strategies)
| Strategy | Description |
| --------------------- | ---------------------------------------------------------------- |
| `merge_commit` | Create a merge commit |
| `squash` | Squash all commits into a single commit |
| `fast_forward` | Fast-forward if possible, fail otherwise |
| `squash_fast_forward` | Squash commits and fast-forward |
| `rebase_fast_forward` | Rebase source commits onto destination and fast-forward |
| `rebase_merge` | Rebase source commits onto destination and create a merge commit |
Omitting `--strategy` uses the repository’s configured merge strategy (typically `merge_commit`), not a CLI default. The CLI sends no strategy at all unless you pass one.
Strategy names are checked when the command runs, not by the argument parser. An unknown value fails with [`5002` VALIDATION\_INVALID](/reference/error-codes/#5002---validation_invalid) and the message `--strategy must be one of: merge_commit, squash, …`. A wrong-case value such as `SQUASH` gets a case-sensitivity note; a typo such as `sqush` gets a “did you mean” suggestion. Under `--json` that failure comes back as a JSON error envelope.
### Examples
[Section titled “Examples”](#examples)
```bash
# Merge PR #42 using the repository's configured strategy
bb pr merge 42
# Squash and delete the source branch
bb pr merge 42 --strategy squash --close-source-branch
# Merge with a custom commit message
bb pr merge 42 -m "Merge feature: Add user authentication"
# Rebase and fast-forward
bb pr merge 42 --strategy rebase_fast_forward
# Capture the merge commit hash (--jq prints JSON-quoted strings, so strip them)
bb pr merge 42 --json --jq '.pullRequest.merge_commit.hash' | tr -d '"'
```
***
## `bb pr approve`, `bb pr decline`, `bb pr ready`
[Section titled “bb pr approve, bb pr decline, bb pr ready”](#bb-pr-approve-bb-pr-decline-bb-pr-ready)
Each takes a pull request ID and nothing else — no command-specific options, only the global ones.
```bash
bb pr approve 42 # Approve
bb pr decline 42 # Decline
bb pr ready 42 # Clear the draft flag, marking the PR ready for review
# Any of them against an explicit repository
bb pr approve 42 -w myworkspace -r myrepo
```
`bb pr ready` is a pull request update that sets `draft: false`. It sends no other fields.
## JSON output
[Section titled “JSON output”](#json-output)
The four commands on this page do not return the same shape. `bb pr approve` returns only the identifiers:
```json
{
"success": true,
"pullRequestId": 42
}
```
`bb pr decline`, `bb pr ready`, and `bb pr merge` add the pull request exactly as the API returned it, so `state` reflects the command you ran — `DECLINED`, `OPEN`, and `MERGED` respectively. Abridged, for `bb pr merge`:
```json
{
"success": true,
"pullRequestId": 42,
"pullRequest": {
"id": 42,
"title": "Add user authentication",
"state": "MERGED"
}
}
```
A script that reads `.pullRequest` after `bb pr approve --json` gets `null`. Fetch the PR separately with `bb pr view 42 --json` if you need its fields after approving.
# Reviewers
> List, add, and remove pull request reviewers
Manage pull request (PR) reviewers.
Global options work on every PR command: `--json [fields]`, `--jq `, `--no-color`, `--no-unicode`, `--no-truncate`, `--locale `, `-w, --workspace`, `-r, --repo` — see [Global Flags](/reference/global-flags/).
Looking for repo-level defaults?
This page covers reviewers on **existing** pull requests. To manage the repository’s **default reviewers** — the list Bitbucket auto-suggests when someone opens a PR — see [`bb repo default-reviewers`](/commands/repo/#bb-repo-default-reviewers). `bb pr create` can also auto-apply them via `--default-reviewers` or the `prCreateIncludeDefaultReviewers` config key.
## Identifying users
[Section titled “Identifying users”](#identifying-users)
Bitbucket Cloud no longer accepts the legacy `username` (login name) when modifying reviewers. The `` positional accepts either:
* An **account ID**, e.g. `712020:3cfed7e0-0ed6-49fc-bb35-410a00ccee6f`
* A **UUID** wrapped in braces, e.g. `{c1cb1bb5-2e32-456e-a373-43978dc12aa1}`
Both forms come back from `bb pr reviewers list --json`, as the `account_id` and `uuid` fields:
```bash
# One object per reviewer: [{"account_id": "712020:3cfed..."}, …]
bb pr reviewers list 42 --json account_id
# Copy every reviewer from PR #42 onto PR #43
for u in $(bb pr reviewers list 42 --json --jq '.reviewers[].account_id' | tr -d '"'); do
bb pr reviewers add 43 "$u"
done
```
Two things to watch in scripts. `--json ` projects across the `reviewers` array and drops the surrounding `{workspace, repoSlug, pullRequestId, count}` envelope, so you get a bare array of objects — not bare IDs. And the built-in jq runs without `-r`, so strings arrive JSON-quoted; strip the quotes with `tr -d '"'` or interpolate inside jq.
See [`bb pr create`](/commands/pr/create-and-edit/#bb-pr-create) for matching `--reviewer` examples.
## `bb pr reviewers`
[Section titled “bb pr reviewers”](#bb-pr-reviewers)
| Subcommand | Description |
| -------------------- | ------------------------------------- |
| `list ` | List reviewers on a pull request |
| `add ` | Add a reviewer to a pull request |
| `remove ` | Remove a reviewer from a pull request |
None of the three take command-specific options — only the global ones. `` is the pull request ID; `` is an account ID or a braced UUID.
***
## `bb pr reviewers list`
[Section titled “bb pr reviewers list”](#bb-pr-reviewers-list)
```bash
bb pr reviewers list
```
```bash
# List reviewers on PR #42
bb pr reviewers list 42
# List reviewers in a specific repository
bb pr reviewers list 42 -w myworkspace -r myrepo
```
Human output is a two-column table of display name and account ID. If the pull request has no reviewers, the command prints `No reviewers assigned to this pull request`. The deprecated `username` field is never shown — Bitbucket Cloud stopped returning it for GDPR reasons.
`--json` returns the full envelope:
```json
{
"workspace": "myworkspace",
"repoSlug": "myrepo",
"pullRequestId": 42,
"count": 1,
"reviewers": [
{
"display_name": "Jane Doe",
"account_id": "712020:3cfed7e0-0ed6-49fc-bb35-410a00ccee6f",
"uuid": "{c1cb1bb5-2e32-456e-a373-43978dc12aa1}"
}
]
}
```
***
## `bb pr reviewers add`
[Section titled “bb pr reviewers add”](#bb-pr-reviewers-add)
Add a reviewer by account ID or UUID. The legacy `username` (login name) is not accepted by Bitbucket Cloud — see [Identifying users](#identifying-users).
```bash
bb pr reviewers add
```
```bash
# By account ID
bb pr reviewers add 42 "712020:3cfed7e0-0ed6-49fc-bb35-410a00ccee6f"
# By UUID (keep the braces, and quote the argument so the shell leaves them alone)
bb pr reviewers add 42 "{c1cb1bb5-2e32-456e-a373-43978dc12aa1}"
```
Adding someone who is already a reviewer succeeds and changes nothing.
***
## `bb pr reviewers remove`
[Section titled “bb pr reviewers remove”](#bb-pr-reviewers-remove)
Remove a reviewer by account ID or UUID. Same `` rules as `add`.
```bash
bb pr reviewers remove
```
```bash
# By account ID
bb pr reviewers remove 42 "712020:3cfed7e0-0ed6-49fc-bb35-410a00ccee6f"
# By UUID
bb pr reviewers remove 42 "{c1cb1bb5-2e32-456e-a373-43978dc12aa1}"
```
Removing someone who is not a reviewer succeeds and changes nothing.
## JSON output for `add` and `remove`
[Section titled “JSON output for add and remove”](#json-output-for-add-and-remove)
Both commands emit the same envelope. `reviewer.username` echoes the `` value you passed, whatever form it was in; `reviewer.uuid` is the resolved UUID.
```json
{
"success": true,
"pullRequestId": 42,
"reviewer": {
"username": "712020:3cfed7e0-0ed6-49fc-bb35-410a00ccee6f",
"uuid": "{c1cb1bb5-2e32-456e-a373-43978dc12aa1}"
},
"pullRequest": { "id": 42, "title": "Add user authentication" }
}
```
## When the user lookup fails
[Section titled “When the user lookup fails”](#when-the-user-lookup-fails)
Both commands resolve `` through Bitbucket’s user endpoint before touching the pull request. A bad account ID or UUID fails there with a 404, carrying whatever message Bitbucket returns. The CLI appends its generic 404 hint, which mentions `--workspace` and `--repo` — but for these two commands the wrong value is almost always the `` argument, not the repository.
# Project Commands - Manage Bitbucket Projects
> Reference for Bitbucket CLI project commands. List, view, and create Bitbucket Cloud projects to organize repositories from the command line.
Projects are the grouping layer for repositories inside a workspace. Use these commands to discover the project keys you pass to `bb repo create -p `.
Project commands run at **workspace** scope; no repository context is required. Unlike `bb workspace view` and the repo-scoped commands, they never infer the workspace from your git remote. Resolution is `-w/--workspace` → `BB_WORKSPACE` → `defaultWorkspace`. With none of those set, `bb project list` fails with `No workspace specified.` even inside a Bitbucket checkout — see [Repository Context](/guides/repository-context/).
All three subcommands are non-interactive and accept the [global flags](/reference/global-flags/), including `--json [fields]` and `--jq `.
***
## `bb project list`
[Section titled “bb project list”](#bb-project-list)
List projects in a workspace.
```bash
bb project list [options]
```
### Options
[Section titled “Options”](#options)
| Option | Description |
| ----------------------------- | ---------------------------------------- |
| `-w, --workspace ` | Workspace |
| `--limit ` | Maximum number of projects (default: 25) |
| `--all` | List all projects (overrides `--limit`) |
| `--json` | Output as JSON |
### Examples
[Section titled “Examples”](#examples)
```bash
bb project list
bb project list -w my-workspace
bb project list --all
# Just key and name — a flat array, not the envelope
bb project list --json key,name
# Keys, one per line (JSON-quoted — the embedded jq has no -r)
bb project list --json --jq '.projects[].key'
# Unquoted keys for a shell loop — needs the jq binary
bb project list --json | jq -r '.projects[].key'
```
### Output
[Section titled “Output”](#output)
```text
KEY NAME PRIVACY DESCRIPTION UPDATED
-------- ----------------- ------- --------------------------------- ------------------------
PLATFORM Platform Services private Shared infrastructure and tooling Jul 30, 2026 at 09:12 AM
WEB Web Apps private Customer-facing web frontends Jul 24, 2026 at 04:38 PM
```
An empty workspace prints `No projects found in workspace `.
### JSON output
[Section titled “JSON output”](#json-output)
The envelope is `{ workspace, count, projects }`, where `projects` is the array of project objects.
### Notes
[Section titled “Notes”](#notes)
* The `DESCRIPTION` column is truncated to 50 characters. Pass the global `--no-truncate` for the full text; `--json` always carries the full values.
* When more results exist than `--limit` returned, the table is followed by `Showing 25 projects. Use --limit or --all to see more.` This footer is never printed under `--json`.
***
## `bb project view`
[Section titled “bb project view”](#bb-project-view)
View project details.
```bash
bb project view [options]
```
### Arguments
[Section titled “Arguments”](#arguments)
| Argument | Description |
| -------- | --------------------------------------------------------------------------------------------------------------------- |
| `key` | Project key (e.g. `PROJ`; lowercase input is uppercased automatically, so `proj` and `PROJ` resolve the same project) |
### Options
[Section titled “Options”](#options-1)
| Option | Description |
| ----------------------------- | -------------- |
| `-w, --workspace ` | Workspace |
| `--json` | Output as JSON |
### Examples
[Section titled “Examples”](#examples-1)
```bash
bb project view PROJ
bb project view PROJ -w my-workspace
# JSON is wrapped: { workspace, project }
bb project view PROJ --json --jq '.project.name'
```
### Notes
[Section titled “Notes”](#notes-1)
* An unknown key fails with `Project not found in workspace .` — exit code 1, and `--json` writes a structured error envelope to stderr.
***
## `bb project create`
[Section titled “bb project create”](#bb-project-create)
Create a new project in a workspace.
```bash
bb project create [options]
```
### Options
[Section titled “Options”](#options-2)
| Option | Description |
| --------------------------------- | ------------------------------------------------------------- |
| `-w, --workspace ` | Workspace |
| `-k, --key ` | Project key, e.g. `PROJ` (required; uppercased automatically) |
| `-n, --name ` | Project name (required) |
| `-d, --description ` | Project description |
| `--private` | Create a private project (default) |
| `--public` | Create a public project |
| `--json` | Output as JSON |
### Examples
[Section titled “Examples”](#examples-2)
```bash
bb project create --key PROJ --name "My Project"
bb project create -k PROJ -n "My Project" -d "Team things" --public
# Then create repositories inside it
bb repo create my-repo -p PROJ
# The response is wrapped: { workspace, project }
bb project create -k PROJ -n "My Project" --json --jq '.project.key'
```
### Notes
[Section titled “Notes”](#notes-2)
* Projects are private by default. `--private` and `--public` cannot both be set. A private project cannot contain public repositories.
* Keys must start with a letter and contain only letters, digits, and underscores. Bitbucket requires uppercase keys, so lowercase input is uppercased automatically; the CLI prints a note when it does, except under `--json`.
### Related
[Section titled “Related”](#related)
* [Workspace Commands](/commands/workspace/) — find the workspace slug these commands need.
* [Repository Context](/guides/repository-context/) — how the CLI resolves workspace and repository.
# Repo Commands - Clone, Create & Manage Bitbucket Repositories
> Complete reference for Bitbucket CLI repository commands. Learn to clone, create, list, view, and delete repositories from the command line with examples.
Manage Bitbucket repositories.
Global options available on all repo commands: `--json [fields]`, `--jq `, `--no-color`, `--no-unicode`, `--no-truncate`, `--locale `, `-w, --workspace`, `-r, --repo`. See [Global flags](/reference/global-flags/) for the full list. The per-command tables below list only command-specific options. One exception: `bb repo clone` ignores `-w, --workspace`.
## `bb repo clone`
[Section titled “bb repo clone”](#bb-repo-clone)
Clone a Bitbucket repository.
```bash
bb repo clone [options]
```
### Arguments
[Section titled “Arguments”](#arguments)
| Argument | Description |
| ------------ | ------------------------------------------------------------- |
| `repository` | `workspace/repo`, a bare repository name, or a full clone URL |
For a bare name, the workspace comes from `BB_WORKSPACE`, then the `defaultWorkspace` config key. The global `-w` is **not** honoured by this command.
### Options
[Section titled “Options”](#options)
| Option | Description |
| ----------------------- | ----------------------- |
| `-d, --directory ` | Directory to clone into |
### Examples
[Section titled “Examples”](#examples)
```bash
# Clone using workspace/repo format
bb repo clone myworkspace/myrepo
# Clone into a specific directory
bb repo clone myworkspace/myrepo -d my-local-dir
# Bare name — workspace comes from the environment
BB_WORKSPACE=myworkspace bb repo clone myrepo
# Clone using full URL
bb repo clone git@bitbucket.org:myworkspace/myrepo.git
```
### Notes
[Section titled “Notes”](#notes)
* For the `workspace/repo` and bare-name forms the CLI clones over SSH (`git@bitbucket.org:/.git`). Pass a full HTTPS URL if you do not have SSH keys set up.
* A path with more than one `/` fails with `Invalid repository format. Use workspace/repo or a full URL.`
* `--json` emits `{ success, repository, path, cloneUrl }`.
***
## `bb repo create`
[Section titled “bb repo create”](#bb-repo-create)
Create a new repository.
```bash
bb repo create [options]
```
### Arguments
[Section titled “Arguments”](#arguments-1)
| Argument | Description |
| -------- | --------------------------- |
| `name` | Name for the new repository |
### Options
[Section titled “Options”](#options-1)
| Option | Description | Default |
| --------------------------------- | --------------------------- | ------- |
| `-d, --description ` | Repository description | |
| `--private` | Create a private repository | true |
| `--public` | Create a public repository | |
| `-p, --project ` | Project key | |
### Examples
[Section titled “Examples”](#examples-1)
```bash
# Create a private repository
bb repo create my-new-repo -w myworkspace
# Create a public repository with description
bb repo create my-new-repo -w myworkspace --public -d "My awesome project"
# Create in a specific project
bb repo create my-new-repo -w myworkspace -p PROJ
```
### Notes
[Section titled “Notes”](#notes-1)
* Visibility is private unless `--public` is passed. If both `--private` and `--public` are given, `--public` currently wins and no error is raised — unlike `bb snippet create` and `bb project create`, which reject the combination.
* `--json` emits the raw Bitbucket repository object, with no envelope.
***
## `bb repo list`
[Section titled “bb repo list”](#bb-repo-list)
List repositories in a workspace.
```bash
bb repo list [options]
```
### Options
[Section titled “Options”](#options-2)
| Option | Description | Default |
| ------------------ | ------------------------------------------- | ------- |
| `--limit ` | Maximum number of repositories | 25 |
| `--all` | List all repositories (overrides `--limit`) | |
### Examples
[Section titled “Examples”](#examples-2)
```bash
# List repositories in a workspace
bb repo list -w myworkspace
# List more repositories
bb repo list -w myworkspace --limit 50
# List every repository in the workspace
bb repo list -w myworkspace --all
# List with JSON output for scripting
bb repo list -w myworkspace --json
# Project to specific fields (returns a flat array)
bb repo list -w myworkspace --json full_name,is_private,language
# Filter with built-in --jq — print just public repo names
bb repo list -w myworkspace --json --jq '.repositories[] | select(.is_private == false) | .full_name'
```
### JSON output
[Section titled “JSON output”](#json-output)
The `--json` envelope is `{ workspace, count, repositories }`, where `repositories` is the array of repository objects. `--json ` drops the envelope and returns a flat array.
### Notes
[Section titled “Notes”](#notes-2)
* `--limit` caps how many repositories come back, not the page size. The CLI walks pages (at most 50 per request) until the cap is reached. A value below 1 fails with `--limit must be a positive integer`.
* Long descriptions are truncated to 50 characters in the table (disable with the global `--no-truncate`); `--json` always carries the full values.
* When the result is capped by `--limit`, a hint shows how many were listed; use a higher `--limit` or `--all` to see the rest (suppressed with `--json`).
***
## `bb repo view`
[Section titled “bb repo view”](#bb-repo-view)
View repository details.
```bash
bb repo view [repository] [options]
```
### Arguments
[Section titled “Arguments”](#arguments-2)
| Argument | Description |
| ------------ | ----------------------------------------------------------------------------------------------------- |
| `repository` | `workspace/repo`, or a bare repository name paired with `-w`. Optional inside a repository directory. |
### Examples
[Section titled “Examples”](#examples-3)
```bash
# View current repository (from within repo directory)
bb repo view
# View specific repository using workspace/repo format
bb repo view myworkspace/myrepo
# View with explicit workspace option
bb repo view myrepo -w myworkspace
# Get repository details as JSON
bb repo view --json
```
### Notes
[Section titled “Notes”](#notes-3)
* Resolution order: the positional argument wins, then the global `-w`/`-r` flags, then the git remote of the current directory.
* `--json` emits the raw Bitbucket repository object, with no envelope.
***
## `bb repo delete`
[Section titled “bb repo delete”](#bb-repo-delete)
Delete a repository.
```bash
bb repo delete [options]
```
### Arguments
[Section titled “Arguments”](#arguments-3)
| Argument | Description |
| ------------ | ----------------------------------------------------------------------------------------------------------------------------------- |
| `repository` | `workspace/repo`, or a bare repository name when the workspace comes from `-w`, `BB_WORKSPACE` or the `defaultWorkspace` config key |
### Options
[Section titled “Options”](#options-3)
| Option | Description |
| ----------- | --------------------------- |
| `-y, --yes` | Confirm deletion (required) |
### Examples
[Section titled “Examples”](#examples-4)
```bash
# Delete a repository (--yes is required to confirm)
bb repo delete myworkspace/myrepo --yes
# Delete using explicit workspace option
bb repo delete myrepo -w myworkspace --yes
```
`--json` emits `{ success, workspace, repoSlug }`.
Danger
Deletion is permanent. All repository data, including code, issues and pull requests, is destroyed. There is no interactive prompt — without `--yes` the command exits with `This will permanently delete /.` followed by `Use --yes to confirm.`
***
[]()
## `bb repo default-reviewers`
[Section titled “bb repo default-reviewers”](#bb-repo-default-reviewers)
Default reviewers are auto-suggested when someone opens a pull request in Bitbucket’s web UI. This group reads and edits that list.
### `bb repo default-reviewers list`
[Section titled “bb repo default-reviewers list”](#bb-repo-default-reviewers-list)
```bash
bb repo default-reviewers list [options]
```
By default the **effective** reviewer list is shown: reviewers configured directly on the repository *and* reviewers inherited from the parent project, matching what Bitbucket’s web UI would auto-populate.
| Option | Description |
| ------------- | ---------------------------------------------------------------------------- |
| `--repo-only` | Only show reviewers configured on the repository (exclude project-inherited) |
```bash
# Effective list (repo + project-inherited)
bb repo default-reviewers list
# Only repo-level entries
bb repo default-reviewers list --repo-only
# JSON for scripting
bb repo default-reviewers list --json
```
`--json` emits `{ workspace, repoSlug, mode, count, reviewers }`, where `mode` is `effective` or `direct`.
### `bb repo default-reviewers add`
[Section titled “bb repo default-reviewers add”](#bb-repo-default-reviewers-add)
```bash
bb repo default-reviewers add
```
Adds a user as a default reviewer on the repository. Requires repository admin permission.
The `` argument accepts either an **account ID** (e.g. `712020:3cfed7e0-0ed6-49fc-bb35-410a00ccee6f`) or a **UUID** in curly braces (e.g. `{c1cb1bb5-2e32-456e-a373-43978dc12aa1}`). Bitbucket Cloud’s GDPR changes retired username lookups, so nicknames like `jdoe` are no longer accepted.
You can find a user’s account ID from the Bitbucket web UI under their profile, or by running `bb pr reviewers list --json` on a pull request they have reviewed.
```bash
bb repo default-reviewers add "712020:3cfed7e0-0ed6-49fc-bb35-410a00ccee6f"
bb repo default-reviewers add "{c1cb1bb5-2e32-456e-a373-43978dc12aa1}"
```
### `bb repo default-reviewers remove`
[Section titled “bb repo default-reviewers remove”](#bb-repo-default-reviewers-remove)
```bash
bb repo default-reviewers remove --yes
```
Removes a user from the repository’s default reviewers. `--yes` is required to confirm. Requires repository admin permission.
`` accepts the same identifiers as `add` (account ID or `{uuid}`).
```bash
bb repo default-reviewers remove "712020:3cfed7e0-0ed6-49fc-bb35-410a00ccee6f" --yes
```
### Notes
[Section titled “Notes”](#notes-4)
* Project-inherited reviewers can only be removed by editing the parent project, not the repository.
* Related: [`bb pr create --default-reviewers`](/commands/pr/create-and-edit/) applies these reviewers when opening a pull request.
# Snippet Commands - Manage Bitbucket Snippets
> Reference for Bitbucket CLI snippet commands. Create, view, edit, delete, watch, and comment on Bitbucket Cloud snippets from the command line.
Manage Bitbucket Cloud snippets — workspace-scoped code/text pastes.
Snippet commands operate at **workspace** scope (no repository context required). Use `-w, --workspace ` or set a default with `bb config set defaultWorkspace `.
Global options available on all snippet commands: `--json [fields]`, `--jq `, `--no-color`, `--no-unicode`, `--no-truncate`, `--locale `, `-w, --workspace`. See [Global flags](/reference/global-flags/) for the full list. The per-command tables below list only command-specific options.
***
## `bb snippet list`
[Section titled “bb snippet list”](#bb-snippet-list)
List snippets in a workspace.
```bash
bb snippet list [options]
```
### Options
[Section titled “Options”](#options)
| Option | Description |
| ------------------ | ------------------------------------------------------------------------ |
| `--role ` | Filter by authenticated user’s role: `owner`, `contributor`, or `member` |
| `--limit