Snippet Commands - Manage Bitbucket Snippets
Manage Bitbucket Cloud snippets, workspace-scoped code/text pastes.
Snippet commands operate at workspace scope (no repository context
required). Use -w, --workspace <workspace> or set a default with
bb config set defaultWorkspace <workspace>.
See Global flags for JSON output, workspace/repository selection, and display options.
bb snippet list
Section titled “bb snippet list”List snippets in a workspace.
bb snippet list [options]Options
Section titled “Options”| Option | Description |
|---|---|
--role <role> |
Filter by authenticated user’s role: owner, contributor, or member |
--limit <number> |
Maximum number of snippets (default: 25) |
--all |
List all snippets (overrides --limit) |
Examples
Section titled “Examples”bb snippet listbb snippet list --role ownerbb snippet list --limit 50 --jsonbb snippet list --all
# 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'- Table columns: ID, TITLE, VISIBILITY, CREATOR, UPDATED.
- JSON envelope:
{ workspace, count, snippets }. --limitis enforced across paginated responses.- When the result is capped by
--limit, a hint shows how many were listed; use a higher--limitor--allto see the rest (suppressed with--json).
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 |
|---|---|
-f, --file <name> |
Print contents of a specific file in the snippet |
--files |
Print contents of all files in the snippet |
Examples
Section titled “Examples”bb snippet view kypjbb snippet view kypj --jsonbb snippet view kypj --file config.ymlbb snippet view kypj --files--filetakes precedence over--files. Pass both and only the single file is printed.- An unknown file name fails with
File not found in snippet: <name>(5003 FILE_NOT_FOUND, see Error codes). The error context carriesavailablewith the snippet’s actual file names. --filesprints the snippet header first, then each file under a bold── <name> ──heading. With the global--no-unicodethe separator renders as--.- JSON shapes differ per flag:
- no flag → the bare Bitbucket snippet object, no envelope
--file <name>→{ file, content }--files→{ snippet, files: { "<name>": "<content>" } }
bb 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 |
|---|---|
-t, --title <title> |
Snippet title (required) |
-f, --file <path...> |
File path(s) to include (required; variadic, pass several paths or repeat the flag) |
--private |
Create a private snippet (default) |
--public |
Create a public snippet |
--dry-run |
Print the write request instead of sending it (details) |
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
# Capture the new snippet idbb snippet create -t "My snippet" -f file.txt --json --jq '.id'- Snippets are private by default.
--privateand--publiccannot both be set.- Each
--filemust exist on disk; missing files fail the command before any upload. --jsonemits the bare Bitbucket snippet object, with no envelope.
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 (e.g. kypj) |
Options
Section titled “Options”| Option | Description |
|---|---|
-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 (variadic) |
--dry-run |
Print the write request instead of sending it (details) |
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. --jsonemits the bare Bitbucket snippet object, with no envelope.
bb snippet delete
Section titled “bb snippet delete”Delete a snippet.
bb snippet delete <id> [options]Arguments
Section titled “Arguments”| Argument | Description |
|---|---|
id |
Snippet encoded ID (e.g. kypj) |
Options
Section titled “Options”| Option | Description |
|---|---|
-y, --yes |
Skip the confirmation prompt (required when not in an interactive terminal) |
--dry-run |
Print the write request instead of sending it (details) |
Examples
Section titled “Examples”bb snippet delete kypj --yes- JSON envelope:
{ success, snippetId, workspace }.
bb 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]Arguments
Section titled “Arguments”| Argument | Description |
|---|---|
id |
Snippet encoded ID (e.g. kypj) |
Options
Section titled “Options”| Option | Description |
|---|---|
--dry-run |
Print the write request instead of sending it (details) |
Examples
Section titled “Examples”bb snippet watch kypjbb snippet unwatch kypj- JSON envelope:
{ success, snippetId, watching },watchingistrueforwatchandfalseforunwatch.
bb snippet comments list
Section titled “bb snippet comments list”See snippet comments for options and examples.