semtools
This skill provides semantic search capabilities using embedding-based similarity matching for code and text. Enables meaning-based search beyond keyword matching, with optional document parsing (PDF, DOCX, PPTX) support.
What this skill does
# Semtools: Semantic Search
Perform semantic (meaning-based) search across code and documents using embedding-based similarity matching.
## Purpose
The semtools skill provides access to Semtools, a high-performance Rust-based CLI for semantic search and document processing. Unlike traditional text search (ripgrep) which matches exact strings, or structural search (ast-grep) which matches syntax patterns, semtools understands **semantic meaning** through embeddings.
**Key capabilities:**
1. **Semantic Search**: Find code/text by meaning, not just keywords
2. **Workspace Management**: Index large codebases for fast repeated searches
3. **Document Parsing**: Convert PDFs, DOCX, PPTX to searchable text (requires API key)
Semtools excels at **discovery** - finding relevant code when you don't know the exact keywords, function names, or syntax patterns.
## When to Use This Skill
Use the semtools skill when you need meaning-based search:
**Semantic Code Discovery:**
- Finding code that implements a concept ("error handling", "data validation")
- Discovering similar functionality across different modules
- Locating examples of a pattern when you don't know exact names
- Understanding what code does without reading everything
**Documentation & Knowledge:**
- Searching documentation by concept, not keywords
- Finding related discussions in comments or docs
- Discovering similar issues or solutions
- Analyzing technical documents (PDFs, reports)
**Use Cases:**
- "Find all authentication-related code" (without knowing function names)
- "Show me error handling patterns" (regardless of specific error types)
- "Find code similar to this implementation" (semantic similarity)
- "Search research papers for 'distributed consensus'" (document search)
**Choose semtools over file-search (ripgrep/ast-grep) when:**
- You know the **concept** but not the **keywords**
- Exact string matching misses relevant results
- You want semantically similar code, not exact matches
- Searching across languages or mixed content
**Still use file-search when:**
- You know exact keywords, function names, or patterns
- You need structural code matching (ast-grep)
- Speed is critical (ripgrep is faster for exact matches)
- You're searching for specific symbols or references
## Available Commands
Semtools provides three CLI commands you can use via `execute_command`:
- **`search`** - Semantic search across code and text files
- **`workspace`** - Manage workspaces for caching embeddings
- **`parse`** - Convert documents (PDF, DOCX, PPTX) to searchable text
**All commands work out-of-the-box** in your execution environment. Document parsing requires the LLAMA_CLOUD_API_KEY environment variable to be set.
## Core Operations
### 1. Semantic Search (`search`)
Find files and code sections by semantic meaning:
```bash
# Basic semantic search
search "authentication logic" src/
# Search with more context (5 lines before/after)
search "error handling" --n-lines 5 src/
# Get more results (default: 3)
search "database queries" --top-k 10 src/
# Control similarity threshold (0.0-1.0, lower = more lenient)
search "API endpoints" --max-distance 0.4 src/
```
**Parameters:**
- `--n-lines N`: Show N lines of context around matches (default: 3)
- `--top-k K`: Return top K most similar matches (default: 3)
- `--max-distance D`: Maximum embedding distance (0.0-1.0, default: 0.3)
- `-i`: Case-insensitive matching
**Output format:**
```
Match 1 (similarity: 0.12)
File: src/auth/handlers.py
Lines: 42-47
----
def authenticate_user(username: str, password: str) -> Optional[User]:
"""Authenticate user credentials against database."""
user = get_user_by_username(username)
if user and verify_password(password, user.password_hash):
return user
return None
----
Match 2 (similarity: 0.18)
File: src/middleware/auth.py
...
```
### 2. Workspace Management (`workspace`)
For large codebases, create workspaces to cache embeddings and enable fast repeated searches:
```bash
# Create/activate workspace
workspace use my-project
# Set workspace via environment variable
export SEMTOOLS_WORKSPACE=my-project
# Index files in workspace (workspace auto-detected from env var)
search "query" src/
# Check workspace status
workspace status
# Clean up old workspaces
workspace prune
```
**Benefits:**
- **Fast repeated searches**: Embeddings cached, no re-computation
- **Large codebases**: IVF_PQ indexing for scalability
- **Session persistence**: Maintain context across multiple searches
**When to use workspaces:**
- Searching the same codebase multiple times
- Very large projects (1000+ files)
- Interactive exploration sessions
- CI/CD pipelines with repeated searches
### 3. Document Parsing (`parse`) ⚠️ Requires API Key
Convert documents to searchable markdown (requires LlamaParse API key):
```bash
# Parse PDFs to markdown
parse research_papers/*.pdf
# Parse Word documents
parse reports/*.docx
# Parse presentations
parse slides/*.pptx
# Parse and pipe to search
parse docs/*.pdf | xargs search "neural networks"
```
**Supported formats:**
- PDF (.pdf)
- Word (.docx)
- PowerPoint (.pptx)
**Configuration:**
```bash
# Via environment variable
export LLAMA_CLOUD_API_KEY="llx-..."
# Via config file
cat > ~/.parse_config.json << EOF
{
"api_key": "llx-...",
"max_concurrent_requests": 10,
"timeout_seconds": 3600
}
EOF
```
**Important:** Document parsing is **optional**. Semantic search works without it.
## Workflow Patterns
### Pattern 1: Concept Discovery
When you know what you're looking for conceptually but not by name:
```bash
# Step 1: Broad semantic search
search "rate limiting implementation" src/
# Step 2: Review results, refine query
search "throttle requests per user" src/ --top-k 10
# Step 3: Use ripgrep for exact follow-up
rg "RateLimiter" --type py src/
```
### Pattern 2: Similar Code Finder
When you want to find code similar to a reference implementation:
```bash
# Step 1: Extract key concepts from reference code
# [Read example_auth.py and identify key concepts]
# Step 2: Search for similar implementations
search "user authentication with JWT tokens" src/
# Step 3: Compare implementations
# [Review semantic matches to find similar approaches]
```
### Pattern 3: Documentation Search
When researching concepts in documentation or comments:
```bash
# Search code comments semantically
search "thread safety guarantees" src/ --n-lines 10
# Search markdown documentation
search "deployment best practices" docs/
# Combined search
search "performance optimization" --top-k 20
```
### Pattern 4: Cross-Language Search
When searching for concepts across different languages:
```bash
# Semantic search works across languages
search "connection pooling" src/
# May find:
# - Java: "ConnectionPool manager"
# - Python: "database connection reuse"
# - Go: "pool of persistent connections"
# All semantically related despite different terminology
```
### Pattern 5: Document Analysis (with API key)
When analyzing PDFs or documents:
```bash
# Step 1: Parse documents to markdown
parse research/*.pdf > papers.md
# Step 2: Search converted content
search "transformer architecture" papers.md
# Step 3: Combine with code search
search "attention mechanism implementation" src/
```
## Integration with file-search
Semtools and file-search (ripgrep/ast-grep) are **complementary tools**. Use them together for comprehensive search:
### Search Strategy Matrix
| You Know | Use First | Then Use | Why |
|----------|-----------|----------|-----|
| Exact keywords | ripgrep | search | Fast exact match, then find similar |
| Concept only | search | ripgrep | Find relevant code, then search specifics |
| Function name | ripgrep | search | Find definition, then find similar usage |
| Code pattern | ast-grep | search | Find structure, then find similar logic |
| Approximate idea | search | ripgrep + ast-grep | Discover, then drill down |
### Layered Search Approach
```bash
# Layer 1Related in Writing & Docs
jax-development
IncludedUse this skill when the user is writing, debugging, profiling, refactoring, reviewing, benchmarking, parallelising, exporting, or explaining JAX code, or when they mention JAX, jax.numpy, jit, grad, value_and_grad, vmap, scan, lax, random keys, pytrees, jax.Array, sharding, Mesh, PartitionSpec, NamedSharding, pmap, shard_map, Pallas, XLA, StableHLO, checkify, profiler, or the JAX repo. It helps turn NumPy or PyTorch-style code into pure functional JAX, fix tracer/control-flow/shape/PRNG bugs, remove recompiles and host-device syncs, choose transforms and sharding strategies, inspect jaxpr/lowering/IR, and benchmark compiled code correctly.
nature-article-writer
IncludedDrafts, rewrites, diagnostically critiques, and style-calibrates primary research manuscripts for Nature and Nature Portfolio journals. Use when the user wants a Nature-style title, summary paragraph or abstract, introduction, results, discussion, methods, figure legends, presubmission enquiry, cover letter, reviewer response, or when a scientific draft sounds generic, jargon-heavy, structurally weak, or AI-ish and needs precise, broad-reader-friendly prose without inventing data, analyses, or references. Best for primary research articles and letters rather than reviews or press releases unless explicitly adapting one.
deckrd
IncludedDocument-driven framework that derives requirements, specifications, implementation plans, and executable tasks from goals through structured AI dialogue. Use when user says "write requirements", "create spec", "plan implementation", "derive tasks", "structure this feature", "break down into tasks", or "document this module". Also use for reverse engineering existing code into docs (/deckrd rev). Do NOT use for direct code writing — use /deckrd-coder after tasks are generated. Do NOT use when the user only wants to run or fix existing code without planning.
clinical-decision-support
IncludedGenerate professional clinical decision support (CDS) documents for pharmaceutical and clinical research settings, including patient cohort analyses (biomarker-stratified with outcomes) and treatment recommendation reports (evidence-based guidelines with decision algorithms). Supports GRADE evidence grading, statistical analysis (hazard ratios, survival curves, waterfall plots), biomarker integration, and regulatory compliance. Outputs publication-ready LaTeX/PDF format optimized for drug development, clinical research, and evidence synthesis.
handling-sf-data
IncludedSalesforce data operations with 130-point scoring. Use this skill to create, update, delete, bulk import/export, generate test data, and clean up org records using sf CLI and anonymous Apex. TRIGGER when: user creates test data, performs bulk import/export, uses sf data CLI commands, needs data factory patterns for Apex tests, or needs to seed/clean records in a Salesforce org. DO NOT TRIGGER when: SOQL query writing only (use querying-soql), Apex test execution (use running-apex-tests), or metadata deployment (use deploying-metadata).
accelint-ac-to-playwright
IncludedConvert and validate acceptance criteria for Playwright test automation. Use when user asks to (1) review/evaluate/check if AC are ready for automation, (2) assess if AC can be converted as-is, (3) validate AC quality for Playwright, (4) turn AC into tests, (5) generate tests from acceptance criteria, (6) convert .md bullets or .feature Gherkin files to Playwright specs, (7) create test automation from requirements. Handles both bullet-style markdown and Gherkin syntax with JSON test plan generation and validation.