360 Secure SkillHub
360 安全技能中心

clawgrep

clawgrep 是一个本地运行的命令行检索工具,把语义嵌入搜索与关键词匹配结合,默认权重为语义 70%、关键词 30%,可用参数调整。输出为 grep 兼容的 file:line:text 格式,支持上下文行、仅列文件名与退出码。首次运行需下载约 30 MB 的 ONNX 嵌入模型并缓存,之后完全离线,无需 API key。

schonhoffer
schonhoffer
热度 46.27
最近更新 2026-05-11 17:36:35
分类:搜索依赖:代码执行 / 读写文件应用场景:研究 / 笔记整理 / 工作流

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add clawgrep
Metadata
name
clawgrep
description
Grep-like CLI with hybrid semantic and keyword search. Combines semantic embedding search with keyword matching for high-quality code and document retrieval. Use when searching for content where the exact wording is unknown, or when grep misses results across large codebases or folders. Useful for recursively searching large collections of markdown files, like memories. Output is grep-compatible for easy parsing.
compatibility
Requires the clawgrep binary on PATH. Works on Linux, macOS, and Windows. No API keys needed. On first run, downloads a small ONNX embedding model (~30 MB) from Hugging Face and caches it locally. Subsequent runs are fully offline. Install via cargo, npm, or pip.
license
MIT OR Apache-2.0
metadata
{"version":"0.1","author":"Schonhoffer","repository":"https://github.com/Schonhoffer/clawgrep","homepage":"https://github.com/Schonhoffer/clawgrep"}

clawgrep

Semantic + keyword file search. Output is grep-compatible. Runs fully locally. On first run, automatically downloads a small ONNX embedding model (~30 MB) from Hugging Face and caches it in the local cache directory. After that, all searches are offline.

Check availability

clawgrep --version

If not found, install from the open-source repository using any of these methods (only one needed):

cargo install clawgrep        # Rust (recommended)
npm install -g clawgrep        # Node.js
pip install clawgrep           # Python

Basic usage

clawgrep --no-color "query" <path>

Always pass --no-color when parsing output programmatically.

Search a workspace

clawgrep --no-color "previous discussion about auth flow" ./memory

Output format

Grep-compatible, one result per line, ranked by relevance (best first):

$ clawgrep --no-color "previous discussion about auth flow" ./memory
memory/2025-06-12-auth-design.md:8:Decided to use OAuth2 with PKCE for all client auth.
memory/2025-06-12-auth-design.md:14:Token refresh should be transparent to the user.
memory/2025-06-10-planning.md:3:Auth flow is the top priority for the sprint.
memory/archive/2025-05-session-notes.md:42:Discussed moving auth to a separate service.
memory/archive/2025-05-session-notes.md:87:Need to revisit token expiry policy.

Each line is file:line:text. Context lines (from -C) use - as the separator instead: file-line-text.

Exit codes

Code Meaning
0 Match found
1 No match
2 Error

Same as grep. Use -q for existence checks without output.

Choosing search mode

Default weights: 70% semantic, 30% keyword.

Concept search (don't know exact wording):

clawgrep --no-color "decision about migration strategy" ./memory

Exact identifier search (note IDs, tags, serial numbers):

clawgrep --no-color --keyword-weight 0.8 --semantic-weight 0.2 "PROJ-1042" ./memory

Key flags

Flag Purpose
-k N Number of results (default: 5)
-C N Context lines before and after
-l Print only matching filenames
-q Quiet; just set exit code
--show-score Append relevance score
--path-boost N Boost filename matches (>1.0 = higher)
--min-score N Filter low-relevance results (0.0–1.0)

See CLI reference for all flags.

Best practices

  1. Use --no-color always when parsing output.
  2. Keep -k small (3–5) to reduce output. Increase only when needed.
  3. Check exit codes instead of parsing stdout when possible.
  4. Let the cache persist — don't use --no-cache unless searching throwaway content. First run indexes; subsequent runs are fast.
  5. Search the narrowest relevant directory, not the whole filesystem.

References (advanced, usually not needed)

The information above should be sufficient for normal use. Only load these if you run into problems or need flags not listed above:

  • CLI reference — all flags, config file format, grep compatibility
  • Examples — more input/output examples for edge cases