Bitbucket CLI is a command line interface for interacting with Bitbucket.
To install the latest version, run:
curl -fsSL https://raw.githubusercontent.com/tmaffia/bitbucket-cli/main/scripts/install.sh | sh- Authentication: Secure login using Bitbucket API Tokens (stored in system keyring).
- Pull Requests: List, view, diff, and comment on pull requests.
- Repository Browsing: List files, view file contents, and open repos in browser.
- Code Search: Search code across your workspace.
- Configuration: Manage multiple profiles and default settings.
- Git Integration: Auto-detects repository and branch from current directory.
To use this CLI, you need an API Token from your Atlassian account:
- Log in to id.atlassian.com.
- Click Create API token.
- Give it a label (e.g., "bb-cli").
- Click Create.
- Copy the generated token. You will need this for the CLI login.
-
Install the binary:
macOS / Linux: Use the install script to download the pre-built binary:
curl -fsSL https://raw.githubusercontent.com/tmaffia/bitbucket-cli/main/scripts/install.sh | shWindows: Clone the repository and install via Cargo:
cargo install --path . -
Authenticate with your Bitbucket account:
bb auth login
- Enter your Bitbucket email.
- Enter the API Token you generated in step 1.
-
Initialize the configuration in your bitbucket repository folder:
bb config init
--json: Output results in JSON format (available forlistcommands).
List repositories in your workspace:
bb repo list
# List with a custom limit (default is 100)
bb repo list --limit 20List files and directories:
# List root directory
bb repo tree
# List specific path
bb repo tree src/commands/
# List on a specific branch
bb repo tree --ref mainView file contents:
bb repo view README.md
bb repo view src/main.rs --ref developOpen repository in browser:
# Current repository
bb browse
# Specific repository
bb browse myworkspace/myrepoSearch code across your workspace:
bb search code "function_name"
# Filter by extension
bb search code "error" --extension rs
# Filter by repository
bb search code "TODO" --repo myrepo
# Limit results
bb search code "panic" --limit 10List pull requests:
bb pr listView a pull request (auto-detected from branch or by ID):
bb pr view
bb pr view 123View Diff with Filtering:
You can filter the diff by file patterns or size.
Inferred Context (Current Branch):
# Filter by file extension
bb pr diff "*.rs"
# Filter by directory
bb pr diff src/commands/Manual Context (Explicit ID):
# Filter by specific file for PR #123
bb pr diff 123 src/main.rs
# Skip large files for PR #123
bb pr diff 123 --max-diff-size 100Review a Pull Request:
Start an interactive review or submit immediately with flags.
Inferred Context (Current Branch):
# Interactive mode
bb pr review
# Approve immediately
bb pr review --approveManual Context (Explicit ID):
# Interactive mode for PR #123
bb pr review 123
# Request changes for PR #123
bb pr review 123 --request-changes
# Comment on PR #123
bb pr review 123 --comment --body "Great work!"Override Repository:
You can run any command against a specific repository using -R:
# List PRs in a different repo
bb pr list -R my-workspace/other-repo
# View PR #123 in a different repo
bb pr view 123 -R my-workspace/other-repoView your current configuration (active profile and local overrides):
bb config listSet a configuration value:
# Set the active profile (user)
bb config set user <PROFILE_NAME>
# Set workspace for the default profile
bb config set profile.default.workspace <WORKSPACE_NAME>For contributing to this repository, you can set up the pre-push hooks (recommended):
cp scripts/pre-push .git/hooks/pre-push
chmod +x .git/hooks/pre-push