codebase-search by supercent-io/skills-template
npx skills add https://github.com/supercent-io/skills-template --skill codebase-search功能实现:
错误定位:
API 使用:
配置:
语义搜索(针对概念性问题):
使用时机:你从概念上理解你要找什么
示例:
- "我们如何处理用户认证?"
- "电子邮件验证在哪里实现?"
- "我们如何连接到数据库?"
优点:
- 通过含义查找相关代码
- 适用于不熟悉的代码库
- 适合探索性搜索
(针对精确文本/模式):
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
使用时机:你知道确切的文本或模式
示例:
- 函数名:"def authenticate"
- 类名:"class UserManager"
- 错误消息:"Invalid credentials"
- 特定字符串:"API_KEY"
优点:
- 快速且精确
- 支持正则表达式模式
- 适用于已知术语
Glob(用于文件发现):
使用时机:你需要按模式查找文件
示例:
- "**/*.test.js"(所有测试文件)
- "**/config*.yaml"(配置文件)
- "src/**/*Controller.py"(控制器)
优点:
- 按类型快速查找文件
- 发现文件结构
- 定位相关文件
1. 先宽泛,后聚焦:
步骤 1:语义搜索 "认证是如何工作的?"
结果:指向 auth/ 目录
步骤 2:在 auth/ 中使用 grep 查找特定函数
模式:"def verify_token"
结果:在 auth/jwt.py 中找到
步骤 3:阅读该文件
文件:auth/jwt.py
结果:理解实现
2. 使用目录定位:
# 开始时不指定目标(到处搜索)
查询:"用户登录在哪里实现?"
目标:[]
# 使用特定目录进行细化
查询:"登录验证在哪里?"
目标:["backend/auth/"]
3. 组合搜索:
# 查找功能实现位置
语义:"用户注册流程"
# 查找所有涉及的文件
Grep:"def register_user"
# 查找测试文件
Glob:"**/*register*test*.py"
# 理解实现
阅读:registration.py, test_registration.py
查找函数定义:
# Python
grep -n "def function_name" --type py
# JavaScript
grep -n "function functionName" --type js
grep -n "const functionName = " --type js
# TypeScript
grep -n "function functionName" --type ts
grep -n "export const functionName" --type ts
# Go
grep -n "func functionName" --type go
# Java
grep -n "public.*functionName" --type java
查找类定义:
# Python
grep -n "class ClassName" --type py
# JavaScript/TypeScript
grep -n "class ClassName" --type js,ts
# Java
grep -n "public class ClassName" --type java
# C++
grep -n "class ClassName" --type cpp
查找类/函数用法:
# Python
grep -n "ClassName(" --type py
grep -n "function_name(" --type py
# JavaScript
grep -n "new ClassName" --type js
grep -n "functionName(" --type js
查找导入/引用:
# Python
grep -n "from.*import.*ModuleName" --type py
grep -n "import.*ModuleName" --type py
# JavaScript
grep -n "import.*from.*module-name" --type js
grep -n "require.*module-name" --type js
# Go
grep -n "import.*package-name" --type go
查找配置:
# 配置文件
glob "**/*config*.{json,yaml,yml,toml,ini}"
# 环境变量
grep -n "process\\.env\\." --type js
grep -n "os\\.environ" --type py
# 常量
grep -n "^[A-Z_]+\\s*=" --type py
grep -n "const [A-Z_]+" --type js
查找 TODO/FIXME:
grep -n "TODO|FIXME|HACK|XXX" -i
查找错误处理:
# Python
grep -n "try:|except|raise" --type py
# JavaScript
grep -n "try|catch|throw" --type js
# Go
grep -n "if err != nil" --type go
追踪数据流:
1. 查找数据创建位置
语义:"用户对象在哪里创建?"
2. 搜索变量使用情况
Grep:"user\\." 并附带上下文行
3. 跟踪转换过程
阅读:修改用户的文件
4. 查找消费位置
Grep:在相关文件中查找 "user\\."
查找函数的所有调用点:
1. 查找函数定义
Grep:"def process_payment"
结果:payments/processor.py:45
2. 查找该模块的所有导入
Grep:"from payments.processor import"
结果:多个文件
3. 查找对该函数的所有调用
Grep:"process_payment\\("
结果:所有调用点
4. 阅读每个调用点的上下文
阅读:每个文件及其上下文
端到端理解一个功能:
1. 查找 API 端点
语义:"用户注册端点在哪里?"
结果:routes/auth.py
2. 追踪到控制器
阅读:routes/auth.py
查找:对 AuthController.register 的调用
3. 追踪到服务
阅读:controllers/auth.py
查找:对 UserService.create_user 的调用
4. 追踪到数据库
阅读:services/user.py
查找:数据库操作
5. 查找测试
Glob:"**/*auth*test*.py"
阅读:测试文件中的示例
查找相关文件:
1. 从已知文件开始
示例:models/user.py
2. 查找此文件的导入
Grep:"from models.user import"
3. 查找此文件导入的文件
阅读:models/user.py
注意:导入语句
4. 构建依赖关系图
映射:所有相关文件
影响分析:
在更改函数 X 之前:
1. 查找所有调用点
Grep:"function_name\\("
2. 查找所有测试
Grep:"test.*function_name" -i
3. 检查相关功能
语义:"什么依赖于 X?"
4. 审查每个用法
阅读:每个使用该函数的文件
5. 计划变更
记录:影响和所需的更新
使用适当的上下文:
# 查看周围上下文
grep -n "pattern" -C 5 # 前后各 5 行
grep -n "pattern" -B 3 # 前 3 行
grep -n "pattern" -A 3 # 后 3 行
区分大小写:
# 不区分大小写
grep -n "pattern" -i
# 区分大小写(默认)
grep -n "Pattern"
文件类型过滤:
# 特定类型
grep -n "pattern" --type py
# 多种类型
grep -n "pattern" --type py,js,ts
# 排除类型
grep -n "pattern" --glob "!*.test.js"
正则表达式模式:
# 任意字符:.
grep -n "function.*Name"
# 行首:^
grep -n "^class"
# 行尾:$
grep -n "TODO$"
# 可选:?
grep -n "function_name_?()"
# 一个或多个:+
grep -n "[A-Z_]+"
# 零个或多个:*
grep -n "import.*"
# 备选项:|
grep -n "TODO|FIXME"
# 分组:()
grep -n "(get|set)_user"
# 转义特殊字符:\
grep -n "function\(\)"
git blame 获取上下文1. 查找错误消息
Grep:"确切的错误消息"
2. 查找抛出位置
阅读:包含错误的文件
3. 查找触发原因
语义:"什么导致 X 错误?"
4. 查找相关代码
Grep:相关函数名
5. 检查测试
Glob:"**/*test*.py"
查找:相关测试用例
1. 查找入口点
语义:"应用程序从哪里开始?"
常见文件:main.py, index.js, app.py
2. 查找主要路由/端点
Grep:"route|endpoint|@app\\."
3. 查找数据模型
语义:"数据模型在哪里定义?"
常见:models/, entities/
4. 查找配置
Glob:"**/*config*"
5. 阅读 README 和文档
阅读:README.md, docs/
1. 查找所有用法
Grep:"function_to_change"
2. 查找测试
Grep:"test.*function_to_change"
3. 查找依赖项
语义:"X 依赖什么?"
4. 检查导入
Grep:"from.*import.*X"
5. 记录范围
列出:所有受影响的文件
1. 查找类似功能
语义:"类似功能是如何实现的?"
2. 查找添加代码的位置
语义:"新功能应该放在哪里?"
3. 检查模式
阅读:类似的实现
4. 查找要模仿的测试
Glob:类似功能的测试文件
5. 检查文档
Grep:"TODO.*new feature" -i
Git 集成:
# 谁更改了这行?
git blame filename
# 文件历史
git log -p filename
# 查找函数何时添加
git log -S "function_name" --source --all
# 查找提及 X 的提交
git log --grep="feature name"
IDE 集成:
文档:
未找到结果:
结果太多:
结果错误:
每周安装量
10.9K
代码仓库
GitHub 星标数
88
首次出现
2026 年 1 月 24 日
安全审计
安装于
codex10.8K
gemini-cli10.8K
opencode10.8K
github-copilot10.7K
cursor10.7K
amp10.7K
Feature implementation :
Bug location :
API usage :
Configuration :
Semantic search (for conceptual questions):
Use when: You understand what you're looking for conceptually
Examples:
- "How do we handle user authentication?"
- "Where is email validation implemented?"
- "How do we connect to the database?"
Benefits:
- Finds relevant code by meaning
- Works with unfamiliar codebases
- Good for exploratory searches
Grep (for exact text/patterns):
Use when: You know exact text or patterns
Examples:
- Function names: "def authenticate"
- Class names: "class UserManager"
- Error messages: "Invalid credentials"
- Specific strings: "API_KEY"
Benefits:
- Fast and precise
- Works with regex patterns
- Good for known terms
Glob (for file discovery):
Use when: You need to find files by pattern
Examples:
- "**/*.test.js" (all test files)
- "**/config*.yaml" (config files)
- "src/**/*Controller.py" (controllers)
Benefits:
- Quickly find files by type
- Discover file structure
- Locate related files
1. Start broad, then narrow :
Step 1: Semantic search "How does authentication work?"
Result: Points to auth/ directory
Step 2: Grep in auth/ for specific function
Pattern: "def verify_token"
Result: Found in auth/jwt.py
Step 3: Read the file
File: auth/jwt.py
Result: Understand implementation
2. Use directory targeting :
# Start without target (search everywhere)
Query: "Where is user login implemented?"
Target: []
# Refine with specific directory
Query: "Where is login validated?"
Target: ["backend/auth/"]
3. Combine searches :
# Find where feature is implemented
Semantic: "user registration flow"
# Find all files involved
Grep: "def register_user"
# Find test files
Glob: "**/*register*test*.py"
# Understand the implementation
Read: registration.py, test_registration.py
Find function definition :
# Python
grep -n "def function_name" --type py
# JavaScript
grep -n "function functionName" --type js
grep -n "const functionName = " --type js
# TypeScript
grep -n "function functionName" --type ts
grep -n "export const functionName" --type ts
# Go
grep -n "func functionName" --type go
# Java
grep -n "public.*functionName" --type java
Find class definition :
# Python
grep -n "class ClassName" --type py
# JavaScript/TypeScript
grep -n "class ClassName" --type js,ts
# Java
grep -n "public class ClassName" --type java
# C++
grep -n "class ClassName" --type cpp
Find class/function usage :
# Python
grep -n "ClassName(" --type py
grep -n "function_name(" --type py
# JavaScript
grep -n "new ClassName" --type js
grep -n "functionName(" --type js
Find imports/requires :
# Python
grep -n "from.*import.*ModuleName" --type py
grep -n "import.*ModuleName" --type py
# JavaScript
grep -n "import.*from.*module-name" --type js
grep -n "require.*module-name" --type js
# Go
grep -n "import.*package-name" --type go
Find configuration :
# Config files
glob "**/*config*.{json,yaml,yml,toml,ini}"
# Environment variables
grep -n "process\\.env\\." --type js
grep -n "os\\.environ" --type py
# Constants
grep -n "^[A-Z_]+\\s*=" --type py
grep -n "const [A-Z_]+" --type js
Find TODO/FIXME :
grep -n "TODO|FIXME|HACK|XXX" -i
Find error handling :
# Python
grep -n "try:|except|raise" --type py
# JavaScript
grep -n "try|catch|throw" --type js
# Go
grep -n "if err != nil" --type go
Trace data flow :
1. Find where data is created
Semantic: "Where is user object created?"
2. Search for variable usage
Grep: "user\\." with context lines
3. Follow transformations
Read: Files that modify user
4. Find where it's consumed
Grep: "user\\." in relevant files
Find all callsites of a function :
1. Find function definition
Grep: "def process_payment"
Result: payments/processor.py:45
2. Find all imports of that module
Grep: "from payments.processor import"
Result: Multiple files
3. Find all calls to the function
Grep: "process_payment\\("
Result: All callsites
4. Read each callsite for context
Read: Each file with context
Understand a feature end-to-end :
1. Find API endpoint
Semantic: "Where is user registration endpoint?"
Result: routes/auth.py
2. Trace to controller
Read: routes/auth.py
Find: Calls to AuthController.register
3. Trace to service
Read: controllers/auth.py
Find: Calls to UserService.create_user
4. Trace to database
Read: services/user.py
Find: Database operations
5. Find tests
Glob: "**/*auth*test*.py"
Read: Test files for examples
Find related files :
1. Start with known file
Example: models/user.py
2. Find imports of this file
Grep: "from models.user import"
3. Find files this imports
Read: models/user.py
Note: Import statements
4. Build dependency graph
Map: All related files
Impact analysis :
Before changing function X:
1. Find all callsites
Grep: "function_name\\("
2. Find all tests
Grep: "test.*function_name" -i
3. Check related functionality
Semantic: "What depends on X?"
4. Review each usage
Read: Each file using function
5. Plan changes
Document: Impact and required updates
Use appropriate context :
# See surrounding context
grep -n "pattern" -C 5 # 5 lines before and after
grep -n "pattern" -B 3 # 3 lines before
grep -n "pattern" -A 3 # 3 lines after
Case sensitivity :
# Case insensitive
grep -n "pattern" -i
# Case sensitive (default)
grep -n "Pattern"
File type filtering :
# Specific type
grep -n "pattern" --type py
# Multiple types
grep -n "pattern" --type py,js,ts
# Exclude types
grep -n "pattern" --glob "!*.test.js"
Regex patterns :
# Any character: .
grep -n "function.*Name"
# Start of line: ^
grep -n "^class"
# End of line: $
grep -n "TODO$"
# Optional: ?
grep -n "function_name_?()"
# One or more: +
grep -n "[A-Z_]+"
# Zero or more: *
grep -n "import.*"
# Alternatives: |
grep -n "TODO|FIXME"
# Groups: ()
grep -n "(get|set)_user"
# Escape special chars: \
grep -n "function\(\)"
git blame for context1. Find error message
Grep: "exact error message"
2. Find where it's thrown
Read: File with error
3. Find what triggers it
Semantic: "What causes X error?"
4. Find related code
Grep: Related function names
5. Check tests
Glob: "**/*test*.py"
Look: For related test cases
1. Find entry point
Semantic: "Where does the application start?"
Common files: main.py, index.js, app.py
2. Find main routes/endpoints
Grep: "route|endpoint|@app\\."
3. Find data models
Semantic: "Where are data models defined?"
Common: models/, entities/
4. Find configuration
Glob: "**/*config*"
5. Read README and docs
Read: README.md, docs/
1. Find all usages
Grep: "function_to_change"
2. Find tests
Grep: "test.*function_to_change"
3. Find dependencies
Semantic: "What does X depend on?"
4. Check imports
Grep: "from.*import.*X"
5. Document scope
List: All affected files
1. Find similar features
Semantic: "How is similar feature implemented?"
2. Find where to add code
Semantic: "Where should new feature go?"
3. Check patterns
Read: Similar implementations
4. Find tests to emulate
Glob: Test files for similar features
5. Check documentation
Grep: "TODO.*new feature" -i
Git integration :
# Who changed this line?
git blame filename
# History of a file
git log -p filename
# Find when function was added
git log -S "function_name" --source --all
# Find commits mentioning X
git log --grep="feature name"
IDE integration :
Documentation :
No results found :
Too many results :
Wrong results :
Weekly Installs
10.9K
Repository
GitHub Stars
88
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex10.8K
gemini-cli10.8K
opencode10.8K
github-copilot10.7K
cursor10.7K
amp10.7K
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
107,800 周安装
GitHub Copilot 技能推荐工具 - 自动分析仓库并推荐相关AI技能
7,600 周安装
结构化自主实施代理 - 精准执行GitHub Copilot实施计划,确保代码变更零偏差
7,500 周安装
GitHub Issues管理助手 - 智能筛选分配给我的问题,提升开发效率
7,500 周安装
GitHub Copilot AI 产品经理助手:自动化功能识别与规范制定工作流
7,500 周安装
first-ask AI助手:先理解再执行,提升GitHub Copilot等AI编程工具协作效率
7,500 周安装
create-tldr-page:AI辅助生成简洁命令文档的GitHub Copilot技能
7,500 周安装