lab(1) Command Manual
LAB(1) General Commands Manual LAB(1)
NAME
lab – Search, fetch, and create snippets in the SnippetsLab library.
SYNOPSIS
lab subcommand [--version] [--help]
DESCRIPTION
lab sends requests to the running SnippetsLab app. Pass --launch to start the app
automatically. Search the library to find snippets and their UUIDs, then fetch a snippet by its
UUID. Create a snippet from standard input when write access is enabled in SnippetsLab. Most
subcommands print JSON, and fetch prints text by default.
EXAMPLES:
# List the snippets matching a query, without their content
lab search --brief "foo"
# Print the first fragment of a snippet
lab fetch --snippet <uuid>
# Create a snippet from a file
lab create --title "Build notes" < notes.md
--version
Show the version.
-h, --help
Show help information.
search Search the library for snippets.
Prints the matching snippets as JSON, in the order shown in the app unless --sort is
given. Without a query, every snippet matches, subject to the filters and to --limit.
By default, each word of the query matches anywhere in a word, and every word must
match. Pass --no-fuzzy to switch to whole-word matching by default and to enable the
additional search syntax shown below.
QUERY SYNTAX:
AND, &, space Both terms must match
OR, | Either term may match
NOT, ! Exclude a term
( ) Group terms
* Match a prefix, suffix, or substring: foo*, *bar, *baz*
"..." Match a phrase
NOT cannot be used as a unary operator, as in `NOT foo`. The full syntax is described
in the SnippetsLab user manual:
https://www.renfei.org/snippets-lab/manual/mac/essentials.html#search-syntax
EXAMPLES:
# Search snippet content and metadata
lab search "hello world"
# Find the ten most recently modified snippets
lab search --brief --sort modified --limit 10
# Search a folder and its subfolders
lab search --folder "Apple Dev" --include-subfolders "foo"
# Match whole words with an operator, in Swift snippets only
lab search --language swift --no-fuzzy "async AND await"
# Match any of several substrings
lab search --no-fuzzy "*certbot* OR *acme*"
# Match titles only, case-sensitively
lab search --scope title --case-sensitive "Hello World"
--timeout seconds
The number of seconds to wait for the app to respond. (default: 5.0)
-l, --launch
Launch SnippetsLab if it is not running. The tool launches the enclosing
SnippetsLab.app, falling back to the installation registered with Launch
Services.
-v, --verbose
Print more information about progress.
--scope scope
The parts of a snippet the query is matched against; all by default.
title Snippet titles only.
all Titles, tags, notes, content, languages, and attachment names.
--fuzzy
Match each word of the query anywhere in a word (the default), or match whole
words and allow the additional search syntax.
--no-fuzzy
Match each word of the query anywhere in a word (the default), or match whole
words and allow the additional search syntax.
--case-sensitive
Match the case of the query.
--folder uuid-or-name...
Only search this folder, by UUID or name; repeat to search several. Prefer the
UUIDs from `lab list filters`, since names may be ambiguous.
--include-subfolders
Also search the subfolders of each --folder.
--uncategorized
Only search snippets that are not in any folder. With --folder, search those
folders and the snippets that are not in any folder.
--tag uuid-or-name...
Only search snippets that have this tag, by UUID or name; repeat to require
every tag.
--language name...
Only search snippets in this language, by lexer name (e.g. SwiftLexer) or alias
(e.g. swift); repeat to require every language.
--sort key
The order of the results. Omit to use the order shown in the app, which also
takes pinned status into account.
relevance
Best match first; requires a query.
modified
Most recently modified first.
created
Most recently created first.
title Alphabetical by title.
--reverse
Reverse the order of the results.
--offset count
The number of results to skip. (default: 0)
--limit count
The maximum number of results to return; 0 for no limit. (default: 100)
--brief
Show only each snippet's UUID, title, folder path, tags, languages, fragment
count, total content length, date modified, search context, and the UUIDs of
the fragments that match the query, without its fragments.
--max-note-length bytes
The maximum length of each fragment's note in UTF-8 bytes. Truncated notes end
with `[truncated]`.
--max-content-length bytes
The maximum length of each fragment's content in UTF-8 bytes. Truncated content
ends with `[truncated]`, and contentLength still reports the full size.
query The text to search for.
--version
Show the version.
-h, --help
Show help information.
list List the folders, tags, and languages that can be used as search filters.
Prints each folder, tag, and language as JSON, with its name, the number of snippets
under it, and the UUID or identifier to pass to `lab search` or `lab create`.
EXAMPLES:
# Show all available filters and the corresponding UUIDs
lab list filters
type The kind of information to list.
--timeout seconds
The number of seconds to wait for the app to respond. (default: 5.0)
-l, --launch
Launch SnippetsLab if it is not running. The tool launches the enclosing
SnippetsLab.app, falling back to the installation registered with Launch
Services.
-v, --verbose
Print more information about progress.
--version
Show the version.
-h, --help
Show help information.
fetch Print a snippet or one of its fragments.
Snippet UUIDs are returned by `lab search`, and individual fragment UUIDs can be
obtained by additionally passing `--format json`.
EXAMPLES:
# Print the first fragment of a snippet
lab fetch --snippet <snippet-uuid>
# Print a specific fragment
lab fetch --snippet <snippet-uuid> --fragment <fragment-uuid>
# Print the snippet, with all fragments and metadata, as JSON
lab fetch --format json --snippet <snippet-uuid>
--snippet uuid
The UUID of the snippet.
--fragment uuid
The UUID of the fragment to include.
--format format
The output format. (default: text)
text The content of one fragment, as plain text. The first fragment is used
unless --fragment is given.
json The snippet and its metadata in JSON. All fragments are included unless
--fragment is given.
--max-output-length bytes
The maximum total length in UTF-8 bytes of all notes and content in the output.
Truncated text ends with `[truncated]`. In JSON, contentLength still reports
each fragment's full size.
--timeout seconds
The number of seconds to wait for the app to respond. (default: 5.0)
-l, --launch
Launch SnippetsLab if it is not running. The tool launches the enclosing
SnippetsLab.app, falling back to the installation registered with Launch
Services.
-v, --verbose
Print more information about progress.
--version
Show the version.
-h, --help
Show help information.
create Create a snippet.
Adds a new snippet to the library and prints its UUID, title, and the names of any tags
it created, as JSON. The content is read from standard input unless --content is given.
In a terminal, type or paste the content and press Control-D to finish.
Write access must be enabled in SnippetsLab Settings > Integrations > AI Agents &
Command-Line Tools. To check whether it is enabled, run `lab info`.
EXAMPLES:
# Create a snippet from a file, in a folder, with a tag
lab create --title "Build a complex user interface" --folder "Apple Dev" \
--tag swiftui < tutorial.md
# Create a snippet from the clipboard, in the given language
pbpaste | lab create --title "Pasted content" --language swift
# Create a short snippet by specifying the content directly
lab create --title "Listening ports" --content "lsof -iTCP -sTCP:LISTEN"
--title title
The title of the snippet.
--content text
The content of the snippet. Read from standard input when omitted.
--note text
A note for the snippet.
--language name
The language, by lexer name (e.g. SwiftLexer) or alias (e.g. swift). Defaults
to the folder's default language, or else the app's default language.
--folder uuid-or-name
The folder, by UUID or name; omit for no folder. Prefer the UUIDs from `lab
list filters`, since names may be ambiguous.
--tag uuid-or-name...
Tags to add, by UUID or name; repeat to add several. New tags will be created.
--timeout seconds
The number of seconds to wait for the app to respond. (default: 5.0)
-l, --launch
Launch SnippetsLab if it is not running. The tool launches the enclosing
SnippetsLab.app, falling back to the installation registered with Launch
Services.
-v, --verbose
Print more information about progress.
--version
Show the version.
-h, --help
Show help information.
info Show information about the library and the app.
Prints the library's name, location, and counts, the app's version and edition, and
whether write access is enabled, as JSON.
--timeout seconds
The number of seconds to wait for the app to respond. (default: 5.0)
-l, --launch
Launch SnippetsLab if it is not running. The tool launches the enclosing
SnippetsLab.app, falling back to the installation registered with Launch
Services.
-v, --verbose
Print more information about progress.
--version
Show the version.
-h, --help
Show help information.
skill Print the agent skill for AI coding tools.
--version
Show the version.
-h, --help
Show help information.
show Print the agent skill to standard output.
The skill describes how an AI coding agent can access the library through this
tool and, when configured, the MCP server (`lab mcp`). Install it by writing
the output to a `snippetslab` directory in the agent's skills location:
mkdir -p <skills-dir>/snippetslab
lab skill show > <skills-dir>/snippetslab/SKILL.md
Setup commands for common agents are in SnippetsLab Settings > Integrations >
AI Agents & Command-Line Tools. This subcommand does not contact the app.
--version
Show the version.
-h, --help
Show help information.
mcp Run an MCP server for SnippetsLab over standard input and output.
Runs a server that offers the SnippetsLab MCP (Model Context Protocol) tools. Reads
JSON-RPC 2.0 messages from standard input, forwards each tool call to the running
SnippetsLab app as a request, and writes responses to standard output. Diagnostics go
to standard error.
SnippetsLab is launched on demand unless --no-launch is given.
EXAMPLES:
# Run the server, automatically launching SnippetsLab as needed
lab mcp
# Run the server, but report an error if SnippetsLab is not running
lab mcp --no-launch
Setup commands for common agents are in SnippetsLab Settings > Integrations > AI Agents
& Command-Line Tools.
--timeout seconds
The number of seconds to wait for the app to respond to a tool call. (default:
30.0)
--no-launch
Do not launch SnippetsLab automatically. Report that the app cannot be reached
instead.
-v, --verbose
Print more information about progress.
--version
Show the version.
-h, --help
Show help information.
help Show subcommand help information.
subcommands...
--version
Show the version.
EXIT STATUS
The lab utility exits 0 on success, and >0 if an error occurs.
SnippetsLab 2.7.1 October 5, 2026 LAB(1)