avivsinai/bitbucket-cli
Overview
This skill provides a unified Bitbucket CLI experience for Data Center and Cloud with gh-like ergonomics. It makes repository, pull request, branch, issue, webhook, pipeline, and permission management scriptable via structured JSON/YAML output. Use it to automate workflows, run ad-hoc admin tasks, and integrate Bitbucket operations into CI/CD pipelines.
How this skill works
The CLI talks directly to Bitbucket Data Center or Cloud using configured contexts and personal access tokens. Commands map common actions (repo, pr, branch, issue, webhook, pipeline, perms) to concise subcommands and support --json/--yaml for machine-readable output. A raw API escape hatch (bkt api ...) covers endpoints not yet wrapped.
When to use it
- List, view, clone, create, or manage repositories across Cloud and Data Center.
- Create, review, merge, or checkout pull requests from scripts or terminals.
- Automate branch creation, deletion, protection, and default branch changes.
- Manage Bitbucket Cloud issues and run or inspect pipelines programmatically.
- Create, list, test, and delete webhooks and manage permissions in Data Center.
- Run ad-hoc REST calls against Bitbucket endpoints not exposed by the CLI.
Best practices
- Always run bkt --version before scripts to confirm installation and fail early.
- Use contexts to switch hosts, projects/workspaces, and default repo settings for portability.
- Prefer --json or --yaml in automation for stable parsing and filtering with jq/yq.
- Use --web only for interactive token creation; store tokens securely and prefer non-file credential stores when possible.
- Test destructive commands (branch delete, pr merge) in a staging context before running in production.
Example use cases
- CI job that lists changed repos and triggers bkt pipeline run on affected projects using --json output.
- Developer workflow: bkt branch create feature/x --from main, push, then bkt pr create --title "feat" --source feature/x --target main.
- Ops task: bkt context create dc-prod --host bitbucket.example.com --project ABC --set-active, then bkt perms project grant to add a user.
- Automation script that polls bkt pr checks <id> --wait --timeout to gate merges on CI success.
- Admin audit: bkt repo list --limit 100 --json | jq to produce inventory of repos and their defaults.
FAQ
Create separate contexts and run bkt auth login with --web or token credentials; use --kind cloud for Bitbucket Cloud and host URL for Data Center.
Can I use the CLI inside CI pipelines?
Yes. Use API tokens with appropriate scopes, prefer structured output (--json), and ensure tokens are injected securely as pipeline secrets.