file-search
Original:🇺🇸 English
Translated
Use when searching codebases (text, structural/AST, files by name, PDFs/archives, code stats) or building context before a task.
18installs
Added on
NPX Install
npx skill4agent add netresearch/file-search-skill file-searchTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →File Search Skill
Efficient CLI search tools for AI agents.
Tool Selection Guide
| Task | Use | Instead of |
|---|---|---|
| Search text in code files | | |
| Find files by name/path | | |
| Structural/syntax-aware code search | | regex hacks |
| Search PDFs, Office docs, archives | | manual extraction |
| Count lines of code by language | | |
| Code stats with complexity metrics | | |
Decision flow: text/regex → | code structure (empty catches,
function sigs, multi-line patterns) → | files by name → |
PDFs/archives → | codebase stats → /
rgsgfdrgatokeisccQuick Examples
bash
rg 'def \w+\(' -t py src/ # rg: text search in Python files
rg -c 'TODO' -t js | wc -l # rg: count first, then drill down
sg --pattern 'console.log($$$)' --rewrite 'logger.info($$$)' --lang js # sg: structural replace
fd -g '*.test.ts' --changed-within 1d # fd: -g for compound suffixes (NOT -e)
fd -g '*_test.go' -X rg 'func Test' # fd+rg: find files, verify contents
rga 'quarterly revenue' docs/ # rga: search inside PDFs/archives
tokei --sort code # tokei: language stats
scc --wide # scc: complexity + COCOMOBest Practices
- Start narrow. Specify types (,
-t,--lang), scope dirs, count first (-e).rg -c - Exclude noise (,
-g '!vendor/').fd -E node_modules - for programmatic processing.
--json - rg ≠ fd types. includes
rg -t ts;.tsxdoes NOT. Nofd -e tsin rg.-t tsx
See references/search-strategies.md.
Beyond Local Files
If local search finds nothing and context lives in issues/PRs/external
docs — hand off (, Jira, WebFetch). Issue keys in comments signal this.
ghSee references/remote-handoff.md.
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 |
| Remote context handoff guide | references/remote-handoff.md |