bitbottle

module
v1.135.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 1, 2026 License: MIT

README

bitbottle

Bitbucket CLI for Cloud and Server / Data Center — built with the same philosophy as GitHub CLI.

CI npm OpenSSF Scorecard

Work with Bitbucket from your terminal — pull requests, repos, branches, tags, commits, pipelines, and raw API access. One tool, both backends, same commands.

$ bitbottle pr list
#47  feat: seamless audit            main ← feat/audit       OPEN   alice
#46  fix: 409 on concurrent merge    main ← fix/merge-race   MERGED bob

$ bitbottle pr create --title "fix: handle empty diff" --base main
✓ Created PR #48 — https://bitbucket.example.com/projects/PROJ/repos/api/pull-requests/48

Installation

npm (recommended — works everywhere Node is installed):

npm install -g @proggarapsody/bitbottle

This also registers the bundled AI agent skill (SKILL.md + topic references) with any agent runtimes detected on your machine — Claude Code, Cursor, Codex, Gemini CLI, and 50+ others — so your agents know how to drive bitbottle correctly. Skip with BITBOTTLE_SKIP_SKILL_INSTALL=1 npm install -g ….

If you installed via Homebrew, Go install, or the bare binary, register the skill explicitly:

bitbottle skill install            # uses npx; needs Node.js >= 18
bitbottle skill path               # show where the skill was installed
bitbottle skill remove             # uninstall

Go install:

go install github.com/proggarapsody/bitbottle/cmd/bitbottle@latest

Homebrew / binary / deb / rpm / Docker — see the latest release.


Authentication

# Bitbucket Cloud
echo "YOUR_APP_PASSWORD" | bitbottle auth login --hostname bitbucket.org --with-token

# Bitbucket Server / Data Center (PAT, self-signed cert)
echo "BBDC-YOUR-PAT" | bitbottle auth login \
  --hostname git.example.com \
  --with-token \
  --git-protocol https \
  --skip-tls-verify

# Verify
bitbottle auth status

# Diagnose credential / keychain / connectivity issues
bitbottle auth doctor [--hostname git.example.com]

Credentials are stored in ~/.config/bitbottle/hosts.yml. Inside a git repo with a Bitbucket remote the host and project/repo are detected automatically. Outside a repo, use -R HOST/PROJECT/REPO.

Tokens are intentionally stripped from hosts.yml on every save. If you have an existing oauth_token in hosts.yml (from an older version), run bitbottle auth migrate to move it to the OS keyring.


Commands

Group Commands
auth login logout status token refresh doctor
pr list view create merge approve unapprove diff checkout edit decline reopen ready unready request-review comment default-reviewer {list|add|remove}
repo list view create delete clone set-default rename fork (Cloud) file get tree watcher list download {list|upload|get|delete} (Cloud only)
branch list create delete checkout compare
tag list create delete
webhook list view create delete
deploy-key list add delete
branch-rule list add delete (Cloud only)
branch-model get set (Cloud only)
ssh-key list add delete
commit log view status status report files comment {list|add|edit|delete}
pipeline list view run steps logs stop trigger watch schedule {list|create|delete} cache {list|delete} artifact {list|download} config {get|enable|disable} test-report view test-case list (Cloud only)
deployment list view (Cloud only)
environment list create delete (Cloud only)
user view
workspace list member list hook list hook create hook delete project {create|view|edit|delete} perms {list|repo list|grant|revoke} (Cloud only)
mirror list view repo list (Server/DC only)
project list WORKSPACE (Cloud only) · server-list create view edit delete (Server/DC only)
issue list view create close edit reopen assign comment {list|add|edit|delete} (Cloud only)
milestone list view (Cloud only)
version list view create delete (Cloud only)
search code QUERY (Cloud only)
api Raw REST passthrough with pagination, --jq, variable expansion
alias Custom command shortcuts
config Editor, pager, git protocol per-host
completion bash zsh fish powershell
mcp MCP stdio server for AI assistants
context One-call orientation: host, repo, branch, default branch, ahead/behind, user, backend

All listing commands support --json fields, --jq expr, --limit N, --hostname HOST. TTY output is aligned and coloured; piped output is plain tab-separated for scripting.


Key Workflows

Pull Requests
# Open PRs in current repo
bitbottle pr list

# Create a PR
bitbottle pr create --title "feat: add retry logic" --base main

# Review
bitbottle pr diff 42 | delta
bitbottle pr checkout 42

# Approve and merge
bitbottle pr approve 42
bitbottle pr merge 42 --squash --delete-branch

# Add reviewers
bitbottle pr request-review 42 --reviewer alice --reviewer bob

# Decline / reopen (reopen is Bitbucket Server / DC only)
bitbottle pr decline 42
bitbottle pr reopen  42

# Read review comments — general + inline (file:line) anchors and replies
bitbottle pr comment list 42                            # all comments; LOCATION column shows path:line for inline
bitbottle pr comment list 42 --inline                   # only inline review comments
bitbottle pr comment list 42 --json id,inline,parentId,resolved,updatedAt

# Write review comments — general, inline, replies
bitbottle pr comment add 42 --body "LGTM!"                              # general comment
bitbottle pr comment add 42 --inline pkg/foo.go:88 --body "rename?"      # inline (new side, single line)
bitbottle pr comment add 42 --inline pkg/foo.go:10-15 --body "..."      # multi-line range (Cloud only)
bitbottle pr comment add 42 --inline pkg/foo.go:7 --side old --body ".." # comment on the old / removed side
bitbottle pr comment add 42 --parent 1234 --body "agreed"                # reply to an existing thread

# Edit / delete / resolve a comment
bitbottle pr comment edit   42 1234 --body "updated"
bitbottle pr comment delete 42 1234
bitbottle pr comment resolve 42 1234                                     # Bitbucket Cloud only

# Submit a compound review (body + inline comments + action) in one call
bitbottle pr review 42 --approve --body "lgtm overall"
bitbottle pr review 42 --request-changes --body "see comments" \
    --inline pkg/foo.go:88:please rename                                  # request-changes is Cloud only
bitbottle pr review 42 --comment --inline pkg/foo.go:10-15:extract helper # comment-only review

