简介
基于 fd 和 ripgrep 的高效文件名与内容搜索工具,零依赖、纯文档驱动,适合开发者快速定位代码资源。
原始描述
Fast file-name and content search using `fd` and `rg` (ripgrep).
通过你的 Agent 添加
安装目录:file-search/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
技能正文
SPDX-License-Identifier: CC-BY-SA-4.0
SPDX-FileCopyrightText: Lufox Digital GmbH
name: file-search
description: "Use when searching codebases (text, structural/AST, files by name, PDFs/archives, code stats) or building context before a task."
license: "(MIT AND CC-BY-SA-4.0). See LICENSE-MIT and LICENSE-CC-BY-SA-4.0"
compatibility: "Requires ripgrep (rg), and uv for the plugin's search-reminder hook (runs it on Python 3.11 or later). Optional: fd, ast-grep, rga, tokei, scc, semgrep."
metadata:
author: Lufox Digital GmbH
version: "1.8.5"
repository: https://github.com/netresearch/file-search-skill
allowed-tools: Bash(rg:) Bash(fd:) Bash(sg:) Bash(rga:) Bash(tokei:) Bash(scc:) Bash(semgrep:*) Read Glob Grep
File Search Skill
name: file-search description: "Use when searching codebases (text, structural/AST, files by name, PDFs/archives, code stats) or building context before a task." license: "(MIT AND CC-BY-SA-4.0). See LICENSE-MIT and LICENSE-CC-BY-SA-4.0" compatibility: "Requires ripgrep (rg), and uv for the plugin's search-reminder hook (runs it on Python 3.11 or later). Optional: fd, ast-grep, rga, tokei, scc, semgrep." metadata: author: Lufox Digital GmbH version: "1.8.5" repository: https://github.com/netresearch/file-search-skill allowed-tools: Bash(rg:) Bash(fd:) Bash(sg:) Bash(rga:) Bash(tokei:) Bash(scc:) Bash(semgrep:*) Read Glob Grep
Efficient CLI search tools for AI agents.
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
Apply rule packs (security/lint, taint)
semgrep
regex CI checks
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
| 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 |
| Apply rule packs (security/lint, taint) | semgrep |
regex CI checks |
| 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 → rg | structural → sg | rule packs →
semgrep | filenames → fd | PDFs/archives → rga | LOC →
tokei/scc
Quick Examples
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 + COCOMO
Best Practices
- Start narrow. Specify types (
-t, --lang, -e), scope dirs, count first (rg -c).
- Exclude noise (
-g '!vendor/', fd -E node_modules).
- Batch independent queries. Union patterns with
rg -e P1 -e P2 -e P3 (one walk), or issue distinct queries as parallel tool calls in one message — never sequential && chains.
--json for programmatic processing.
- rg ≠ fd types.
rg -t ts includes .tsx; fd -e ts does NOT. No -t tsx in rg.
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 + COCOMO
- Start narrow. Specify types (
-t,--lang,-e), scope dirs, count first (rg -c). - Exclude noise (
-g '!vendor/',fd -E node_modules). - Batch independent queries. Union patterns with
rg -e P1 -e P2 -e P3(one walk), or issue distinct queries as parallel tool calls in one message — never sequential&&chains. --jsonfor programmatic processing.- rg ≠ fd types.
rg -t tsincludes.tsx;fd -e tsdoes NOT. No-t tsxin rg.
See references/search-strategies.md.
Beyond Local Files
If local search finds nothing and context lives in issues/PRs/external
docs — hand off (gh, Jira, WebFetch). Issue keys in comments signal this.
See 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
semgrep rules and taint mode
references/semgrep-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
PreToolUse nudge (ships with plugin)
references/enforcement-hook.md
Search targeting strategies
references/search-strategies.md
Remote context handoff guide
references/remote-handoff.md
Modern CLI tools comparison (legacy→modern, all domains)
cli-tools SKILL.md#preferred-modern-tools
| Topic | File |
|---|---|
| rg flags, patterns, recipes | references/ripgrep-patterns.md |
| ast-grep patterns by language | references/ast-grep-patterns.md |
| semgrep rules and taint mode | references/semgrep-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 |
| PreToolUse nudge (ships with plugin) | references/enforcement-hook.md |
| Search targeting strategies | references/search-strategies.md |
| Remote context handoff guide | references/remote-handoff.md |
| Modern CLI tools comparison (legacy→modern, all domains) | cli-tools SKILL.md#preferred-modern-tools |