grepai-search-basics by yoanbernabeu/grepai-skills
npx skills add https://github.com/yoanbernabeu/grepai-skills --skill grepai-search-basics本技能涵盖使用 GrepAI 进行语义代码搜索的基础知识。
grepai init)grepai watch)与传统的文本搜索(grep, ripgrep)不同,GrepAI 根据含义进行搜索:
| 类型 | 工作原理 | 示例 |
|---|---|---|
| 文本搜索 | 精确字符串匹配 | "login" → 查找 "login" |
| 语义搜索 | 含义相似性 | "authenticate user" → 查找登录、认证、注册代码 |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
grepai search "your query here"
grepai search "user authentication flow"
输出:
Score: 0.89 | src/auth/middleware.go:15-45
──────────────────────────────────────────
func AuthMiddleware() gin.HandlerFunc {
return func(c *gin.Context) {
token := c.GetHeader("Authorization")
if token == "" {
c.AbortWithStatus(401)
return
}
claims, err := ValidateToken(token)
if err != nil {
c.AbortWithStatus(401)
return
}
c.Set("user", claims.UserID)
c.Next()
}
}
Score: 0.82 | src/auth/jwt.go:23-55
──────────────────────────────────────────
func ValidateToken(tokenString string) (*Claims, error) {
token, err := jwt.Parse(tokenString, func(t *jwt.Token) (interface{}, error) {
return []byte(secretKey), nil
})
if err != nil {
return nil, err
}
if claims, ok := token.Claims.(*Claims); ok && token.Valid {
return claims, nil
}
return nil, errors.New("invalid token")
}
Score: 0.76 | src/handlers/login.go:10-35
──────────────────────────────────────────
func HandleLogin(c *gin.Context) {
var req LoginRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(400, gin.H{"error": "invalid request"})
return
}
user, err := userService.Authenticate(req.Email, req.Password)
// ...
}
Score: 0.89 | src/auth/middleware.go:15-45
──────────────────────────────────────────
[code content]
| 组件 | 含义 |
|---|---|
| Score | 相似度 (0.0 到 1.0,越高越相关) |
| File path | 代码位置 |
| Line numbers | 代码块的起始-结束行号 |
| Content | 实际代码 |
| 分数 | 含义 |
|---|---|
| 0.90+ | 优秀匹配 |
| 0.80-0.89 | 良好匹配 |
| 0.70-0.79 | 相关 |
| 0.60-0.69 | 弱相关 |
| <0.60 | 微弱匹配 |
默认情况下,GrepAI 返回 10 个结果。使用 --limit 进行调整:
# 仅获取前 3 个结果
grepai search "database queries" --limit 3
# 获取更多结果
grepai search "error handling" --limit 20
搜索前,请验证您的索引:
grepai status
输出:
✅ GrepAI Status
Index:
- Files: 245
- Chunks: 1,234
- Last updated: 2 minutes ago
Ready for search.
grep -r "authenticate" .
grepai search "authenticate user credentials"
描述意图或行为:
grepai search "validate user credentials"
grepai search "handle HTTP request errors"
grepai search "connect to the database"
grepai search "send email notification"
grepai search "parse JSON configuration"
过于简短或通用:
grepai search "auth" # 太模糊
grepai search "function" # 太通用
grepai search "getUserById" # 精确名称 (应使用 grep)
GrepAI 理解自然语言:
# 提问
grepai search "how are users authenticated"
grepai search "where is the database connection configured"
# 描述行为
grepai search "code that sends emails to users"
grepai search "functions that validate input data"
两者都有效,但短语通常效果更好:
# 多个单词 (类似 OR 行为)
grepai search "login password validation"
# 短语 (描述特定意图)
grepai search "validate user login credentials"
grepai search "main entry point"
grepai search "application startup"
grepai search "HTTP server initialization"
grepai search "error handling and logging"
grepai search "exception handling"
grepai search "error response to client"
grepai search "database query execution"
grepai search "fetch user from database"
grepai search "save data to storage"
grepai search "calculate order total"
grepai search "process payment transaction"
grepai search "validate business rules"
❌ 问题: 无结果 ✅ 解决方案:
grepai statusgrepai watch❌ 问题: 结果不相关 ✅ 解决方案:
❌ 问题: 缺少预期的代码 ✅ 解决方案:
rm .grepai/index.gob && grepai watch成功的基础搜索:
Query: "user authentication flow"
Results: 5 matches
Score: 0.89 | src/auth/middleware.go:15-45
──────────────────────────────────────────
[relevant code...]
Score: 0.82 | src/auth/jwt.go:23-55
──────────────────────────────────────────
[relevant code...]
[additional results...]
Tip: Use --limit to adjust number of results
Use --json for machine-readable output
每周安装量
358
仓库
GitHub 星标
15
首次出现
2026年1月28日
安全审计
安装于
opencode288
codex281
gemini-cli260
github-copilot260
kimi-cli240
amp238
This skill covers the fundamentals of semantic code search with GrepAI.
grepai init)grepai watch)Unlike traditional text search (grep, ripgrep), GrepAI searches by meaning :
| Type | How it Works | Example |
|---|---|---|
| Text search | Exact string match | "login" → finds "login" |
| Semantic search | Meaning similarity | "authenticate user" → finds login, auth, signin code |
grepai search "your query here"
grepai search "user authentication flow"
Output:
Score: 0.89 | src/auth/middleware.go:15-45
──────────────────────────────────────────
func AuthMiddleware() gin.HandlerFunc {
return func(c *gin.Context) {
token := c.GetHeader("Authorization")
if token == "" {
c.AbortWithStatus(401)
return
}
claims, err := ValidateToken(token)
if err != nil {
c.AbortWithStatus(401)
return
}
c.Set("user", claims.UserID)
c.Next()
}
}
Score: 0.82 | src/auth/jwt.go:23-55
──────────────────────────────────────────
func ValidateToken(tokenString string) (*Claims, error) {
token, err := jwt.Parse(tokenString, func(t *jwt.Token) (interface{}, error) {
return []byte(secretKey), nil
})
if err != nil {
return nil, err
}
if claims, ok := token.Claims.(*Claims); ok && token.Valid {
return claims, nil
}
return nil, errors.New("invalid token")
}
Score: 0.76 | src/handlers/login.go:10-35
──────────────────────────────────────────
func HandleLogin(c *gin.Context) {
var req LoginRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(400, gin.H{"error": "invalid request"})
return
}
user, err := userService.Authenticate(req.Email, req.Password)
// ...
}
Score: 0.89 | src/auth/middleware.go:15-45
──────────────────────────────────────────
[code content]
| Component | Meaning |
|---|---|
| Score | Similarity (0.0 to 1.0, higher = more relevant) |
| File path | Location of the code |
| Line numbers | Start-end lines of the chunk |
| Content | The actual code |
| Score | Meaning |
|---|---|
| 0.90+ | Excellent match |
| 0.80-0.89 | Good match |
| 0.70-0.79 | Related |
| 0.60-0.69 | Loosely related |
| <0.60 | Weak match |
By default, GrepAI returns 10 results. Adjust with --limit:
# Get only top 3 results
grepai search "database queries" --limit 3
# Get more results
grepai search "error handling" --limit 20
Before searching, verify your index:
grepai status
Output:
✅ GrepAI Status
Index:
- Files: 245
- Chunks: 1,234
- Last updated: 2 minutes ago
Ready for search.
grep -r "authenticate" .
grepai search "authenticate user credentials"
Describe the intent or behavior:
grepai search "validate user credentials"
grepai search "handle HTTP request errors"
grepai search "connect to the database"
grepai search "send email notification"
grepai search "parse JSON configuration"
Too short or generic:
grepai search "auth" # Too vague
grepai search "function" # Too generic
grepai search "getUserById" # Exact name (use grep)
GrepAI understands natural language:
# Ask questions
grepai search "how are users authenticated"
grepai search "where is the database connection configured"
# Describe behavior
grepai search "code that sends emails to users"
grepai search "functions that validate input data"
Both work, but phrases often get better results:
# Multiple words (OR-like behavior)
grepai search "login password validation"
# Phrase (describes specific intent)
grepai search "validate user login credentials"
grepai search "main entry point"
grepai search "application startup"
grepai search "HTTP server initialization"
grepai search "error handling and logging"
grepai search "exception handling"
grepai search "error response to client"
grepai search "database query execution"
grepai search "fetch user from database"
grepai search "save data to storage"
grepai search "calculate order total"
grepai search "process payment transaction"
grepai search "validate business rules"
❌ Problem: No results ✅ Solutions:
grepai statusgrepai watch if index is empty❌ Problem: Irrelevant results ✅ Solutions:
❌ Problem: Missing expected code ✅ Solutions:
rm .grepai/index.gob && grepai watchSuccessful basic search:
Query: "user authentication flow"
Results: 5 matches
Score: 0.89 | src/auth/middleware.go:15-45
──────────────────────────────────────────
[relevant code...]
Score: 0.82 | src/auth/jwt.go:23-55
──────────────────────────────────────────
[relevant code...]
[additional results...]
Tip: Use --limit to adjust number of results
Use --json for machine-readable output
Weekly Installs
358
Repository
GitHub Stars
15
First Seen
Jan 28, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode288
codex281
gemini-cli260
github-copilot260
kimi-cli240
amp238
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
140,500 周安装
API文档生成器 - 自动生成REST/GraphQL/WebSocket API专业文档
289 周安装
Salesforce开发最佳实践:LWC、Apex触发器与异步处理模式详解
289 周安装
ChatGPT应用构建器 - 基于MCP服务器创建扩展LLM功能的对话式应用
290 周安装
HeyGen数字人视频API教程:创建AI虚拟人视频,控制形象、语音、脚本和场景
290 周安装
PyAutoGUI 自动化脚本:鼠标键盘控制、截图、图像识别、颜色操作全指南
290 周安装
TypeScript Monorepo 启动模板 | pnpm + tdown 构建工具链 | 现代化库开发架构
290 周安装