← 返回
内容创作 中文

Code Search

Search codebase contents, filenames, or directory structures using ripgrep, fd, and tree with filters for file types, context, depth, and result limits.
使用 ripgrep、fd 和 tree 搜索代码库内容、文件名或目录结构,支持文件类型、上下文、深度和结果数量的过滤。
yanxingang
内容创作 clawhub v1.0.0 1 版本 99878.3 Key: 无需
★ 0
Stars
📥 821
下载
💾 19
安装
1
版本
#latest

概述

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 <command> [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 — Search directory (default: current dir)
  • --type — File type filter: go, py, ts, js, etc. (repeatable)
  • --literal — Treat pattern as literal text, not regex
  • --max — Max results (default: 100)
  • --context — 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 — Search directory (default: current dir)
  • --type — f=files only, d=directories only
  • --max — 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 — Target directory (default: current dir)
  • --depth — 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

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-29 23:56 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

content-creation

Baidu Wenku AIPPT

ide-rea
使用百度文库 AI 智能生成 PPT,自动根据内容选择模板。
★ 66 📥 46,221
content-creation

AdMapix

fly0pants
广告情报与应用数据分析助手,支持搜索广告素材、分析应用排名、下载量、收入及市场洞察,用于广告素材和竞品分析。
★ 295 📥 136,513
content-creation

YouTube

byungkyu
使用托管OAuth集成YouTube Data API,支持搜索视频、管理播放列表、获取频道数据及评论互动,适用于用户需要时使用此技能。
★ 142 📥 41,087