mcpField
F
file-search

file-search

github.com/0xdarkmatter开发79244 次安装5 天前更新
代码仓库

关于 file-search

file-search 是面向开发者的文件与内容搜索技能,结合 fd、rg 和 fzf 完成查找、筛选与打开,并提供进阶工作流参考。

主要功能

  1. 01按名称、扩展名和类型查找
  2. 02按模式搜索文件内容
  3. 03使用 fzf 交互式筛选
  4. 04预览并打开匹配结果
  5. 05提供进阶工作流参考

适用场景

  1. 01查找特定类型的源文件
  2. 02在代码中定位 TODO 或错误
  3. 03筛选搜索结果后打开文件

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/0xdarkmatter/claude-mods --skill file-search

安装后在 Claude Code 中输入/file-search确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

assets/
.gitkeep
references/
advanced-workflows.md
scripts/
.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