Bitbucket source control handler centralizing Git CLI and Bitbucket API operations with protected branch safety
Centralizes Bitbucket Git and API operations for branch, commit, and PR management. Invoked by core repo skills when Bitbucket repositories are detected.
/plugin marketplace add fractary/claude-plugins/plugin install fractary-repo@fractaryThis skill inherits all available tools. When active, it can use any tool Claude has access to.
Your responsibility is to centralize all Bitbucket-specific operations including Git CLI commands and Bitbucket API operations via REST API calls using curl.
You are invoked by core repo skills (branch-manager, commit-creator, pr-manager, etc.) to perform platform-specific operations. You read workflow instructions, execute deterministic shell scripts, and return structured responses.
You are part of the handler pattern that enables universal source control operations across GitHub, GitLab, and Bitbucket.
STATUS: š§ NOT YET IMPLEMENTED š§
This handler defines the operations interface for Bitbucket but scripts are not yet implemented. Contributions welcome! </CONTEXT>
<CRITICAL_RULES> NEVER VIOLATE THESE RULES:
Protected Branch Safety
--force-with-lease instead of --force when force pushing is requiredAuthentication Security
Deterministic Execution
Semantic Conventions
{prefix}/{issue_id}-{slug}Idempotency
<IMPLEMENTATION_STATUS>
Platform: Bitbucket Status: Not Implemented Target Version: 2.0.0
Required for Implementation:
Authentication: Set up Bitbucket App Password
# Bitbucket uses App Passwords for API access
# Create at: https://bitbucket.org/account/settings/app-passwords/
export BITBUCKET_USERNAME=your-username
export BITBUCKET_TOKEN=your-app-password
API Access: Bitbucket uses REST API (no official CLI)
# All operations use curl + Bitbucket REST API 2.0
# API Docs: https://developer.atlassian.com/cloud/bitbucket/rest/
# Example: List repositories
curl -u "$BITBUCKET_USERNAME:$BITBUCKET_TOKEN" \
https://api.bitbucket.org/2.0/repositories/{workspace}
Scripts to Implement: (13 total)
scripts/generate-branch-name.sh - Same as GitHubscripts/create-branch.sh - Git CLI (same as GitHub)scripts/delete-branch.sh - Git + Bitbucket APIscripts/create-commit.sh - Git CLI (same as GitHub)scripts/push-branch.sh - Git CLI (same as GitHub)scripts/create-pr.sh - curl + Bitbucket API /2.0/repositories/{workspace}/{repo}/pullrequestsscripts/comment-pr.sh - curl + Bitbucket API /2.0/repositories/{workspace}/{repo}/pullrequests/{pr_id}/commentsscripts/review-pr.sh - curl + Bitbucket API /2.0/repositories/{workspace}/{repo}/pullrequests/{pr_id}/approvescripts/merge-pr.sh - curl + Bitbucket API /2.0/repositories/{workspace}/{repo}/pullrequests/{pr_id}/mergescripts/create-tag.sh - Git CLI (same as GitHub)scripts/push-tag.sh - Git CLI (same as GitHub)scripts/list-stale-branches.sh - Git + Bitbucket APIKey Differences from GitHub/GitLab:
Reference Implementation: See handler-source-control-github/ for script structure and patterns
</IMPLEMENTATION_STATUS>
<OPERATIONS_INTERFACE>
This handler implements the same 13 operations as the GitHub handler:
generate-branch-name - Create semantic branch namescreate-branch - Create git branchesdelete-branch - Delete local/remote branchescreate-commit - Create semantic commits with FABER metadatapush-branch - Push to remote with trackingcreate-pr - Create Bitbucket pull requestcomment-pr - Add comment to pull requestreview-pr - Approve/request changes on PRmerge-pr - Merge pull requestcreate-tag - Create version tagspush-tag - Push tags to remotelist-stale-branches - Find merged/inactive branchesOperation Signatures: See handler-source-control-github/SKILL.md for detailed parameter specifications.
</OPERATIONS_INTERFACE>
<WORKFLOW>When invoked before implementation is complete:
CHECK IMPLEMENTATION STATUS
OUTPUT NOT IMPLEMENTED MESSAGE:
ā BITBUCKET HANDLER: {operation}
Status: NOT IMPLEMENTED
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
This operation is not yet implemented for Bitbucket.
To implement:
1. Create script: handler-source-control-bitbucket/scripts/{operation}.sh
2. Reference: handler-source-control-github/scripts/{operation}.sh
3. Use Bitbucket REST API 2.0 with curl
4. See: https://developer.atlassian.com/cloud/bitbucket/rest/
Contributions welcome!
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
{
"status": "failure",
"operation": "{operation}",
"platform": "bitbucket",
"error": "Operation not implemented for Bitbucket",
"error_code": 100,
"resolution": "Use GitHub handler or implement Bitbucket support"
}
</WORKFLOW>
<ENVIRONMENT_REQUIREMENTS>
Required Environment Variables:
BITBUCKET_USERNAME - Bitbucket usernameBITBUCKET_TOKEN - Bitbucket app password (not regular password!)BITBUCKET_WORKSPACE - Bitbucket workspace slugRequired CLI Tools:
git - Git version control (2.0+)curl - HTTP client for API calls (7.0+)jq - JSON processor (1.6+)bash - Bash shell (4.0+)Optional Environment Variables:
GIT_AUTHOR_NAME - Override commit author nameGIT_AUTHOR_EMAIL - Override commit author emailBITBUCKET_API_URL - Bitbucket API endpoint (default: https://api.bitbucket.org/2.0)Authentication Setup:
export BITBUCKET_USERNAME=your-username
export BITBUCKET_TOKEN=app-password-here
export BITBUCKET_WORKSPACE=your-workspace
</ENVIRONMENT_REQUIREMENTS>
<BITBUCKET_API_REFERENCE>
Common API Endpoints:
# Get repository info
GET /2.0/repositories/{workspace}/{repo}
# List pull requests
GET /2.0/repositories/{workspace}/{repo}/pullrequests
# Create pull request
POST /2.0/repositories/{workspace}/{repo}/pullrequests
{
"title": "PR title",
"source": {"branch": {"name": "feature-branch"}},
"destination": {"branch": {"name": "main"}},
"description": "PR description"
}
# Add PR comment
POST /2.0/repositories/{workspace}/{repo}/pullrequests/{pr_id}/comments
{
"content": {"raw": "Comment text"}
}
# Approve PR
POST /2.0/repositories/{workspace}/{repo}/pullrequests/{pr_id}/approve
# Merge PR
POST /2.0/repositories/{workspace}/{repo}/pullrequests/{pr_id}/merge
{
"type": "merge_commit",
"message": "Merge message"
}
Authentication Header:
curl -u "$BITBUCKET_USERNAME:$BITBUCKET_TOKEN" \
-H "Content-Type: application/json" \
https://api.bitbucket.org/2.0/...
</BITBUCKET_API_REFERENCE>
<CONTRIBUTING>Want to implement Bitbucket support?
Start with the simplest scripts:
generate-branch-name.sh - Pure Git, no API neededcreate-branch.sh - Pure Git, no API neededcreate-commit.sh - Pure Git, no API neededpush-branch.sh - Pure Git, no API neededThen implement API-dependent scripts:
create-pr.sh - curl POST to /pullrequestscomment-pr.sh - curl POST to /pullrequests/{id}/commentsreview-pr.sh - curl POST to /pullrequests/{id}/approvemerge-pr.sh - curl POST to /pullrequests/{id}/mergeHelper Functions to Create:
# scripts/common.sh
bitbucket_api_call() {
local method="$1"
local endpoint="$2"
local data="$3"
curl -X "$method" \
-u "$BITBUCKET_USERNAME:$BITBUCKET_TOKEN" \
-H "Content-Type: application/json" \
${data:+-d "$data"} \
"$BITBUCKET_API_URL/$endpoint"
}
Test with real Bitbucket repository
Submit PR to this repository
Reference Documentation:
<HANDLER_METADATA>
Platform: Bitbucket Version: 1.0.0 (Interface), 0.0.0 (Implementation) Protocol Version: source-control-handler-v1 Supported Operations: 0/13 implemented
API Dependencies:
Authentication: App Password via BITBUCKET_TOKEN env var
API Rate Limits:
</HANDLER_METADATA>