mcpField
L
leann-search

leann-search

github.com/parcadeiDevelopment3.9k76 installsUpdated 39w ago
Repository

About leann-search

leann-search is a skill for searching code by meaning with LEANN, suited to finding concepts, implementation patterns, and related code. It uses sentence embeddings and ranks results by semantic similarity; exact identifiers, regex patterns, and file paths are better handled with Grep or Glob.

Key features

  1. 01Search code by meaning
  2. 02Rank results by semantic similarity
  3. 03List available indexes
  4. 04Rebuild project indexes
  5. 05Provide a Claude Code MCP tool

Use cases

  1. 01Find authentication or error-handling logic
  2. 02Explore streaming or provider architecture
  3. 03Locate similar implementations using different terms

MCP support

In Claude Code, it provides the `leann_search` MCP tool for semantic queries against a named index.

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/parcadei/continuous-claude-v3 --skill leann-search

After installing, type/leann-searchin Claude Code to confirm it loaded.

Details

From the project README

LEANN Semantic Search

Use LEANN for meaning-based code search instead of grep.

When to Use

  • Conceptual queries: "how does authentication work", "where are errors handled"
  • Understanding patterns: "streaming implementation", "provider architecture"
  • 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

MCP Tool (in Claude Code)

leann_search(index_name="rigg", query="your semantic query", top_k=5)

Rebuilding the Index

When codebase changes significantly:

cd /path/to/project
leann build <project-name> --docs src tests scripts \
  --file-types '.ts,.py,.md,.json' \
  --no-recompute --no-compact \
  --embedding-mode sentence-transformers \
  --embedding-model all-MiniLM-L6-v2

How It Works

  1. LEANN uses sentence embeddings to understand meaning
  2. Searches find conceptually similar code, not just text matches
  3. Results ranked by semantic similarity score (0-1)

Grep vs LEANN Decision

Query TypeToolExample
Natural languageLEANN"how does caching work"
Class/function nameGrep"class CacheManager"
Pattern matchingGreperror|warning
Find implementationsLEANN"rate limiting logic"

Comments

Markdown supported