A gh-compatible CLI for Bitbucket Cloud. Single shell script, zero compilation, instant setup.
If you use GitHub's gh CLI and wish Bitbucket had the same thing — this is it.
- Pull Requests — create, list, view, diff, comment, approve, merge, close, activity log
- Repos — list, view, clone
- Branches — list remote branches
- Search — repos by name, PRs by title
- CI/CD — view pipeline status for any PR
- URL parsing — pass Bitbucket PR URLs directly (
bb pr view https://...) - JSON output —
--jsonflag on most commands for scripting - AI-agent friendly — non-interactive flags, Claude Code skill included
| Tool | Install |
|---|---|
| zsh | Default shell on macOS; apt install zsh on Linux |
| curl | Ships with macOS; apt install curl on Linux |
| jq | brew install jq or apt install jq |
| python3 | brew install python3 or comes with most systems |
| git | brew install git or Xcode CLT on macOS |
git clone https://github.com/grohit1810/bb-cli.git
cd bb-cli
./install.shThe installer will:
- Check prerequisites
- Add a
sourceline to your~/.zshrcpointing to this repo - Run
bb setupif no credentials exist (interactive wizard)
To update later: cd bb-cli && git pull — changes take effect on next shell session.
Works with any zsh plugin manager out of the box:
zinit:
zinit light grohit1810/bb-clisheldon (~/.config/sheldon/plugins.toml):
[plugins.bb-cli]
github = "grohit1810/bb-cli"antidote (~/.zsh_plugins.txt):
grohit1810/bb-cli
oh-my-zsh (clone to custom plugins):
git clone https://github.com/grohit1810/bb-cli.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/bb-cliThen add bb-cli to your plugins=(...) array in ~/.zshrc.
After loading via any plugin manager, run bb setup to configure credentials.
If you prefer not to run the installer:
# Add to ~/.zshrc
source "/path/to/bb-cli/bb.sh"
# Create credentials
mkdir -p ~/.config/bb
cp credentials.example ~/.config/bb/credentials
# Edit ~/.config/bb/credentials with your values
chmod 600 ~/.config/bb/credentials
# Reload
source ~/.zshrccd bb-cli
./uninstall.shRun the interactive setup wizard:
bb setupThis will:
- Show you which Bitbucket App Password scopes are needed and which commands use them
- Prompt for your username, token, and workspace
- Verify the credentials work before saving
- Store credentials at
~/.config/bb/credentials(mode 600)
Run bb setup again anytime to change credentials.
Create an App Password at: https://bitbucket.org/account/settings/app-passwords/
| Scope | Used by |
|---|---|
read:pullrequest:bitbucket |
pr list, pr view, pr diff, pr checks, pr status, pr activity |
read:repository:bitbucket |
repo list, repo view, repo clone, branch list, browse |
read:workspace:bitbucket |
repo list, search repos |
read:user:bitbucket |
pr status (finding your PRs) |
read:me |
auth status, pr status |
read:pipeline:bitbucket |
pr checks |
write:pullrequest:bitbucket |
pr create, pr edit, pr comment, pr approve, pr merge, pr close |
write:repository:bitbucket |
Reserved for future repo write operations |
write:pipeline:bitbucket |
Reserved for future pipeline triggers |
bb help # Full command reference
# Pull requests
bb pr list # List open PRs
bb pr view 123 # View PR details
bb pr view 123 -c # With comments
bb pr view 123 -w # Open in browser
bb pr diff 123 # Full diff
bb pr checks 123 # Pipeline status
bb pr status # Your PRs + review requests
bb pr activity 123 # Full timeline
bb pr checkout 123 # Fetch + switch to PR branch
bb pr create -t "My PR" -b main # Create PR from current branch
bb pr comment 123 -m "LGTM" # Add comment
bb pr approve 123 # Approve
bb pr merge 123 --squash --yes # Merge with squash
bb pr close 123 --yes # Decline (permanent!)
# Repos
bb repo list # All workspace repos
bb repo view # Current repo info
bb repo view myrepo --json # Specific repo, JSON output
bb repo clone myrepo # Clone via SSH
# Branches
bb branch list # Remote branches
# Search
bb search repos myservice # Search repos by name
bb search prs "bug fix" # Search PRs by title
# Utilities
bb browse # Print current branch URL
bb browse --web # Open in browser
bb api GET /user # Raw API callPass Bitbucket URLs directly — no need to extract workspace/repo/id manually:
bb pr view https://bitbucket.org/myworkspace/myrepo/pull-requests/456Most read commands support --json for scripting:
bb pr list --json | jq '.[].title'
bb pr view 123 --json | jq '.state'
bb repo list --json -L 10 | jq '.[].slug'Copy the skill file to your Claude Code skills directory:
cp skills/bb-cli.md ~/.claude/skills/bb-cli.mdThis teaches Claude Code the full command reference, safe vs. write operation boundaries, and common workflows.
The skill enforces that AI agents never execute write operations (pr create, pr merge, pr comment, etc.) without explicit user approval. Read operations are always safe.
| Variable | Default | Description |
|---|---|---|
BB_CREDENTIALS_FILE |
~/.config/bb/credentials |
Path to credentials file |
_BB_CURL |
auto-detected | Path to curl binary |
_BB_JQ |
auto-detected | Path to jq binary |
_BB_PY |
auto-detected | Path to python3 binary |
The test suite only exercises read-only commands — safe to run anytime:
export TEST_REPO_DIR=/path/to/a/bitbucket/repo
export TEST_PR_ID=123
export TEST_SEARCH_QUERY=reponame
export TEST_PR_SEARCH=keyword
export TEST_EXPLICIT_SLUG=reponame
zsh tests/test_bb.sh- Fork and clone
- Make changes to
bb.sh - Update
skills/bb-cli.mdif adding/changing commands - Run the test suite
- Submit a PR
MIT