Advanced Find Platform
Production-ready skill that handles find, bugs, security, vulnerabilities. Includes structured workflows, validation checks, and reusable patterns for sentry.
Advanced Find Platform
A powerful search and discovery skill for locating files, code patterns, and content across codebases, file systems, and repositories using advanced search techniques.
When to Use
Choose Advanced Find Platform when:
- Searching across large codebases for specific patterns, functions, or usages
- Finding files matching complex criteria (size, date, type, content)
- Performing codebase-wide refactoring by first locating all relevant references
- Building custom search indexes for project-specific discovery needs
Consider alternatives when:
- Searching within a single file — use your editor's built-in search
- Looking up API documentation — use the official docs or search engine
- Browsing git history — use
git logwith search options
Quick Start
# Find files by name pattern recursively fd --type f --extension ts --exclude node_modules # Search code content with ripgrep rg "function.*export" --type ts -l --stats # Find large files in a project fd --type f --size +1m --exec ls -lh {}
import os import re from pathlib import Path from dataclasses import dataclass @dataclass class SearchResult: filepath: str line_number: int line_content: str match_text: str class CodeFinder: def __init__(self, root_dir, exclude=None): self.root = Path(root_dir) self.exclude = exclude or [ 'node_modules', '.git', 'dist', 'build', '__pycache__', '.venv', 'vendor' ] def find_pattern(self, pattern, extensions=None): """Search for regex pattern across all matching files""" results = [] compiled = re.compile(pattern, re.IGNORECASE) for filepath in self._walk_files(extensions): try: content = filepath.read_text(encoding='utf-8', errors='ignore') for i, line in enumerate(content.split('\n'), 1): match = compiled.search(line) if match: results.append(SearchResult( filepath=str(filepath.relative_to(self.root)), line_number=i, line_content=line.strip(), match_text=match.group() )) except (PermissionError, OSError): continue return results def find_definitions(self, name, language='typescript'): """Find function/class/variable definitions""" patterns = { 'typescript': [ rf'(?:export\s+)?(?:async\s+)?function\s+{name}\s*[(<]', rf'(?:export\s+)?(?:const|let|var)\s+{name}\s*=', rf'(?:export\s+)?(?:class|interface|type|enum)\s+{name}\s*[{{<]', ], 'python': [ rf'def\s+{name}\s*\(', rf'class\s+{name}\s*[:(]', rf'{name}\s*=\s*', ] } results = [] for pattern in patterns.get(language, patterns['typescript']): results.extend(self.find_pattern(pattern)) return results def find_usages(self, name, extensions=None): """Find all usages of a symbol""" return self.find_pattern(rf'\b{name}\b', extensions) def find_imports(self, module_name): """Find all imports of a module""" patterns = [ rf"import\s+.*from\s+['\"].*{module_name}['\"]", rf"require\s*\(\s*['\"].*{module_name}['\"]\s*\)", rf"from\s+{module_name}\s+import", ] results = [] for pattern in patterns: results.extend(self.find_pattern(pattern)) return results def _walk_files(self, extensions=None): for root, dirs, files in os.walk(self.root): dirs[:] = [d for d in dirs if d not in self.exclude] for f in files: if extensions: if not any(f.endswith(ext) for ext in extensions): continue yield Path(root) / f
Core Concepts
Search Tool Comparison
| Tool | Best For | Speed | Regex | Install |
|---|---|---|---|---|
ripgrep (rg) | Content search | Fastest | Full PCRE2 | cargo install ripgrep |
fd | File finding | Fast | Basic | cargo install fd-find |
fzf | Interactive fuzzy finding | Fast | Fuzzy | brew install fzf |
grep -r | Basic content search | Slow | POSIX ERE | Built-in |
find | File system queries | Medium | Glob | Built-in |
ag (Silver Searcher) | Content search | Fast | PCRE | brew install ag |
Advanced Search Patterns
# Find unused exports in TypeScript rg "export (function|const|class|interface|type) (\w+)" --type ts -o -r '$2' | \ sort -u | while read symbol; do count=$(rg "\b$symbol\b" --type ts -l | wc -l) if [ "$count" -le 1 ]; then echo "Potentially unused: $symbol" fi done # Find TODO/FIXME comments with context rg "(TODO|FIXME|HACK|XXX)" --type-add 'code:*.{ts,tsx,py,js,jsx}' --type code -C 2 # Find duplicate function names across files rg "^(export\s+)?(async\s+)?function\s+(\w+)" --type ts -o -r '$3' | \ sort | uniq -d # Find files modified in last 24 hours matching pattern fd --type f --changed-within 24h --extension ts --exec grep -l "TODO" {}
Configuration
| Option | Description | Default |
|---|---|---|
root_directory | Base directory for searches | Current directory |
exclude_dirs | Directories to exclude | ["node_modules",".git","dist"] |
file_extensions | File types to search | All text files |
case_sensitive | Enable case-sensitive matching | false |
max_results | Maximum number of results returned | 1000 |
include_hidden | Search hidden files and directories | false |
follow_symlinks | Follow symbolic links | false |
context_lines | Lines of context around matches | 0 |
Best Practices
- Use ripgrep with type filters instead of grep for codebase searches —
rg --type ts "pattern"is orders of magnitude faster thangrep -rbecause it respects.gitignore, skips binary files, and uses SIMD-accelerated search - Combine fd and rg for complex queries like "find all TypeScript files modified this week containing async functions" by piping fd output into rg:
fd -e ts --changed-within 7d | xargs rg "async function" - Create shell aliases for common searches so team members can quickly run standardized queries like "find unused exports," "list all API endpoints," or "show recent TODOs" without remembering complex command flags
- Exclude generated files from searches by maintaining a comprehensive
.rgignoreor.fdignorefile that covers build output, vendor dependencies, and auto-generated code that clutters search results - Use word boundary matching with
\bin regex patterns to avoid false matches — searching for\buser\bmatches the word "user" but not "username" or "superuser"
Common Issues
Search too slow on large repositories: Repositories with millions of files or large binary assets slow down content searches dramatically. Configure ignore files to skip node_modules, build output, and binary directories. For very large repos, build a search index with tools like ctags or tree-sitter for instant symbol lookups.
Regex escaping mistakes: Special characters like ., (, $, and * have meaning in regex and need escaping with \ for literal matching. Use ripgrep's --fixed-strings flag when searching for literal text that contains special characters rather than crafting complex escape sequences.
Missing results from binary or encoded files: Standard search tools skip binary files and may miss content in files with non-UTF-8 encoding. Use rg --binary to search binary files when needed, and check file encoding with file --mime if you suspect encoding-related missed matches.
Reviews
No reviews yet. Be the first to review this template!
Similar Templates
Full-Stack Code Reviewer
Comprehensive code review skill that checks for security vulnerabilities, performance issues, accessibility, and best practices across frontend and backend code.
Test Suite Generator
Generates comprehensive test suites with unit tests, integration tests, and edge cases. Supports Jest, Vitest, Pytest, and Go testing.
Pro Architecture Workspace
Battle-tested skill for architectural, decision, making, framework. Includes structured workflows, validation checks, and reusable patterns for development.