File Searcher Skill
This skill searches for files in the codebase based on text content and returns a list of matching file paths.
Core Principles
- •Use Grep tool: Always use the Grep tool for searching - never use bash grep/rg commands
- •Return file paths: Provide a clear list of file paths that match the search criteria
- •Include context: Show relevant context (line numbers, matching lines) to help users understand results
- •Flexible search: Support different search modes (content, files_only, count)
Search Workflow
Step 1: Understand the Search Request
Clarify what the user wants to find:
- •Text/Pattern: The specific text or regex pattern to search for
- •Scope: Entire codebase or specific directory
- •File Type: Optional filter (e.g., only .py, .js files)
Step 2: Choose the Appropriate Search Mode
Use Grep with these parameters:
| Parameter | Description | Common Values |
|---|---|---|
pattern | The search term or regex | User's search text |
output_mode | What to return | files_with_matches (default), content, count |
path | Directory to search | Current directory or specific path |
glob | Filter by file pattern | *.py, **/*.js, etc. |
type | Filter by file type | py, js, ts, etc. |
-i | Case insensitive search | true or false |
-C | Context lines | Number of lines before/after match |
Step 3: Execute the Search
markdown
Use Grep tool with: - pattern: <search term> - output_mode: "files_with_matches" for just file paths, "content" for lines with context
Step 4: Present Results
Format the output clearly:
- •Matching files: List all file paths found
- •Match count: Total number of files
- •Excerpts (optional): Show relevant lines from matches
- •Next steps: Suggest actions like "Read specific file", "Narrow search", etc.
Common Search Patterns
Find files containing specific text
code
Grep: pattern="search term", output_mode="files_with_matches"
Find text with context (showing matching lines)
code
Grep: pattern="search term", output_mode="content", -C=2
Case-insensitive search
code
Grep: pattern="search term", -i=true
Search specific file types
code
Grep: pattern="search term", type="py" Grep: pattern="search term", glob="*.md"
Count matches per file
code
Grep: pattern="search term", output_mode="count"
Example Usage
User request: "Find all files that contain 'TODO' comments"
Skill response:
- •Search:
Grep: pattern="TODO", output_mode="content", -C=1 - •Results: List file paths with TODO lines and line numbers
- •Summary: "Found 5 files with TODO comments"
User request: "Search for 'function' in Python files only"
Skill response:
- •Search:
Grep: pattern="function", type="py", output_mode="files_with_matches" - •Results: List matching .py files
- •Summary: "Found 3 Python files containing 'function'"
Tips for Better Searches
- •Start broad: Use
files_with_matchesfirst, then drill down withcontentmode - •Use regex patterns: Grep supports full regex syntax for complex searches
- •Filter by type: Use
typeorglobto narrow search scope - •Case sensitivity: Use
-i=truewhen the exact case doesn't matter - •Context: Use
-Cto see lines around matches for better understanding