bbt is a .NET CLI for Bitbucket Cloud pull request workflows.
It supports profile-based authentication, PR read/write operations, structured JSON output for scripting, and a raw API command for endpoints that are not wrapped yet.
dotnet tool install --global MkDevForge.BbtVerify:
bbt --versionFirst run after install:
bbt auth loginbbt auth login is interactive by default (prompts for email and token).
For non-interactive use, pass credentials explicitly:
bbt auth login --email <atlassian-email> --token <api-token>- Bitbucket Cloud account
- Bitbucket API token
- Atlassian email address for HTTP Basic auth (
email:token) - Optional:
jqif you want to use--jq
Minimum token scopes required by bbt:
read:repository:bitbucketread:workspace:bitbucketread:user:bitbucketread:pullrequest:bitbucketwrite:pullrequest:bitbucket
- From your Bitbucket repo folder, login:
bbt auth login- List open pull requests (workspace/repo inferred from git
origin):
bbt pr list- View the PR for your current branch (or pass an explicit id):
bbt pr view- Get structured diff JSON:
bbt pr diff <id> --jsonbbt auth login [--email <email>] [--token <token>] [--workspace <slug>] [--profile <name>]bbt auth switch <profile>bbt auth status [--check]bbt auth logout [--profile <name>]
auth login validates credentials with Bitbucket before saving. If --workspace is provided, it also validates access and stores it as the profile default workspace.
auth status --check performs a live API check.
If --email/--token are omitted, auth login prompts interactively (unless stdin is redirected). When prompting for a token, it prints the minimum required scopes above.
bbt pr list [--state <STATE>] [--limit <n>]bbt pr view [<id>]bbt pr diff [<id>] [--include-raw]bbt pr comments [<id>] [--limit <n>] [--sort <expr>] [--page <n>] [--pagelen <n>] [--paginate] [--contains <text> | -q/--query <expr>]bbt pr threads [<id>] [--limit <n>] [--sort <expr>] [--pagelen <n>] [--contains <text> | -q/--query <expr>]bbt pr comment <id> (--body <text> | --body-file <path>) [--reply-to <comment-id>] [--file <path> --line <n> [--line-end <n>] [--side <to|from>]]bbt pr review <id> (--approve|--unapprove|--request-changes|--unrequest-changes) [--body <text>|--body-file <path>]
Notes:
- For
pr view,pr diff,pr comments, andpr threads,<id>is optional. - If
<id>is omitted,bbttries to resolve the PR from your current git branch. pr listdefaults to--state OPEN.pr commentandpr reviewalways require explicit PR id.- Inline comments default to
--side to(new side). pr commentsdefaults to newest-first (--sort -created_on) and returns one page by default (50 comments). Use--paginate, a larger--pagelen, or--limitto fetch more.pr threadsgroups comments into discussion threads (root + replies, including nested replies). Threads are ordered by discovery sort (default:--sort -created_on); with--contains/-q, ordering is based on the newest matching comment. Defaults:--limit 20,--pagelen 100.pr review --body/--body-fileposts a global comment first, then performs the review action.
Use this during code review to focus on discussions instead of a flat comment list.
# newest active threads for the PR of your current branch
bbt pr threads
# filter threads that mention a phrase (matches any comment in the thread)
bbt pr threads --contains "AI Code Review"
# JSON thread objects: root + replies + lastActivityOn
bbt pr threads --json
# root ids only (one per line)
bbt pr threads --quiet
# fetch more threads (may require more API calls)
bbt pr threads --limit 50bbt api <PATH> <METHOD> [--input <file>] [--paginate]
--paginate follows Bitbucket next links and emits a merged values array.
bbt api <METHOD> <PATH> ... is also accepted.
Path placeholders:
{workspace}{repo}/{repo_slug}
Example:
bbt api "/repositories/{workspace}/{repo}/pullrequests?state=OPEN&pagelen=10" GET --paginate --jsonbbt llmsbbt llms --json
Use this to print a single, complete CLI capability reference for AI/automation tooling.
Most commands support:
--jsonfor structured output--fields <csv>to keep top-level fields from JSON output--jq <expr>to pipe JSON through externaljq--quietfor minimal output--verbosefor request diagnostics to stderr--no-retryto disable transient retry/backoff
Rules:
--fieldsand--jqrequire--json--jsonand--quietare mutually exclusivejqis optional unless--jqis used
When a command needs workspace/repo, resolution order is:
- CLI flags (
--workspace,--repo) - Environment (
BBT_WORKSPACE,BBT_REPO) - Current profile defaults
- Git
originURL (https://bitbucket.org/<workspace>/<repo>.gitorgit@bitbucket.org:<workspace>/<repo>.git)
Workspace and repo can come from different sources in the same invocation.
BBT_EMAILBBT_TOKENBBT_WORKSPACEBBT_REPOBBT_BASE_URL(default:https://api.bitbucket.org/2.0)BBT_ALLOW_INSECURE_HTTP(set to allow sending credentials overhttp://URLs; not recommended)BBT_DISABLE_CRL_CHECK(set to disable TLS certificate revocation checking)
Environment values override profile values.
- Non-secret config is stored in
config.jsonunder OS-specific app config directories. - Tokens are stored in:
- macOS: Keychain
- Windows: Credential Manager
- Linux:
secret-toolwhen available - Linux fallback: token file with restrictive permissions (
0600)
- Bitbucket Cloud only
- API token auth only (no OAuth flow yet)
- No dedicated
pr comment editcommand yet (you can usebbt api PUT .../comments/{id})
MIT. See LICENSE.