Best practices and common patterns for effective code search with Probe.
# 1. Start with broad search
probe search "authentication" ./
# 2. Narrow by context
probe search "authentication AND middleware" ./
# 3. Filter by location
probe search "authentication AND dir:src/auth" ./
# 4. Use specific patterns
probe query "fn authenticate($$$)" ./src/auth -l rust| Need | Use | Example |
|---|---|---|
| Find by concept | search |
probe search "error handling" |
| Find by structure | query |
probe query "try { $$$ } catch" |
| Find exact text | grep |
probe grep "TODO: fix" |
| Extract context | extract |
probe extract file.rs:42 |
# AND: both terms required
probe search "database AND connection" ./
# OR: either term matches
probe search "login OR authenticate OR auth" ./
# NOT: exclude matches
probe search "error NOT test" ./
# Grouping: complex conditions
probe search "(error OR exception) AND (handler OR process)" ./# By file extension
probe search "class AND ext:ts,tsx" ./
# By language
probe search "struct AND lang:rust" ./
# By directory
probe search "config AND dir:settings" ./
# By file path
probe search "api AND file:**/routes/*" ./
# Combine hints
probe search "interface AND lang:typescript AND dir:types" ./# Prefix matching
probe search "auth*" ./ # auth, authenticate, authorization
# Suffix matching
probe search "*Handler" ./ # errorHandler, requestHandler
# Pattern matching
probe search "get*User*" ./ # getUserById, getCurrentUser# REST endpoints
probe search "router OR endpoint OR handler AND api" ./
# Express.js routes
probe query "app.$METHOD('$PATH', $$$)" ./src -l javascript
# FastAPI routes
probe query "@app.$METHOD('$PATH')" ./src -l python# SQL queries
probe search "SELECT OR INSERT OR UPDATE OR DELETE" ./
# ORM operations
probe search "query OR find OR create AND database" ./
# Transaction handling
probe query "transaction { $$$BODY }" ./src -l rust# Try-catch patterns
probe query "try { $$$TRY } catch ($E) { $$$CATCH }" ./src -l javascript
# Rust error handling
probe query "match $EXPR { Ok($OK) => $$$, Err($ERR) => $$$ }" ./src -l rust
# Python exceptions
probe search "except AND handle" ./
probe query "except $EXCEPTION as $E: $$$" ./src -l python# Config files
probe search "config AND settings" ./ --files-only
# Environment variables
probe search "process.env OR getenv OR env::" ./
# Feature flags
probe search "feature AND flag OR toggle" ./# Test functions
probe search "test OR spec" ./ --allow-tests
# Test assertions
probe query "expect($VALUE).toBe($EXPECTED)" ./tests -l javascript
# Rust tests
probe query "#[test] fn $NAME() { $$$BODY }" ./src -l rust# Comment markers
probe search "TODO OR FIXME OR HACK OR XXX" ./
# Deprecated code
probe search "deprecated OR obsolete" ./
# Temporary code
probe search "temporary OR workaround" ./Rust:
# All functions
probe query "fn $NAME($$$PARAMS) { $$$BODY }" ./src -l rust
# Async functions
probe query "async fn $NAME($$$PARAMS) { $$$BODY }" ./src -l rust
# Functions returning Result
probe query "fn $NAME($$$) -> Result<$OK, $ERR> { $$$ }" ./src -l rust
# Public functions
probe query "pub fn $NAME($$$) { $$$ }" ./src -l rustJavaScript/TypeScript:
# Function declarations
probe query "function $NAME($$$PARAMS) { $$$BODY }" ./src -l javascript
# Arrow functions
probe query "const $NAME = ($$$PARAMS) => $BODY" ./src -l typescript
# Async functions
probe query "async function $NAME($$$) { $$$ }" ./src -l javascript
# Class methods
probe query "$NAME($$$PARAMS) { $$$BODY }" ./src -l javascriptPython:
# Function definitions
probe query "def $NAME($$$PARAMS): $$$BODY" ./src -l python
# Async functions
probe query "async def $NAME($$$): $$$" ./src -l python
# Decorated functions
probe query "@$DEC def $NAME($$$): $$$" ./src -l python
# Class methods
probe query "def $NAME(self, $$$): $$$" ./src -l python# TypeScript classes
probe query "class $NAME extends $BASE { $$$BODY }" ./src -l typescript
# Python classes
probe query "class $NAME($BASES): $$$BODY" ./src -l python
# Rust structs with impl
probe query "impl $TRAIT for $STRUCT { $$$METHODS }" ./src -l rust# ES6 named imports
probe query "import { $$$NAMES } from '$MODULE'" ./src -l javascript
# Default imports
probe query "import $NAME from '$MODULE'" ./src -l javascript
# Python imports
probe query "from $MODULE import $$$NAMES" ./src -l python
# Rust use statements
probe query "use $$$PATH;" ./src -l rust# Component definitions
probe query "function $NAME($PROPS) { return ($$$JSX) }" ./src -l javascript
# useState hooks
probe query "const [$STATE, $SET_STATE] = useState($INITIAL)" ./src -l javascript
# useEffect hooks
probe query "useEffect(() => { $$$BODY }, [$$$DEPS])" ./src -l javascript
# Custom hooks
probe query "function use$NAME($$$) { $$$BODY }" ./src -l javascript# Limit results early
probe search "api" ./ --max-results 50
# Use pagination
probe search "api" ./ --session api-search --max-results 50
# Filter by language
probe search "interface" ./ --language typescript
# Target specific directories
probe search "model" ./src/models ./src/types# Token-limited for context windows
probe search "authentication flow" ./ --max-tokens 8000 --format json
# Extract with prompt
probe extract src/auth.rs:42 --prompt engineer
# Outline format for structure
probe search "api handler" ./ --format outline# 1. Find relevant files
FILES=$(probe search "user authentication" ./ --files-only)
# 2. Extract specific code
for file in $FILES; do
probe extract "$file:1" --format markdown
done# 1. Find files with concept
probe search "middleware" ./src --files-only
# 2. Query for specific structure
probe query "function $NAME(req, res, next) { $$$ }" ./src/middleware -l javascript# 1. Overview search
probe search "authentication" ./ --max-results 10
# 2. Drill into specific file
probe extract src/auth/login.ts:15
# 3. Find related code
probe search "login AND session" ./src/auth
# 4. Structural analysis
probe query "class $NAME extends AuthService { $$$ }" ./src -l typescript# See what files contain a concept
probe search "database" ./ --files-only# Find files by concept, query by structure
probe search "validation AND input" ./src --files-only
probe query "function validate$NAME($$$) { $$$ }" ./src -l javascript# Start simple
probe query "function $NAME() {}" ./src -l javascript
# Add constraints
probe query "async function $NAME($$$) { $$$ }" ./src -l javascript
# Add return types (TypeScript)
probe query "async function $NAME($$$): Promise<$T> { $$$ }" ./src -l typescript# Paginate through results
probe search "api" ./ --session explore --max-results 20
probe search "api" ./ --session explore --max-results 20 # Next page
probe search "api" ./ --session explore --max-results 20 # And next...- Search Command - Search reference
- Query Command - Query reference
- Extract Command - Extract reference
- Performance Tuning - Optimization