Skip to content

Configuration File

The Bitbucket CLI stores configuration in a JSON file. This page documents the file format, location, and available settings.

File Location

~/.config/bb/config.json

Configuration Schema

KeyTypeDescriptionSet By
usernamestringYour Bitbucket usernamebb auth login
apiTokenstringYour API token (stored securely)bb auth login
workspacestringDefault workspacebb config set
repostringDefault repositorybb config set

Example Configuration

{
"username": "myuser",
"apiToken": "ATBB_xxxxxxxxxxxxxxxxxxxx",
"workspace": "myworkspace",
"repo": "myrepo"
}

Managing Configuration

View All Settings

Terminal window
bb config list

Output:

Configuration file: /Users/you/.config/bb/config.json
Key Value
username myuser
apiToken ********
workspace myworkspace
repo myrepo

Get a Specific Value

Terminal window
bb config get workspace
# Output: myworkspace

Set a Value

Terminal window
bb config set workspace myworkspace
bb config set repo myrepo

Protected Keys

Some configuration keys cannot be set directly:

KeyReasonHow to Set
usernameTied to authenticationUse bb auth login
apiTokenSecurity-sensitiveUse bb auth login

Configuration Precedence

When determining workspace and repository, the CLI checks sources in this order:

  1. Command-line flags (highest priority)

    Terminal window
    bb pr list -w otherworkspace -r otherrepo
  2. Git repository remote (if in a git repo)

    Terminal window
    cd /path/to/cloned-repo
    bb pr list # Uses workspace/repo from git remote
  3. Configuration file (lowest priority)

    Terminal window
    bb config set workspace myworkspace
    bb pr list # Uses config default

See Understanding Repository Context for detailed examples.


File Permissions

The configuration file contains sensitive data (API token). The CLI sets appropriate permissions automatically:

PlatformPermissions
macOS/Linux0600 (owner read/write only)
WindowsInherits user profile permissions

Reset Configuration

Clear Authentication Only

Terminal window
bb auth logout

This removes username and apiToken but keeps workspace and repo settings.

Full Reset

Delete the configuration file entirely:

Terminal window
rm ~/.config/bb/config.json

Then re-authenticate:

Terminal window
bb auth login

Troubleshooting

”Cannot read config file”

The file may be corrupted. Delete and recreate it:

Terminal window
rm ~/.config/bb/config.json
bb auth login

“Cannot write config file”

Check directory permissions:

Terminal window
ls -la ~/.config/bb/

Create the directory if it doesn’t exist:

Terminal window
mkdir -p ~/.config/bb

Config Not Being Used

Verify the CLI is reading from the expected location:

Terminal window
bb config list
# Check the "Configuration file:" line

Remember that command-line flags and git context take precedence over config file settings.