bb
bb is a gh-style CLI for Bitbucket Cloud: one binary for pull requests, repositories,
Pipelines and raw API calls, usable by people and by scripts and AI agents alike.
If you know gh, you know bb. Commands, flags and flag values are gh’s, with gh’s meaning.
Bitbucket’s own names work too, as extras: pr decline = pr close, pipeline = run,
workspace = org, pipeline stop = run cancel, --state declined.
bb pr list # open PRs in the current repository
bb pr view 42 --json | jq .state
bb pr checks --watch # CI status of the current branch's PR
bb run view --log-failed # logs of the failed steps of the latest pipeline
bb api /user
Where to go next:
- Install
bbwith Homebrew, Cargo or a prebuilt binary. - Authenticate with an Atlassian API token.
- Read the conventions every command follows, then the command reference.
- Scripting? See JSON output and exit codes.
- Using an AI coding agent? See the agent skill.
Scope
bb targets Bitbucket Cloud (api.bitbucket.org/2.0). Not in scope: Bitbucket Server /
Data Center, Bitbucket issues, multiple accounts, OAuth browser login, shell completions,
user-defined aliases and extensions, and gh’s --json FIELDS / --jq / --template
(bb --json prints the raw API JSON; pipe it to jq).
The full design, including every deliberate difference from gh, is in
PRD.md.
Install
Homebrew (macOS and Linux)
brew install pallewela/tap/bb
brew update && brew upgrade pallewela/tap/bb # upgrade later
The tap covers macOS and Linux on both arm64 and x86_64. Always use the full name
pallewela/tap/bb: plain bb also matches an unrelated cask.
Cargo
cargo install bitbucket-bb-cli # from crates.io; installs the `bb` binary
cargo install --path . # from a clone of the repository
On crates.io the crate is bitbucket-bb-cli (bb, bb-cli and bitbucket-cli are other
projects). Building it needs Rust and a C compiler.
Prebuilt binaries
Every release on the releases page has an archive per
platform, named bb-vX.Y.Z-TARGET.tar.gz (.zip on Windows), each with a .sha256 file:
| Target | Platform |
|---|---|
aarch64-apple-darwin | macOS, Apple silicon |
x86_64-apple-darwin | macOS, Intel |
x86_64-unknown-linux-musl | Linux x86_64, any distro (static) |
aarch64-unknown-linux-musl | Linux arm64, any distro (static) |
x86_64-pc-windows-msvc | Windows x86_64 (.zip with bb.exe) |
Linux binaries are statically linked (musl), so one file works on every distro, including Alpine and scratch containers.
On Windows, unzip bb.exe into a folder on your PATH. The binary is unsigned, so SmartScreen may
warn the first time it runs. There is no Scoop or winget package yet.
Check the install:
bb --version
Next: authenticate.
Authentication
bb authenticates with an Atlassian API token and your Atlassian account email (HTTP Basic
email:token; Bitbucket API tokens do not work as Bearer tokens).
1. Create a token
Create a scoped API token for the Bitbucket product at https://id.atlassian.com/manage-profile/security/api-tokens. Give it:
- repository, pull request and pipeline scopes,
read:workspace:bitbucket, forbb org list,read:user, forbb pr comment --edit-last/--delete-last.
Scopes are chosen when the token is created; bb has no --scopes flag.
2. Log in, or use environment variables
bb auth login # prompts, verifies, saves the token to the system keychain
bb auth login --insecure-storage # ...or in plaintext in hosts.json (mode 0600)
export BITBUCKET_EMAIL=... BITBUCKET_TOKEN=... # or use env vars (take precedence)
bb auth login prompts for the email (or takes --email EMAIL) and the token (or reads it from
stdin with --with-token), verifies them against the API, then saves them, replacing any previous
login. It reports where the token was stored. Non-interactive example:
printf '%s' "$TOKEN" | bb auth login --email me@example.com --with-token
Where credentials come from
In order:
BITBUCKET_EMAIL+BITBUCKET_TOKENenvironment variables.- The saved login.
As in gh, the saved token lives in the OS keychain (macOS Keychain, Windows Credential Manager,
or Secret Service on Linux; service bb:bitbucket.org, account = your email), and hosts.json
(mode 0600) holds only the email. hosts.json is in:
$XDG_CONFIG_HOME/bb/ifXDG_CONFIG_HOMEis set,- else
%APPDATA%\bb\on Windows, - else
~/.config/bb/.
With --insecure-storage, or when no keychain is available, the token is written to hosts.json
in plaintext instead. Keychain calls time out (3 s on Linux, 60 s elsewhere to allow for an OS
access prompt) and then fail or fall back rather than hang.
Checking and removing the login
bb auth status # where creds come from, the account, and whether the token works
bb auth status -t # ...and print the token
bb auth token # print the token only (for scripting)
bb auth logout # delete the keychain entry and hosts.json
A command that needs credentials and finds none exits with code 4 (see exit codes).
Token verification uses GET /user. A scoped token without read:user gets 403 there; bb treats
that as valid, because a bad token gets 401.
Only one account is supported: there is no auth switch and no -u/--user flag.
Usage and conventions
These apply to every command.
Choosing the repository
Run bb inside a clone of a Bitbucket repository: the repository is read from the origin git
remote. Anywhere else, pass the global flag -R, --repo WORKSPACE/REPO (a bitbucket.org URL also
works). There is no HOST/ prefix: bb is Cloud only.
bb pr list -R myteam/api
bb pr view https://bitbucket.org/myteam/api/pull-requests/12
Output
Output is human-readable tables and text by default. The global --json flag prints the raw
Bitbucket API JSON instead; lists print one JSON array. See
JSON output and exit codes.
Data goes to stdout. Hints, prompts, notes and errors go to stderr.
Lists
- Lists show 30 items by default (
run list: 20). Use-L, --limit Nto choose how many, or-L 0for all. Pagination is followed automatically up to the limit. - When
-Lis not given and items were left out, a note on stderr says how many were shown of the total and how to see more. Nothing is added to stdout or to--jsonoutput. lsis an alias for everylist.
--web
Where offered, -w, --web opens the resource in the browser instead of printing it (open on
macOS, xdg-open on Linux, rundll32 url.dll,FileProtocolHandler on Windows).
Command aliases
gh name | Bitbucket name |
|---|---|
bb run | bb pipeline |
bb run cancel | bb pipeline stop |
bb org | bb workspace, bb ws |
bb pr close | bb pr decline |
bb pr checkout | bb pr co |
bb pr create, bb repo create | new |
Errors
Error messages go to stderr; API errors show as HTTP <code>: <message>. Exit codes follow gh:
see exit codes.
No prompts
Apart from bb auth login, bb never prompts and has no editor mode. Where gh would prompt for
a missing argument, bb uses a default (for example the current branch’s pull request) or fails.
Destructive commands need an explicit --yes (repo delete, pr comment --delete-last). Pass
bodies with -b TEXT or -F FILE (-F - reads stdin).
Command reference
bb [OPTIONS] <COMMAND>
Commands:
auth Manage credentials
repo Work with repositories
workspace Work with workspaces [alias: org]
pr Work with pull requests
pipeline Work with Bitbucket Pipelines
workflow Run custom pipelines (the `gh workflow` analog)
api Make an authenticated API request
browse Open the repository in the browser
help Print this message or the help of the given subcommand(s)
Global options, accepted by every command:
| Flag | Meaning |
|---|---|
-R, --repo <WORKSPACE/REPO> | Select another repository: WORKSPACE/REPO or a bitbucket.org URL |
--json | Print raw API JSON instead of human-readable output |
-h, --help | Print help |
-V, --version | Print version (top level only) |
The pages in this section list each subcommand’s own flags, taken from bb <command> --help.
bb <command> <subcommand> --help is always the authoritative reference for the version you have
installed.
Each page ends with the differences from gh for that command group: extras are Bitbucket
additions gh lacks, gaps are gh forms bb does not support (with the reason).
bb auth
Manage credentials. See Authentication for how to create a token and where it is stored.
bb auth login
Verify an Atlassian email + API token and save them (token in the system keychain). Replaces any previous login and reports where the token was stored.
| Flag | Meaning |
|---|---|
--email <EMAIL> | Atlassian account email (prompted if absent) |
--with-token | Read the API token from stdin |
--insecure-storage | Store the token in plaintext in the config file instead of the system keychain |
bb auth status
Show where credentials come from (env / keychain / plaintext file), the account if readable, and whether the token works.
| Flag | Meaning |
|---|---|
-t, --show-token | Also print the API token |
bb auth logout
Delete the saved login (keychain entry and config file).
bb auth token
Print the API token (for scripting).
Differences from gh
- Extra:
auth login --email. Bitbucket API tokens authenticate asemail:token, so the email is required. - Gap: no
auth login -w/--web(no OAuth),-p/--git-protocol(git is always SSH, seerepo clone) or-s/--scopes(scopes are chosen when the token is created). - Gap: no
-u/--useronlogout/token, and noauth status -a(single account).
bb repo
Work with repositories.
bb repo list (alias ls)
bb repo list [OPTIONS] [WORKSPACE]
List repositories in a workspace (default: the current repo’s workspace). Columns: full name, visibility, language, updated.
| Flag | Meaning |
|---|---|
-L, --limit <N> | Maximum number of repositories to list [default: 30; 0 = all] |
--visibility <VISIBILITY> | Filter by visibility: public, private |
-l, --language <LANGUAGE> | Filter by primary language |
--fork | Show only forks |
--source | Show only non-forks |
bb repo view
bb repo view [OPTIONS] [REPO]
Show a repository: name, description, main branch, visibility, clone URLs, web URL. REPO is
WORKSPACE/REPO or a URL (default: the current repo).
| Flag | Meaning |
|---|---|
-w, --web | Open in the browser |
-b, --branch <BRANCH> | Show this branch’s latest commit (with --web: open the branch). --json still prints the repository. |
bb repo clone
bb repo clone [OPTIONS] <REPO> [DIR] [-- <GIT_ARGS>...]
Clone a repository over SSH (git@bitbucket.org:WORKSPACE/REPO.git). Arguments after -- are
passed to git clone.
bb repo create (alias new)
bb repo create [OPTIONS] <REPO>
Create a repository WORKSPACE/REPO (private by default).
| Flag | Meaning |
|---|---|
--private | Make the repository private (default) |
--public | Make the repository public |
-d, --description <DESCRIPTION> | Repository description |
-p, --project <PROJECT> | Project key to create the repository in |
-c, --clone | Clone the new repository afterwards |
bb repo delete
bb repo delete [OPTIONS] [REPO]
Delete a repository (default: the current repo). Refuses without --yes.
| Flag | Meaning |
|---|---|
--yes | Confirm deletion |
Differences from gh
repo listwith no argument uses the current repo’s workspace rather than “your” repos, because Bitbucket removed the cross-workspace listing.- Extra:
repo create -p/--project KEY(Bitbucket projects). - Gap:
repo createis private by default and needsWORKSPACE/REPO;bbdoesn’t prompt. - Gap:
repo deleterefuses without--yesinstead of prompting. - Gap:
repo cloneis SSH only (API tokens don’t work for git over HTTPS); no fork/upstream flags. - Gap: no
repo list --archived/--no-archived,--visibility internalor--topic(Bitbucket has no archived flag, internal visibility or topics). - Gap:
repo view -bshows the branch’s head commit rather than its README.
bb workspace (aliases org, ws)
Work with workspaces. bb org list is the gh org list analog.
bb workspace list (alias ls)
List workspaces you can access. Columns: slug, role (admin/member). Needs the
read:workspace:bitbucket token scope; a 403 explains that.
| Flag | Meaning |
|---|---|
--admin | Only workspaces you administer |
-L, --limit <N> | Maximum number of workspaces to list [default: 30; 0 = all] |
Differences from gh
- Extra:
--admin(Bitbucket’s per-workspace admin flag);workspaceandwsas Bitbucket names fororg.
bb pr
Work with pull requests.
[PR] is a numeric id (optionally #12), a PR URL, or a branch name, as in gh. A branch, or an
omitted [PR] (meaning the current git branch), resolves to the open PR whose source is that
branch, else the most recently updated PR from it in any state. Scripts and agents should pass an
explicit id for every write.
bb pr list (alias ls)
List pull requests. Columns: id, title, source branch, author, state (+ draft).
| Flag | Meaning |
|---|---|
-s, --state <STATE> | open, closed (merged, declined or superseded), merged, all, declined, superseded [default: open] |
-A, --author <AUTHOR> | Filter by author username |
-B, --base <BASE> | Filter by base (destination) branch |
-H, --head <HEAD> | Filter by head (source) branch |
-S, --search <QUERY> | Search pull request titles and descriptions (substring match) |
-d, --draft | Only draft pull requests |
-w, --web | Open the pull request list in the browser |
-L, --limit <N> | Maximum number of pull requests to list [default: 30; 0 = all] |
How --state maps to Bitbucket states:
--state | Bitbucket states | |
|---|---|---|
open | OPEN | gh |
merged | MERGED | gh |
closed | MERGED, DECLINED, SUPERSEDED | gh (gh’s closed includes merged) |
all | all four | gh |
declined | DECLINED | extra |
superseded | SUPERSEDED | extra |
bb pr view [PR]
Show a pull request: title, state, author, branches, reviewers and approval status, description, URL.
| Flag | Meaning |
|---|---|
-c, --comments | Also show comments |
-w, --web | Open in the browser |
bb pr create (alias new)
Create a pull request and print its URL. The head defaults to the current branch, the base to the repository’s main branch.
| Flag | Meaning |
|---|---|
-t, --title <TITLE> | Title |
-b, --body <BODY> | Description |
-F, --body-file <FILE> | Read the body from FILE (- for stdin) |
-B, --base <BASE> | Base (destination) branch (default: repo main branch) |
-H, --head <HEAD> | Head (source) branch (default: current branch) |
-d, --draft | Mark the pull request as a draft |
-r, --reviewer <REVIEWER> | Reviewer UUID ({...}) or account_id; repeatable |
--close-source-branch | Close the source branch when the pull request is merged |
-f, --fill | Use commit info for title and body |
--fill-first | Use the first commit’s info for title and body |
--fill-verbose | Use commit messages and bodies for the description |
--dry-run | Print what would be created instead of creating it |
-w, --web | Open the create page in the browser instead |
Fill modes read the commits in origin/BASE..HEAD (falling back to the last commit). --fill uses
one commit’s subject and body, or for several commits the humanized branch name as title and a
commit list as body. Explicit -t/-b win.
bb pr checkout PR (alias co)
Check out a pull request’s source branch.
| Flag | Meaning |
|---|---|
-b, --branch <BRANCH> | Local branch name to use (default: the source branch name) |
-f, --force | Reset the existing local branch to the pull request’s state |
--detach | Check out with a detached HEAD |
bb pr diff [PR]
Show a pull request’s diff.
| Flag | Meaning |
|---|---|
--name-only | Only list the names of changed files |
--patch | Show the diff in patch format (one patch per commit) |
--color <COLOR> | always, never or auto [default: auto] |
-e, --exclude <PATTERN> | Exclude files whose path or file name matches a glob (repeatable) |
-w, --web | Open the diff in the browser |
bb pr merge [PR]
Merge a pull request.
| Flag | Meaning |
|---|---|
-m, --merge | Merge commit (Bitbucket merge_commit) |
-s, --squash | Squash the commits into one (Bitbucket squash) |
-r, --rebase | Rebase the commits onto the base branch (Bitbucket rebase_fast_forward) |
--fast-forward | Fast-forward only (Bitbucket fast_forward) |
--rebase-merge | Rebase, then create a merge commit (Bitbucket rebase_merge) |
--squash-fast-forward | Squash, then fast-forward (Bitbucket squash_fast_forward) |
-t, --subject <SUBJECT> | Subject text for the merge commit |
-b, --body <BODY> | Body text for the merge commit |
-F, --body-file <FILE> | Read the merge commit body from FILE (- for stdin) |
-d, --delete-branch | Delete the source branch on Bitbucket and locally after merge |
--close-source-branch | Close the source branch on Bitbucket after merge (keeps the local branch) |
bb pr close [PR] (alias decline)
Close (decline) a pull request.
| Flag | Meaning |
|---|---|
-c, --comment <COMMENT> | Leave a closing comment |
-d, --delete-branch | Delete the source branch on Bitbucket and locally after closing |
bb pr review [PR]
Add a review: approve, request changes or comment. One of -a, -r, -c is required; a body is
required for -r and -c and is posted as a comment.
| Flag | Meaning |
|---|---|
-a, --approve | Approve the pull request |
-r, --request-changes | Request changes on the pull request |
-c, --comment | Comment on the pull request |
-b, --body <BODY> | Review body |
-F, --body-file <FILE> | Read the review body from FILE (- for stdin) |
bb pr approve / unapprove [PR]
Approve a pull request, or remove your approval.
bb pr request-changes [PR]
Request changes on a pull request.
| Flag | Meaning |
|---|---|
--undo | Withdraw the change request |
bb pr comment [PR]
Comment on a pull request.
| Flag | Meaning |
|---|---|
-b, --body <BODY> | Comment text |
-F, --body-file <FILE> | Read the comment from FILE (- for stdin) |
--file <FILE> | File path for an inline comment |
--line <LINE> | Line (new version) for an inline comment |
--edit-last | Edit your last comment instead of adding one |
--create-if-none | With --edit-last: add a comment if you have none |
--delete-last | Delete your last comment (needs --yes) |
--yes | Confirm --delete-last |
-w, --web | Open the pull request in the browser to comment there |
--edit-last and --delete-last find your newest comment via GET /user, so the token needs the
read:user scope.
bb pr comments [PR]
List comments on a pull request: author, location (if inline), body.
bb pr checks [PR]
Show build statuses for a pull request: state, name, URL. Exits 1 if any check failed or was stopped, 8 if any is still in progress, 0 otherwise (including when no checks are reported).
| Flag | Meaning |
|---|---|
--watch | Watch checks until they finish |
-i, --interval <SECONDS> | Refresh interval in seconds for --watch [default: 10] |
--fail-fast | Stop watching at the first failed check |
-w, --web | Open the pull request in the browser |
Differences from gh
- Extra:
pr declineis the Bitbucket name forpr close; both work. - Extra:
pr approve,pr unapproveandpr request-changes [--undo]alongsidegh’spr review -a/-r/-c. - Extra:
pr comments(ghonly haspr view --comments, whichbbalso supports). - Extra:
pr comment --file/--linefor inline comments. - Extra:
pr create --close-source-branch;pr merge --fast-forward,--rebase-merge,--squash-fast-forwardand--close-source-branch.-r/--rebaseusesrebase_fast_forward, the closest togh’s rebase. - Gap:
pr create -r/--reviewerneeds a UUID or account_id, not a handle: Bitbucket can’t look users up by nickname. - Gap: no labels, assignees or milestones (Bitbucket has none).
- Gap: no
pr checks --required,pr merge --auto/--admin/--match-head-commit,pr create --no-maintainer-edit/--recover/--attach,pr comment --attach, or-e/--editor. - Gap:
pr list -Sis a substring match on title and description, not GitHub search syntax. - Gap:
pr checkswith nothing reported prints “No checks reported” and exits 0.
bb pipeline (alias run)
Work with Bitbucket Pipelines. bb run is the gh run name; bb pipeline is the Bitbucket name.
Both work everywhere on this page.
[ID] is a build number or a pipeline UUID. Omitted, it is the latest pipeline for the current git
branch.
bb pipeline list (alias ls)
List recent pipelines, newest first: build number, state/result, ref, trigger, creator, created.
| Flag | Meaning |
|---|---|
-b, --branch <BRANCH> | Only pipelines for this branch (including pull request pipelines from it) |
-s, --status <STATUS> | Only pipelines with this status (see below) |
-u, --user <USER> | Only pipelines started by this user (nickname, display name, account ID, UUID or @me) |
-c, --commit <SHA> | Only pipelines for this commit (full or abbreviated SHA) |
-w, --workflow <NAME> | Only runs of this pipeline (custom pipeline name or branch pattern) |
-e, --event <EVENT> | Only pipelines with this trigger: push, pull_request, workflow_dispatch (= manual), schedule, parent_step |
-L, --limit <N> | Maximum number of pipelines to list [default: 20; 0 = all] |
--status accepts gh’s values and Bitbucket’s:
| Value | Bitbucket states |
|---|---|
queued, pending, requested | PENDING, PARSING |
in_progress | BUILDING, PAUSED, HALTED |
waiting, action_required | PAUSED, HALTED |
completed | PASSED, FAILED, ERROR, STOPPED |
success | PASSED |
failure | FAILED |
cancelled | STOPPED |
startup_failure | ERROR |
| Bitbucket extras | successful, failed, error, stopped, running, paused, halted, parsing |
All filters run server-side. A nickname, display name or account ID for -u is looked up among the
creators of the 500 most recent pipelines (the API can’t filter by name); a UUID or @me is exact.
bb pipeline view [ID]
Show a pipeline and its steps, or its logs.
| Flag | Meaning |
|---|---|
-j, --job <STEP> | Only this step (name, case-insensitive, or UUID) |
--log | Print the full log (of all steps, or of --job) |
--log-failed | Print the log of failed steps only |
--exit-status | Exit with non-zero status if the pipeline failed |
-v, --verbose | Steps are always shown; accepted for gh compatibility |
-w, --web | Open the pipeline in the browser |
bb pipeline watch [ID]
Watch a pipeline until it finishes, printing each pipeline and step status change. It also stops (exit 0) when the pipeline is paused or halted waiting for a manual step.
| Flag | Meaning |
|---|---|
--exit-status | Exit with non-zero status if the pipeline fails |
-i, --interval <N> | Refresh interval in seconds [default: 3] |
bb pipeline run
Trigger a pipeline on a branch. See also bb workflow run, the gh form.
| Flag | Meaning |
|---|---|
-r, --ref <BRANCH> (alias --branch) | Branch to run on (default: the current branch) |
-f, --raw-field <KEY=VALUE> (alias --var) | Pipeline variable (repeatable) |
-F, --field <KEY=VALUE> | Pipeline variable; VALUE @file reads a file, @- stdin (repeatable) |
--pipeline <NAME> | Custom pipeline name (from bitbucket-pipelines.yml custom:) |
bb pipeline cancel ID (alias stop)
Cancel (stop) a running pipeline.
bb pipeline logs [ID]
Print step logs: all steps in order by default. The same as run view --log / --log-failed /
-j.
| Flag | Meaning |
|---|---|
--step <NAME|UUID> | Only this step (name, case-insensitive, or UUID) |
--failed | Only failed steps |
Differences from gh
- Extra:
pipeline,pipeline stopandpipeline logsas Bitbucket names;run list -saccepts Bitbucket’s status names;-uaccepts a UUID or display name. - Extra:
pipeline run --branch/--pipeline/--var(and-r/--ref,-f,-F). run view/run watchwithout an ID use the latest pipeline for the current branch instead of prompting.run view -jneeds the pipeline ID too.run watchprints status-change lines rather than redrawing the screen.- Gap: no
run rerun: the Bitbucket Cloud REST API has no endpoint to re-run a pipeline or its failed steps. Start a new run withworkflow run/pipeline run. - Gap: no
run list --created,-a/--all; norun view -a/--attempt; norun cancel --force; norun watch --compact; norun delete,run download.
bb workflow
Run custom pipelines (the gh workflow analog).
bb workflow run [NAME]
Run a custom pipeline NAME (from bitbucket-pipelines.yml custom:), or, with no NAME, the
default pipeline for the ref. The ref defaults to the repository’s main branch, as in gh.
| Flag | Meaning |
|---|---|
-r, --ref <BRANCH> (alias --branch) | Branch to run on (default: the main branch) |
-f, --raw-field <KEY=VALUE> (alias --var) | Pipeline variable (repeatable) |
-F, --field <KEY=VALUE> | Pipeline variable; VALUE @file reads a file, @- stdin (repeatable) |
bb workflow run deploy -r main -f ENV=staging
Differences from gh
- Gap:
workflow run --json(inputs as JSON on stdin) clashes with the global--jsonflag; use-f/-F.--reftakes a branch only. - Gap: no
workflow list/view/enable/disable: custom pipelines live inbitbucket-pipelines.yml, and there is no API to list or toggle them.
bb api
bb api [OPTIONS] <PATH>
Make an authenticated API request. PATH is relative to /2.0, or a full URL.
| Flag | Meaning |
|---|---|
-X, --method <METHOD> | HTTP method (default GET, or POST when a body or fields are given) |
-f, --raw-field <KEY=VALUE> | Add a string field (repeatable). Fields form a JSON body, or the query string for GET or with --input |
-F, --field <KEY=VALUE> | Add a typed field (repeatable): true/false/null/integers become JSON values; @FILE or @- reads the value |
-H, --header <KEY:VALUE> | Add a request header (repeatable) |
--input <FILE> | Raw JSON body from FILE, or - for stdin |
-i, --include | Print the response status line and headers before the body |
--silent | Do not print the response body |
--verbose | Print the request and response headers to stderr (the Authorization header is never shown) |
--paginate | Follow next links and print the concatenated values array (GET only) |
Output is the response body, pretty-printed if it is JSON. On a non-2xx status the body is still
printed, then HTTP <code>: <message> goes to stderr and the exit code is 1.
bb api /user
bb api /repositories/myteam/api/pullrequests --paginate | jq '.[].title'
echo '{"content":{"raw":"hi"}}' | bb api /repositories/myteam/api/pullrequests/7/comments --input -
Differences from gh
- Deliberate:
--paginateprints one combined array of every page’svalues, not each page in turn, sojq '.[]'works as withgh.--slurpis not accepted. - Gap:
--paginatecan’t be combined with-H,-ior--verbose. - Gap: no nested field syntax (
key[sub]=v,key[]=v) and no{owner}/{repo}/{branch}placeholders; use--inputfor nested bodies.--inputmust be JSON. - Gap:
-i/--verboseshow HTTP/1.1 and lowercased header names (as received). --jq,--template,--cache,-p/--previewand--hostnameare out of scope.
bb browse
bb browse [OPTIONS] [NUMBER|PATH|SHA]
Open the repository on bitbucket.org. As in gh browse, the argument is a PR if it is a number, a
commit if it is 7 to 40 lowercase hex characters, and otherwise a file or directory path relative
to the repository root (PATH:LINE or PATH:START-END selects lines).
| Flag | Meaning |
|---|---|
-b, --branch <BRANCH> | Branch to browse (default with PATH: current branch, else the main branch) |
-c, --commit[=<SHA>] | Browse at a commit: --commit=SHA, or the last commit when no SHA is given |
--blame | Open the blame view for a file |
-s, --settings | Open the repository settings |
-a, --actions | Open the repository’s Pipelines (the gh Actions analog) |
-w, --wiki | Open the repository wiki |
-n, --no-browser | Print the URL instead of opening a browser |
bb browse src/main.rs:10-20 -n
bb browse 42
Differences from gh
- Gap:
-p/--projectsand-r/--releaseshave no Bitbucket equivalent. - Gap:
--commitand--branchcan’t be combined (ingh,--commitwins).
JSON output and exit codes
--json
The global --json flag prints the raw Bitbucket API JSON instead of a table. List commands
print a single JSON array of the items from every page they fetched. There is no field selection:
pipe to jq.
bb pr list --json | jq -r '.[] | "\(.id)\t\(.title)"'
bb pr view 42 --json | jq '{state, draft, branch: .source.branch.name}'
bb run list -b main -L 1 --json | jq '.[0].state'
Notes such as “Showing 30 of 120…” go to stderr, never into the --json output, so stdout is
always one valid JSON document.
gh’s --json FIELDS, --jq and --template are not supported (they are a v1 non-goal).
Fields you will commonly need
Pull request (pr view --json, items of pr list --json):
.id, .title, .state (OPEN, MERGED, DECLINED, SUPERSEDED), .draft,
.source.branch.name, .destination.branch.name, .author.display_name,
.participants[] | {approved, state, role} (state is "changes_requested" when a reviewer
requested changes), .links.html.href, .updated_on.
Check (pr checks --json items): .state (SUCCESSFUL, FAILED, INPROGRESS, STOPPED),
.name, .key, .url.
Pipeline (run list --json items, newest first): .build_number, .state.name
(PENDING, IN_PROGRESS, COMPLETED), .state.result.name (SUCCESSFUL, FAILED, ERROR,
STOPPED), .target.ref_name. run view N --json prints {pipeline, steps}.
Comment (pr comments --json items): .id, .content.raw, .user.account_id, .deleted,
.inline.path, .links.self.href.
repo view -b BRANCH --json still prints the repository, not the branch.
Exit codes
Exit codes follow gh. Check the exit code rather than parsing error text.
| Exit | Meaning |
|---|---|
| 0 | Success. For pr checks: all checks passed, or none were reported. |
| 1 | Error (including an API error, shown as HTTP <code>: <message> on stderr). Also: pr checks when a check failed or was stopped; run view --exit-status / run watch --exit-status when the pipeline failed; bb api on a non-2xx response. |
| 2 | Usage error: an unknown flag or a bad argument (reported by the argument parser). Fix the command; don’t retry it as-is. |
| 4 | Authentication required: no usable credentials. Run bb auth login or set BITBUCKET_EMAIL + BITBUCKET_TOKEN. |
| 8 | pr checks: some checks are still in progress. Wait (bb pr checks ID --watch) or report “pending”. |
bb has no interactive prompts to cancel, so unlike gh it never uses exit code 2 to mean
“cancelled”.
pr checks --json still prints the JSON array of checks when it exits 1 or 8, so a script can tell
“a check failed” (exit 1 and an array on stdout) from a real error (exit 1 and no JSON):
out="$(bb pr checks 42 --json 2>/dev/null)"; rc=$?
if jq -e 'type == "array"' >/dev/null 2>&1 <<<"$out"; then
case $rc in 0) echo passing ;; 1) echo failing ;; 8) echo pending ;; esac
else
echo "could not read checks (exit $rc)" >&2
fi
Agent skill
skills/bitbucket-cli/SKILL.md
is an agent skill that teaches AI coding agents to use bb safely. It adds no commands; it
documents how an agent should use the ones in this book.
Install for Claude Code
From a clone of the repository:
ln -s "$PWD/skills/bitbucket-cli" ~/.claude/skills/bitbucket-cli
The skill triggers when the git remote is bitbucket.org, or the user mentions Bitbucket, a
Bitbucket PR, or Pipelines. It is not for GitHub (gh) or Bitbucket Server/Data Center.
What it teaches
- Read with
--json, parse withjq. Human tables can change; the JSON is the API’s. - Reads are free; writes need the user’s go-ahead. Create, merge, close, approve, review,
comment, pipeline run/cancel, repo create/delete and non-GET
bb apicalls only when the user asked for that action on that object. - Name the PR by id for every write. A branch (or no argument) resolves to the open PR for that branch, else the most recently updated PR of any state, possibly an old merged one.
- Match branches exactly, and confirm a list result with
bb pr view ID --jsonbefore acting on it:pr listcan lag for a while after a write. - Never prompt or open a browser: no
bb auth login,-w/--weborbb browsefrom an agent; pass bodies with-bor-F. - Use
-L 0when completeness matters. - Keep secrets out of output: never
bb auth tokenorbb auth status -t. - Check exit codes 1, 2, 4 and 8 (see exit codes).
Recipes
The skill’s workflows are shell functions, each in a bash block starting with # recipe: NAME:
| Recipe | What it does |
|---|---|
bb_pr_is_open ID BRANCH [BASE] | Exit 0 if pr view says the PR is open, from BRANCH (into BASE) |
bb_pr_for_branch BRANCH [BASE] | Print the id of the one open PR from BRANCH; fail rather than guess |
bb_checks_state ID [--watch] | Print passing, failing, pending or none |
bb_pr_summary ID | Read-only summary: state, branches, approvals, change requests, checks |
bb_failed_logs BRANCH | Failed steps’ logs of the branch’s latest pipeline |
bb_ensure_pr HEAD BASE TITLE [BODY] | Reuse an open PR or create one (after a dry run); print its URL |
bb_upsert_comment ID MARKER BODY | Post or update the agent’s own marked status comment |
bb_safe_merge ID STRATEGY [--allow-no-checks] | Merge only if open, not a draft, no change requests, checks passed |
How it is tested
tests/skill/run.sh(run bycargo test; needsjq) extracts the recipe blocks from SKILL.md, runs them against a mockbb(tests/skill/mock-bb) with a fixture, asserts they pick the right PR and make only the expected writes, then replays each command line against the realbbto catch flags that no longer exist.scripts/skill-e2e.shruns the same recipes against a throwaway repository on Bitbucket.scripts/skill-eval.shtests the agent: it givesclaude -prealistic requests in a scratch checkout wherebbis the mock, and scores whether the right PR was used and only the expected writes were made. It costs API usage and is run by hand.
The skill is part of bb’s interface: a change to a command, flag, default, --json shape, exit
code or PR resolution rule that the skill mentions updates SKILL.md (and the mock) in the same
change.
Releases and platforms
How releases happen
Every push to main that passes CI is released automatically by
.github/workflows/release.yml.
The patch version is bumped by default. Put one of these in the head commit’s subject to change that
(the same text in the body is ignored; only BREAKING CHANGE counts anywhere in the message):
| Marker | Effect |
|---|---|
[bump:minor] | Bump the minor version |
[bump:major] or BREAKING CHANGE | Bump the major version |
[skip release] | Don’t release this push |
See CONTRIBUTING.md for how this works with squash merges.
Pull requests build every target too (without publishing), so a change that breaks one platform’s
build is caught before it reaches main.
Targets
Each release publishes one archive per target, built and checked on a native GitHub runner:
| Target | Platform | Archive | Check before publishing |
|---|---|---|---|
aarch64-apple-darwin | macOS, Apple silicon | .tar.gz | runs bb --version |
x86_64-apple-darwin | macOS, Intel (cross-built on arm64) | .tar.gz | lipo -archs is x86_64 |
x86_64-unknown-linux-musl | Linux x86_64, any distro | .tar.gz | runs bb --version; no shared libraries |
aarch64-unknown-linux-musl | Linux arm64, any distro | .tar.gz | runs bb --version; no shared libraries |
x86_64-pc-windows-msvc | Windows x86_64 | .zip (bb.exe) | runs bb --version |
Archives are named bb-vX.Y.Z-TARGET.{tar.gz,zip}, contain the binary, LICENSE and
README.md, and come with a .sha256 file. All of them are published in one release call, so a
release is never partial.
Linux binaries are static (musl): TLS is rustls and the keychain (Secret Service) is reached
over D-Bus with pure-Rust zbus, so no system library is needed.
Not built: Windows arm64, 32-bit targets, FreeBSD.
Distribution channels
- GitHub Releases: https://github.com/pallewela/bb/releases.
- Homebrew: after a release, the formula in
pallewela/homebrew-tap is updated with each
archive’s SHA256 (needs the
TAP_REPO_TOKENsecret). - crates.io: the crate
bitbucket-bb-cliis published with the same version, using crates.io trusted publishing (GitHub OIDC, no stored token), when the repository variableCRATES_IO_PUBLISHistrue. A version that is already on crates.io is skipped, so re-runs are safe. - Windows: install from the
.zipby hand. No Scoop or winget package yet; the binary is unsigned.
This documentation site
This book lives in docs/ and is built with mdBook. Pushes
to main that change docs/** rebuild and deploy it to GitHub Pages
(.github/workflows/pages.yml). To preview locally:
mdbook serve docs --open