hive.terminal-tools-fs-search
它能做什么
这个技能说明 AI 如何在文件内查找文字,以及按名称定位文件。适合需要在项目或日志文件夹中查找内容的任何人。
适用场景
- ✓当你需要查找某个词或代码在整个项目中出现的位置时。
- ✓当你想按文件名或模式定位文件的时候。
- ✓当你需要查看电脑上文件的大小、日期或文件夹内容的时候。
技能链接
https://github.com/aden-hive/hive/blob/main/core/framework/skills/_preset_skills/terminal-tools-fs-search/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请找出我项目文件夹中所有提到旧价格 49 美元的文件。”
每周 5 个新技能,1 分钟读完。
工作原理
AI 会使用 ripgrep 搜索文件内的文字,使用 glob 搜索查找文件名,并使用简单的列表命令查看文件夹视图、大小和日期。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Filesystem search
terminal-tools provides two structured search tools: terminal_rg (ripgrep for content) and terminal_glob (find files by name/glob). Predicate queries (mtime/size/type) and everything else (tree, stat, du) are just terminal_exec.
When to use what
| Task | Tool |
|---|---|
| Find code/text matching a pattern (project tree or any path) | terminal_rg (gitignore-aware; defaults to your session workdir) |
| Find files by name/glob (any path) | terminal_glob |
| Find files by mtime/size/type predicate | terminal_exec("find ...") (see references/find_predicates.md) |
| List a directory | terminal_exec("ls -la /path") |
| Tree view | terminal_exec("tree -L 2 /path") |
| Single-path stat | terminal_exec("stat /path") |
| Disk usage | terminal_exec("du -sh /path") or terminal_exec("du -h --max-depth=2 /") |
| Count matching lines in returned results | terminal_rg(...).total (check truncated before treating it as complete) |
terminal_rg — content search
ripgrep is fast, gitignore-aware, and has a deep flag surface. The structured wrapper exposes common search flags directly; extra_args accepts additional flags compatible with JSON output. Output modes such as --count and --files-with-matches are not compatible with this structured interface; use the CLI when that output is needed.
Quickstart installs and verifies ripgrep. Existing installations can be repaired with uv run scripts/ensure_ripgrep.py --install from the repository root. The runtime also checks Windows package-manager locations and current registry PATH entries; HIVE_RIPGREP_PATH can select an absolute executable path. Startup logs report the executable and version, or instructions to fix the missing dependency.
If ripgrep is unavailable, terminal_rg returns code="ripgrep_required" without searching by default. For an approximate search, explicitly set allow_fallback=True: this uses Python regex, a limited filetype table, and basename globs, and does not honor .gitignore. Even with opt-in, context, extra_args, unknown filetypes and complex globs require ripgrep and return an error. Inspect fallback_limitations; do not treat approximate results as a gitignore-aware inventory.
With context=N, surrounding lines are returned in context, separate from matches. Both contain path, line, and text; total counts only match entries.
Common patterns
# All Python files containing "TODO"
terminal_rg(pattern="TODO", path=".", type_filter="py")
# Case-insensitive, with context
terminal_rg(pattern="error", path="/var/log", ignore_case=True, context=2)
# Search hidden files (rg ignores them by default)
terminal_rg(pattern="api_key", path="~", hidden=True)
# Don't respect .gitignore (find files git would ignore)
terminal_rg(pattern="generated", path=".", no_ignore=True)
# Multi-line pattern (e.g., function definitions spanning lines)
terminal_rg(pattern=r"def\s+\w+\(.*\n.*\n", path="src", extra_args=["--multiline"])
# Specific filename glob
terminal_rg(pattern="version", path=".", glob="*.toml")
rg flag idioms
| Flag | Effect |
|---|---|
-tpy (type_filter="py") |
Only Python files |
-uu |
Don't respect any ignores (incl. .git/) |
--multiline (extra_args) |
Allow regex spanning lines |
--max-count (max_count) |
Stop after N matches per file |
--max-depth (max_depth) |
Limit recursion |
-w (extra_args) |
Whole word match |
-F (extra_args) |
Fixed string (no regex) |
See references/ripgrep_cheatsheet.md for the long form.
terminal_glob — find files by name
Lists files matching a glob, gitignore-aware (backed by rg --files). The pattern is widened for you so a bare stem Just Works — the actual glob run is returned as expanded_pattern:
lk_scan_post_reactors→ matched as**/*lk_scan_post_reactors*(recursive substring)*.py→ matched as**/*.py(recursive by default)src/**/*.py→ used verbatim
If rg is unavailable, filename search retains a best-effort walk with fallback="python-walk" and a note that .gitignore is not honored.
# Find a file by stem anywhere under a tree
terminal_glob(pattern="lk_scan_post_reactors", path="core/framework/skills")
# All YAML configs under /etc
terminal_glob(pattern="*.yaml", path="/etc")
# Include .gitignored / hidden / build-cache files
terminal_glob(pattern="*.log", path=".", include_ignored=True)
For predicate queries (modified in last N
常见问题
文字搜索和名称搜索有什么区别?
文字搜索在文件内部查找匹配的词语,名称搜索则按文件名或模式查找文件。
搜索会跳过被忽略的文件吗?
会。在项目中,文字搜索会遵循 gitignore 规则。
如果结果被截断怎么办?
该技能会提示先检查结果是否被截断,然后再把它们当作完整结果。
详情
作者的原始描述
Use terminal_rg / terminal_glob for all filesystem search — your project tree as well as system configs, /var/log, /etc, archive contents. Teaches the rg vs glob vs terminal_exec("find/ls/du/tree") split, common rg flag combos for code/logs/configs, glob patterns for finding files by name, the rule that mtime/size/type predicate queries drop to terminal_exec("find ..."), and that for tree views or single-file stat info you should just use terminal_exec instead of inventing a tool. Read before reaching for raw shell to grep or find anything.
repo: aden-hive/hive
热度
- GitHub 星标
- 11k
- 排名
- #11813
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
browser-edge-cases
11k帮你的智能体修复在 LinkedIn、X 或脚本繁重的页面等复杂网站上失败的浏览器自动化任务。
hive.browser-automation
11k教你的智能体使用 hive-browser 工具控制你自己的 Chrome 浏览器,通过截图和点击完成操作。
hive.colony-progress-tracker
11k帮你的智能体认领任务,并把它的步骤和检查记录在共享数据库中,让工作在进行中就被跟踪。
hive.context-preservation
11k帮你的智能体在较早的细节从记忆中被移除之前,把长篇工具结果中的关键事实保存到笔记里。