Code Search
/install code-search
Code Search Skill
Fast code search toolkit for exploring codebases. Provides structured grep (content search), glob (filename search), and tree (directory structure) via ripgrep, fd, and tree CLI tools.
When to Use
- Searching for function/class/variable definitions or usages in code
- Finding files by name or extension pattern
- Understanding project directory structure
- Exploring unfamiliar codebases
- Looking for configuration files, imports, error messages
Prerequisites
Run dependency check first:
bash /root/.openclaw/workspace/skills/code-search/scripts/search.sh check
Commands
All commands go through a single entry point:
bash /root/.openclaw/workspace/skills/code-search/scripts/search.sh \x3Ccommand> [options]
grep — Search file contents
# Basic search
bash /root/.openclaw/workspace/skills/code-search/scripts/search.sh grep "func main" --path /some/project
# Literal text (no regex interpretation)
bash /root/.openclaw/workspace/skills/code-search/scripts/search.sh grep "fmt.Println(" --literal --path /some/project
# Filter by file type
bash /root/.openclaw/workspace/skills/code-search/scripts/search.sh grep "import" --type go --path /some/project
# With context lines
bash /root/.openclaw/workspace/skills/code-search/scripts/search.sh grep "TODO" --context 2 --path /some/project
# Limit results
bash /root/.openclaw/workspace/skills/code-search/scripts/search.sh grep "error" --max 20 --path /some/project
Options:
--path \x3Cdir>— Search directory (default: current dir)--type \x3Cext>— File type filter: go, py, ts, js, etc. (repeatable)--literal— Treat pattern as literal text, not regex--max \x3Cn>— Max results (default: 100)--context \x3Cn>— Show N lines of context around matches (default: 0)
glob — Search filenames
# Find all Go files
bash /root/.openclaw/workspace/skills/code-search/scripts/search.sh glob "*.go" --path /some/project
# Find test files
bash /root/.openclaw/workspace/skills/code-search/scripts/search.sh glob "*_test.go" --path /some/project
# Find config files
bash /root/.openclaw/workspace/skills/code-search/scripts/search.sh glob "*.{json,yaml,yml,toml}" --path /some/project
# Filter by type
bash /root/.openclaw/workspace/skills/code-search/scripts/search.sh glob "config" --type f --path /some/project
Options:
--path \x3Cdir>— Search directory (default: current dir)--type \x3Cf|d>— f=files only, d=directories only--max \x3Cn>— Max results (default: 200)
tree — Directory structure
# Default (3 levels deep)
bash /root/.openclaw/workspace/skills/code-search/scripts/search.sh tree --path /some/project
# Shallow view
bash /root/.openclaw/workspace/skills/code-search/scripts/search.sh tree --path /some/project --depth 1
# With file sizes
bash /root/.openclaw/workspace/skills/code-search/scripts/search.sh tree --path /some/project --depth 2 --size
Options:
--path \x3Cdir>— Target directory (default: current dir)--depth \x3Cn>— Max depth (default: 3)--size— Show file sizes
check — Verify dependencies
bash /root/.openclaw/workspace/skills/code-search/scripts/search.sh check
Output Format
All commands output structured text with clear delimiters:
[SEARCH RESULTS: grep]/[SEARCH RESULTS: glob]/[DIRECTORY TREE][END RESULTS]/[END TREE][TRUNCATED: ...]when results exceed the limit[ERROR] ...on failures
Notes
- All operations are read-only — no files are modified
- Automatically ignores .git, node_modules, pycache, vendor, build artifacts
- Respects .gitignore rules
- Results sorted by modification time (newest first) for grep and glob
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install code-search - 安装完成后,直接呼叫该 Skill 的名称或使用
/code-search触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
Code Search 是什么?
Search codebase contents, filenames, or directory structures using ripgrep, fd, and tree with filters for file types, context, depth, and result limits. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 494 次。
如何安装 Code Search?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install code-search」即可一键安装,无需额外配置。
Code Search 是免费的吗?
是的,Code Search 完全免费(开源免费),可自由下载、安装和使用。
Code Search 支持哪些平台?
Code Search 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Code Search?
由 Yanxingang(@yanxingang)开发并维护,当前版本 v1.0.0。