# PR activity event stream (approvals, comments, updates, merges)
bitbottle pr activity 42
bitbottle pr activity 42 --limit 20
bitbottle pr activity 42 --json type,actor,createdAt,detail

# PR commits
bitbottle pr commits 42
bitbottle pr commits 42 --json hash,message,author,date

# PR files changed
bitbottle pr files 42
bitbottle pr files 42 --json status,path,additions,deletions

# PR participants (author, reviewers, observers)
bitbottle pr participants 42
bitbottle pr participants 42 --json role,display_name,username,approved

# Apply a suggested change (Bitbucket Server / DC only — commits to the PR branch)
bitbottle pr suggestion apply 42 COMMENT_ID SUGGESTION_ID
bitbottle pr suggestion apply 42 COMMENT_ID SUGGESTION_ID --preview   # show without applying
Repos & Branches
bitbottle repo list --limit 20
bitbottle repo create my-service --project MYPROJ
bitbottle repo clone MYPROJ/my-service

bitbottle branch list
bitbottle branch create MYPROJ/my-service feature/x main     # positional START_AT
bitbottle branch create MYPROJ/my-service feature/x --start-at main  # flag form
bitbottle branch delete MYPROJ/my-service feature/x
Branch protection (Bitbucket Server / DC only)

Branch restrictions on Bitbucket Server / DC. Cloud has a different model that isn't wired up yet — invocations against Cloud return a typed "unsupported on host" error.

bitbottle branch protect list   MYPROJ/my-service
bitbottle branch protect create MYPROJ/my-service \
  --type fast-forward-only --branch main \
  --user alice --group devs
bitbottle branch protect delete MYPROJ/my-service 42

