关于 file-search
file-search 是面向开发者的文件与内容搜索技能,结合 fd、rg 和 fzf 完成查找、筛选与打开,并提供进阶工作流参考。
主要功能
- 01按名称、扩展名和类型查找
- 02按模式搜索文件内容
- 03使用 fzf 交互式筛选
- 04预览并打开匹配结果
- 05提供进阶工作流参考
适用场景
- 01查找特定类型的源文件
- 02在代码中定位 TODO 或错误
- 03筛选搜索结果后打开文件
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ 0xdarkmatter/ claude-mods --skill file-search安装后在 Claude Code 中输入/file-search确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
assets/.gitkeepreferences/advanced-workflows.mdscripts/.gitkeep详细介绍
文件搜索
现代文件和内容搜索。
fd - 查找文件
# Find by name
fd config # Files containing "config"
fd -e py # Python files
# By type
fd -t f config # Files only
fd -t d src # Directories only
# Exclude
fd -E node_modules # Exclude directory
fd -E "*.min.js" # Exclude pattern
# Execute command
fd -e py -x wc -l # Line count per file
rg - 搜索内容
# Simple search
rg "TODO" # Find TODO
rg -i "error" # Case-insensitive
# By file type
rg -t py "import" # Python files only
rg -t js -t ts "async" # JS and TS
# Context
rg -C 3 "function" # 3 lines before/after
# Output modes
rg -l "TODO" # File names only
rg -c "TODO" # Count per file
fzf - 交互式选择
# Find and select
fd | fzf
# With preview
fd | fzf --preview 'bat --color=always {}'
# Multi-select
fd -e ts | fzf -m | xargs code
组合模式
# Find files, search content
fd -e py -x rg "async def" {}
# Search, select, open
rg -l "pattern" | fzf --preview 'rg -C 3 "pattern" {}' | xargs vim
快速参考
| 任务 | 命令 |
|---|---|
| 查找 TS 文件 | fd -e ts |
| 在 src 中查找 | fd -e ts src/ |
| 搜索模式 | rg "pattern" |
| 在指定类型中搜索 | rg -t py "import" |
| 匹配的文件 | rg -l "pattern" |
| 统计匹配数 | rg -c "pattern" |
| 交互式选择 | fd | fzf |
| 带预览 | fd | fzf --preview 'bat {}' |
性能提示
| 提示 | 原因 |
|---|---|
两者都会遵循 .gitignore | 自动跳过 node_modules、dist |
优先使用 -t 而不是 -g | 类型标志速度更快 |
| 缩小路径范围 | rg pattern src/ 更快 |
对字面量使用 -F | 避免正则表达式开销 |
更多资源
如需了解详细模式,请加载:
./references/advanced-workflows.md- Git 集成、shell 函数和高效工作流
评论
支持 Markdown