code-search
它能做什么
这项技能帮助智能体使用 ripgrep 和 Git 快速搜索代码,而不是逐个读取整个文件。适合需要找到某个函数定义或使用位置的开发者。
适用场景
- ✓当你需要找到某个函数、类或符号的定义位置时。
- ✓当你想找出项目中某个名称被使用的每一处时。
- ✓当你需要查明某行代码何时或为何被修改的时候。
技能链接
https://github.com/agentscope-ai/agentscope-java/blob/main/agentscope-examples/agents/agentscope-codingagent/src/main/resources/workspace-templates/skills/code-search/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请在这个项目中找出函数 calculateTax 被定义或调用的每一处。”
每周 5 个新技能,1 分钟读完。
工作原理
这项技能使用 ripgrep 进行正则表达式搜索,并可按文件类型筛选;使用 Git 历史命令追踪某个字符串何时被添加,或某行是谁修改的。它会让搜索结果保持精简,使输出保持较小。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Code Search
The built-in grep tool matches LITERAL text only. For real regular-expression search and
history-aware lookups, drive ripgrep and git through execute.
Ripgrep (regex)
- Symbol definition:
rg -n "fn\s+\w+\(" src/,rg -n --type java "class \w+Service". - Usages of a name:
rg -n "\bmyFunction\b". - Limit by file type:
rg -n --type ts "useEffect\(". - List files only:
rg -l "TODO"; find files by name:rg --files | rg <name>or useglob.
Git history search
- When a string was introduced/removed:
git log -S "<string>" --oneline. - Who/why a line changed:
git blame -L <start>,<end> <file>. - Search tracked files:
git grep -n "<regex>".
Tips
- Prefer a targeted regex over reading whole files when locating symbols or call sites.
- Escape regex metacharacters when you want a literal match, or pass
-Fto ripgrep. - Narrow scope with a path argument to keep output small (tool output is truncated).
常见问题
它需要 ripgrep 吗?
需要。这项技能使用 ripgrep 进行正则表达式搜索。
它能搜索 Git 历史吗?
能。它可以找出某个字符串何时被添加或删除,以及某行由谁修改。
为什么不直接读取整个文件?
有针对性的搜索能让结果更简短,也更便于处理。
详情
作者的原始描述
Search a codebase efficiently with ripgrep regular expressions, file globs, and git history search. Use to locate symbols, usages, and definitions instead of reading whole files.
热度
- GitHub 星标
- 6.2k
- 排名
- #14387
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
agentscope-java
6.2k帮你的智能体用 Java 编写非阻塞的 AgentScope 代码,AgentScope 是基于 Project Reactor 的多智能体框架。
data-report
6.2k帮你的智能体把数据集汇总成报告,包括平均值、总数、范围和趋势,并保存为 Markdown 文件。
data-transform
6.2k帮你的智能体在 CSV 和 JSON 等格式之间转换数据文件,使数据可以在其他工具中使用。
git-changelog
6.2k帮你的智能体根据 Git 历史编写变更日志或发布说明,并按新功能、修复和其他改动分组。