5. AI Agents and Command Line Tools
SnippetsLab includes lab, a command-line tool for searching your library, fetching snippets, and saving new snippets from the shell. Together with the agent skill and the MCP server (lab mcp), it gives AI coding agents access to your library while they work:
An agent can search your library, browse your folders, tags, and languages, and read snippets. When you turn on write access (see Allowing Write Access), it can also create new snippets. It can never change or delete anything.
An agent sees the library that is currently open in SnippetsLab, excluding the trash.
Snippets that an agent reads become part of its conversation and are sent to the agent’s model provider, in the same way as any file the agent opens. The skill asks agents to fetch only what the task at hand needs.
If SnippetsLab is not running when an agent needs it, the app is opened automatically.
Note
SnippetsLab Settings > Integrations > AI Agents & Command Line Tools > Set Up… shows the setup commands for common agents, with the location of your copy of SnippetsLab filled in.
5.1. The lab Command-Line Tool
lab is part of the SnippetsLab app bundle. If SnippetsLab is in your Applications folder, the tool is at /Applications/SnippetsLab.app/Contents/Helpers/lab. You and your agents can run it directly from there without installing anything, for example:
'/Applications/SnippetsLab.app/Contents/Helpers/lab' search --launch -- "foo"
The tool can search your library, fetch snippets, list the folders, tags, and languages it contains, and, when write access is on, create snippets. Most commands return JSON, so lab can be used both from scripts and by agents. See the lab(1) Command Manual for all commands and options.
To run the tool simply as lab from any shell, create a symbolic link in /usr/local/bin:
sudo mkdir -p /usr/local/bin && sudo ln -s '/Applications/SnippetsLab.app/Contents/Helpers/lab' /usr/local/bin/lab
The command may ask for your administrator password. Adjust the path if SnippetsLab is installed somewhere other than your Applications folder. If /usr/local/bin/lab already exists, it stops without changing anything (this happens if you have another tool with the same name installed, such as the GitLab command-line tool, or if a link from a previous installation already exists).
Note
Installing lab is optional. The MCP server configurations on this page refer to the tool by its full path, and the agent skill tells agents to use the full path in the Applications folder when lab is not installed. If SnippetsLab is installed somewhere else, install lab for agents that use the skill.
5.2. Installing the Agent Skill
An agent skill is a set of instructions that tells an agent when a capability is relevant and how to use it. SnippetsLab’s skill follows the Agent Skills open standard. It tells the agent to consult your library only when it is relevant to the task, to start with small searches, to read a snippet in full before using it, to link back to the source, and to create a snippet only when you ask it to save something to your snippets library. You can read the full text in SnippetsLab Agent Skill.
To install the skill, save a copy to your agent’s skills folder. For example:
mkdir -p ~/.agents/skills/snippetslab && '/Applications/SnippetsLab.app/Contents/Helpers/lab' skill show > ~/.agents/skills/snippetslab/SKILL.md
Each agent has its own skills folder:
Agent |
Skills folder |
|---|---|
Antigravity |
|
Claude Code |
|
Gemini CLI |
|
Codex, Cursor, GitHub Copilot, and many others |
|
The ~/.agents/skills folder is a shared location read by many agents, including Amp, Codex, Cursor, GitHub Copilot, JetBrains Junie, OpenCode, Windsurf, and Zed. For the most up-to-date information, and for agents that are not listed here, consult the vendor’s documentation.
The installed file is a static copy. To pick up a new version of the skill after app updates, run the command again.
5.3. Connecting the MCP Server
Agents that support the Model Context Protocol (MCP) can work with your library without using a shell. SnippetsLab’s MCP server offers the same capabilities as lab, and is further optimized for agents. It is also the only option for agents that do not have shell access. The skill and the MCP server work together; an agent with both prefers the server and follows the skill’s guidance.
Once registered, your agent starts the server on demand:
- Claude Code
claude mcp add --scope user snippetslab -- '/Applications/SnippetsLab.app/Contents/Helpers/lab' mcp
- Codex
codex mcp add snippetslab -- '/Applications/SnippetsLab.app/Contents/Helpers/lab' mcp
Codex shares this configuration between its command-line tool, the ChatGPT desktop app, and its IDE extension.
- Gemini CLI
gemini mcp add --scope user snippetslab '/Applications/SnippetsLab.app/Contents/Helpers/lab' mcp
- GitHub Copilot
copilot mcp add snippetslab -- '/Applications/SnippetsLab.app/Contents/Helpers/lab' mcp
- Visual Studio Code
code --add-mcp '{"name":"snippetslab","command":"/Applications/SnippetsLab.app/Contents/Helpers/lab","args":["mcp"]}'
This requires the
codecommand, which you can install by choosing Shell Command: Install ‘code’ command in PATH from Visual Studio Code’s Command Palette.
Other agents usually read available servers from a configuration file. Add the following to the configuration file used by your agent, or add the snippetslab entry to its existing mcpServers object. If your agent is not listed or does not pick up the server, check the vendor’s documentation for the required format.
{
"mcpServers": {
"snippetslab": {
"command": "/Applications/SnippetsLab.app/Contents/Helpers/lab",
"args": ["mcp"]
}
}
}
Agent |
Configuration file |
|---|---|
Antigravity |
|
Claude desktop app |
|
Cursor |
|
JetBrains Junie |
|
Windsurf |
|
Note
You may need to start a new session or restart the agent app or IDE (Antigravity, Claude desktop app, Codex, etc.) after installing the MCP configuration for it to take effect.
Tip
By default, the MCP server opens SnippetsLab if the app is not running. To prevent this, add --no-launch after mcp in the configuration file. Agents will be told that SnippetsLab is unavailable until you open it yourself.
5.4. Allowing Write Access
Out of the box, the lab CLI and its MCP server have read-only access to your library. To allow saving new snippets, turn on Write Access in SnippetsLab Settings > Integrations > AI Agents & Command Line Tools > Set Up…. The change takes effect immediately.
With write access on, the CLI and agents can create new snippets with a title, content, note, language, folder, and tags. The folder must already exist. Tags that do not exist yet will be created.
Note
It is not possible to edit, move, or delete existing content via the CLI or MCP server.