v2/src/cli/simple-commands/init/templates/commands/hooks/pre-search.md
Optimize search operations with caching and intelligent filtering.
npx claude-flow hook pre-search [options]
--query, -q <text> - Search query to optimize--cache-results - Cache search results (default: true)--suggest-filters - Suggest search filters--check-memory - Check memory for answers--expand-query - Expand search termsnpx claude-flow hook pre-search --query "authentication implementation"
npx claude-flow hook pre-search -q "React hooks usage" --cache-results
npx claude-flow hook pre-search -q "previous bug fixes" --check-memory
npx claude-flow hook pre-search -q "auth" --expand-query --suggest-filters
This hook is automatically called by Claude Code when:
Manual usage in agents:
# Before searching
npx claude-flow hook pre-search --query "your search" --cache-results --check-memory
Returns JSON with:
{
"query": "authentication implementation",
"cached": true,
"cacheHit": false,
"memoryResults": 3,
"expandedQuery": "(auth|authentication|login|oauth) (impl|implementation|code)",
"suggestedFilters": ["*.js", "*.ts", "src/**"],
"estimatedFiles": 45
}
Grep - Content search toolGlob - File pattern toolmemory search - Memory queriescache manage - Cache operations