Finding related code: code that's semantically similar but uses different terms
When NOT to Use
Exact matches: Use Grep for class Foo, def bar, specific identifiers
Regex patterns: Use Grep for error.*handling, import.*from
File paths: Use Glob for *.test.ts, src/**/*.py
Commands
# Search the current project's index
leann search <index-name> "<query>" --top-k 5
# List available indexes
leann list
# Example
leann search rigg "how do providers handle streaming" --top-k 5
LEANN uses sentence embeddings to understand meaning
Searches find conceptually similar code, not just text matches
Results ranked by semantic similarity score (0-1)
Grep vs LEANN Decision
Query Type
Tool
Example
Natural language
LEANN
"how does caching work"
Class/function name
Grep
"class CacheManager"
Pattern matching
Grep
error|warning
Find implementations
LEANN
"rate limiting logic"
1---2name: leann-search3description: LEANN Semantic Search4---56# LEANN Semantic Search78Use LEANN for meaning-based code search instead of grep.910## When to Use1112- **Conceptual queries**: "how does authentication work", "where are errors handled"13- **Understanding patterns**: "streaming implementation", "provider architecture"14- **Finding related code**: code that's semantically similar but uses different terms1516## When NOT to Use1718- **Exact matches**: Use Grep for `class Foo`, `def bar`, specific identifiers19- **Regex patterns**: Use Grep for `error.*handling`, `import.*from`20- **File paths**: Use Glob for `*.test.ts`, `src/**/*.py`2122## Commands2324```bash25# Search the current project's index26leann search <index-name> "<query>" --top-k 52728# List available indexes29leann list3031# Example32leann search rigg "how do providers handle streaming" --top-k 533```3435## MCP Tool (in Claude Code)3637```38leann_search(index_name="rigg", query="your semantic query", top_k=5)39```4041## Rebuilding the Index4243When codebase changes significantly:4445```bash46cd /path/to/project47leann build <project-name> --docs src tests scripts \48 --file-types '.ts,.py,.md,.json' \49 --no-recompute --no-compact \50 --embedding-mode sentence-transformers \51 --embedding-model all-MiniLM-L6-v252```5354## How It Works55561. LEANN uses sentence embeddings to understand *meaning*572. Searches find conceptually similar code, not just text matches583. Results ranked by semantic similarity score (0-1)5960## Grep vs LEANN Decision6162| Query Type | Tool | Example |63|------------|------|---------|64| Natural language | LEANN | "how does caching work" |65| Class/function name | Grep | "class CacheManager" |66| Pattern matching | Grep | `error\|warning` |67| Find implementations | LEANN | "rate limiting logic" |
Run npx skillmds@latest add dojogenesis/leann-search in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
LEANN Semantic Search It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
DojoGenesis (@dojogenesis) published this skill. Their other Agent Skills are listed on their SkillMD profile.