Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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:

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:

TargetPlatform
aarch64-apple-darwinmacOS, Apple silicon
x86_64-apple-darwinmacOS, Intel
x86_64-unknown-linux-muslLinux x86_64, any distro (static)
aarch64-unknown-linux-muslLinux arm64, any distro (static)
x86_64-pc-windows-msvcWindows 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, for bb org list,
  • read:user, for bb 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:

  1. BITBUCKET_EMAIL + BITBUCKET_TOKEN environment variables.
  2. 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/ if XDG_CONFIG_HOME is 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 N to choose how many, or -L 0 for all. Pagination is followed automatically up to the limit.
  • When -L is 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 --json output.
  • ls is an alias for every list.

--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 nameBitbucket name
bb runbb pipeline
bb run cancelbb pipeline stop
bb orgbb workspace, bb ws
bb pr closebb pr decline
bb pr checkoutbb pr co
bb pr create, bb repo createnew

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:

FlagMeaning
-R, --repo <WORKSPACE/REPO>Select another repository: WORKSPACE/REPO or a bitbucket.org URL
--jsonPrint raw API JSON instead of human-readable output
-h, --helpPrint help
-V, --versionPrint 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.

FlagMeaning
--email <EMAIL>Atlassian account email (prompted if absent)
--with-tokenRead the API token from stdin
--insecure-storageStore 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.

FlagMeaning
-t, --show-tokenAlso 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 as email:token, so the email is required.
  • Gap: no auth login -w/--web (no OAuth), -p/--git-protocol (git is always SSH, see repo clone) or -s/--scopes (scopes are chosen when the token is created).
  • Gap: no -u/--user on logout/token, and no auth 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.

FlagMeaning
-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
--forkShow only forks
--sourceShow 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).

FlagMeaning
-w, --webOpen 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).

FlagMeaning
--privateMake the repository private (default)
--publicMake the repository public
-d, --description <DESCRIPTION>Repository description
-p, --project <PROJECT>Project key to create the repository in
-c, --cloneClone the new repository afterwards

bb repo delete

bb repo delete [OPTIONS] [REPO]

Delete a repository (default: the current repo). Refuses without --yes.

FlagMeaning
--yesConfirm deletion

Differences from gh

  • repo list with 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 create is private by default and needs WORKSPACE/REPO; bb doesn’t prompt.
  • Gap: repo delete refuses without --yes instead of prompting.
  • Gap: repo clone is SSH only (API tokens don’t work for git over HTTPS); no fork/upstream flags.
  • Gap: no repo list --archived/--no-archived, --visibility internal or --topic (Bitbucket has no archived flag, internal visibility or topics).
  • Gap: repo view -b shows 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.

FlagMeaning
--adminOnly 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); workspace and ws as Bitbucket names for org.

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).

FlagMeaning
-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, --draftOnly draft pull requests
-w, --webOpen 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:

--stateBitbucket states
openOPENgh
mergedMERGEDgh
closedMERGED, DECLINED, SUPERSEDEDgh (gh’s closed includes merged)
allall fourgh
declinedDECLINEDextra
supersededSUPERSEDEDextra

bb pr view [PR]

Show a pull request: title, state, author, branches, reviewers and approval status, description, URL.

FlagMeaning
-c, --commentsAlso show comments
-w, --webOpen 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.

FlagMeaning
-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, --draftMark the pull request as a draft
-r, --reviewer <REVIEWER>Reviewer UUID ({...}) or account_id; repeatable
--close-source-branchClose the source branch when the pull request is merged
-f, --fillUse commit info for title and body
--fill-firstUse the first commit’s info for title and body
--fill-verboseUse commit messages and bodies for the description
--dry-runPrint what would be created instead of creating it
-w, --webOpen 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.

FlagMeaning
-b, --branch <BRANCH>Local branch name to use (default: the source branch name)
-f, --forceReset the existing local branch to the pull request’s state
--detachCheck out with a detached HEAD

bb pr diff [PR]

Show a pull request’s diff.

FlagMeaning
--name-onlyOnly list the names of changed files
--patchShow 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, --webOpen the diff in the browser

bb pr merge [PR]

Merge a pull request.

FlagMeaning
-m, --mergeMerge commit (Bitbucket merge_commit)
-s, --squashSquash the commits into one (Bitbucket squash)
-r, --rebaseRebase the commits onto the base branch (Bitbucket rebase_fast_forward)
--fast-forwardFast-forward only (Bitbucket fast_forward)
--rebase-mergeRebase, then create a merge commit (Bitbucket rebase_merge)
--squash-fast-forwardSquash, 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-branchDelete the source branch on Bitbucket and locally after merge
--close-source-branchClose the source branch on Bitbucket after merge (keeps the local branch)

bb pr close [PR] (alias decline)

Close (decline) a pull request.

FlagMeaning
-c, --comment <COMMENT>Leave a closing comment
-d, --delete-branchDelete 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.

FlagMeaning
-a, --approveApprove the pull request
-r, --request-changesRequest changes on the pull request
-c, --commentComment 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.

FlagMeaning
--undoWithdraw the change request

bb pr comment [PR]

Comment on a pull request.

FlagMeaning
-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-lastEdit your last comment instead of adding one
--create-if-noneWith --edit-last: add a comment if you have none
--delete-lastDelete your last comment (needs --yes)
--yesConfirm --delete-last
-w, --webOpen 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).

FlagMeaning
--watchWatch checks until they finish
-i, --interval <SECONDS>Refresh interval in seconds for --watch [default: 10]
--fail-fastStop watching at the first failed check
-w, --webOpen the pull request in the browser

