Comprehensive guide for managing Claude Code snippets v2.0 - discovering locations, creating snippets from files, searching by name/pattern/description, and validating configurations. Use this skill when users want to create, search, or manage snippet configurations in their Claude Code environment. Updated for LLM-friendly interface with TTY auto-detection.
Manages snippet configurations that auto-inject context when regex patterns match user messages. Use this when users want to create, search, or manage snippets—triggered by commands like `snippets create`, `snippets docker`, or `snippets paths`.
/plugin marketplace add WarrenZhu050413/Warren-Claude-Code-Plugin-Marketplace/plugin install claude-context-orchestrator@warren-claude-code-plugin-marketplaceThis skill inherits all available tools. When active, it can use any tool Claude has access to.
Snippets auto-inject context when regex patterns match user messages. This skill provides a streamlined workflow for discovering snippet locations, creating snippets, searching configurations, and direct file editing.
Snippets are pattern-triggered context injection files that enhance Claude's capabilities by automatically loading relevant information when specific keywords appear in user prompts. Think of them as "smart bookmarks" that activate based on what you're working on.
Every snippet consists of two components:
Located at:
/Users/wz/.claude/plugins/marketplaces/warren-claude-code-plugin-marketplace/claude-context-orchestrator/scripts/config.local.json
Structure:
{
"name": "snippet-identifier",
"pattern": "\\b(PATTERN)\\b[.,;:!?]?",
"snippet": ["../snippets/local/category/name/SNIPPET.md"],
"separator": "\n",
"enabled": true
}
Key fields:
name: Unique identifier for the snippetpattern: Regex pattern that triggers the snippet (MUST follow standard format)snippet: Array of file paths to inject (relative to config file)separator: How to join multiple files (usually "\n")enabled: Whether snippet is active (true/false)Located in subdirectory under:
/Users/wz/.claude/plugins/marketplaces/warren-claude-code-plugin-marketplace/claude-context-orchestrator/snippets/local/
Structure:
---
name: "Descriptive Name"
description: "When to use this snippet and what it provides"
---
[Content to be injected into context]
Organization: Snippets are organized by category:
snippets/local/communication/ - Email, reports, writing templatessnippets/local/documentation/ - Guides, references, how-tossnippets/local/development/ - Code patterns, debugging workflowssnippets/local/productivity/ - Workflow automation, task managementsnippets/local/output-formats/ - Formatting styles, templatesThe snippets CLI provides four focused commands:
paths - Discover available snippet categories and locationscreate - Create snippets from source files with validationlist / search - Search snippets by name, pattern, or descriptionvalidate - Verify configuration integrityInstallation:
cd /Users/wz/.claude/plugins/.../scripts
make install # Global: uv tool install
# OR
make dev # Local dev: uv run snippets
Auto-detect modes:
Follow these steps in order to effectively manage snippets.
Before creating a snippet, explore where snippets can be placed using the paths command.
List all categories:
snippets paths
# OR with JSON output
snippets paths --output json
Filter by keyword:
snippets paths dev # Shows categories matching "dev"
snippets paths email # Shows categories matching "email"
Output:
Determine the regex pattern that will trigger your snippet. Patterns must follow the standard format (see Regex Protocol below).
Pattern planning:
_, -, or no separator)|\b(PATTERN)\b[.,;:!?]?Examples:
\b(DOCKER)\b[.,;:!?]?\b(DOCKER|CONTAINER|DOCKERFILE)\b[.,;:!?]?\b(BUILD_ARTIFACT)\b[.,;:!?]?Create snippets using the create command, which validates and registers the snippet automatically.
Creation workflow:
Create source SKILL.md file with frontmatter:
---
name: "Docker Best Practices"
description: "Use when working with Docker containers, images, and containerization"
pattern: "\\b(DOCKER|CONTAINER|DOCKERFILE)\\b[.,;:!?]?"
---
# Docker Best Practices
[Content here...]
Run create command:
snippets create source.md snippets/local/development/docker/SKILL.md
# With pattern override
snippets create source.md snippets/local/development/docker/SKILL.md \
--pattern "\\b(NEW_PATTERN)\\b[.,;:!?]?"
# Force overwrite existing
snippets create source.md snippets/local/development/docker/SKILL.md --force
What create does:
Helpful error messages:
Common mistakes to avoid:
\\b word boundaries (requires double backslash)Search snippets using enhanced multi-level matching (name → pattern → description).
List all snippets:
snippets # Default: list all (TTY: interactive, piped: JSON)
snippets list # Explicit list command
snippets --output json # Force JSON output
Search by keyword:
snippets docker # Searches name, pattern, and description
snippets kubernetes # Priority: exact name > name contains > pattern > description
Interactive mode (TTY):
Non-interactive mode (piped/JSON):
Match priority ranking:
snippets mail finds snippet named "mail"snippets dock finds "docker"snippets KUBECTL finds patterns with KUBECTLsnippets "email templates" finds description matchesWhat to check:
Regular audits:
Philosophy: v2.0 CLI focuses on search and creation. Updates are done by editing files directly.
Modify existing snippets when:
Update workflow:
Find the snippet:
snippets docker # Search to locate snippet
# OR in interactive mode: select snippet → opens in $EDITOR
Determine what needs updating:
enabled field)name field)For pattern updates:
# Edit config.local.json directly
vim ~/.claude/plugins/.../scripts/config.local.json
# Modify the pattern field
{
"name": "docker",
"pattern": "\\b(DOCKER|CONTAINER|DOCKERFILE|KUBECTL)\\b[.,;:!?]?", # Added KUBECTL
...
}
For content updates:
# Edit SKILL.md directly
vim ~/.claude/plugins/.../snippets/local/development/docker/SKILL.md
# Update content while maintaining YAML frontmatter
Validate changes:
snippets validate # Check for errors
snippets validate --output json # JSON output for scripting
Test:
Context-aware updating: If a snippet failed to load during a session, analyze why:
"enabled": false to trueRemove snippets that are:
Deletion workflow:
Backup first:
# Create backup of config
cp ~/.claude/plugins/.../scripts/config.local.json \
~/.claude/plugins/.../scripts/config.local.json.backup.$(date +%Y%m%d_%H%M%S)
# Backup snippet file
cp -r ~/.claude/plugins/.../snippets/local/category/snippet-name \
~/.claude/plugins/.../backups/snippet-name_$(date +%Y%m%d_%H%M%S)
Remove from config.local.json:
vim ~/.claude/plugins/.../scripts/config.local.json
# Delete the entire mapping object
# Ensure JSON remains valid (check commas)
Optionally delete SKILL.md:
rm -rf ~/.claude/plugins/.../snippets/local/category/snippet-name
Validate and verify:
snippets validate # Check JSON is valid
snippets # Confirm snippet is gone
# Type trigger keyword → should not load
Restoration: If you need to restore:
cp backup/config.local.json.backup.TIMESTAMP config.local.jsoncp -r backup/snippet-name_TIMESTAMP snippets/local/category/snippet-namesnippets validate and test trigger keywordCRITICAL: All snippet patterns MUST follow this format.
\b(PATTERN)\b[.,;:!?]?
Rules:
\b at start and end()_, -, or no separator (never spaces)_ and - in same pattern[.,;:!?]? at end| for multiple keywordsUsers naturally add punctuation when typing. Excluding punctuation causes mismatches:
[.,;:]? does NOT match "ARTIFACT!"[.,;:!?]? matches "ARTIFACT!", "ARTIFACT?", "ARTIFACT."Always use the full set: [.,;:!?]?
\b(DOCKER)\b[.,;:!?]? # Single word
\b(DOCKER|CONTAINER|DOCKERFILE)\b[.,;:!?]? # Alternation
\b(BUILD_ARTIFACT)\b[.,;:!?]? # Underscore separator
\b(BUILD-ARTIFACT)\b[.,;:!?]? # Hyphen separator
\b(BUILDARTIFACT)\b[.,;:!?]? # No separator
\b(docker)\b[.,;:!?]? # ❌ Lowercase
\b(BUILD ARTIFACT)\b[.,;:!?]? # ❌ Space separator
\b(BUILD_ART-IFACT)\b[.,;:!?]? # ❌ Mixed separators
\bDOCKER\b # ❌ Missing parens and punctuation
\b(DOCKER)\b[.,;:]? # ❌ Incomplete punctuation
User input → Standard format:
Convert to ALL CAPS:
Handle multi-word:
_ (preferred), -, or noneHandle alternation:
(DOCKER|CONTAINER|DOCKERFILE)Apply standard format:
\b boundaries[.,;:!?]? for punctuationIMPORTANT: In config.local.json, backslashes must be doubled:
{
"pattern": "\\b(DOCKER)\\b[.,;:!?]?"
}
Single \b becomes \\b in JSON.
Step 1: Understand needs
Step 2: Plan pattern
\b(DOCKER|CONTAINER|DOCKERFILE)\b[.,;:!?]?Step 3: Create snippet
Create directory:
mkdir -p ~/.claude/plugins/.../snippets/local/development/docker
Create SNIPPET.md:
---
name: "Docker Best Practices"
description: "Use when working with Docker containers, images, and containerization"
---
# Docker Best Practices
[Content here...]
Add to config.local.json:
{
"name": "docker",
"pattern": "\\b(DOCKER|CONTAINER|DOCKERFILE)\\b[.,;:!?]?",
"snippet": ["../snippets/local/development/docker/SNIPPET.md"],
"separator": "\n",
"enabled": true
}
Step 4: Test
Scenario: User typed "kubectl" but kubernetes snippet didn't load
Step 5: Update pattern
Current pattern: \b(KUBERNETES|K8S)\b[.,;:!?]?
Analysis: Missing "kubectl" keyword
New pattern: \b(KUBERNETES|K8S|KUBECTL)\b[.,;:!?]?
Edit config.local.json:
{
"name": "kubernetes",
"pattern": "\\b(KUBERNETES|K8S|KUBECTL)\\b[.,;:!?]?",
...
}
Test: Type "kubectl" → snippet now loads
Backup → Remove from config.local.json → Delete SNIPPET.md → Verify
~/.claude/plugins/.../scripts/config.local.json~/.claude/plugins/.../snippets/local/{category}/{name}/SNIPPET.mdcommunication/, documentation/, development/, productivity/, output-formats/[.,;:!?]?\\b not \b| Task | Command / Action |
|---|---|
| Discover categories | snippets paths or snippets paths <filter> |
| Create snippet | snippets create source.md snippets/local/category/name/SKILL.md |
| List all snippets | snippets or snippets list |
| Search snippets | snippets <keyword> (searches name/pattern/description) |
| Update pattern | Edit pattern field in config.local.json directly |
| Update content | Edit SKILL.md file directly (or use snippets <name> in TTY → opens $EDITOR) |
| Enable/disable | Change enabled field in config.local.json |
| Delete snippet | 1. Backup files<br>2. Remove from config.local.json<br>3. Delete SKILL.md directory |
| Validate config | snippets validate or snippets validate --output json |
| Test pattern | Type trigger keyword in new prompt |
| Issue | Fix |
|---|---|
| Not loading | Check enabled: true, pattern matches (ALL CAPS), file path correct |
| Pattern not matching | Verify standard format, use [.,;:!?]?, test with ALL CAPS |
| Too many loading | Check overlapping patterns, disable conflicts |
| JSON errors | Validate syntax, use \\b not \b |
Architecture:
\\bWhen User Corrects You: Stop → Read actual files → Understand architecture → Fix all related mistakes → Verify