file-search
SKILL.md
File Search Skill
Efficient CLI search tools for AI agents. Covers tool selection, targeting strategies, and best practices.
Tool Selection Guide
| Task | Use | Instead of |
|---|---|---|
| Search text in code files | rg (ripgrep) |
grep, grep -r |
| Find files by name/path | fd |
find, ls -R |
| Structural/syntax-aware code search | sg (ast-grep) |
regex hacks |
| Search PDFs, Office docs, archives | rga (ripgrep-all) |
manual extraction |
| Count lines of code by language | tokei |
cloc, wc -l |
| Code stats with complexity metrics | scc |
cloc, tokei |
Decision flow:
- Text pattern in source code? -->
rg - Code structure (function signatures, class patterns)? -->
sg - Files by name, extension, or type? -->
fd - Inside PDFs, Word docs, spreadsheets, archives? -->
rga - Codebase size/language breakdown? -->
tokeiorscc
Quick Examples
rg -- text/regex search:
rg 'def \w+\(' -t py src/ # Python function defs in src/
rg -c 'TODO' -t js | wc -l # count files with TODOs
rg 'pattern' -g '!vendor/' -g '!node_modules/' # exclude noise
sg -- structural/AST search:
sg --pattern 'if $ERR != nil { return $ERR }' --lang go # unwrapped errors
sg --pattern 'console.log($$$)' --rewrite 'logger.info($$$)' --lang js
fd -- find files:
fd -e py --changed-within 1d # Python files changed today
fd -g '*_test.go' -X rg 'func Test' # verify test files have tests
Targeting Your Searches
- Specify file types (
rg -t py,sg --lang go,fd -e ts) to cut search space dramatically. - Limit directory scope (
rg pattern src/api/) -- never search from root. - Count before viewing (
rg -c pattern -t py | wc -l) -- if results exceed ~50 files, narrow the search. - Exclude noise (
-g '!vendor/',fd -E node_modules) -- skip generated and vendored code.
See references/search-strategies.md for progressive refinement workflows.
Best Practices
- Start narrow, widen if needed. Begin with the most specific search.
- Use
fdfor files,rgfor content. Do not usefindorgrep -r. - Use
rgafor non-code files. Do not manually extract text from PDFs. - Use
sgfor structural patterns. If regex is fragile, use ast-grep. - Use
--jsonoutput when results feed into further processing. - Combine tools:
fd -e py --changed-within 1d -X rg 'TODO'
References
| Topic | File |
|---|---|
| rg flags, patterns, recipes | references/ripgrep-patterns.md |
| ast-grep patterns by language | references/ast-grep-patterns.md |
| fd flags, usage, fd+rg combos | references/fd-guide.md |
| rga formats, usage, caching | references/rga-guide.md |
| tokei and scc usage | references/code-metrics.md |
| Search targeting strategies | references/search-strategies.md |
| Tool comparison and decision guide | references/tool-comparison.md |
Weekly Installs
2
Repository
netresearch/fil…ch-skillFirst Seen
1 day ago
Security Audits
Installed on
amp2
cline2
opencode2
cursor2
kimi-cli2
codex2