A comprehensive command-line interface for Bitbucket Cloud, designed for developers and AI agents.
- Features
- Installation
- Quick Start
- Authentication
- Commands
- Configuration
- Output Formats
- Environment Variables
- Examples
- Development
- Contributing
- License
Core Features:
- Browser-based OAuth authentication (like GitHub CLI)
- Multiple authentication methods (OAuth, API tokens, repository tokens)
- Comprehensive Bitbucket Cloud API coverage
- AI-agent friendly (JSON output, stdin support)
- Beautiful terminal UI with colors and tables
- Secure credential storage in OS keychain
- Fast and efficient (written in Rust)
- Auto-detection of workspace/repo from git remote
Supported Operations:
- Repositories (create, list, view, clone, fork, delete)
- Pull Requests (create, list, view, merge, approve, comment)
- Issues (create, list, view, update, comment)
- Pipelines (view, trigger, monitor)
- Branches (list, create, delete)
- Commits (view, compare)
- Workspaces & Projects
- Webhooks
- File/source browsing
- And much more!
# Clone the repository
git clone https://github.com/datlechin/bitbucket-cli.git
cd bitbucket-cli
# Build and install
cargo install --path .
# Verify installation
bb --versioncargo install bitbucket-cliDownload pre-built binaries from the Releases page.
Option A: Browser-based authentication (Recommended)
# Simply run - OAuth credentials are built-in!
bb auth login --with-webYour browser will open automatically. Click "Grant access" and you're done!
Option B: API Token (Also Easy)
bb auth login --with-api-token
# Enter your Atlassian account email and API tokenOption C: Interactive Setup
bb auth setup
# Follow the guided setup wizardbb config set default_workspace my-workspace# List your repositories
bb repo list
# View pull requests
bb pr list
# Check pipeline status
bb pipeline listBitbucket CLI supports multiple authentication methods:
Like GitHub CLI - authenticate via your web browser. No setup required!
Login:
bb auth login --with-webThat's it! The CLI has built-in OAuth credentials. Your browser opens, you click "Grant access", and you're authenticated.
Most secure and easy to set up.
Create API Token:
- Go to https://id.atlassian.com/manage-profile/security/api-tokens
- Click "Create API token"
- Select scopes: account, repository, pullrequest, issue, pipeline, webhook
Login:
bb auth login --with-api-tokenLimited to a specific repository.
bb auth login
# Select "Repository Access Token"Limited to a specific workspace.
bb auth login
# Select "Workspace Access Token"# Check authentication status
bb auth status
# Refresh OAuth token (for OAuth auth)
bb auth refresh
# Logout
bb auth logout# List repositories in configured workspace
bb repo list
# List repositories in specific workspace
bb repo list -W myworkspace
# List with JSON output
bb repo list -o json
# Filter by name
bb repo list --name myrepo# View repository details
bb repo view myrepo
# View specific workspace's repository
bb repo view -W myworkspace myrepo
# JSON output
bb repo view myrepo -o json# Create a repository
bb repo create my-new-repo
# Create with description
bb repo create my-new-repo --description "My awesome project"
# Create private repository
bb repo create my-new-repo --private
# Create with specific language
bb repo create my-new-repo --language python# Clone via HTTPS
bb repo clone myrepo
# Clone via SSH
bb repo clone myrepo --ssh
# Clone to specific directory
bb repo clone myrepo --path /path/to/dir# Fork a repository
bb repo fork original-owner/original-repo
# Fork to specific workspace
bb repo fork original-owner/original-repo -W my-workspace# Delete repository (with confirmation)
bb repo delete myrepo
# Force delete (no confirmation)
bb repo delete myrepo --yes# List all pull requests
bb pr list
# List open PRs
bb pr list --state OPEN
# List merged PRs
bb pr list --state MERGED
# List PRs for specific repository
bb pr list -R myrepo
# List with specific author
bb pr list --author username# View PR details
bb pr view 123
# View with comments
bb pr view 123 --with-comments
# JSON output
bb pr view 123 -o json# Create PR (interactive)
bb pr create
# Create with title and description
bb pr create --title "Add new feature" --description "This PR adds..."
# Create from branch
bb pr create --source feature-branch --destination main
# Create with reviewers
bb pr create --reviewer user1 --reviewer user2
# Close PR after merge
bb pr create --close-source-branch# Merge PR
bb pr merge 123
# Merge with merge commit
bb pr merge 123 --strategy merge
# Squash merge
bb pr merge 123 --strategy squash
# Fast-forward merge
bb pr merge 123 --strategy fast-forward
# Close source branch after merge
bb pr merge 123 --close-source-branch
# Add merge message
bb pr merge 123 --message "Merged feature X"# Approve PR
bb pr approve 123
# Decline PR
bb pr decline 123
# Request changes
bb pr request-changes 123# Add comment
bb pr comment 123 --body "Looks good to me!"
# Add inline comment
bb pr comment 123 --body "Fix this" --file src/main.rs --line 42# View PR diff
bb pr diff 123
# View specific file
bb pr diff 123 --file src/main.rs# List all issues
bb issue list
# List open issues
bb issue list --state open
# List closed issues
bb issue list --state closed
# List issues assigned to you
bb issue list --assignee @me
# List issues by reporter
bb issue list --reporter username# View issue details
bb issue view 42
# With comments
bb issue view 42 --with-comments# Create issue (interactive)
bb issue create
# Create with title and description
bb issue create --title "Bug: App crashes" --description "Steps to reproduce..."
# Create with priority
bb issue create --title "Fix typo" --priority minor
# Assign to user
bb issue create --title "New feature" --assignee username
# Set type
bb issue create --title "Enhancement" --kind enhancement# Update issue title
bb issue update 42 --title "New title"
# Change state
bb issue update 42 --state resolved
# Change priority
bb issue update 42 --priority major
# Assign to user
bb issue update 42 --assignee usernamebb issue comment 42 --body "Thanks for reporting!"# Close issue
bb issue close 42
# Reopen issue
bb issue reopen 42# List all pipelines
bb pipeline list
# List recent pipelines
bb pipeline list --limit 10
# List for specific branch
bb pipeline list --branch main
# List with specific status
bb pipeline list --status SUCCESSFUL
bb pipeline list --status FAILED
bb pipeline list --status IN_PROGRESS# View pipeline details
bb pipeline view {uuid}
# View with steps
bb pipeline view {uuid} --with-steps
# View logs
bb pipeline view {uuid} --with-logs# Trigger pipeline for branch
bb pipeline run --branch main
# Trigger with custom variables
bb pipeline run --branch main --variable KEY1=VALUE1 --variable KEY2=VALUE2
# Trigger specific pipeline
bb pipeline run --branch main --pipeline custom-pipeline.ymlbb pipeline stop {uuid}# List all branches
bb branch list
# Filter by name
bb branch list --name feature
# List with commit info
bb branch list --with-commits# Create branch from main
bb branch create feature-branch --from main
# Create from specific commit
bb branch create hotfix --from abc123# Delete branch
bb branch delete feature-branch
# Force delete
bb branch delete feature-branch --force# List commits
bb commit list
# List for specific branch
bb commit list --branch main
# List with limit
bb commit list --limit 20
# List by author
bb commit list --author username# View commit details
bb commit view abc123
# View with diff
bb commit view abc123 --with-diff
# View specific file in commit
bb commit view abc123 --file src/main.rs# List your workspaces
bb workspace list
# View workspace details
bb workspace view myworkspace# List projects in workspace
bb project list -W myworkspace
# View project details
bb project view PROJ -W myworkspace# List repository webhooks
bb webhook list -R myrepo
# List workspace webhooks
bb webhook list -W myworkspace# Create repository webhook
bb webhook create -R myrepo \
--url https://example.com/hook \
--events repo:push \
--events pullrequest:created
# Create with description
bb webhook create -R myrepo \
--url https://example.com/hook \
--description "CI/CD webhook"bb webhook delete {uuid} -R myrepobb config show# Set default workspace
bb config set default_workspace myworkspace
# Set default repository
bb config set default_repository myrepo
# Set output format
bb config set output_format json
# Set page size
bb config set page_size 50
# Set OAuth credentials
bb config set oauth_client_id YOUR_CLIENT_ID
bb config set oauth_client_secret YOUR_CLIENT_SECRET
# Set editor
bb config set editor vim
# Set pager
bb config set pager lessbb config get default_workspacebb config resetbb config pathFor advanced users and AI agents.
# GET request
bb api /repositories/{workspace}/{repo}
# POST request
bb api -X POST /repositories/{workspace}/{repo}/issues \
--data '{"title":"Bug report"}'
# With custom headers
bb api /user --header "X-Custom: value"
# Paginated request
bb api /repositories/{workspace} --paginateLocation: ~/.config/bitbucket-cli/config.toml
default_workspace = "myworkspace"
default_repository = "myrepo"
output_format = "table"
api_url = "https://api.bitbucket.org/2.0"
color = true
page_size = 25
editor = "vim"
pager = "less"
oauth_client_id = "your-client-id"
oauth_client_secret = "your-client-secret"
[aliases]
prs = "pr list --state OPEN"
repos = "repo list"Credentials are stored securely in your OS keychain:
- macOS: Keychain
- Windows: Credential Manager
- Linux: Secret Service (gnome-keyring, kwallet, etc.)
Bitbucket CLI supports multiple output formats:
# Table (default) - Human-readable
bb repo list
# JSON - Machine parsing
bb repo list -o json
# Pretty JSON - Readable JSON
bb repo list -o json-pretty
# YAML
bb repo list -o yaml
# TSV - Tab-separated values
bb repo list -o tsv
# CSV - Comma-separated values
bb repo list -o csv
# Quiet - IDs only
bb repo list -o quiet# API Token
export BITBUCKET_EMAIL="your@email.com"
export BITBUCKET_API_TOKEN="your-token"
# OAuth Access Token
export BITBUCKET_ACCESS_TOKEN="token"
export BITBUCKET_REFRESH_TOKEN="refresh-token"
# Repository Token
export BITBUCKET_REPO_TOKEN="token"
# Workspace Token
export BITBUCKET_WORKSPACE_TOKEN="token"
# OAuth Credentials (for browser auth)
export BITBUCKET_CLI_OAUTH_CLIENT_ID="client-id"
export BITBUCKET_CLI_OAUTH_CLIENT_SECRET="client-secret"# Workspace/Repository
export BITBUCKET_WORKSPACE="myworkspace"
export BITBUCKET_REPO="myrepo"# Morning: Check what's new
bb pr list --state OPEN
bb issue list --assignee @me
bb pipeline list --limit 5
# Create a feature
git checkout -b feature-xyz
# ... make changes ...
git push origin feature-xyz
bb pr create --title "Add feature XYZ" --reviewer teammate
# Monitor PR
bb pr view 123
bb pr diff 123
# Approve teammate's PR
bb pr approve 124
bb pr merge 124
# Check pipelines
bb pipeline list --branch main# Create new project
bb repo create my-project --description "My awesome project" --private
cd my-project
git init
git remote add origin $(bb repo view my-project -o json | jq -r '.clone_url')
# Fork and clone
bb repo fork upstream/awesome-lib
bb repo clone awesome-lib# Create bug report
bb issue create \
--title "App crashes on startup" \
--description "Steps: 1. Open app 2. Crash" \
--priority critical \
--kind bug
# Track progress
bb issue list --state open
bb issue update 42 --state in-progress
bb issue comment 42 --body "Working on this"
bb issue close 42# Watch pipeline
watch -n 5 'bb pipeline list --branch main --limit 1'
# Trigger build
bb pipeline run --branch main
# Check logs
bb pipeline view {uuid} --with-logs# Get all open PRs as JSON
bb pr list --state OPEN -o json | jq
# Extract PR titles
bb pr list -o json | jq -r '.values[].title'
# Get all repos with SSH URLs
bb repo list -o json | jq -r '.values[] | "\(.name): \(.links.clone[] | select(.name=="ssh") | .href)"'
# List all failed pipelines
bb pipeline list -o json | jq -r '.values[] | select(.state.result.name=="FAILED") | .uuid'# Clone repository
git clone https://github.com/datlechin/bitbucket-cli.git
cd bitbucket-cli
# Build
cargo build --release
# Run tests
cargo test
# Run locally
cargo run -- --helpbitbucket-cli/
├── src/
│ ├── api/ # API client and OAuth
│ ├── commands/ # CLI commands
│ ├── config/ # Configuration and auth
│ ├── models/ # Data models
│ ├── output/ # Output formatting
│ └── main.rs # Entry point
├── Cargo.toml
├── README.md
- Language: Rust 🦀
- CLI Framework: clap
- HTTP Client: reqwest
- Async Runtime: tokio
- Serialization: serde
- Credential Storage: keyring
We welcome contributions! Here's how to get started:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes
- Run tests:
cargo test - Commit:
git commit -m 'Add amazing feature' - Push:
git push origin feature/amazing-feature - Open a Pull Request
- Follow Rust best practices
- Add tests for new features
- Update documentation
- Keep commits atomic and descriptive
- GitHub CLI-style aliases (
bb pr checkout) - Interactive TUI mode
- Code search
- Snippets management
- Team/permissions management
- Repository settings
- Deployment environments
- SSH key management
- GPG key support
- Advanced git operations
A: Bitbucket CLI (bb) is designed to be similar to GitHub CLI (gh):
- More user-friendly interface
- Browser-based authentication
- Better output formatting
- AI-agent optimized
- Comprehensive API coverage
A: Currently, only Bitbucket Cloud is supported. Server/Data Center support is on the roadmap.
A: Yes! Credentials are stored in your OS keychain using industry-standard security practices.
A: Yes! Use API tokens and JSON output:
export BITBUCKET_EMAIL="ci@example.com"
export BITBUCKET_API_TOKEN="$CI_TOKEN"
bb repo list -o jsonA: Rust provides:
- Fast performance
- Memory safety
- Excellent async support
- Great CLI libraries
- Single-binary distribution
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by GitHub CLI
- Built with ❤️ by the Bitbucket CLI community
- Powered by Bitbucket Cloud API
Happy coding!
For more information, visit https://github.com/datlechin/bitbucket-cli