// "โก PRIMARY TOOL for semantic code understanding with LLM enrichment. ANTI-PATTERNS: Reading 5+ files sequentially, Glob then read all, Grep for 'how does X work'. CORRECT: claudemem search first (use --use-case navigation for agents), Read specific lines after."
| name | claudemem-search |
| description | โก PRIMARY TOOL for semantic code understanding with LLM enrichment. ANTI-PATTERNS: Reading 5+ files sequentially, Glob then read all, Grep for 'how does X work'. CORRECT: claudemem search first (use --use-case navigation for agents), Read specific lines after. |
| allowed-tools | Bash, Task, AskUserQuestion |
This Skill provides comprehensive guidance on leveraging claudemem v0.2.0 with LLM enrichment for intelligent, context-aware semantic code search.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ CLAUDEMEM v0.2.0 ARCHITECTURE โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ SEARCH LAYER โโ
โ โ Query โ Embed โ Vector Search + BM25 โ Ranked Results โโ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ ENRICHMENT LAYER (LLM) โญNEW โโ
โ โ file_summary โ symbol_summary โ idiom โ usage_example โโ
โ โ (1 call/file)โ (batched/file) โ โ โโ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ INDEX LAYER โโ
โ โ AST Parse โ Chunk (functions/classes) โ Embed โ LanceDB โโ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Search queries now match BOTH:
This dramatically improves semantic understanding over v0.1.x.
Source: Tree-sitter AST parsing Content: Actual code blocks (functions, classes, methods) Best for: Implementation details, signatures, exact syntax
| Field | Description |
|---|---|
id | SHA256 hash |
content | Raw code |
filePath | File location |
startLine / endLine | Line numbers (1-indexed) |
chunkType | function, class, method, module, block |
name | Function/class name |
signature | Extracted signature |
When to prioritize:
Source: LLM analysis (1 call per file) Content: File purpose, exports, dependencies, patterns Best for: Architecture discovery, understanding file roles
Example enriched content:
File: src/core/indexer.ts
Purpose: Core indexing orchestrator for claudemem
Responsibilities:
- Coordinates file scanning, parsing, and embedding
- Manages incremental updates via content hashing
- Integrates with enrichment pipeline for LLM summaries
Exports: CodebaseIndexer, IndexStatus
Dependencies: VectorStore, FileTracker, Enricher
Patterns: Factory pattern, progress callbacks
When to prioritize:
Source: LLM analysis (1 call for ALL symbols in file) Content: Function/class documentation Best for: API understanding, finding by behavior
Example enriched content:
function: enrichFiles
Summary: Enriches multiple files using batched LLM calls for efficiency
Parameters:
- files: Array of files with content and code chunks
- options: Concurrency and progress callback settings
Returns: EnrichmentResult with document counts and errors
Side effects: Stores documents in vector store, updates tracker
Usage: Called during index --enrich or standalone enrich command
When to prioritize:
claudemem v0.2.0 provides three optimized search modes:
Use case: Code completion, autocomplete Optimizes for: Exact code patterns
claudemem search "async function handle" --use-case fim
Weight distribution:
| Document Type | Weight |
|---|---|
| code_chunk | 50% |
| usage_example | 25% |
| idiom | 15% |
| symbol_summary | 10% |
Use case: Developer searching codebase Optimizes for: Balanced understanding
claudemem search "authentication flow" # default mode
Weight distribution:
| Document Type | Weight |
|---|---|
| file_summary | 25% |
| symbol_summary | 25% |
| code_chunk | 20% |
| idiom | 15% |
| usage_example | 10% |
Use case: AI agent exploring codebase Optimizes for: Understanding structure
claudemem search "authentication middleware" --use-case navigation
Weight distribution:
| Document Type | Weight |
|---|---|
| symbol_summary | 35% |
| file_summary | 30% |
| code_chunk | 20% |
| idiom | 10% |
| project_doc | 5% |
โ ๏ธ IMPORTANT: When using claudemem in detective agents, ALWAYS use --use-case navigation for optimal results.
# Basic indexing (AST + embeddings only)
claudemem index [path]
# Force full re-index
claudemem index -f
# Index with LLM enrichment โญNEW
claudemem index --enrich
# Force re-index with enrichment
claudemem index -f --enrich
# Run enrichment on indexed files
claudemem enrich [path]
# Control parallelism (default: 10)
claudemem enrich --concurrency 5
# Enrich specific path
claudemem enrich ./src/core
# Semantic search (default: search use case)
claudemem search "authentication middleware"
# Limit results
claudemem search "error handling" -n 20
# Filter by language
claudemem search "class definition" -l typescript
# Specific use case โญNEW
claudemem search "validate input" --use-case navigation
claudemem search "async handler" --use-case fim
# Show index and enrichment status
claudemem status
# Output includes:
# - Total files/chunks indexed
# - Document type counts (code_chunk, file_summary, symbol_summary) โญNEW
# - Enrichment progress (pending/complete) โญNEW
# - Embedding model used
# Get role-specific instructions
claudemem ai architect # System design focus
claudemem ai developer # Implementation focus
claudemem ai tester # Test coverage focus
claudemem ai debugger # Error tracing focus
# Raw output for clipboard
claudemem ai developer --raw | pbcopy
Claude should invoke this Skill when:
# Check if claudemem CLI is available
which claudemem || command -v claudemem
# Check version (must be 0.2.0+)
claudemem --version
If NOT installed, present installation options:
AskUserQuestion({
questions: [{
question: "claudemem CLI not found. How would you like to install it?",
header: "Install",
multiSelect: false,
options: [
{ label: "npm (Recommended)", description: "npm install -g claude-codemem" },
{ label: "Homebrew (macOS)", description: "brew tap MadAppGang/claude-mem && brew install --cask claudemem" },
{ label: "Shell script", description: "curl -fsSL https://raw.githubusercontent.com/MadAppGang/claudemem/main/install.sh | bash" },
{ label: "Skip installation", description: "I'll install it manually later" }
]
}]
})
# Check if initialized (looks for config)
ls ~/.claudemem/config.json 2>/dev/null || echo "Not configured"
# Check for project-local index
ls .claudemem/ 2>/dev/null || echo "No local index"
# Check full status including enrichment
claudemem status
Status output now includes:
# Full index with LLM enrichment (recommended)
claudemem index --enrich
# Or index first, then enrich separately
claudemem index
claudemem enrich
โ ๏ธ Without enrichment, you only get code_chunk results (v0.1.x behavior). โ With enrichment, you get file_summary + symbol_summary for much better semantic understanding.
# Index with enrichment (recommended for semantic search)
claudemem index --enrich
# Or index in stages
claudemem index # Fast: AST + embeddings
claudemem enrich # Slower: LLM enrichment
What happens during enrichment:
claudemem status
Look for:
Document Types:
code_chunk: 1,234
file_summary: 567 โ Should match file count
symbol_summary: 890 โ Functions/classes documented
Enrichment: complete โ Ready for semantic search
claudemem --models
Curated Picks:
| Model | Best For | Price | Context |
|---|---|---|---|
voyage/voyage-code-3 | Best Quality (default) | $0.180/1M | 32K |
qwen/qwen3-embedding-8b | Best Balanced | $0.010/1M | 33K |
qwen/qwen3-embedding-0.6b | Best Value | $0.002/1M | 33K |
Recommendation: Use voyage/voyage-code-3 for best code understanding (default).
Choose the right use case for your task:
| Task | Use Case | Command |
|---|---|---|
| Developer searching | search (default) | claudemem search "query" |
| AI agent exploring | navigation | claudemem search "query" --use-case navigation |
| Code completion | fim | claudemem search "query" --use-case fim |
Concept-Based Queries (Best for enriched search):
claudemem search "user authentication login flow with JWT tokens"
claudemem search "database connection pooling initialization"
claudemem search "error handling middleware for HTTP requests"
Why These Work Better with Enrichment:
Architecture Discovery (use file_summary):
claudemem search "main entry point application bootstrap" --use-case navigation
claudemem search "service layer business logic orchestration" --use-case navigation
claudemem search "repository data access pattern" --use-case navigation
API Exploration (use symbol_summary):
claudemem search "create user account function parameters" --use-case navigation
claudemem search "validate input before save" --use-case navigation
claudemem search "error response formatting" --use-case navigation
Implementation Details (use code_chunk):
claudemem search "JWT token generation implementation"
claudemem search "password hashing bcrypt"
claudemem search "database transaction commit"
Anti-pattern: Sequential file reads, grep for keywords Best practice: Semantic search โ targeted file reads
// WRONG: Read all files
const files = await glob("src/**/*.ts");
for (const file of files) {
const content = await read(file);
if (content.includes("auth")) { /* ... */ }
}
// RIGHT: Semantic search first
// 1. Check enrichment status
claudemem status // Verify enrichment complete
// 2. Search with navigation use case
claudemem search "authentication flow user login" --use-case navigation -n 10
// 3. Only read high-scoring matches
// Results are ranked by combined code_chunk + file_summary + symbol_summary
Match document type to your needs:
| Task | Primary Types | Why |
|---|---|---|
| Architecture discovery | file_summary | Understands file purposes |
| API exploration | symbol_summary | Has params, returns, side effects |
| Code completion | code_chunk | Exact syntax needed |
| Understanding behavior | symbol_summary | LLM-analyzed purpose |
| Finding patterns | file_summary | Contains detected patterns |
Start broad with file_summary, narrow down to symbol_summary, then code_chunk:
# Step 1: Broad architecture search (file_summary weighted)
claudemem search "authentication" --use-case navigation -n 5
# Step 2: Specific function search (symbol_summary weighted)
claudemem search "validate JWT token function" --use-case navigation -n 10
# Step 3: Implementation details (code_chunk weighted)
claudemem search "JWT verification implementation" -n 3
# ALWAYS check status first
claudemem status
# If enrichment not complete, run it
claudemem enrich
# Then search with confidence
claudemem search "auth flow" --use-case navigation
// Semantic search
search_code(
query: string,
limit?: number, // Default: 10
language?: string, // Filter by language
autoIndex?: boolean // Auto-index changes (default: true)
)
// Index codebase
index_codebase(
path?: string, // Default: current directory
force?: boolean, // Force re-index
model?: string // Override embedding model
)
// Get status
get_status(path?: string)
// Clear index
clear_index(path?: string)
// List models
list_embedding_models(freeOnly?: boolean)
Add to .mcp.json:
{
"mcpServers": {
"claudemem": {
"command": "claudemem",
"args": ["--mcp"]
}
}
}
| Score | Meaning | Action |
|---|---|---|
| > 0.85 | Strong match | Use directly |
| 0.70-0.85 | Good match | Review briefly |
| 0.50-0.70 | Partial match | Verify manually |
| < 0.50 | Weak match | Refine query |
With enrichment, scores are generally higher because:
# Check enrichment status
claudemem status
# Look for:
# Enrichment: not run OR incomplete
# Run enrichment if needed
claudemem enrich
# Reduce concurrency
claudemem enrich --concurrency 3
# Or enrich specific directories
claudemem enrich ./src/core
claudemem enrich ./src/services
claudemem status--use-case navigation for agent tasks-l typescript# Check document type counts
claudemem status
# If file_summary count is 0, enrichment hasn't run
claudemem enrich
# Force re-enrichment
claudemem index -f --enrich
Before completing a claudemem workflow, ensure:
claudemem status)--use-case navigation for agents) โญNEWโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ COMMON MISTAKES TO AVOID โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฃ
โ โ
โ โ Reading 5+ files sequentially when investigating a feature โ
โ โ WHY WRONG: Token waste, no ranking, no context โ
โ โ DO INSTEAD: claudemem search "feature concept" --use-case navigation โ
โ โ
โ โ Using Glob to find all files, then reading them one-by-one โ
โ โ WHY WRONG: Gets ALL files, not RELEVANT files โ
โ โ DO INSTEAD: claudemem search "what you're looking for" โ
โ โ
โ โ Using Grep for architectural questions like "how does X work" โ
โ โ WHY WRONG: Text match โ semantic understanding โ
โ โ DO INSTEAD: claudemem search "X functionality flow" --use-case nav โ
โ โ
โ โ Searching without checking enrichment status โ
โ โ WHY WRONG: Missing file_summary and symbol_summary matches โ
โ โ DO INSTEAD: claudemem status first, enrich if needed โ
โ โ
โ โ Using default search mode for agent exploration โ
โ โ WHY WRONG: Default weights optimized for humans, not agents โ
โ โ DO INSTEAD: --use-case navigation for agent tasks โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
| Anti-Pattern | Why It's Wrong | Correct Pattern |
|---|---|---|
claudemem search "auth" (no enrichment) | Missing LLM summaries | claudemem status โ enrich โ search |
claudemem search "auth flow" (agent) | Wrong use case | claudemem search "auth flow" --use-case navigation |
Read auth/login.ts then Read auth/session.ts... | No ranking, token waste | claudemem search "auth login session" |
grep -r "auth" src/ | No semantic understanding | claudemem search "authentication flow" |
| Assume enrichment is done | May miss summaries | Check claudemem status first |
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ CORRECT INVESTIGATION FLOW (v0.2.0) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ 1. claudemem status โ Check index AND enrichment โ
โ 2. claudemem enrich โ Run if enrichment incomplete โ
โ 3. claudemem search "..." โ Use --use-case navigation โ
โ --use-case navigation โ
โ 4. Review results โ See ranked file/symbol/code โ
โ 5. Read specific lines โ ONLY from search results โ
โ โ
โ โ ๏ธ NEVER: Start with Read/Glob for semantic questions โ
โ โ ๏ธ NEVER: Search without verifying enrichment โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
voyage/voyage-code-3 (best code understanding, $0.180/1M tokens)claudemem --models to see all available models and choose based on budget/quality.claudemem/ directory (no cloud storage)--mcp flag--use-case navigation for AI agent explorationMaintained by: Jack Rudenko @ MadAppGang Plugin: code-analysis v2.4.0 Last Updated: December 2025