Get the FREE Ultimate OpenClaw Setup Guide →

search-tools

npx machina-cli add skill parcadei/Continuous-Claude-v3/search-tools --openclaw
Files (1)
SKILL.md
1.9 KB

Search Tool Hierarchy

When searching code, use this decision tree:

Decision Tree

Need CONCEPTUAL/SEMANTIC search?
  (how does X work, find patterns, understand architecture)
  → Use LEANN (/leann-search) - embedding-based semantic search
  → PreToolUse hook auto-redirects semantic Grep queries

Need to understand code STRUCTURE?
  (find function calls, class usages, refactor patterns)
  → Use AST-grep (/ast-grep-find)

Need to find TEXT in code?
  → Use Morph (/morph-search) - 20x faster
  → If no Morph API key: fall back to Grep tool

Simple one-off search?
  → Use built-in Grep tool directly

Tool Comparison

ToolBest ForRequires
LEANNSemantic search: "how does caching work", "error handling patterns", conceptual queriesIndex built
AST-grepStructural patterns: "find all calls to foo()", refactoring, find usages by typeMCP server
MorphFast text search: "find files mentioning error", grep across codebaseAPI key
GrepLiteral patterns, class/function names, regexNothing (built-in)

Examples

LEANN (semantic/conceptual):

  • "how does authentication work"
  • "find error handling patterns"
  • "where is rate limiting implemented"

AST-grep (structural):

  • "Find all functions that return a Promise"
  • "Find all React components using useState"
  • "Refactor all imports of X to Y"

Morph (text search):

  • "Find all files mentioning 'authentication'"
  • "Search for TODO comments"

Grep (literal):

  • class ProviderAdapter
  • def __init__
  • Regex patterns

LEANN Commands

# Search with semantic query
leann search opc-dev "how does blackboard communication work" --top-k 5

# List available indexes
leann list

# Rebuild index (when code changes)
leann build opc-dev --docs dir1 dir2 --no-recompute --no-compact --force

Source

git clone https://github.com/parcadei/Continuous-Claude-v3/blob/main/.claude/skills/search-tools/SKILL.mdView on GitHub

Overview

Code Search Tool Hierarchy guides when to use semantic, structural, or text searches in code. It maps decision steps to LEANN for semantic search, AST-grep for structure, Morph for fast text search, and Grep for literal matches.

How This Skill Works

Follow the decision tree: conceptual/semantic searches use LEANN (/leann-search) and may be auto-redirected from semantic Grep queries via the PreToolUse hook; for code structure, use AST-grep (/ast-grep-find); for text search, use Morph (/morph-search) with a Morph API key; if Morph isn't available or for simple literal searches, fall back to the built-in Grep tool.

When to Use It

  • Need conceptual/semantic search (how does X work, patterns) using LEANN
  • Need to understand code structure (function calls, refactor patterns) using AST-grep
  • Need to find text in code (Morph) or fall back to Grep if Morph API key is missing
  • Do a simple one-off search using the built-in Grep tool directly
  • When evaluating tool options, compare LEANN, AST-grep, Morph, and Grep to decide the best fit

Quick Start

  1. Step 1: Decide which tool to use (semantic LEANN, AST-grep, Morph, or Grep)
  2. Step 2: Run a sample query, e.g. leann search opc-dev "how does authentication work" --top-k 5 or /ast-grep-find <pattern> or /morph-search "Find all files mentioning 'authentication'"
  3. Step 3: If Morph API key is missing, fall back to Grep; optionally list/build LEANN indexes using leann list and leann build

Best Practices

  • Start with LEANN for semantic questions when you need conceptual understanding
  • Use AST-grep to target structural patterns like specific calls or refactor opportunities
  • Use Morph for fast text searches; ensure you have a Morph API key before querying
  • Fallback to Grep for literal patterns or when Morph is unavailable
  • Validate results by cross-checking across tools and refreshing LEANN indexes if code changes

Example Use Cases

  • how does authentication work
  • Find all functions that return a Promise
  • Find all files mentioning 'authentication'
  • `class ProviderAdapter`
  • Refactor all imports of X to Y

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers