Bitbucket CLI with gh-like ergonomics
npx skills add https://github.com/avivsinai/bitbucket-cli --skill bktInstallieren Sie diesen Skill über die CLI und beginnen Sie mit der Verwendung des SKILL.md-Workflows in Ihrem Arbeitsbereich.
Bitbucket Cloud & Data Center workflows for developers, coding agents, and automation-first teams.
bkt is a stand-alone Bitbucket command-line interface that targets Bitbucket Data Center and Bitbucket Cloud. It mirrors the ergonomics of gh and delivers a consistent JSON/YAML contract for automation.
Built for AI & automation: Drop bkt into Claude Code, Codex and other coding agents, or shell scripts and they inherit structured output, predictable flags, and safe defaults—no glue code required.
brew install avivsinai/tap/bitbucket-cli
scoop bucket add avivsinai https://github.com/avivsinai/scoop-bucket
scoop install bitbucket-cli
go install github.com/avivsinai/bitbucket-cli/cmd/bkt@latest
This installs bkt to $GOPATH/bin (or $HOME/go/bin by default). Ensure the directory is in your $PATH.
Run the latest master without installing:
nix run github:avivsinai/bitbucket-cli -- --version
Install into your user profile:
nix profile install github:avivsinai/bitbucket-cli
Pin to a specific tag or commit by appending a ref (e.g. github:avivsinai/bitbucket-cli/v1.2.3).
Note: The Nix package does not embed OAuth client credentials. For Bitbucket Cloud OAuth (
bkt auth login --kind cloud --web), setBKT_OAUTH_CLIENT_IDandBKT_OAUTH_CLIENT_SECRETin your environment.
Don't have Nix yet? See nixos.asia/en/install for a quick setup guide (installs Nix with flakes enabled out of the box).
Download pre-built binaries for your platform from the releases page.
bkt supports fully config-free headless use via environment variables. Set BKT_TOKEN and BKT_HOST as secured repository variables — no prior bkt auth login or bkt context create step required.
pipelines:
default:
- step:
name: Open PR
script:
- export BKT_VERSION="0.19.0" # pin to a specific release
- curl -sL "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"
All bkt behaviour can be configured via environment variables, which is especially useful in containers and CI/CD pipelines.
| Variable | Description |
|---|---|
BKT_TOKEN |
Authentication token. Bypasses keyring storage entirely. |
BKT_HOST |
Bitbucket server base URL (e.g. https://bitbucket.example.com). Required alongside BKT_TOKEN for config-free use. bitbucket.org is auto-detected as Cloud. |
BKT_USERNAME |
Username for basic authentication in headless mode. |
BKT_AUTH_METHOD |
Authentication method: basic or bearer. DC defaults to bearer when BKT_USERNAME is absent; Cloud always uses basic. |
BKT_PROJECT |
Default Data Center project key (headless mode). |
BKT_WORKSPACE |
Default Bitbucket Cloud workspace (headless mode). |
BKT_REPO |
Default repository slug (headless mode). |
BKT_CONFIG_DIR |
Override the config file directory (default: $XDG_CONFIG_HOME/bkt). |
BKT_HTTP_DEBUG |
Set to 1 to log HTTP request URLs and response status codes. |
BKT_ALLOW_INSECURE_STORE |
Set to 1 to use encrypted file fallback when no OS keychain is available. |
Minimal headless example (Data Center):
export BKT_HOST=https://bitbucket.example.com
export BKT_TOKEN=my-personal-access-token
export BKT_PROJECT=MYPROJ
export BKT_REPO=my-service
bkt pr list
bkt pr create --title "Automated PR" --source feature/my-branch
Minimal headless example (Bitbucket Cloud):
export BKT_HOST=https://bitbucket.org
export BKT_TOKEN=my-api-token
export [email protected]
export BKT_WORKSPACE=my-workspace
export BKT_REPO=my-repo
bkt pr list
git clone https://github.com/avivsinai/bitbucket-cli.git
cd bitbucket-cli
make build # produces ./bin/bkt
./bin/bkt --help
Install the bkt skill to give Claude Code or Codex CLI native Bitbucket knowledge:
npx skild install @avivsinai/bkt -t claude -y
Known Issue: Claude Code uses SSH to clone marketplace repos, which fails without SSH keys configured. See issue #14485. Use the skills or skild methods instead.
/plugin marketplace add avivsinai/skills-marketplace
/plugin install bkt@avivsinai-marketplace
git clone https://github.com/avivsinai/bitbucket-cli.git
cp -r bitbucket-cli/.claude/skills/bkt ~/.claude/skills/
After installation, verify it works:
bkt --help
# Guided flow: opens browser to create token
bkt auth login https://bitbucket.mycorp.example --web
# Or provide credentials directly
bkt auth login https://bitbucket.mycorp.example --username alice --token <PAT>
Create a Personal Access Token (PAT) in Bitbucket Data Center:
# Guided flow: opens browser to create token
bkt auth login https://bitbucket.org --kind cloud --web
# Or provide credentials directly
bkt auth login https://bitbucket.org --kind cloud --username <email> --token <api-token>
Create an API token with scopes for Bitbucket Cloud:
read:user:bitbucket) — Required for authenticationWarning: General Atlassian API tokens won't work. You must select "Bitbucket" as the application when creating the token.
Note: Use your Atlassian account email as the username (not your Bitbucket username).
App passwords are deprecated. New app passwords cannot be created since September 2025, and existing ones will stop working June 2026. If you have an existing app password:
bkt auth login https://bitbucket.org --kind cloud --username <bitbucket-username> --token <app-password>
Note: For app passwords, use your Bitbucket username (not email).
Access tokens are stored in your OS keychain (Keychain Access on macOS, Windows Credential Manager, or
Secret Service/KWallet on Linux) while host metadata lives in
$XDG_CONFIG_HOME/bkt/config.yml. Pass --allow-insecure-store (or set
BKT_ALLOW_INSECURE_STORE=1) to permit the encrypted file backend on systems
without a native keychain.
If your keyring requires an interactive unlock prompt, you can increase the keyring timeout via
BKT_KEYRING_TIMEOUT (for example BKT_KEYRING_TIMEOUT=2m).
bkt context create dc-prod --host bitbucket.mycorp.example --project ABC --set-active
bkt context list
bkt context create cloud-prod --host api.bitbucket.org --workspace myteam --set-active
bkt context list
Tip: Run
bkt auth statusto see configured hosts and the exact host value to use with--host.
Contexts capture the host mapping, default project/workspace, and optional default repository for commands.
bkt repo list --limit 20
bkt repo list --workspace myteam --limit 10 # Cloud workspace override
bkt repo view platform-api
bkt repo create data-pipeline --description "Data ingestion" --project DATA
bkt repo browse --project DATA --repo platform-api
bkt repo clone platform-api --project DATA --ssh
repo list/repo view automatically target the right REST API for your active context: Data Center uses /rest/api/1.0/projects/{projectKey}/repos, while Cloud uses /2.0/repositories/{workspace}.
bkt pr list --state OPEN --limit 10
bkt pr create --title "feat: cache" --source feature/cache --target main --reviewer alice
bkt pr merge 42 --message "merge: feature/cache"
bkt pr checks 42 # Show build/CI status
bkt pr checks 42 --wait # Wait for builds to complete
bkt pr checks 42 --wait --timeout 5m # Wait with timeout
bkt pr checks 42 --wait --max-interval 1m # Custom backoff cap
The CLI wraps Bitbucket pull-request endpoints for creation, listing, review, and merge operations. The checks command displays build status with color-coded output (green for success, red for failure, yellow for in-progress) and supports polling until all builds complete. Polling uses exponential backoff with jitter to avoid overwhelming the API during long builds.
bkt issue list --state open --kind bug # List open bugs
bkt issue view 42 --comments # View issue with comments
bkt issue create -t "Login broken" -k bug -p major
bkt issue edit 42 --assignee "{abc-123}" --priority critical
bkt issue close 42 # Close an issue
bkt issue reopen 42 # Reopen a closed issue
bkt issue comment 42 -b "Fixed in v1.2.0" # Add a comment
bkt issue status # Show your assigned/created issues
# Attachments
bkt issue attachment list 42 # List attachments
bkt issue attachment upload 42 screenshot.png # Upload file(s)
bkt issue attachment download 42 --all # Download all attachments
bkt issue attachment delete 42 old-file.txt # Delete an attachment
Note: The issue tracker is only available for Bitbucket Cloud. Bitbucket Data Center uses Jira for issue tracking.
bkt branch list --workspace myteam # Cloud branch listing
bkt branch create release/1.9 --from main # Data Center branch utils
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 pipeline run --workspace myteam --repo api --ref main --var ENV=staging
bkt extension install https://github.com/example/bkt-hello.git
bkt extension exec hello -- --flag=1
bkt status pipeline {pipeline-uuid}
bkt status rate-limit
Branch utilities use Bitbucket's Branch Utils REST API for listing, creation, deletion, and default updates. Permission and webhook commands map to their respective REST endpoints for consistent automation.
Extensions are cloned into $XDG_CONFIG_HOME/bkt/extensions (or the directory configured via BKT_CONFIG_DIR) and executed in-place. Binaries should follow the bkt-<name> naming convention so the CLI can discover them automatically.
Every command supports the global --json and --yaml flags for automation-ready output.
For endpoints that are not yet wrapped, reach directly for the API escape hatch:
bkt api /rest/api/1.0/projects --param limit=100 --json
bkt api /repositories --param workspace=myteam --field pagelen=50
This project uses automated secret scanning (gitleaks), dependency updates (Dependabot), and security posture tracking (OSSF Scorecard).
Found a security issue? See our security policy for responsible disclosure.
cmd/bkt/ # CLI entry point
internal/bktcmd/ # Main() wiring (factory + root command)
internal/build/ # Version metadata (overridden via ldflags)
internal/config/ # Context and host configuration
internal/remote/ # Git remote parsing utilities
pkg/cmd/ # Cobra command implementations (auth, repo, pr, ...)
pkg/cmdutil/ # Shared command helpers and factory wiring
pkg/iostreams/ # IO stream abstractions
pkg/bbdc/ # Bitbucket Data Center client implementation
pkg/bbcloud/ # Bitbucket Cloud client implementation
pkg/format/ # Output rendering helpers
pkg/httpx/ # Shared HTTP client and retry logic
make build # Build the binary to ./bin/bkt
make test # Run unit tests
make fmt # Format code
make lint # Run linters
make tidy # Tidy go modules
go test ./... runs fast smoke coverage that wires the CLI against an in-memory Bitbucket mock (see pkg/cmd/smoke/cli_smoke_test.go).
To see API request URLs and response status codes, set the BKT_HTTP_DEBUG environment variable:
BKT_HTTP_DEBUG=1 bkt pipeline view 10
This outputs request method/URL and response status, useful for diagnosing API errors.
bkt is available under the MIT License.