--type accepts read-only, no-deletes, fast-forward-only, or pull-request-only. Pass exactly one of --branch NAME (literal branch) or --pattern GLOB (e.g. release/*).

Pipelines (Cloud only)
bitbottle pipeline list  MYWORKSPACE/my-service
bitbottle pipeline run   MYWORKSPACE/my-service --branch main
bitbottle pipeline view  MYWORKSPACE/my-service {uuid} --web

# Drill into a run:
bitbottle pipeline steps MYWORKSPACE/my-service {pipeline-uuid}
bitbottle pipeline logs  MYWORKSPACE/my-service {pipeline-uuid} {step-uuid}

# Repository-level pipeline variables (upsert by KEY):
bitbottle variable list   MYWORKSPACE/my-service
bitbottle variable set    MYWORKSPACE/my-service DEPLOY_ENV prod
echo "$TOKEN" | bitbottle variable set MYWORKSPACE/my-service \
  API_TOKEN --body=- --secured
bitbottle variable delete MYWORKSPACE/my-service DEPLOY_ENV --confirm

Secured variables redact their value on read (TTY column shows <secured>, JSON value shows "<secured>"). Use --body=- to read the value from stdin so the secret never touches shell history.

Pipeline Schedules (Cloud only)
# List all pipeline schedules for a repository
bitbottle pipeline schedule list MYWORKSPACE/my-service

# Create a schedule (runs daily at midnight on main)
bitbottle pipeline schedule create MYWORKSPACE/my-service \
  --cron "0 0 * * *" --branch main

# Create a disabled schedule
bitbottle pipeline schedule create MYWORKSPACE/my-service \
  --cron "0 12 * * 1" --branch develop --enabled=false

# Delete a schedule by UUID
bitbottle pipeline schedule delete MYWORKSPACE/my-service {uuid}
Pipeline Caches (Cloud only)
# List all pipeline caches for a repository
bitbottle pipeline cache list MYWORKSPACE/my-service

# Delete a cache by UUID
bitbottle pipeline cache delete MYWORKSPACE/my-service {uuid}
Pipeline Artifacts (Cloud only)
# List artifacts produced by a pipeline step
bitbottle pipeline artifact list {pipeline-uuid} MYWORKSPACE/my-service --step {step-uuid}

# Download an artifact to the current directory
bitbottle pipeline artifact download {pipeline-uuid} MYWORKSPACE/my-service \
  --step {step-uuid} --name build.tar.gz

# Download to a specific path, or pipe to stdout
bitbottle pipeline artifact download {pipeline-uuid} MYWORKSPACE/my-service \
  --step {step-uuid} --name build.tar.gz --out /tmp/build.tar.gz
bitbottle pipeline artifact download {pipeline-uuid} MYWORKSPACE/my-service \
  --step {step-uuid} --name build.tar.gz --out -
Deployments & Environments (Cloud only)
# List recent deployments
bitbottle deployment list  MYWORKSPACE/my-service
bitbottle deployment list  MYWORKSPACE/my-service --limit 25

# View a single deployment
bitbottle deployment view  MYWORKSPACE/my-service {deployment-uuid}

# List environments
bitbottle environment list MYWORKSPACE/my-service

# Create an environment (type must be Test, Staging, or Production)
bitbottle environment create MYWORKSPACE/my-service --name "QA" --type Test
bitbottle environment create MYWORKSPACE/my-service --name "Prod" --type Production --rank 10

# Delete an environment (destructive — --confirm required on non-TTY)
bitbottle environment delete MYWORKSPACE/my-service {env-uuid} --confirm

# Environment variables — use variable --scope deployment (see deprecation note below)
bitbottle variable list   MYWORKSPACE/my-service --scope deployment --env {env-uuid}
bitbottle variable set    MYWORKSPACE/my-service DEPLOY_KEY prod-val --scope deployment --env {env-uuid}
bitbottle variable set    MYWORKSPACE/my-service API_TOKEN secret --scope deployment --env {env-uuid} --secured
bitbottle variable delete MYWORKSPACE/my-service DEPLOY_KEY --scope deployment --env {env-uuid} --confirm

All commands support --json fields and --jq expr. Secured variable values are never returned by the API once set.

These commands return a typed unsupported-capability error on Bitbucket Server / Data Center — deployments and environments are a Cloud-only feature.

Webhooks
bitbottle webhook list   MYPROJ/my-service
bitbottle webhook view   MYPROJ/my-service {id}

# Create
bitbottle webhook create MYPROJ/my-service \
  --url https://hooks.example.com/bb \
  --events 'repo:push,pullrequest:created'

# With shared secret from stdin (keeps secret out of shell history)
echo "$WEBHOOK_SECRET" | bitbottle webhook create MYPROJ/my-service \
  --url https://hooks.example.com/bb \
  --events 'repo:push' \
  --secret -

# Delete (destructive — --confirm required when not interactive)
bitbottle webhook delete MYPROJ/my-service {id} --confirm

Event keys differ between backends:

  • Cloud uses repo:push, pullrequest:created, pullrequest:approved, …
  • Server/DC uses repo:refs_changed, pr:opened, pr:merged, …

--secret accepts the raw value, - to read from stdin, or @PATH to read from a file. Trailing newlines from stdin / file are trimmed. Webhook secrets are write-only — neither backend returns them on read.

Deploy keys
# List deploy keys
bitbottle deploy-key list MYPROJ/my-service

# Add a deploy key
bitbottle deploy-key add MYPROJ/my-service --key "ssh-rsa AAAA..." --label "CI server"

# Delete a deploy key by ID
bitbottle deploy-key delete MYPROJ/my-service 42

All three subcommands work on both Bitbucket Cloud and Server/DC. list and add support --json / --jq / --yaml for structured output.

Branch restriction rules (Cloud only)
# List branch restriction rules
bitbottle branch-rule list myworkspace/my-service

# Add a rule requiring 2 approvals before merging to main
bitbottle branch-rule add myworkspace/my-service --kind require_approvals_to_merge --pattern main --value 2

# Add a push restriction (no direct pushes to main)
bitbottle branch-rule add myworkspace/my-service --kind push --pattern main

# Delete a rule by ID
bitbottle branch-rule delete myworkspace/my-service 7

Cloud only. list and add support --json / --jq / --yaml for structured output.

SSH keys (Cloud only)
# List SSH keys for the current user
bitbottle ssh-key list

# Add an SSH key
bitbottle ssh-key add --key "ssh-rsa AAAA..." --label "Laptop"

# Delete an SSH key by ID
bitbottle ssh-key delete 42

list and add support --json / --jq / --yaml for structured output.

PR default reviewers
# List default reviewers
bitbottle pr default-reviewer list MYPROJ/my-service

# Add a default reviewer (Server: user slug; Cloud: account ID or nickname)
bitbottle pr default-reviewer add MYPROJ/my-service jsmith

# Remove a default reviewer
bitbottle pr default-reviewer remove MYPROJ/my-service jsmith

Both Cloud and Server/DC are supported. list supports --json / --jq / --yaml.

Repo extras
# Rename (both backends — slug derives from new name on Cloud).
# --confirm is required on non-TTY because the slug change breaks existing
# clones' origin URL — run `git remote set-url origin ...` after.
bitbottle repo rename MYPROJ/my-service my-service-v2 --confirm

# Fork into another workspace (Bitbucket Cloud only)
bitbottle repo fork myworkspace/my-service --into otherws
bitbottle repo fork myworkspace/my-service --into otherws --name my-fork

# Transfer to another project (Server) or workspace (Cloud)
bitbottle repo transfer MYPROJ/my-service --to NEWPROJ
bitbottle repo transfer myworkspace/my-service --to otherws

repo fork returns a typed unsupported-capability error on Bitbucket Server / Data Center, which has no fork primitive in its REST API. Both rename and fork accept --json fields and --jq expr for structured output. repo transfer works on both backends and also accepts --json/--jq.

# Get or set repository visibility
bitbottle repo visibility MYPROJ/my-service          # prints "public" or "private"
bitbottle repo visibility MYPROJ/my-service public   # make the repo public
bitbottle repo visibility MYPROJ/my-service private  # make the repo private

repo visibility works on both Bitbucket Cloud and Server / Data Center. MCP tool: repo_visibility(repo[, visibility]).

Reading source at a ref

Read file content and directory listings at any ref (branch, tag, commit hash) without cloning. Both backends; the bytes round-trip cleanly so binary files survive --out.

# Read a file at a ref — straight to stdout
bitbottle repo file get MYPROJ/my-service README.md --ref main

# Pin a tag and write to disk (binary-safe)
bitbottle repo file get MYPROJ/my-service logo.png --ref v1.2.0 --out logo.png

# List a directory at a ref. PATH defaults to the repo root.
bitbottle repo tree MYPROJ/my-service --ref main
bitbottle repo tree MYPROJ/my-service cmd --ref main

# Structured output for scripts and agents
bitbottle repo tree MYPROJ/my-service --ref main --json path,type,size
bitbottle repo tree MYPROJ/my-service --ref main --jq '.[]|select(.type=="dir").path'

type is normalised to file or dir across both backends. Submodules surface as dir (with the submodule pointer in hash) so renderers can recurse uniformly without a special case. The MCP equivalents are get_file_content and list_tree.

Workspaces & Projects (Cloud only)
# Workspaces the authenticated user belongs to
bitbottle workspace list
bitbottle workspace list --json slug,name --jq '.[].slug'

# Projects within a workspace
bitbottle project list myworkspace
bitbottle project list myworkspace --limit 100

# Members of a workspace
bitbottle workspace member list myworkspace
bitbottle workspace member list              # inferred from pinned repo
bitbottle workspace member list myworkspace --json

# Webhooks for a workspace
bitbottle workspace hook list myworkspace
bitbottle workspace hook list myworkspace --json

bitbottle workspace hook create myworkspace --url https://example.com/hook --events repo:push,pullrequest:created
bitbottle workspace hook create myworkspace --url https://example.com/hook --events repo:push --events pullrequest:created

bitbottle workspace hook delete myworkspace WEBHOOK-UUID

# Workspace permissions (Cloud only)
bitbottle workspace perms list myworkspace
bitbottle workspace perms list myworkspace --json

bitbottle workspace perms repo list myworkspace

bitbottle workspace perms grant myworkspace --user alice --permission member
bitbottle workspace perms revoke myworkspace --user alice --confirm

All commands surface a typed unsupported-capability error against Bitbucket Server / Data Center hosts (workspaces are a Cloud concept).

User Profile
# Display the currently authenticated user's profile
bitbottle user view

# JSON output
bitbottle user view --json

# Filter with jq
bitbottle user view --json slug,name --jq '.slug'

Works on both Bitbucket Cloud and Bitbucket Server / Data Center.

Search (Cloud only)
# Search across the workspace inferred from the current checkout's pinned default
bitbottle search code 'TODO'

# Explicit workspace, custom limit
bitbottle search code 'foo bar' --workspace myws --limit 50

# Path-restricted query, JSON for scripting
bitbottle search code 'path:README' --workspace myws --json path,repository
bitbottle search code 'TODO' --workspace myws --json path --jq '.[].path'

Bitbucket Cloud's query language (path:, lang:, repo:, exact-phrase quoting, etc.) is passed through verbatim — bitbottle does not translate operators. The matched-segment shape (pathMatches, contentMatches) is preserved on the JSON side so renderers can highlight the matched runs. Bitbucket Server / Data Center has no first-class code-search REST endpoint; invocations against a Server host return the typed host.unsupported error.

Code Insights (Bitbucket Server / DC only)

Post build / quality / security analysis results as structured annotations on commits. Requires Bitbucket Server / Data Center.

# Create or update a report (upsert by key)
bitbottle --hostname git.example.com code-insights report set \
  MYPROJ/my-service abc123def456 my-scanner \
  --title "Security Scan" --result PASS \
  --report-type SECURITY --reporter "semgrep"

# List all reports for a commit
bitbottle --hostname git.example.com code-insights report list \
  MYPROJ/my-service abc123def456

# View a single report as JSON
bitbottle --hostname git.example.com code-insights report view \
  MYPROJ/my-service abc123def456 my-scanner \
  --json key,title,result,details

# Bulk-add annotations from a JSON file
bitbottle --hostname git.example.com code-insights annotation add \
  MYPROJ/my-service abc123def456 my-scanner \
  --from-json @findings.json

# Single annotation
bitbottle --hostname git.example.com code-insights annotation add \
  MYPROJ/my-service abc123def456 my-scanner \
  --path src/main.go --line 42 --severity HIGH --type BUG \
  --message "Potential null dereference"

# List annotations for a report
bitbottle --hostname git.example.com code-insights annotation list \
  MYPROJ/my-service abc123def456 my-scanner --json path,severity,message

# Delete a report and all its annotations
bitbottle --hostname git.example.com code-insights report delete \
  MYPROJ/my-service abc123def456 my-scanner
Merge checks (experimental)

Configure a Code Insights report as a required gate for PR merges. The underlying API is partly undocumented — commands are marked experimental.

# Require the "my-scanner" report to pass before merging
bitbottle --hostname git.example.com code-insights merge-check set \
  MYPROJ/my-service required-scan \
  --report-key my-scanner --must-pass --min-severity MEDIUM

# Inspect the current merge-check configuration
bitbottle --hostname git.example.com code-insights merge-check get \
  MYPROJ/my-service required-scan

# Remove the merge check
bitbottle --hostname git.example.com code-insights merge-check delete \
  MYPROJ/my-service required-scan

Invoking any code-insights command against a Bitbucket Cloud host returns the typed host.unsupported error.

Mirror Servers (Bitbucket Server / DC only)

List and inspect Smart Mirror servers configured on a Bitbucket Server instance.

# List all mirror servers
bitbottle mirror list --hostname git.example.com

# View a specific mirror server
bitbottle mirror view MIRROR-ID --hostname git.example.com

# List repos mirrored by a specific server
bitbottle mirror repo list MIRROR-ID --hostname git.example.com

# JSON output
bitbottle mirror list --hostname git.example.com --json
bitbottle mirror view MIRROR-ID --hostname git.example.com --json

Requires the Bitbucket Server Mirror module to be enabled and at least one mirror configured.

Permissions (Bitbucket Server / DC only)

Manage user and group permissions for projects and repositories. Requires PROJECT_ADMIN on the target project.

# List all grants for a project (users + groups, sorted ADMIN → WRITE → READ)
bitbottle --hostname git.example.com perms project list MYPROJ

# Grant a user PROJECT_WRITE on a project
bitbottle --hostname git.example.com perms project grant MYPROJ PROJECT_WRITE --user alice

# Grant a group PROJECT_READ on a project
bitbottle --hostname git.example.com perms project grant MYPROJ PROJECT_READ --group "qa team"

# Revoke a user's permission on a project
bitbottle --hostname git.example.com perms project revoke MYPROJ --user bob

# List all grants for a repository
bitbottle --hostname git.example.com perms repo list MYPROJ/my-service

# Grant a user REPO_WRITE on a repository
bitbottle --hostname git.example.com perms repo grant MYPROJ/my-service REPO_WRITE --user carol

# Revoke a group's permission on a repository
bitbottle --hostname git.example.com perms repo revoke MYPROJ/my-service --group "qa team"

# Structured output
bitbottle --hostname git.example.com perms project list MYPROJ --json permission,subject
bitbottle --hostname git.example.com perms project list MYPROJ --jq '.[] | select(.permission == "PROJECT_ADMIN")'

If a grant call would downgrade an existing permission (e.g. ADMIN → READ), grant prompts for confirmation on a TTY. Pass --force to skip the prompt.

Commit Files

List files added, modified, or deleted in a specific commit. Both Bitbucket Cloud and Server / Data Center are supported.

# List files changed in a commit (repo from git remote)
bitbottle commit files abc1234

# Explicit repo
bitbottle commit files abc1234 MYPROJ/my-service

# Structured output
bitbottle commit files abc1234 MYPROJ/my-service --json
bitbottle commit files abc1234 MYPROJ/my-service --jq '.[].path'

Output columns: STATUS, PATH, +ADDITIONS, -DELETIONS. Line counts are not available on Bitbucket Server / Data Center (always 0).

Commit Comments

Add and manage review-style comments on individual commits. Both Bitbucket Cloud and Server / Data Center are supported.

# List all comments on a commit
bitbottle commit comment list MYPROJ/my-service abc1234

# Add a comment
bitbottle commit comment add MYPROJ/my-service abc1234 --body "LGTM"

# Edit an existing comment (COMMENT_ID from list --json id)
bitbottle commit comment edit MYPROJ/my-service abc1234 1234 --body "Updated text"

# Delete a comment
bitbottle commit comment delete MYPROJ/my-service abc1234 1234

# Structured output
bitbottle commit comment list MYPROJ/my-service abc1234 --json id,author,body
bitbottle commit comment list MYPROJ/my-service abc1234 --jq '.[].body'

# Emoji reactions (Bitbucket Server / DC only)
bitbottle commit comment list MYPROJ/my-service abc1234 --reactions   # adds REACTIONS column
bitbottle commit comment react   MYPROJ/my-service abc1234 1234 --emoji thumbs_up
bitbottle commit comment unreact MYPROJ/my-service abc1234 1234 --emoji thumbs_up

On Bitbucket Server / Data Center, edit and delete use optimistic concurrency (fetches the current version before writing). A 409 Conflict means the comment changed between calls — retry.

Raw API
# Any endpoint not yet wrapped
bitbottle api 2.0/user
bitbottle api --paginate --jq '.[].full_name' '2.0/repositories/{workspace}'
bitbottle api -X POST -F 'title=hotfix' -F 'source.branch.name=hotfix/x' \
  '2.0/repositories/{workspace}/{repo_slug}/pullrequests'
Context (one-call orientation)

bitbottle context collapses three previously independent calls (auth status, repo view, git status) into a single structured snapshot of where you are. Especially useful for AI agents that drive bitbottle through MCP — get_context is the standard first call.

bitbottle context
# Host:           git.example.com
# Backend:        server
# Project:        PROJ
# Slug:           repo
# Branch:         feat/ctx
# Default branch: main
# Ahead/Behind:   2 / 0
# User:           alice (Alice Smith)

bitbottle context --json host,project,slug,branch,default_branch,ahead,behind,user,backend
bitbottle context --json user --jq '.user.slug'

Outside a git repo project, slug, branch, and default_branch are empty; ahead and behind are omitted from the JSON output entirely (and rendered as (unknown — run 'git fetch') in the human table). They are also omitted whenever git rev-list cannot compute the counts — 0 / 0 would falsely read as "in sync". host, user, and backend still resolve via the configured (or --hostname) host.

Outside a git repo
bitbottle pr list   -R git.example.com/PROJ/api
bitbottle pr merge 42 -R git.example.com/PROJ/api

MCP Server — AI Assistant Integration

bitbottle mcp serve exposes all CLI operations as Model Context Protocol tools. Claude Desktop, Claude Code, and any MCP client can call Bitbucket as native tools — no raw API, no output parsing.

Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "bitbottle": {
      "command": "bitbottle",
      "args": ["mcp", "serve"]
    }
  }
}

Claude Code (.mcp.json in project root):

{
  "mcpServers": {
    "bitbottle": {
      "command": "bitbottle",
      "args": ["mcp", "serve"]
    }
  }
}

Docker (no local install required):

docker run --rm -i \
  -v ~/.config/bitbottle:/root/.config/bitbottle \
  proggarapsody/bitbottle mcp serve

The MCP server uses the same ~/.config/bitbottle/hosts.yml credentials as the CLI — no separate auth setup needed.


Cloud vs Server / Data Center

bitbottle automatically routes to the correct backend based on hostname: bitbucket.org → Cloud; anything else → Server/DC. Override with backend_type: cloud|server in hosts.yml.

The same commands and flags work on both backends. Differences in API shape, pagination style, and endpoint paths are handled internally — no --cloud / --server flags needed.


Shell Completion

bitbottle completion --shell bash   >> ~/.bash_profile
bitbottle completion --shell zsh    >> ~/.zshrc
bitbottle completion --shell fish   > ~/.config/fish/completions/bitbottle.fish
bitbottle completion --shell powershell >> $PROFILE

Environment Variables

Variable Effect
BB_TOKEN Override auth token
BB_HOST Default hostname
BB_REPO Override [HOST/]PROJECT/REPO
BB_FORCE_TTY Force aligned/coloured output in pipes
NO_COLOR Disable colour (standard)

Full list in internal/envvars/envvars.go.

Colour & pager

State columns in TTY tables are colourised: OPEN / SUCCESSFUL / active webhooks render green; MERGED magenta; DECLINED / SUPERSEDED / FAILED / ERROR / STOPPED / inactive webhooks red; IN_PROGRESS / PENDING yellow. Colour applies to TTY table output only — JSON (--json) and piped output stay raw.

Disable colour with the global --no-color flag or by setting NO_COLOR=1 in the environment. JSON output is never colourised.

Long-output commands (pr diff, commit log) pipe through $PAGER when stdout is a TTY (default less -FRX). Set PAGER=cat to disable.


Extensions

bitbottle supports third-party extensions. Extension repositories must be named bitbottle-<name>.

bitbottle extension install USER/bitbottle-<name>  # install from GitHub
bitbottle extension install --local PATH           # install from local dir
bitbottle extension list                           # list installed

Contributing

See CONTRIBUTING.md. Run go test ./... before sending a PR.

License

MIT

Directories

Path Synopsis
api
Package api re-exports the HTTP middleware stack from api/internal/httpx so callers outside the api/ subtree (notably pkg/cmd/factory) can wrap their http.Client transports without needing access to the internal package.
Package api re-exports the HTTP middleware stack from api/internal/httpx so callers outside the api/ subtree (notably pkg/cmd/factory) can wrap their http.Client transports without needing access to the internal package.
cloud
Package cloud does not implement AdminClient.
Package cloud does not implement AdminClient.
cloud/gen
Package gen provides primitives to interact with the openapi HTTP API.
Package gen provides primitives to interact with the openapi HTTP API.
internal/httpx
Package httpx is the shared HTTP transport used by the Bitbucket Server/DC and Cloud API adapters.
Package httpx is the shared HTTP transport used by the Bitbucket Server/DC and Cloud API adapters.
internal/paging
Package paging bounds typed pagination above httpx.Transport.GetAllJSON.
Package paging bounds typed pagination above httpx.Transport.GetAllJSON.
server
Package server is the Bitbucket Data Center (a.k.a.
Package server is the Bitbucket Data Center (a.k.a.
server/gen
Package gen provides primitives to interact with the openapi HTTP API.
Package gen provides primitives to interact with the openapi HTTP API.
cmd
bitbottle command
Package git wraps internal/run.Runner to provide git-specific operations.
Package git wraps internal/run.Runner to provide git-specific operations.
internal
aliases
Package aliases stores user-defined command shortcuts in ~/.config/bitbottle/aliases.yml.
Package aliases stores user-defined command shortcuts in ~/.config/bitbottle/aliases.yml.
app
Package app contains the real entry-point logic for the bitbottle binary.
Package app contains the real entry-point logic for the bitbottle binary.
envvars
Package envvars is the single source of truth for environment variables that influence bitbottle's behavior.
Package envvars is the single source of truth for environment variables that influence bitbottle's behavior.
extensions
Package extensions manages bitbottle CLI extensions: install, list.
Package extensions manages bitbottle CLI extensions: install, list.
profiles
Package profiles stores named credential profiles in ~/.config/bitbottle/profiles.yml.
Package profiles stores named credential profiles in ~/.config/bitbottle/profiles.yml.
run
tlsprobe
Package tlsprobe runs a handshake-only TLS dial against a host so callers (currently `bitbottle auth login`) can decide whether the host's certificate chains to a CA the OS already trusts.
Package tlsprobe runs a handshake-only TLS dial against a host so callers (currently `bitbottle auth login`) can decide whether the host's certificate chains to a CA the OS already trusts.
userconfig
Package userconfig stores bitbottle user preferences in ~/.config/bitbottle/config.yml.
Package userconfig stores bitbottle user preferences in ~/.config/bitbottle/config.yml.
pkg
cmd/admin
Package admin is the root of the `admin` subcommand tree.
Package admin is the root of the `admin` subcommand tree.
cmd/admin/banner
Package banner implements `admin banner get`, `admin banner set`, and `admin banner clear`.
Package banner implements `admin banner get`, `admin banner set`, and `admin banner clear`.
cmd/admin/banner/clear
Package clear implements `admin banner clear`.
Package clear implements `admin banner clear`.
cmd/admin/banner/get
Package get implements `admin banner get`.
Package get implements `admin banner get`.
cmd/admin/banner/set
Package set implements `admin banner set`.
Package set implements `admin banner set`.
cmd/admin/cluster
Package cluster implements `admin cluster`.
Package cluster implements `admin cluster`.
cmd/admin/license
Package license implements `admin license`.
Package license implements `admin license`.
cmd/admin/logging
Package logging is the `admin logging` subcommand tree.
Package logging is the `admin logging` subcommand tree.
cmd/admin/logging/get
Package get implements `admin logging get`.
Package get implements `admin logging get`.
cmd/admin/logging/set
Package set implements `admin logging set`.
Package set implements `admin logging set`.
cmd/admin/mail
Package mail implements `admin mail get` and `admin mail set`.
Package mail implements `admin mail get` and `admin mail set`.
cmd/admin/mail/get
Package get implements `admin mail get`.
Package get implements `admin mail get`.
cmd/admin/mail/set
Package set implements `admin mail set`.
Package set implements `admin mail set`.
cmd/admin/ratelimit
Package ratelimit is the `admin rate-limit` subcommand tree.
Package ratelimit is the `admin rate-limit` subcommand tree.
cmd/admin/ratelimit/get
Package get implements `admin rate-limit get`.
Package get implements `admin rate-limit get`.
cmd/admin/ratelimit/set
Package set implements `admin rate-limit set`.
Package set implements `admin rate-limit set`.
cmd/admin/secrets
Package secrets is the `admin secrets` subcommand tree.
Package secrets is the `admin secrets` subcommand tree.
cmd/admin/secrets/rotate
Package rotate implements `admin secrets rotate`.
Package rotate implements `admin secrets rotate`.
cmd/admin/user
Package user implements `admin user` subcommands.
Package user implements `admin user` subcommands.
cmd/alias
Package alias implements `bitbottle alias` — user-defined command shortcuts.
Package alias implements `bitbottle alias` — user-defined command shortcuts.
cmd/api
Package api implements `bitbottle api` — a generic Bitbucket REST passthrough modeled on `gh api`.
Package api implements `bitbottle api` — a generic Bitbucket REST passthrough modeled on `gh api`.
cmd/auth/pat
Package pat implements the `auth pat` subgroup for managing Bitbucket Server/DC personal access tokens.
Package pat implements the `auth pat` subgroup for managing Bitbucket Server/DC personal access tokens.
cmd/branch/compare
Package compare implements `bitbottle branch compare BASE..HEAD`.
Package compare implements `bitbottle branch compare BASE..HEAD`.
cmd/branch/protect
Package protect is the root of the `branch protect` subcommand tree.
Package protect is the root of the `branch protect` subcommand tree.
cmd/branchmodel
Package branchmodel implements the `bitbottle branch-model` command group.
Package branchmodel implements the `bitbottle branch-model` command group.
cmd/branchrule
Package branchrule implements the `bitbottle branch-rule` command group.
Package branchrule implements the `bitbottle branch-rule` command group.
cmd/codeinsights
Package codeinsights is the root of the `code-insights` command group.
Package codeinsights is the root of the `code-insights` command group.
cmd/codeinsights/annotation
Package annotation is the `code-insights annotation` subcommand group.
Package annotation is the `code-insights annotation` subcommand group.
cmd/codeinsights/mergecheck
Package mergecheck is the `code-insights merge-check` subcommand group.
Package mergecheck is the `code-insights merge-check` subcommand group.
cmd/codeinsights/report
Package report is the `code-insights report` subcommand group.
Package report is the `code-insights report` subcommand group.
cmd/config
Package config implements `bitbottle config` — get/set/list user preferences stored in ~/.config/bitbottle/config.yml.
Package config implements `bitbottle config` — get/set/list user preferences stored in ~/.config/bitbottle/config.yml.
cmd/context
Package context implements the `bitbottle context` command — a single one-call orientation primitive that returns the current host, project, slug, branch, default branch, ahead/behind counts vs the default branch, authenticated user, and backend type.
Package context implements the `bitbottle context` command — a single one-call orientation primitive that returns the current host, project, slug, branch, default branch, ahead/behind counts vs the default branch, authenticated user, and backend type.
cmd/deploykey
Package deploykey implements the `bitbottle deploy-key` command group.
Package deploykey implements the `bitbottle deploy-key` command group.
cmd/deployment/shared
Package shared holds format helpers for deployment and environment subcommands.
Package shared holds format helpers for deployment and environment subcommands.
cmd/diff
Package diff implements the top-level `bb diff` command.
Package diff implements the top-level `bb diff` command.
cmd/extension
Package extension implements the `bitbottle extension` command group.
Package extension implements the `bitbottle extension` command group.
cmd/factory/factorytest
Package factorytest builds a *factory.Factory for tests with sane, minimal defaults.
Package factorytest builds a *factory.Factory for tests with sane, minimal defaults.
cmd/group
Package group implements the `group` command group for managing Bitbucket Server/DC admin groups and their members.
Package group implements the `group` command group for managing Bitbucket Server/DC admin groups and their members.
cmd/group/member
Package member implements the `group member` subcommand group.
Package member implements the `group member` subcommand group.
cmd/host
Package host implements the `bitbottle host` command group.
Package host implements the `bitbottle host` command group.
cmd/internal/cmdtest
Package cmdtest holds shared test fixtures for pkg/cmd subcommand tests.
Package cmdtest holds shared test fixtures for pkg/cmd subcommand tests.
cmd/internal/enumflag
Package enumflag provides a pflag.Value implementation that restricts a string flag to a fixed set of allowed values, rejecting off-enum input (including the empty string) at flag-parse time rather than silently accepting it downstream.
Package enumflag provides a pflag.Value implementation that restricts a string flag to a fixed set of allowed values, rejecting off-enum input (including the empty string) at flag-parse time rather than silently accepting it downstream.
cmd/internal/reactions
Package reactions provides a shared concurrent helper for fetching emoji reactions on comments.
Package reactions provides a shared concurrent helper for fetching emoji reactions on comments.
cmd/internal/repoarg
Package repoarg holds the single repository-reference parser shared by every CLI command.
Package repoarg holds the single repository-reference parser shared by every CLI command.
cmd/issue
Package issue implements the `bitbottle issue` command group.
Package issue implements the `bitbottle issue` command group.
cmd/issue/activity
Package activity implements the `bitbottle issue activity` subcommand.
Package activity implements the `bitbottle issue activity` subcommand.
cmd/mcp/argval
Package argval holds typed argument extractors for MCP tool handlers.
Package argval holds typed argument extractors for MCP tool handlers.
cmd/milestone
Package milestone implements the `bitbottle milestone` command group.
Package milestone implements the `bitbottle milestone` command group.
cmd/mirror
Package mirror implements the `bitbottle mirror` command group.
Package mirror implements the `bitbottle mirror` command group.
cmd/perms
Package perms is the root of the `perms` subcommand tree.
Package perms is the root of the `perms` subcommand tree.
cmd/perms/project
Package project is the `perms project` subcommand tree.
Package project is the `perms project` subcommand tree.
cmd/perms/repo
Package repo is the `perms repo` subcommand tree.
Package repo is the `perms repo` subcommand tree.
cmd/perms/shared
Package shared provides shared helpers for the perms command tree.
Package shared provides shared helpers for the perms command tree.
cmd/pipeline/artifact
Package artifact implements the `pipeline artifact` subcommand group.
Package artifact implements the `pipeline artifact` subcommand group.
cmd/pipeline/config
Package config implements `bitbottle pipeline config get/enable/disable`.
Package config implements `bitbottle pipeline config get/enable/disable`.
cmd/pipeline/oidc
Package oidc implements `bitbottle pipeline oidc` subcommand group.
Package oidc implements `bitbottle pipeline oidc` subcommand group.
cmd/pipeline/rerun
Package rerun implements `bitbottle pipeline rerun UUID [PROJECT/REPO]`.
Package rerun implements `bitbottle pipeline rerun UUID [PROJECT/REPO]`.
cmd/pipeline/shared
Package shared holds helpers used across pipeline subcommands.
Package shared holds helpers used across pipeline subcommands.
cmd/pipeline/ssh
Package ssh implements `bitbottle pipeline ssh` subcommand group.
Package ssh implements `bitbottle pipeline ssh` subcommand group.
cmd/pipeline/ssh/keypair
Package keypair implements `bitbottle pipeline ssh key-pair` subcommands.
Package keypair implements `bitbottle pipeline ssh key-pair` subcommands.
cmd/pipeline/ssh/knownhosts
Package knownhosts implements `bitbottle pipeline ssh known-hosts` subcommands.
Package knownhosts implements `bitbottle pipeline ssh known-hosts` subcommands.
cmd/pipeline/stop
Package stop implements `bitbottle pipeline stop UUID [PROJECT/REPO]`.
Package stop implements `bitbottle pipeline stop UUID [PROJECT/REPO]`.
cmd/pipeline/testreport
Package testreport implements `bitbottle pipeline test-report` and `bitbottle pipeline test-case` subcommand groups.
Package testreport implements `bitbottle pipeline test-report` and `bitbottle pipeline test-case` subcommand groups.
cmd/pipeline/watch
Package watch implements `bb pipeline watch UUID`.
Package watch implements `bb pipeline watch UUID`.
cmd/pr/mergepreview
Package mergepreview implements the `pr merge-preview` command, which performs a dry-run merge check and reports conflicts without merging.
Package mergepreview implements the `pr merge-preview` command, which performs a dry-run merge check and reports conflicts without merging.
cmd/pr/reopen
Package reopen implements the `pr reopen` command.
Package reopen implements the `pr reopen` command.
cmd/pr/shared
Package shared holds helpers shared by pr sub-command subpackages.
Package shared holds helpers shared by pr sub-command subpackages.
cmd/profile
Package profile implements the `profile` command group for managing named credential profiles (kubectl-context-like).
Package profile implements the `profile` command group for managing named credential profiles (kubectl-context-like).
cmd/profile/create
Package create implements `profile create NAME`.
Package create implements `profile create NAME`.
cmd/profile/delete
Package delete implements `profile delete NAME`.
Package delete implements `profile delete NAME`.
cmd/profile/list
Package list implements `profile list`.
Package list implements `profile list`.
cmd/profile/use
Package use implements `profile use NAME`.
Package use implements `profile use NAME`.
cmd/project
Package project implements the `bitbottle project` command group.
Package project implements the `bitbottle project` command group.
cmd/project/list
Package list implements `bitbottle project list WORKSPACE`.
Package list implements `bitbottle project list WORKSPACE`.
cmd/repo/download
Package download implements the `bitbottle repo download` subcommand group.
Package download implements the `bitbottle repo download` subcommand group.
cmd/repo/file/put
Package put implements `repo file put`.
Package put implements `repo file put`.
cmd/repo/hook
Package hook implements the `repo hook` command group.
Package hook implements the `repo hook` command group.
cmd/repo/hook/settings
Package settings implements the `repo hook settings` command group.
Package settings implements the `repo hook settings` command group.
cmd/repo/pr-settings
Package prsettings implements the `repo pr-settings` command group.
Package prsettings implements the `repo pr-settings` command group.
cmd/repo/sync
Package sync implements the "repo sync" command which synchronises a Cloud fork branch with its upstream repository.
Package sync implements the "repo sync" command which synchronises a Cloud fork branch with its upstream repository.
cmd/runner
Package runner implements the `bitbottle runner` command group.
Package runner implements the `bitbottle runner` command group.
cmd/runner/create
Package create implements the `runner create` command.
Package create implements the `runner create` command.
cmd/runner/delete
Package delete implements the `runner delete` command.
Package delete implements the `runner delete` command.
cmd/runner/list
Package list implements the `runner list` command.
Package list implements the `runner list` command.
cmd/search
Package search implements the `bitbottle search` command group.
Package search implements the `bitbottle search` command group.
cmd/skill
Package skill implements the `bitbottle skill` command tree, which installs, refreshes, and removes the bundled bitbottle agent skill (the SKILL.md + references that teach AI agents how to drive bitbottle correctly).
Package skill implements the `bitbottle skill` command tree, which installs, refreshes, and removes the bundled bitbottle agent skill (the SKILL.md + references that teach AI agents how to drive bitbottle correctly).
cmd/snippet
Package snippet implements the `bitbottle snippet` command group.
Package snippet implements the `bitbottle snippet` command group.
cmd/snippet/comment
Package comment implements the `bitbottle snippet comment` subcommand group.
Package comment implements the `bitbottle snippet comment` subcommand group.
cmd/snippet/create
Package create implements `bitbottle snippet create`.
Package create implements `bitbottle snippet create`.
cmd/snippet/delete
Package delete implements `bitbottle snippet delete`.
Package delete implements `bitbottle snippet delete`.
cmd/snippet/list
Package list implements `bitbottle snippet list`.
Package list implements `bitbottle snippet list`.
cmd/snippet/view
Package view implements `bitbottle snippet view`.
Package view implements `bitbottle snippet view`.
cmd/sshkey
Package sshkey implements the `bitbottle ssh-key` command group.
Package sshkey implements the `bitbottle ssh-key` command group.
cmd/user
Package user implements the `bitbottle user` command group.
Package user implements the `bitbottle user` command group.
cmd/user/view
Package view implements `bitbottle user view`.
Package view implements `bitbottle user view`.
cmd/variable
Package variable wires the top-level `variable` command group.
Package variable wires the top-level `variable` command group.
cmd/variable/delete
Package delete implements the `variable delete` subcommand.
Package delete implements the `variable delete` subcommand.
cmd/variable/list
Package list implements the `variable list` subcommand.
Package list implements the `variable list` subcommand.
cmd/variable/set
Package set implements the `variable set` subcommand.
Package set implements the `variable set` subcommand.
cmd/variable/shared
Package shared holds format helpers for variable subcommands.
Package shared holds format helpers for variable subcommands.
cmd/variable/view
Package view implements the `variable view` subcommand.
Package view implements the `variable view` subcommand.
cmd/version
Package version implements the `bitbottle version` command group.
Package version implements the `bitbottle version` command group.
cmd/webhook
Package webhook is the root of the `webhook` subcommand tree.
Package webhook is the root of the `webhook` subcommand tree.
cmd/webhook/shared
Package shared holds helpers used across webhook subcommands.
Package shared holds helpers used across webhook subcommands.
cmd/workspace
Package workspace implements the `bitbottle workspace` command group.
Package workspace implements the `bitbottle workspace` command group.
cmd/workspace/audit
Package audit implements the `bitbottle workspace audit` command.
Package audit implements the `bitbottle workspace audit` command.
cmd/workspace/hook
Package hook implements the `bitbottle workspace hook` command group.
Package hook implements the `bitbottle workspace hook` command group.
cmd/workspace/ipallowlist
Package ipallowlist implements the `bitbottle workspace ipallowlist` command group.
Package ipallowlist implements the `bitbottle workspace ipallowlist` command group.
cmd/workspace/list
Package list implements `bitbottle workspace list`.
Package list implements `bitbottle workspace list`.
cmd/workspace/member
Package member implements the `bitbottle workspace member` command group.
Package member implements the `bitbottle workspace member` command group.
cmd/workspace/perms
Package perms implements the `bitbottle workspace perms` command group.
Package perms implements the `bitbottle workspace perms` command group.
cmd/workspace/pipelinevar
Package pipelinevar implements the `bitbottle workspace pipeline-variable` command group.
Package pipelinevar implements the `bitbottle workspace pipeline-variable` command group.
cmd/workspace/project
Package project implements the `bitbottle workspace project` command group.
Package project implements the `bitbottle workspace project` command group.
cmd/workspace/project/defaultreviewer
Package defaultreviewer implements the `bitbottle workspace project default-reviewer` command group.
Package defaultreviewer implements the `bitbottle workspace project default-reviewer` command group.
cmd/workspace/project/perms
Package perms implements the `bitbottle workspace project perms` command group.
Package perms implements the `bitbottle workspace project perms` command group.
cmd/workspace/search
Package search implements `bitbottle workspace search`.
Package search implements `bitbottle workspace search`.
cmdregistry
Package cmdregistry provides a self-registration mechanism for Cobra subcommands.
Package cmdregistry provides a self-registration mechanism for Cobra subcommands.
cmdutil
Package cmdutil provides CLI command utilities including JSON output helpers.
Package cmdutil provides CLI command utilities including JSON output helpers.
errfmt
Package errfmt is the central renderer for user-facing CLI errors.
Package errfmt is the central renderer for user-facing CLI errors.
test

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL