# Bitbucket

> Connect Bitbucket so the Coder can read repositories and pull requests, and open pull requests for review once your house rules are met.

Connect Bitbucket and the Coder reads your repository, its pull requests, and its issues, does the work in its own [workspace](/docs/workspaces/files), and hands you a pull request for review.

## At a glance

| | |
| --- | --- |
| Category | Source control |
| Status | Available |
| Used by | Coder (available now) |

## What assistants can do

| Ability | How it runs |
| --- | --- |
| Read repositories, pull requests, and issues | Reads on its own |
| Read changed files and build results | Reads on its own |
| Open issues | Waits for your Approve |
| Push a branch with the Coder's work | Waits for your Approve (unless your house rules allow it) |
| Open a pull request, a draft by default | Waits for your Approve (unless your house rules allow it) |
| Merge a pull request | Only when your house rules allow it |

## Setup

1. In Bitbucket, create a repository or workspace access token that can read and write the repository and its pull requests. Or create an Atlassian token or app password to use together with your account name.
2. Open [Integrations](https://stellarfirm.ai/app/integrations) and pick **Bitbucket**.
3. Paste the token. If you made an Atlassian token or app password, also enter your account name.
4. Press **Connect**, then tell the Coder which repository to use, for example "work in [workspace]/[repository]".

## Permissions

In plain words, the token needs to:

- **Read** the repository, its pull requests, issues, and build results.
- **Write** to the repository, so the Coder can push a branch.
- **Read and write** pull requests, so it can open one.

A repository access token is the narrowest choice. An Atlassian token or app password acts as you, so give it only these permissions.

## Good to know

- **Pushing and merging follow your house rules.** The work becomes a pull request for review, a draft by default on a first run. If your house rules allow it, the Coder can also merge. Pushing a branch waits for your Approve unless your house rules allow it. See [approvals](/docs/ceo/approvals).
- Your token stays with your StellarFirm workspace and is never shown back to you. The page shows only that it is connected.
- The account name is needed only with an Atlassian token or app password, not with a repository or workspace access token.
- If the clone fails, the job stops as **Blocked** before any coding and says what to fix.

## Prompts

```prompt title="Pick up a ticket"
Coder, Bitbucket is connected. Pick up the top open issue on [workspace]/[repository], implement it, and open a pull request for review once I Approve.
```

```prompt title="Summarise open pull requests"
Coder, list the open pull requests on [workspace]/[repository], say which ones are stuck, and what each is waiting for.
```

```prompt title="Check a build"
Coder, read the latest build results on [workspace]/[repository] and tell me whether the main branch is healthy.
```

---

Source: https://stellarfirm.ai/docs/integrations/bitbucket
