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. With lab, the agent skill, and the MCP server (lab mcp), AI coding agents can access your library while they work:
An agent can search your library, browse folders, tags, and languages, and read snippets. When you turn on write access, it can also create new snippets. It can never change or delete anything.
An agent has access to 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 instructs agents to fetch only what is needed for the task at hand.
If SnippetsLab isn’t open when an agent needs it, the app is opened automatically.
5.1. The lab Command-Line Tool
lab is bundled with SnippetsLab. When the app is in the Applications folder, the tool is at /Applications/SnippetsLab.app/Contents/Helpers/lab. Scripts and agents can run it directly with its full path:
'/Applications/SnippetsLab.app/Contents/Helpers/lab' search --launch -- "docker"
Most commands return JSON output, making lab well suited for automation and agent workflows. For a complete list of commands and options, see the lab(1) Command Manual.
To run the tool simply as lab from any shell session, create a symlink to it in a folder in your PATH, such as /usr/local/bin:
sudo mkdir -p /usr/local/bin && sudo ln -s '/Applications/SnippetsLab.app/Contents/Helpers/lab' /usr/local/bin/lab
Adjust the target path if SnippetsLab isn’t in the Applications folder. If /usr/local/bin/lab already exists (for example, from the GitLab CLI), the command fails without modifying the existing file.
Note
Creating the symlink is optional. The MCP server configurations and the agent skill use the full path to lab in the app bundle. However, if SnippetsLab isn’t in the Applications folder, add lab to your PATH so that agents using the skill can find it.
5.2. Agent Skill
The agent skill contains instructions for an agent on when and how to use the CLI and MCP server. The SnippetsLab skill follows the open Agent Skills standard and instructs agents to:
Query the library only when it’s relevant to the current task.
Read snippets completely before using them, and link back to their sources.
Create snippets only upon explicit request.
The skill file is a static copy. To get updates after a new SnippetsLab release, follow the installation steps again to overwrite the existing file.
For the full skill definition, see SnippetsLab Agent Skill.
5.3. MCP Server
Agents that support the Model Context Protocol (MCP) can interact with your library directly without shell access. The MCP server provides the same features as lab, and is optimized for agents. When both the skill and the MCP server are set up, agents prefer the MCP server while following the skill’s instructions.
The server provides six tools:
Read-only:
search_snippets,get_snippet,list_filters, andinfoWrite:
create_snippet, which requires write accessApp:
open_snippet, which opens a snippet in SnippetsLab and brings the app to the front, so you can ask the agent to show you a snippet it found or added
5.4. Installation
5.4.1. Installing from SnippetsLab
You can set up the agent skill and the MCP server in SnippetsLab settings for Antigravity, Claude Code, Claude Desktop, Cursor, Gemini CLI, GitHub Copilot, LM Studio, OpenAI Codex, and Visual Studio Code:
Go to Settings > Integrations and click Set Up for AI Agents & Command-Line Tools.
Click the pop-up menu next to Set up the skill and MCP server for, and then choose your agent.
Next to Agent Skill and MCP Server, click Set Up to see the command or configuration snippet for your agent, or click Install to continue the setup in the agent’s app.
For Claude Desktop, SnippetsLab adds an extension that works in chats, Cowork, and Claude Code sessions. For Claude Code in Terminal or an IDE, choose Claude Code in the pop-up menu instead.
For other agents, see the following sections on how to install the skill and the MCP server manually.
Note
The commands and installations use the location of the SnippetsLab app. If you move SnippetsLab to a different folder later, repeat the setup.
5.4.2. Installing Manually
Installing the Agent Skill
To install the skill manually, save the skill file in 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
The location of the skills folder varies by agent:
Agent |
Skills folder |
|---|---|
Antigravity |
|
Claude Code |
|
Gemini CLI |
|
Codex, Cursor, GitHub Copilot, and many others |
|
The ~/.agents/skills folder is a shared location supported by many tools, including Amp, Codex, Cursor, GitHub Copilot, JetBrains Junie, OpenCode, Windsurf, and Zed. If your agent isn’t listed, see the agent’s documentation for the location of its skills folder.
Connecting the MCP Server
To add the server manually, use the configuration command for your agent. After it’s configured, the agent starts and manages the server automatically.
- 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 CLI
copilot mcp add snippetslab -- '/Applications/SnippetsLab.app/Contents/Helpers/lab' mcp
Most other environments define MCP servers in a JSON configuration file. Add the snippetslab entry to your agent’s existing mcpServers object, or create the file with the following content:
{
"mcpServers": {
"snippetslab": {
"command": "/Applications/SnippetsLab.app/Contents/Helpers/lab",
"args": ["mcp"]
}
}
}
Common configuration paths include:
Agent |
Configuration file |
|---|---|
Antigravity |
|
JetBrains Junie |
|
Windsurf |
|
If your agent isn’t listed or can’t find the server, see the agent’s documentation for the location and format of the configuration file.
By default, the MCP server opens SnippetsLab if the app isn’t open. To turn this off, add --no-launch after mcp in the configuration command or the args array. Until you open SnippetsLab manually, requests fail with an error indicating the app is unavailable.
Note
After you update the configuration file, restart the agent or IDE for the changes to take effect.
5.5. Allowing Write Access
By default, lab and the MCP server have read-only access to your library. To allow saving new snippets, go to Settings > Integrations, click Set Up for AI Agents & Command-Line Tools, and turn on Write Access. This change takes effect immediately.
With write access on, lab and agents can create new snippets and set their title, content, notes, language, folder, and tags. The folder must already exist. Tags that don’t exist yet are created.
Note
It’s not possible to edit, move, or delete existing snippets with lab or the MCP server.