Skip to content
Code Guide

Search Tools Cheatsheet

Search Tools Cheatsheet (1-Page Reference)

Section titled “Search Tools Cheatsheet (1-Page Reference)”

Quick reference for choosing between rg, grepai, Serena & ast-grep


Know exact text? → rg
Know exact name? → rg or Serena
Know concept? → grepai
Know structure? → ast-grep
Need dependencies? → grepai trace

Fast ←─────────────────────────────────→ Smart
rg Serena ast-grep grepai
~20ms ~100ms ~200ms ~500ms
Exact Symbols Structure Meaning

TaskToolCommand
”Find TODO comments”rgrg "TODO"
”Find login function”rg/Serenarg "login" or serena find_symbol
”Find auth code”grepaigrepai search "authentication"
”Who calls login?”grepaigrepai trace callers "login"
”Get file structure”Serenaserena get_symbols_overview
”Async without try/catch”ast-grepast-grep "async function $F"
”React class → hooks”ast-grepMigration pattern
”Remember decision”Serenaserena write_memory

FeaturerggrepaiSerenaast-grep
Exact match
Semantic
Call graph
Symbols
AST patterns
Memory
Setup⚠️⚠️⚠️

Example: Refactor authentication

Terminal window
# 1. DISCOVER (grepai - semantic)
grepai search "authentication flow"
# 2. STRUCTURE (Serena - symbols)
serena get_symbols_overview --file auth.service.ts
# 3. DEPENDENCIES (grepai - call graph)
grepai trace callers "login"
# 4. PATTERNS (ast-grep - structure)
ast-grep "async function login"
# 5. VERIFY (rg - exact)
rg "validateSession" --type ts

❌ Wrong✅ Right
grepai search "createSession"rg "createSession"
rg "auth.*login.*session"grepai search "auth flow"
rg + sed for refactoringSerena find_symbol
Refactor without checking callersgrepai trace callers first

Start: rg (90% of searches)
Need meaning? → grepai
Need symbols? → Serena
Need AST? → ast-grep

📖 Search Tools Mastery - Complete workflows, scenarios, benchmarks


Print this page for quick reference | Last updated: January 2026