name: github-issues description: 使用 gh CLI 查询和搜索 GitHub 问题,支持通过标签、状态、分配者和全文搜索过滤。用于故障排除错误、检查问题是否已报告或查找解决方案时。 allowed-tools: Bash, Read, Glob, Grep, WebFetch, WebSearch
GitHub 问题查找
查询和搜索 GitHub 问题以进行故障排除、bug 跟踪和查找解决方案。支持 gh CLI 并自动回退到基于网页的方法。
概述
此技能提供从任何仓库查询 GitHub 问题的全面指南。它优先使用 GitHub CLI (gh) 进行快速、可靠的访问,并在 gh 不可用时自动回退到基于网页的方法。
核心价值: 在故障排除错误、检查 bug 是否已报告或发现已知问题的解决方案时快速找到相关问题。
何时使用此技能
此技能应在以下情况下使用:
- 故障排除错误 - 搜索与错误消息或症状匹配的问题
- 检查问题是否存在 - 在报告 bug 之前,搜索重复项
- 查找解决方案 - 从问题讨论中发现解决方案
- 跟踪功能 - 搜索功能请求及其状态
- 理解历史 - 查找解释过去决策的已关闭问题
触发关键词: github issues, search issues, find issue, bug report, issue lookup, gh issue, troubleshoot, workaround, known issue
先决条件
推荐(非必需):
- GitHub CLI (gh) - 从 https://cli.github.com/ 安装
- 认证 - 运行
gh auth login用于私有仓库
此技能在没有 gh 的情况下通过回退到基于网页的方法工作。
快速开始
搜索问题 (gh CLI)
# 检查 gh 是否可用
gh --version
# 通过关键词搜索问题
gh issue list --repo owner/repo --search "keyword" --state all
# 通过标签过滤
gh issue list --repo owner/repo --label "bug" --state open
# 查看特定问题
gh issue view 11984 --repo owner/repo
# 使用多个术语搜索
gh issue list --repo owner/repo --search "error message here" --limit 20
搜索问题 (网页回退)
当 gh 不可用时,使用 WebSearch 或 WebFetch:
# 通过网页搜索(使用 WebSearch 工具)
Search: "site:github.com/owner/repo/issues keyword"
# 直接 URL 模式
https://github.com/owner/repo/issues?q=keyword
核心能力
1. 基本问题搜索
通过关键词搜索问题,匹配标题和正文文本。
gh CLI:
# 基本关键词搜索(所有状态)
gh issue list --repo anthropics/claude-code --search "path doubling" --state all
# 仅开放问题
gh issue list --repo anthropics/claude-code --search "path doubling" --state open
# 仅关闭问题
gh issue list --repo anthropics/claude-code --search "path doubling" --state closed
详细查询语法: 参见 references/query-patterns.md
2. 通过标签过滤
使用仓库标签缩小结果范围。
# 单标签
gh issue list --repo owner/repo --label "bug"
# 多标签(AND)
gh issue list --repo owner/repo --label "bug" --label "high-priority"
# 常见标签模式
gh issue list --repo owner/repo --label "enhancement" --state open
gh issue list --repo owner/repo --label "documentation"
3. 通过分配者/作者过滤
查找由谁创建或分配给谁的问题。
# 按分配者
gh issue list --repo owner/repo --assignee username
# 按作者
gh issue list --repo owner/repo --author username
# 组合过滤器
gh issue list --repo owner/repo --author username --state closed
4. 查看问题详情
获取完整问题内容,包括描述和评论。
# 查看问题(在终端中打开)
gh issue view 11984 --repo anthropics/claude-code
# 查看带评论
gh issue view 11984 --repo anthropics/claude-code --comments
# 用于解析的 JSON 输出
gh issue view 11984 --repo anthropics/claude-code --json title,body,comments
5. 网页回退策略
当 gh CLI 不可用时,回退到基于网页的方法。
检测:
# 检查 gh 是否可用
if command -v gh &> /dev/null; then
echo "gh available"
else
echo "falling back to web"
fi
网页方法(按优先顺序):
- WebSearch 工具:
site:github.com/owner/repo/issues keyword - firecrawl MCP:抓取 GitHub 搜索结果
- 直接 URL:
https://github.com/owner/repo/issues?q=keyword
详细回退指南: 参见 references/web-fallback.md
输出格式
此技能支持三种输出格式:
紧凑(默认)
每问题一行,适合扫描:
#11984 [open] Path doubling in PowerShell hooks (bug, hooks)
#11523 [closed] Fix memory leak in long sessions (bug, fixed)
#10892 [open] Add custom status line support (enhancement)
表格
用于结构化显示的 Markdown 表格格式:
| # | State | Title | Labels |
| --- | --- | --- | --- |
| 11984 | open | Path doubling in PowerShell hooks | bug, hooks |
| 11523 | closed | Fix memory leak in long sessions | bug, fixed |
详细
用于深度调查的完整信息:
### #11984 - Path doubling in PowerShell hooks
**State:** open | **Labels:** bug, hooks | **Created:** 2024-12-01
**URL:** https://github.com/anthropics/claude-code/issues/11984
When using cd && in PowerShell, paths get doubled...
常见工作流
故障排除错误
- 从错误消息中提取关键术语
- 使用这些术语搜索问题
- 检查开放和关闭的问题
- 在评论中查找解决方案
# 示例:故障排除特定错误
gh issue list --repo anthropics/claude-code --search "ENOENT" --state all --limit 10
在报告 Bug 之前
- 搜索具有类似症状的现有问题
- 检查关闭的问题以了解过去的修复
- 如果存在重复项,添加您的上下文作为评论
# 报告前搜索
gh issue list --repo owner/repo --search "feature not working" --state all
查找解决方案
- 搜索使用您问题关键词的关闭问题
- 查找正文中包含“workaround”或“solution”的问题
- 检查问题评论中的社区解决方案
# 查找解决方案
gh issue list --repo owner/repo --search "workaround" --state closed --label "bug"
错误处理
gh 未安装
Error: gh: command not found
Solution: 从 https://cli.github.com/ 安装 GitHub CLI
- macOS: brew install gh
- Windows: winget install --id GitHub.cli
- Linux: 参见 https://github.com/cli/cli/blob/trunk/docs/install_linux.md
Alternatively, falling back to web-based search...
未认证
Error: gh requires authentication
Solution: 运行 `gh auth login` 并按照提示操作。
对于公共仓库,可以在没有认证的情况下使用网页回退。
速率限制
Error: API rate limit exceeded
Solution: 在重试前等待 60 秒。
认证请求有更高的限制(5000/小时 vs 60/小时)。
未找到结果
No issues found matching "very specific query"
Suggestions:
- 尝试更广泛的搜索术语
- 移除过滤器(状态、标签)
- 检查拼写
- 也搜索关闭的问题(--state all)
参考
详细指南:
- references/gh-cli-guide.md - 安装、认证、高级用法
- references/query-patterns.md - 搜索语法和过滤器示例
- references/web-fallback.md - 基于网页的回退策略
相关代理:
- history-reviewer agent - Git 历史探索和总结
测试场景
场景 1: 基本问题搜索
查询: “Search for issues about hooks in the Claude Code repo”
预期行为:
- 技能在“issues”、“hooks”、“Claude Code”上激活
- 检查 gh CLI 是否可用
- 运行
gh issue list --repo anthropics/claude-code --search "hooks" --state all - 返回格式化结果
场景 2: 故障排除错误
查询: “I’m getting a path doubling error in PowerShell. Is this a known issue?”
预期行为:
- 技能在“error”、“known issue”、“PowerShell”上激活
- 搜索相关问题
- 找到 #11984 和类似问题
- 如果可用,提供解决方案
场景 3: 回退到网页
查询: “Search for issues but gh isn’t installed”
预期行为:
- 检测到 gh 不可用
- 回退到使用
site:github.com/owner/repo/issues的 WebSearch - 以相同格式返回结果
版本历史
- v1.0.0 (2025-12-26): 初始发布
最后更新
日期: 2025-12-05 模型: claude-opus-4-5-20251101 审计状态: NEW - 待初始审计