code-exploration
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCross-Repository Code Exploration via Glean
借助Glean进行跨仓库代码探索
When users need to understand code across internal repositories—beyond the local codebase—use Glean's code search to explore the entire organization's code.
当用户需要了解跨内部仓库的代码(而非仅本地代码库)时,可使用Glean的代码搜索功能探索整个组织的代码。
Tool Naming
工具命名
See the skill for Glean MCP tool naming conventions. Tools follow the pattern where the server name is dynamic.
glean-tools-guidemcp__glean_[server-name]__[tool]请查看技能了解Glean MCP工具的命名规范。工具遵循的命名模式,其中服务器名称是动态的。
glean-tools-guidemcp__glean_[server-name]__[tool]When This Applies
适用场景
Use Glean code search when users ask about:
- How something is implemented (in other repos)
- Where the code for a system/service lives
- Who has been working on a codebase
- Similar implementations across the org
- Examples of how to use an internal API/library
- Code patterns used by other teams
当用户询问以下问题时,使用Glean代码搜索:
- 某功能在其他仓库中的实现方式
- 某系统/服务的代码存放位置
- 谁在维护某代码库
- 组织内的类似实现案例
- 内部API/库的使用示例
- 其他团队采用的代码模式
BE SKEPTICAL
保持审慎
Not every code result is worth presenting.
Quality Test
- Is this good code to reference?
- ✅ GOOD: Clean, tested, actively maintained
- ⚠️ ACCEPTABLE: Works but has caveats
- ❌ POOR: Hacky, deprecated, abandoned
Recency Test
- Is this code maintained?
- ✅ ACTIVE: Commits in past 3 months
- ⚠️ SLOWING: 3-12 months since last commit
- ❌ STALE: 12+ months - likely outdated patterns
Relevance Test
- Does this actually answer the question?
- ✅ RELEVANT: Directly addresses what was asked
- ⚠️ RELATED: Similar but different context
- ❌ TANGENTIAL: Keyword match only
Filter Out:
- Code in ,
/deprecated/,/old/paths/legacy/ - Abandoned repositories
- Prototype/experimental code
- Code with extensive TODO/FIXME comments
Quality over quantity: 3 good examples beat 10 mediocre ones.
并非所有代码结果都值得展示。
质量测试
- 该代码是否适合作为参考?
- ✅ 优质:代码简洁、经过测试、持续维护
- ⚠️ 可接受:能正常运行但存在局限性
- ❌ 劣质:代码粗糙、已废弃、无人维护
时效性测试
- 该代码是否仍在维护?
- ✅ 活跃:近3个月内有提交记录
- ⚠️ 维护放缓:上次提交距今3-12个月
- ❌ 过时:上次提交距今12个月以上——代码模式可能已过时
相关性测试
- 该结果是否能真正回答问题?
- ✅ 相关:直接回应用户问题
- ⚠️ 关联:内容相似但场景不同
- ❌ 无关:仅关键词匹配
过滤内容:
- 位于、
/deprecated/、/old/路径下的代码/legacy/ - 已废弃的仓库
- 原型/实验性代码
- 包含大量TODO/FIXME注释的代码
质量优先:3个优质示例胜过10个平庸结果。
Key Differentiator
核心优势
Local tools (grep, glob) search only the current repo. Glean searches across ALL repositories in the organization. This is powerful for:
- Finding examples: "How do other teams handle authentication?"
- Understanding systems: "What repos touch the billing service?"
- Finding owners: "Who's been active in the payments codebase?"
本地工具(grep、glob)仅能搜索当前仓库,而Glean可搜索组织内的所有仓库。这一功能在以下场景中极具价值:
- 查找示例:“其他团队是如何处理认证的?”
- 了解系统:“哪些仓库涉及计费服务?”
- 查找负责人:“谁在活跃维护支付代码库?”
Tool Selection
工具选择
| User Intent | Glean Tool |
|---|---|
| Find code by content, pattern, or file | |
| Find related design docs or specs | |
| Identify code owners/contributors | |
| Read full file content | |
| 用户意图 | Glean工具 |
|---|---|
| 根据内容、模式或文件查找代码 | |
| 查找相关设计文档或规范 | |
| 识别代码所有者/贡献者 | |
| 查看完整文件内容 | |
Query Patterns
查询模式
Glean's code search understands natural language. Use filters for precision:
undefinedGlean的代码搜索支持自然语言查询,可使用过滤器提高精准度:
undefinedSearch by content
按内容搜索
code_search "authentication middleware"
code_search "rate limiting implementation"
code_search "authentication middleware"
code_search "rate limiting implementation"
Search by contributor
按贡献者搜索
code_search "owner:"John Smith" billing service"
code_search "from:me updated:past_week"
code_search "owner:"John Smith" billing service"
code_search "from:me updated:past_week"
Search by time
按时间搜索
code_search "after:2024-01-01 payments API"
code_search "after:2024-01-01 payments API"
Search by file pattern
按文件模式搜索
code_search "*.proto user service"
undefinedcode_search "*.proto user service"
undefinedWorkflow: Exploring a System
系统探索流程
- Find the code:
code_search "[system name]" - Vet results: Filter for quality and recency
- Find the docs:
search "[system name] design doc OR architecture" - Find the people:
code_search "owner:* [system] updated:past_month" - Read details: with URLs from vetted results
read_document
- 查找代码:
code_search "[系统名称]" - 筛选结果:根据质量和时效性过滤结果
- 查找文档:
search "[系统名称] design doc OR architecture" - 查找负责人:
code_search "owner:* [系统名称] updated:past_month" - 查看详情:使用经筛选结果中的URL调用查看完整内容
read_document
If No Good Code Found
未找到优质代码时的处理
Don't pad with weak results:
markdown
No high-quality code examples found for [topic].
**What was searched:**
- [Queries attempted]
**What was filtered:**
- [X] matches - [reasons: outdated/poor quality]
**Suggestions:**
- Check external libraries
- Ask in [relevant channel]
- This may need to be built from scratch请勿用劣质结果填充内容:
markdown
未找到与[主题]相关的高质量代码示例。
**搜索内容:**
- [尝试的查询语句]
**过滤原因:**
- [X] 匹配结果 - [原因:过时/质量低下]
**建议:**
- 查看外部库
- 在[相关频道]中提问
- 该功能可能需要从零开始构建Relationship to Commands
与命令的关联
For structured workflows, suggest the relevant slash command:
- - Get comprehensive context
/glean-code:codebase-context [system] - - Find usage examples
/glean-code:find-examples [API/pattern] - - Identify maintainers
/glean-code:code-owners [component] - - Find similar implementations
/glean-code:similar-code [pattern]
对于结构化工作流,可推荐使用对应的斜杠命令:
- - 获取全面的代码库上下文
/glean-code:codebase-context [system] - - 查找使用示例
/glean-code:find-examples [API/pattern] - - 识别维护者
/glean-code:code-owners [component] - - 查找类似实现
/glean-code:similar-code [pattern]