Snippet Commands - Manage Bitbucket Snippets
Manage Bitbucket Cloud snippets — workspace-scoped code/text pastes.
Snippet commands operate at workspace scope (no repo context required). Use
-w, --workspace <workspace> or set a default with
bb config set defaultWorkspace <workspace>.
Global options available on all snippet commands: --json [fields], --jq <expression>, --no-color, -w, --workspace.
bb snippet list
Section titled “bb snippet list”List snippets in a workspace.
bb snippet list [options]Options
Section titled “Options”| Option | Description |
|---|---|
-w, --workspace <workspace> | Workspace |
--role <role> | Filter by authenticated user’s role: owner, contributor, or member |
--limit <number> | Maximum number of snippets (default: 25) |
--json | Output as JSON |
Examples
Section titled “Examples”bb snippet listbb snippet list --role ownerbb snippet list --limit 50 --json
# Project to specific fields (returns a flat array)bb snippet list --json id,title,is_private
# Filter with built-in --jq — public snippets onlybb snippet list --json --jq '.snippets[] | select(.is_private == false) | .title'--limitis enforced across paginated responses.
bb snippet view
Section titled “bb snippet view”View snippet details. Optionally print file contents.
bb snippet view <id> [options]Arguments
Section titled “Arguments”| Argument | Description |
|---|---|
id | Snippet encoded ID (e.g. kypj) |
Options
Section titled “Options”| Option | Description |
|---|---|
-w, --workspace <workspace> | Workspace |
-f, --file <name> | Print contents of a specific file in the snippet |
--files | Print contents of all files in the snippet |
--json | Output as JSON |
Examples
Section titled “Examples”bb snippet view kypjbb snippet view kypj --jsonbb snippet view kypj --file config.ymlbb snippet view kypj --filesbb snippet create
Section titled “bb snippet create”Create a snippet. The files you pass are uploaded as multipart/form-data
to Bitbucket — their contents are the snippet body.
bb snippet create [options]Options
Section titled “Options”| Option | Description |
|---|---|
-w, --workspace <workspace> | Workspace |
-t, --title <title> | Snippet title (required) |
-f, --file <path...> | One or more file paths to include (required) |
--private | Create a private snippet (default) |
--public | Create a public snippet |
--json | Output as JSON |
Examples
Section titled “Examples”bb snippet create -t "My snippet" -f file.txtbb snippet create -t "Config files" -f config.yml -f setup.sh --public- Snippets are private by default.
--privateand--publiccannot both be set.- Each
--filemust exist on disk; missing files fail the command before any upload.
bb snippet edit
Section titled “bb snippet edit”Update a snippet’s title, visibility, or files.
bb snippet edit <id> [options]Arguments
Section titled “Arguments”| Argument | Description |
|---|---|
id | Snippet encoded ID |
Options
Section titled “Options”| Option | Description |
|---|---|
-w, --workspace <workspace> | Workspace |
-t, --title <title> | New title |
--private | Make snippet private |
--public | Make snippet public |
-f, --file <path...> | Replace or add file(s); sends a multipart update |
--json | Output as JSON |
Examples
Section titled “Examples”bb snippet edit kypj -t "New title"bb snippet edit kypj --publicbb snippet edit kypj -f updated.txt- Metadata-only edits (title, visibility) send a JSON PUT.
- Passing
--fileswitches to a multipart PUT and uploads the given files. - At least one of
--title,--private,--public, or--fileis required.
bb snippet delete
Section titled “bb snippet delete”Delete a snippet. Permanent.
bb snippet delete <id> [options]Options
Section titled “Options”| Option | Description |
|---|---|
-w, --workspace <workspace> | Workspace |
-y, --yes | Confirm deletion (required) |
--json | Output as JSON |
Examples
Section titled “Examples”bb snippet delete kypj --yesbb snippet watch / bb snippet unwatch
Section titled “bb snippet watch / bb snippet unwatch”Subscribe or unsubscribe the authenticated user to/from a snippet.
bb snippet watch <id> [options]bb snippet unwatch <id> [options]Examples
Section titled “Examples”bb snippet watch kypjbb snippet unwatch kypjbb snippet comments list
Section titled “bb snippet comments list”List comments on a snippet.
bb snippet comments list <id> [options]Options
Section titled “Options”| Option | Description |
|---|---|
-w, --workspace <workspace> | Workspace |
--limit <number> | Maximum number of comments (default: 25) |
--json | Output as JSON |
Examples
Section titled “Examples”bb snippet comments list kypjbb snippet comments list kypj --limit 50 --jsonbb snippet comments add
Section titled “bb snippet comments add”Add a comment to a snippet.
bb snippet comments add <id> [options]Options
Section titled “Options”| Option | Description |
|---|---|
-w, --workspace <workspace> | Workspace |
-m, --message <message> | Comment body (required) |
--json | Output as JSON |
Examples
Section titled “Examples”bb snippet comments add kypj -m "Great snippet!"bb snippet comments edit
Section titled “bb snippet comments edit”Edit a comment on a snippet.
bb snippet comments edit <snippet-id> <comment-id> <message> [options]Examples
Section titled “Examples”bb snippet comments edit kypj 123 "Updated comment"bb snippet comments delete
Section titled “bb snippet comments delete”Delete a comment on a snippet.
bb snippet comments delete <snippet-id> <comment-id> [options]Options
Section titled “Options”| Option | Description |
|---|---|
-w, --workspace <workspace> | Workspace |
-y, --yes | Confirm deletion (required) |
--json | Output as JSON |
Examples
Section titled “Examples”bb snippet comments delete kypj 123 --yes