bkt by avivsinai/bitbucket-cli
npx skills add https://github.com/avivsinai/bitbucket-cli --skill bktbkt 是一个适用于 Bitbucket Data Center 和 Bitbucket Cloud 的统一命令行界面。它借鉴了 gh 的交互设计,并为自动化任务提供结构化的 JSON/YAML 输出。
在执行任何 bkt 命令之前,请确认 CLI 已安装:
bkt --version
如果命令执行失败或未找到 bkt,请使用以下方法之一进行安装:
| 平台 | 命令 |
|---|---|
| macOS/Linux | brew install avivsinai/tap/bitbucket-cli |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| Windows |
scoop bucket add avivsinai https://github.com/avivsinai/scoop-bucket && scoop install bitbucket-cli |
| Go | go install github.com/avivsinai/bitbucket-cli/cmd/bkt@latest |
| 二进制文件 | 从 GitHub Releases 下载 |
只有在确认安装成功后,才能继续执行 bkt 命令。
# Data Center (打开浏览器创建 PAT)
bkt auth login https://bitbucket.example.com --web
# Data Center (直接方式)
bkt auth login https://bitbucket.example.com --username alice --token <PAT>
# Bitbucket Cloud
bkt auth login https://bitbucket.org --kind cloud --web
# 检查认证状态
bkt auth status
Bitbucket Cloud 令牌要求:
read:user:bitbucket)上下文用于存储主机、项目/工作空间以及默认仓库设置:
# 为 Data Center 创建上下文
bkt context create dc-prod --host bitbucket.example.com --project ABC --set-active
# 为 Cloud 创建上下文
bkt context create cloud-team --host bitbucket.org --workspace myteam --set-active
# 列出和切换上下文
bkt context list
bkt context use cloud-team
| 任务 | 命令 |
|---|---|
| 列出仓库 | bkt repo list |
| 查看仓库 | bkt repo view <slug> |
| 克隆仓库 | bkt repo clone <slug> --ssh |
| 创建仓库 | bkt repo create <name> --description "..." |
| 列出 PR | bkt pr list --state OPEN |
| 查看 PR | bkt pr view <id> |
| 创建 PR | bkt pr create --title "..." --source feature --target main |
| 合并 PR | bkt pr merge <id> |
| PR 检查 | bkt pr checks <id> --wait |
| 列出分支 | bkt branch list |
| 创建分支 | bkt branch create <name> --from main |
| 删除分支 | bkt branch delete <name> |
| 列出问题 (Cloud) | bkt issue list --state open |
| 创建问题 | bkt issue create -t "Bug title" -k bug |
| Webhooks | bkt webhook list |
| 运行流水线 | bkt pipeline run --ref main |
| API 应急通道 | bkt api /rest/api/1.0/projects |
bkt repo list --limit 20
bkt repo list --workspace myteam # Cloud 工作空间覆盖
bkt repo view platform-api
bkt repo create data-pipeline --description "数据摄取" --project DATA
bkt repo browse --project DATA --repo platform-api
bkt repo clone platform-api --ssh
# 列出和查看
bkt pr list --state OPEN --limit 10
bkt pr list --mine # 您创建的 PR
bkt pr view 42
bkt pr view 42 --web # 在浏览器中打开
# 创建和编辑
bkt pr create --title "feat: cache" --source feature/cache --target main --reviewer alice
bkt pr edit 123 --title "新标题" --body "更新后的描述"
# 评审和合并
bkt pr approve 42
bkt pr comment 42 --text "LGTM"
bkt pr merge 42 --message "merge: feature/cache"
bkt pr merge 42 --strategy fast-forward
# CI/构建状态
bkt pr checks 42 # 显示构建状态
bkt pr checks 42 --wait # 等待构建完成
bkt pr checks 42 --wait --timeout 5m # 带超时设置
bkt pr checks 42 --fail-fast # 首次失败即退出
# 本地检出
bkt pr checkout 42 # 检出到 pr/42 分支
bkt branch list
bkt branch list --filter "feature/*"
bkt branch create release/1.9 --from main
bkt branch delete feature/old-stuff
bkt branch set-default main # 仅限 DC
bkt branch protect add main --type fast-forward-only # 仅限 DC
bkt issue list --state open --kind bug
bkt issue view 42 --comments
bkt issue create -t "登录故障" -k bug -p major
bkt issue edit 42 --assignee "{uuid}" --priority critical
bkt issue close 42
bkt issue reopen 42
bkt issue comment 42 -b "已在 v1.2.0 中修复"
bkt issue status # 您分配/创建的问题
问题类型:bug、enhancement、proposal、task
优先级:trivial、minor、major、critical、blocker
bkt webhook list
bkt webhook create --name "CI" --url https://ci.example.com/hook --event repo:refs_changed
bkt webhook delete <id>
bkt webhook test <id>
bkt pipeline run --ref main --var ENV=staging
bkt pipeline list # 最近运行记录
bkt pipeline view <uuid> # 流水线详情
bkt pipeline logs <uuid> # 获取日志
bkt status pipeline <uuid> # 替代方案:状态检查
bkt perms project list --project DATA
bkt perms project grant --project DATA --user alice --perm PROJECT_WRITE
bkt perms repo list --project DATA --repo platform-api
bkt perms repo grant --project DATA --repo api --user alice --perm REPO_WRITE
对于尚未封装的端点:
bkt api /rest/api/1.0/projects --param limit=100 --json
bkt api /repositories --param workspace=myteam --field pagelen=50
所有命令都支持结构化输出:
bkt pr list --json # JSON 输出
bkt pr list --yaml # YAML 输出
bkt pr list --json | jq '.pull_requests[0].title'
--json / --yaml — 结构化输出--context <name> — 使用特定上下文--project <key> — 覆盖项目 (DC)--workspace <name> — 覆盖工作空间 (Cloud)--repo <slug> — 覆盖仓库BKT_CONFIG_DIR — 配置目录覆盖BKT_ALLOW_INSECURE_STORE — 允许基于文件的凭据存储BKT_KEYRING_TIMEOUT — 密钥环操作超时(例如 2m)每周安装量
113
仓库
GitHub Stars
32
首次出现
2026年1月26日
安全审计
安装于
gemini-cli93
codex91
cursor88
opencode87
claude-code86
github-copilot83
bkt is a unified CLI for Bitbucket Data Center and Bitbucket Cloud. It mirrors gh ergonomics and provides structured JSON/YAML output for automation.
Before executing anybkt command, verify the CLI is installed:
bkt --version
If the command fails or bkt is not found, install it using one of these methods:
| Platform | Command |
|---|---|
| macOS/Linux | brew install avivsinai/tap/bitbucket-cli |
| Windows | scoop bucket add avivsinai https://github.com/avivsinai/scoop-bucket && scoop install bitbucket-cli |
| Go | go install github.com/avivsinai/bitbucket-cli/cmd/bkt@latest |
| Binary | Download from GitHub Releases |
Only proceed withbkt commands after confirming installation succeeds.
# Data Center (opens browser for PAT creation)
bkt auth login https://bitbucket.example.com --web
# Data Center (direct)
bkt auth login https://bitbucket.example.com --username alice --token <PAT>
# Bitbucket Cloud
bkt auth login https://bitbucket.org --kind cloud --web
# Check auth status
bkt auth status
Bitbucket Cloud Token Requirements:
read:user:bitbucket)Contexts store host, project/workspace, and default repo settings:
# Create context for Data Center
bkt context create dc-prod --host bitbucket.example.com --project ABC --set-active
# Create context for Cloud
bkt context create cloud-team --host bitbucket.org --workspace myteam --set-active
# List and switch contexts
bkt context list
bkt context use cloud-team
| Task | Command |
|---|---|
| List repos | bkt repo list |
| View repo | bkt repo view <slug> |
| Clone repo | bkt repo clone <slug> --ssh |
| Create repo | bkt repo create <name> --description "..." |
| List PRs | bkt pr list --state OPEN |
| View PR | bkt pr view <id> |
bkt repo list --limit 20
bkt repo list --workspace myteam # 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 --ssh
# List and view
bkt pr list --state OPEN --limit 10
bkt pr list --mine # PRs you authored
bkt pr view 42
bkt pr view 42 --web # Open in browser
# Create and edit
bkt pr create --title "feat: cache" --source feature/cache --target main --reviewer alice
bkt pr edit 123 --title "New title" --body "Updated description"
# Review and merge
bkt pr approve 42
bkt pr comment 42 --text "LGTM"
bkt pr merge 42 --message "merge: feature/cache"
bkt pr merge 42 --strategy fast-forward
# CI/build status
bkt pr checks 42 # Show build status
bkt pr checks 42 --wait # Wait for builds to complete
bkt pr checks 42 --wait --timeout 5m # With timeout
bkt pr checks 42 --fail-fast # Exit on first failure
# Checkout locally
bkt pr checkout 42 # Fetches to pr/42 branch
bkt branch list
bkt branch list --filter "feature/*"
bkt branch create release/1.9 --from main
bkt branch delete feature/old-stuff
bkt branch set-default main # DC only
bkt branch protect add main --type fast-forward-only # DC only
bkt issue list --state open --kind bug
bkt issue view 42 --comments
bkt issue create -t "Login broken" -k bug -p major
bkt issue edit 42 --assignee "{uuid}" --priority critical
bkt issue close 42
bkt issue reopen 42
bkt issue comment 42 -b "Fixed in v1.2.0"
bkt issue status # Your assigned/created issues
Issue kinds: bug, enhancement, proposal, task Priorities: trivial, minor, major, critical, blocker
bkt webhook list
bkt webhook create --name "CI" --url https://ci.example.com/hook --event repo:refs_changed
bkt webhook delete <id>
bkt webhook test <id>
bkt pipeline run --ref main --var ENV=staging
bkt pipeline list # Recent runs
bkt pipeline view <uuid> # Pipeline details
bkt pipeline logs <uuid> # Fetch logs
bkt status pipeline <uuid> # Alt: status check
bkt perms project list --project DATA
bkt perms project grant --project DATA --user alice --perm PROJECT_WRITE
bkt perms repo list --project DATA --repo platform-api
bkt perms repo grant --project DATA --repo api --user alice --perm REPO_WRITE
For endpoints not yet wrapped:
bkt api /rest/api/1.0/projects --param limit=100 --json
bkt api /repositories --param workspace=myteam --field pagelen=50
All commands support structured output:
bkt pr list --json # JSON output
bkt pr list --yaml # YAML output
bkt pr list --json | jq '.pull_requests[0].title'
--json / --yaml — Structured output--context <name> — Use specific context--project <key> — Override project (DC)--workspace <name> — Override workspace (Cloud)--repo <slug> — Override repositoryBKT_CONFIG_DIR — Config directory overrideBKT_ALLOW_INSECURE_STORE — Allow file-based credential storageBKT_KEYRING_TIMEOUT — Keyring operation timeout (for example 2m)Weekly Installs
113
Repository
GitHub Stars
32
First Seen
Jan 26, 2026
Security Audits
Gen Agent Trust HubWarnSocketPassSnykWarn
Installed on
gemini-cli93
codex91
cursor88
opencode87
claude-code86
github-copilot83
| Create PR | bkt pr create --title "..." --source feature --target main |
| Merge PR | bkt pr merge <id> |
| PR checks | bkt pr checks <id> --wait |
| List branches | bkt branch list |
| Create branch | bkt branch create <name> --from main |
| Delete branch | bkt branch delete <name> |
| List issues (Cloud) | bkt issue list --state open |
| Create issue | bkt issue create -t "Bug title" -k bug |
| Webhooks | bkt webhook list |
| Run pipeline | bkt pipeline run --ref main |
| API escape hatch | bkt api /rest/api/1.0/projects |