Differences from gh

  • Extra: pr decline is the Bitbucket name for pr close; both work.
  • Extra: pr approve, pr unapprove and pr request-changes [--undo] alongside gh’s pr review -a/-r/-c.
  • Extra: pr comments (gh only has pr view --comments, which bb also supports).
  • Extra: pr comment --file/--line for inline comments.
  • Extra: pr create --close-source-branch; pr merge --fast-forward, --rebase-merge, --squash-fast-forward and --close-source-branch. -r/--rebase uses rebase_fast_forward, the closest to gh’s rebase.
  • Gap: pr create -r/--reviewer needs 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 -S is a substring match on title and description, not GitHub search syntax.
  • Gap: pr checks with 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.

FlagMeaning
-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:

ValueBitbucket states
queued, pending, requestedPENDING, PARSING
in_progressBUILDING, PAUSED, HALTED
waiting, action_requiredPAUSED, HALTED
completedPASSED, FAILED, ERROR, STOPPED
successPASSED
failureFAILED
cancelledSTOPPED
startup_failureERROR
Bitbucket extrassuccessful, 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.

FlagMeaning
-j, --job <STEP>Only this step (name, case-insensitive, or UUID)
--logPrint the full log (of all steps, or of --job)
--log-failedPrint the log of failed steps only
--exit-statusExit with non-zero status if the pipeline failed
-v, --verboseSteps are always shown; accepted for gh compatibility
-w, --webOpen 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.

FlagMeaning
--exit-statusExit 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.

FlagMeaning
-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.

FlagMeaning
--step <NAME|UUID>Only this step (name, case-insensitive, or UUID)
--failedOnly failed steps

Differences from gh

  • Extra: pipeline, pipeline stop and pipeline logs as Bitbucket names; run list -s accepts Bitbucket’s status names; -u accepts a UUID or display name.
  • Extra: pipeline run --branch/--pipeline/--var (and -r/--ref, -f, -F).
  • run view / run watch without an ID use the latest pipeline for the current branch instead of prompting. run view -j needs the pipeline ID too.
  • run watch prints 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 with workflow run / pipeline run.
  • Gap: no run list --created, -a/--all; no run view -a/--attempt; no run cancel --force; no run watch --compact; no run 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.

FlagMeaning
-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 --json flag; use -f/-F. --ref takes a branch only.
  • Gap: no workflow list/view/enable/disable: custom pipelines live in bitbucket-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.

FlagMeaning
-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, --includePrint the response status line and headers before the body
--silentDo not print the response body
--verbosePrint the request and response headers to stderr (the Authorization header is never shown)
--paginateFollow 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: --paginate prints one combined array of every page’s values, not each page in turn, so jq '.[]' works as with gh. --slurp is not accepted.
  • Gap: --paginate can’t be combined with -H, -i or --verbose.
  • Gap: no nested field syntax (key[sub]=v, key[]=v) and no {owner}/{repo}/{branch} placeholders; use --input for nested bodies. --input must be JSON.
  • Gap: -i/--verbose show HTTP/1.1 and lowercased header names (as received).
  • --jq, --template, --cache, -p/--preview and --hostname are 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).

FlagMeaning
-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
--blameOpen the blame view for a file
-s, --settingsOpen the repository settings
-a, --actionsOpen the repository’s Pipelines (the gh Actions analog)
-w, --wikiOpen the repository wiki
-n, --no-browserPrint the URL instead of opening a browser
bb browse src/main.rs:10-20 -n
bb browse 42

Differences from gh

  • Gap: -p/--projects and -r/--releases have no Bitbucket equivalent.
  • Gap: --commit and --branch can’t be combined (in gh, --commit wins).

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.

ExitMeaning
0Success. For pr checks: all checks passed, or none were reported.
1Error (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.
2Usage error: an unknown flag or a bad argument (reported by the argument parser). Fix the command; don’t retry it as-is.
4Authentication required: no usable credentials. Run bb auth login or set BITBUCKET_EMAIL + BITBUCKET_TOKEN.
8pr 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 with jq. 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 api calls 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 --json before acting on it: pr list can lag for a while after a write.
  • Never prompt or open a browser: no bb auth login, -w/--web or bb browse from an agent; pass bodies with -b or -F.
  • Use -L 0 when completeness matters.
  • Keep secrets out of output: never bb auth token or bb 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:

RecipeWhat 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 IDRead-only summary: state, branches, approvals, change requests, checks
bb_failed_logs BRANCHFailed 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 BODYPost 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 by cargo test; needs jq) extracts the recipe blocks from SKILL.md, runs them against a mock bb (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 real bb to catch flags that no longer exist.
  • scripts/skill-e2e.sh runs the same recipes against a throwaway repository on Bitbucket.
  • scripts/skill-eval.sh tests the agent: it gives claude -p realistic requests in a scratch checkout where bb is 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):

MarkerEffect
[bump:minor]Bump the minor version
[bump:major] or BREAKING CHANGEBump 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:

TargetPlatformArchiveCheck before publishing
aarch64-apple-darwinmacOS, Apple silicon.tar.gzruns bb --version
x86_64-apple-darwinmacOS, Intel (cross-built on arm64).tar.gzlipo -archs is x86_64
x86_64-unknown-linux-muslLinux x86_64, any distro.tar.gzruns bb --version; no shared libraries
aarch64-unknown-linux-muslLinux arm64, any distro.tar.gzruns bb --version; no shared libraries
x86_64-pc-windows-msvcWindows 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_TOKEN secret).
  • crates.io: the crate bitbucket-bb-cli is published with the same version, using crates.io trusted publishing (GitHub OIDC, no stored token), when the repository variable CRATES_IO_PUBLISH is true. A version that is already on crates.io is skipped, so re-runs are safe.
  • Windows: install from the .zip by 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