Cloud 的 API token 必须在 Atlassian 创建时选择 Bitbucket 应用并授予相应 scope,通用 Atlassian token 不可用;登录用 Atlassian 邮箱而非 Bitbucket 用户名,且 app password 已被移除;无钥匙串的环境需加 --allow-insecure-store 或设 BKT_ALLOW_INSECURE_STORE=1;Homebrew core 与 avivsinai/tap 提供同一个 bkt 命令,只装其一。
bitbucket-cli
avivsinaiMIT活跃维护仿 gh 使用体验的 Bitbucket 命令行工具,用 Go 编写,让 Bitbucket Cloud 和 Data Center 的仓库、PR、CI 操作在终端里像 GitHub CLI 一样顺手。
Bitbucket CLI with gh-like ergonomics
brew install bitbucket-cli
bkt auth login https://bitbucket.org --kind cloud --webREADME 未说明硬件要求;它是 Go 编写的 CLI,可在 macOS、Linux、Windows 上运行,无需 GPU。
一个命令行工具统一管理 Bitbucket Cloud 和 Data Center,沿用 gh 的使用习惯,并输出稳定的 JSON/YAML
仿 gh 使用体验的 Bitbucket 命令行工具,用 Go 编写,让 Bitbucket Cloud 和 Data Center 的仓库、PR、CI 操作在终端里像 GitHub CLI 一样顺手。
核心能力
- 用 gh 风格命令管理 PR、仓库、流水线、分支、权限和 Webhook
- 所有命令提供稳定的 JSON/YAML 输出,并支持 --jq 与 Go 模板
- 内置 MCP server 与 agent skill,供编码代理直接操作 Bitbucket
- bkt api 可用已存凭据调用任意 REST 端点
- 凭据存入系统钥匙串,CI 中可用 BKT_TOKEN 免登录
容易踩的坑
- v0.38.1最新正式版2026-11-09 · 2026-11-09 13:41 UTC
bkt v0.38.1 (2026-11-09T13:39:13Z)
Thanks for trying the Bitbucket CLI!
[0.38.1] - 2026-11-09
Fixed
- Fetch newly created release tags into the packaging checkout before GoReleaser runs. v0.38.0 created its tag but stopped before publishing binaries because GoReleaser selected v0.37.0. This release publishes the mergeability command and Cloud state-filtering fixes documented under 0.38.0 below.
Full Changelog: https://github.com/avivsinai/bitbucket-cli/compare/v0.38.0...v0.38.1
Homebrew (macOS/Linux)
brew install avivsinai/tap/bitbucket-cliScoop (Windows)
scoop bucket add avivsinai https://github.com/avivsinai/scoop-bucket scoop install bitbucket-cliGo Install
go install github.com/avivsinai/bitbucket-cli/cmd/[email protected]Binary Downloads
Pick the archive for your platform from the assets below.
- v0.37.02026-10-25 · 2026-10-25 06:27 UTC
查看更新说明
bkt v0.37.0 (2026-10-25T06:25:00Z)
Thanks for trying the Bitbucket CLI!
[0.37.0] - 2026-10-25
Changed
- Log in again once: run
bkt auth login https://bitbucket.org --kind cloud --web. bkt's Bitbucket Cloud OAuth consumer now grants Repositories Admin, sobkt repo createworks with browser login; before, it failed with "credentials lack one or more required privilege scopes". It also no longer grants unused project-write, workspace-membership, and issue permissions. Bitbucket expires every token issued before this change.
Removed
bkt issuenow explains that Atlassian removed Bitbucket Cloud Issues on 20 August 2026 and exits, instead of calling an API that answers 410 Gone. The command is hidden from help; track issues in Jira.
Full Changelog: https://github.com/avivsinai/bitbucket-cli/compare/v0.36.0...v0.37.0
Homebrew (macOS/Linux)
brew install avivsinai/tap/bitbucket-cliScoop (Windows)
scoop bucket add avivsinai https://github.com/avivsinai/scoop-bucket scoop install bitbucket-cliGo Install
go install github.com/avivsinai/bitbucket-cli/cmd/[email protected]Binary Downloads
Pick the archive for your platform from the assets below.
- Log in again once: run
- v0.36.02026-10-23 · 2026-10-23 05:20 UTC
查看更新说明
bkt v0.36.0 (2026-10-23T05:19:00Z)
Thanks for trying the Bitbucket CLI!
[0.36.0] - 2026-10-22
Fixed
- Bitbucket Cloud browser login (
bkt auth login --kind cloud --web) and OAuth token refresh work in every build, including Homebrew core,go install, and Nix. bkt's OAuth consumer now ships in source, as the GitHub CLI and Git Credential Manager ship theirs, instead of only in release binaries.
Changed
BKT_OAUTH_CLIENT_IDandBKT_OAUTH_CLIENT_SECRETnow select your own OAuth consumer over bkt's, and must be set together. Before, release binaries ignored them. A stored OAuth token refreshes with the consumer that issued it.
Full Changelog: https://github.com/avivsinai/bitbucket-cli/compare/v0.35.2...v0.36.0
Homebrew (macOS/Linux)
brew install avivsinai/tap/bitbucket-cliScoop (Windows)
scoop bucket add avivsinai https://github.com/avivsinai/scoop-bucket scoop install bitbucket-cliGo Install
go install github.com/avivsinai/bitbucket-cli/cmd/[email protected]Binary Downloads
Pick the archive for your platform from the assets below.
- Bitbucket Cloud browser login (
- v0.35.22026-10-20 · 2026-10-20 18:19 UTC
查看更新说明
bkt v0.35.2 (2026-10-20T18:18:12Z)
Thanks for trying the Bitbucket CLI!
[0.35.2] - 2026-10-20
Fixed
- macOS release binaries run on macOS 13 and later again. Releases built on the
macos-latestrunner required macOS 26, so older Macs refused to startbkt.
Changed
- macOS release binaries are signed with a Developer ID (Aviv Sinai, 93ZUZ2PTM9) and notarized by Apple. After this upgrade, macOS asks for Keychain access one last time; later upgrades keep the approval.
Full Changelog: https://github.com/avivsinai/bitbucket-cli/compare/v0.35.1...v0.35.2
Homebrew (macOS/Linux)
brew install avivsinai/tap/bitbucket-cliScoop (Windows)
scoop bucket add avivsinai https://github.com/avivsinai/scoop-bucket scoop install bitbucket-cliGo Install
go install github.com/avivsinai/bitbucket-cli/cmd/[email protected]Binary Downloads
Pick the archive for your platform from the assets below.
- macOS release binaries run on macOS 13 and later again. Releases built on the
- v0.35.12026-10-20 · 2026-10-20 07:21 UTC
查看更新说明
bkt v0.35.1 (2026-10-20T07:19:49Z)
Thanks for trying the Bitbucket CLI!
[0.35.1] - 2026-10-20
Fixed
- Repository auto-detection treats
ssh.bitbucket.orgremotes as Bitbucket Cloud. Bitbucket Cloud moves SSH to this hostname on 12 November 2026 (#357).
Changed
- The release workflow can sign and notarize macOS binaries with a Developer ID.
This release is still signed ad-hoc, so macOS asks again for Keychain access
after
brew upgrade. A Developer ID release will key the Keychain grant to the team ID, so one "Always Allow" then survives upgrades. - Build with
golang.org/x/sys0.49 andgolang.org/x/term0.47.
Full Changelog: https://github.com/avivsinai/bitbucket-cli/compare/v0.35.0...v0.35.1
Homebrew (macOS/Linux)
brew install avivsinai/tap/bitbucket-cliScoop (Windows)
scoop bucket add avivsinai https://github.com/avivsinai/scoop-bucket scoop install bitbucket-cliGo Install
go install github.com/avivsinai/bitbucket-cli/cmd/[email protected]Binary Downloads
Pick the archive for your platform from the assets below.
- Repository auto-detection treats
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
bkt – Bitbucket CLI
bkt is one command-line interface for Bitbucket Cloud and Bitbucket Data Center. It follows the ergonomics of gh, gives every command a stable JSON/YAML output contract, and ships an agent skill and an MCP server so coding agents can work with Bitbucket too.
This project (github.com/avivsinai/bitbucket-cli, binary bkt) is unrelated to the Rust bkt subprocess-caching tool, the Bitbucket Enterprise CLI, and other packages named bitbucket-cli.
Quick start
brew install bitbucket-cli
# Bitbucket Cloud: log in through your browser
bkt auth login https://bitbucket.org --kind cloud --web
bkt context create cloud --host api.bitbucket.org --workspace myteam --set-active
# Bitbucket Data Center: paste a Personal Access Token
bkt auth login https://bitbucket.example.com --web-token
bkt context create dc --host bitbucket.example.com --project ABC --set-active
bkt pr list --mine
bkt pr create --title "feat: cache" --source feature/cache --target main
Inside a clone, bkt takes the workspace or project and the repository from the git remote when the remote points at the active context's host.
Install
| Platform | Command |
|---|---|
| macOS / Linux (Homebrew core) | brew install bitbucket-cli |
| Windows (WinGet) | winget install AvivSinai.Bitbucket-CLI |
| Windows (Scoop) | scoop bucket add avivsinai https://github.com/avivsinai/scoop-bucketscoop install bitbucket-cli |
| Go 1.26+ | go install github.com/avivsinai/bitbucket-cli/cmd/bkt@latest |
| Nix (flakes) | nix profile install github:avivsinai/bitbucket-cli |
| Debian / Ubuntu | .deb from the latest release |
| Any | Archive from the latest release |
Every install method supports Bitbucket Cloud browser login with no extra setup.
- Homebrew tap.
brew install avivsinai/tap/bitbucket-cliinstalls the prebuilt release binary, signed with a Developer ID and notarized, instead of Homebrew's source build. Both provide the samebktcommand, so install only one. - Nix.
nix run github:avivsinai/bitbucket-cli -- --versionrunsmasterwithout installing. Append a ref, such asgithub:avivsinai/bitbucket-cli/v0.36.0, to pin a release. - Release archives also contain
skills/bkt/, so the CLI and its agent skill stay on one version. - Verify a download. Each release publishes
checksums.txt, a CycloneDX SBOM, and GitHub build provenance:gh attestation verify <archive> --repo avivsinai/bitbucket-cli. - From source.
git clone https://github.com/avivsinai/bitbucket-cli && cd bitbucket-cli && make buildproduces./bin/bkt.
Authenticate
bkt auth login checks a credential against the host before it stores it. bkt auth status lists your hosts and when OAuth tokens expire.
Bitbucket Cloud
Browser OAuth (recommended). bkt opens Bitbucket in your browser. After you approve access, bkt stores a short-lived access token and refreshes it automatically:
bkt auth login https://bitbucket.org --kind cloud --web
To use your own OAuth consumer instead of bkt's, set both BKT_OAUTH_CLIENT_ID and BKT_OAUTH_CLIENT_SECRET before you log in.
API token. --web-token opens Atlassian's token page, then prompts for the token:
bkt auth login https://bitbucket.org --kind cloud --web-token
# or non-interactively
bkt auth login https://bitbucket.org --kind cloud --username <atlassian-email> --with-token < token.txt
Create the token under Atlassian account → Security → API tokens with Create API token with scopes. Choose Bitbucket as the app (general Atlassian tokens do not work) and grant:
- Account: Read (
read:user:bitbucket), required - Repositories: Read, Write, plus Admin for
bkt repo create - Pull requests: Read, Write
- Pipelines and Webhooks, if you use
bkt pipeline,bkt variable, orbkt webhook
Log in with your Atlassian account email, not your Bitbucket username. Atlassian has removed app passwords; replace any you still use with an API token.
Bitbucket Data Center
bkt auth login https://bitbucket.example.com --web-token
# or non-interactively
bkt auth login https://bitbucket.example.com --username alice --with-token < pat.txt
Create the Personal Access Token under Profile picture → Manage account → Personal access tokens with Repository Read/Write and Project Read.
Credential storage
Tokens live in the OS keychain: macOS Keychain, Windows Credential Manager, or Secret Service/KWallet on Linux. Host metadata lives in $XDG_CONFIG_HOME/bkt/config.yml and never contains a token.
- No keychain (containers, minimal Linux): pass
--allow-insecure-storeor setBKT_ALLOW_INSECURE_STORE=1to use an encrypted file instead. - Slow unlock prompts: raise
BKT_KEYRING_TIMEOUT, for exampleBKT_KEYRING_TIMEOUT=2m. - A passphrase prompt on every run (Linux): some Secret Service providers, such as KWallet, create a separate wallet for bkt's
bktcollection. SetBKT_KEYRING_COLLECTIONto your provider's default collection (for examplekdewallet) to share the wallet you already unlocked. Add credentials stored under the old collection again. Distributors can set the default at build time with-ldflags -X github.com/avivsinai/bitbucket-cli/internal/secret.defaultKeyringCollection=<collection>; the environment variable still wins. - macOS Keychain prompts: release binaries are signed with one Developer ID, so after you choose Always Allow once, upgrades keep access.
bkt auth doctorexplains prompts that persist; it never reads the stored secret.
CI and containers
Set BKT_TOKEN and BKT_HOST, and bkt needs no login and no config file:
# Data Center
export BKT_HOST=https://bitbucket.example.com BKT_TOKEN=<pat> BKT_PROJECT=MYPROJ BKT_REPO=my-service
# Cloud, user API token (basic auth)
export BKT_HOST=https://bitbucket.org BKT_TOKEN=<api-token> [email protected] \
BKT_WORKSPACE=my-workspace BKT_REPO=my-repo
# Cloud, repository / project / workspace access token (bearer auth)
export BKT_HOST=https://bitbucket.org BKT_TOKEN=<access-token> BKT_AUTH_METHOD=bearer
bkt pr list
Resource access tokens belong to no user. Commands that need a user identity, such as bkt pr list --mine across repositories, still need a user API token or OAuth.
In Bitbucket Pipelines, store BKT_TOKEN and BKT_HOST as secured repository variables and install a pinned release:
pipelines:
default:
- step:
name: Open PR
script:
- export BKT_VERSION=0.36.0 # pin the release you have tested
- curl -fsSL "https://github.com/avivsinai/bitbucket-cli/releases/download/v${BKT_VERSION}/bkt_${BKT_VERSION}_linux_x86_64.tar.gz" | tar xz -C /tmp && install /tmp/bkt /usr/local/bin/
- bkt pr create --title "Auto PR" --source "$BITBUCKET_BRANCH"
| Variable | Purpose |
|---|---|
BKT_TOKEN | Token for every request; bypasses the keychain. |
BKT_HOST | Base URL, for example https://bitbucket.example.com. bitbucket.org selects Cloud. |
BKT_USERNAME | Username for basic auth. Required for Cloud user API tokens. |
BKT_AUTH_METHOD | basic or bearer. Data Center defaults to bearer without BKT_USERNAME; Cloud defaults to basic. |
BKT_PROJECT / BKT_WORKSPACE / BKT_REPO | Default Data Center project, Cloud workspace, and repository. |
BKT_CONFIG_DIR | Config directory (default $XDG_CONFIG_HOME/bkt). |
BKT_OAUTH_CLIENT_ID / BKT_OAUTH_CLIENT_SECRET | Your own Bitbucket Cloud OAuth consumer for --web; set both. |
BKT_ALLOW_INSECURE_STORE | 1 allows the encrypted file store when no keychain exists. |
BKT_KEYRING_TIMEOUT | Keychain operation timeout, for example 2m. |
BKT_KEYRING_COLLECTION | Secret Service collection (Linux). |
BKT_HTTP_DEBUG | 1 logs each request URL and response status. |
Use it
A context binds a host to a default workspace or project, and optionally a repository. bkt auth status prints the host value to pass to --host.
bkt context create cloud --host api.bitbucket.org --workspace myteam --set-active
bkt context list
Repositories
bkt repo list --limit 20
bkt repo view platform-api
bkt repo create data-pipeline --description "Data ingestion" --project DATA # Data Center
bkt repo create frontend-app --workspace myteam --cloud-project WEB # Cloud
bkt repo clone platform-api --project DATA --ssh
bkt repo browse --project DATA --repo platform-api
bkt repo downloads upload before.png after.png # Cloud: host images for PR descriptions
Pull requests
bkt pr list --state OPEN --limit 10
bkt pr create --title "feat: cache" --source feature/cache --target main --reviewer alice
bkt pr checks 42 --wait --timeout 5m # wait for builds, with backoff
bkt pr comments 42 --details # threads with file/line anchors
bkt pr comments resolve 42 1001
bkt pr merge 42 --message "merge: feature/cache"
Issues. Atlassian removed Bitbucket Cloud Issues in August 2026, and Data Center never had them; track issues in Jira.
Pipelines, branches, permissions, webhooks
bkt pipeline run --workspace myteam --repo api --ref main --var ENV=staging
bkt pipeline run --ref master --selector-type custom --selector-pattern deploy-to-production
bkt status pipeline {pipeline-uuid}
bkt branch create release/1.9 --from main
bkt perms repo list --project DATA --repo platform-api
bkt webhook create --name "CI" --url https://ci.example.com/hook --event repo:refs_changed
bkt status rate-limit
Anything else. bkt api calls any REST endpoint with your stored credentials:
bkt api /rest/api/1.0/projects --param limit=100 --json # Data Center
bkt api /repositories --param workspace=myteam --field pagelen=50 # Cloud
Output for scripts. Commands accept --json, --yaml, --jq <expr>, and --template <go-template>.
Extensions. bkt extension install <git-url> adds a bkt-<name> command; bkt extension exec <name> runs it.
Shell completion. bkt completion bash|zsh|fish|powershell. The Homebrew core formula installs completions for you.
The full command reference, generated from bkt --help, is in skills/bkt/rules/.
Coding agents
Agent skill. The bkt skill teaches Claude Code, Codex, and other agents to use bkt:
npx skills add avivsinai/bitbucket-cli -g -y
Alternatives: npx skild install @avivsinai/bkt -t claude -y; the Claude Code marketplace (/plugin marketplace add avivsinai/skills-marketplace, then /plugin install bkt@avivsinai-marketplace); or copy skills/bkt into ~/.claude/skills/.
MCP server. bkt mcp serve exposes read-only Bitbucket tools over MCP stdio for one pinned context:
claude mcp add bitbucket -- bkt mcp serve
Skills hosted on Bitbucket. bkt skill installs Agent Skills from Bitbucket repositories, mirroring gh skill:
bkt skill install myteam/agent-skills # list what a repository publishes
bkt skill install myteam/agent-skills [email protected] --agent claude-code --scope user
bkt skill list
bkt skill update --all
bkt skill publish --tag v1.2.0 # validate and tag your own skills
--agent selects the target agent (Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, and more; see bkt skill install --help). The default, universal, writes to the shared .agents/skills directory. Installed skills record their source in SKILL.md frontmatter, and bkt skill update compares it with the repository; @version or --pin pins a skill until --unpin. bkt skill search uses the Bitbucket Cloud code-search API, which Atlassian has announced for deprecation; Data Center has no equivalent API.
Troubleshooting
BKT_HTTP_DEBUG=1 bkt <command>prints each request URL and response status.bkt auth statusshows each host, its auth method, and OAuth expiry.bkt auth doctordiagnoses keychain prompts and timeouts.
Project
- Contributing: build, test, and pull request workflow
- Security policy and security operations
- Changelog · Versioning · Privacy
- Questions and bugs: GitHub issues
bkt is available under the MIT License.