mcpField
G
github-copilot-agent-tips-and-tricks

github-copilot-agent-tips-and-tricks

github.com/githubAgent 工作流5.5k57 次安装今天更新
代码仓库

关于 github-copilot-agent-tips-and-tricks

这份指南帮助 gh-aw 用户查找、审阅和跟踪 GitHub Copilot 编码 Agent 的拉取请求,涵盖 GitHub CLI 与 Git 搜索、PR 检查及故障排查。

主要功能

  1. 01按作者或分支前缀查找 PR
  2. 02用 GitHub CLI 和 jq 筛选 PR
  3. 03搜索分支和提交历史
  4. 04检查 PR 元数据和差异
  5. 05排查搜索与身份验证问题

适用场景

  1. 01定位 Copilot 编码 Agent 的拉取请求
  2. 02合并前审阅 Copilot PR 的改动
  3. 03持续跟踪 Copilot 贡献

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/github/gh-aw --skill github-copilot-agent-tips-and-tricks

安装后在 Claude Code 中输入/github-copilot-agent-tips-and-tricks确认已加载。

详细介绍

GitHub Copilot Agent 提示与技巧

使用本指南查找、审查和处理 gh-aw 中由 Copilot 编码 Agent 创建的拉取请求。

识别 Copilot Agent 拉取请求

分支命名约定

Copilot 编码 Agent 的分支使用 copilot/ 前缀,便于识别和筛选。

本仓库中的示例:

  • copilot/add-cache-for-imported-workflows
  • copilot/fix-istruthy-bundling-issue
  • copilot/update-audit-command-copilot
  • copilot/refactor-mcp-tool-rendering
作者归属

Copilot 编码 Agent 的拉取请求通常由以下主体创建:

  • app/github-copilot - GitHub Copilot 机器人账号
  • 使用 Copilot 作为助手的个人开发者

搜索 Copilot Agent 拉取请求

使用 GitHub CLI(gh)

前提条件:

# Authenticate with GitHub CLI
gh auth login

按作者搜索(GitHub Copilot 机器人):

# List all PRs created by the Copilot bot
gh pr list --author "app/github-copilot" --limit 100

# Include closed PRs
gh pr list --author "app/github-copilot" --state all --limit 100

# Get detailed JSON output
gh pr list --author "app/github-copilot" --json number,title,author,headRefName,createdAt,state

按分支前缀搜索:

# Find all PRs from copilot/* branches
gh pr list --search "head:copilot/" --state all

# Combine with other filters
gh pr list --search "head:copilot/ is:open"
gh pr list --search "head:copilot/ is:merged"

使用 jq 筛选:

# Extract specific fields
gh pr list --limit 100 --json author,number,title,headRefName \
  --jq '.[] | select(.headRefName | startswith("copilot/")) | {number, title, branch: .headRefName}'

# Filter by author containing "copilot"
gh pr list --limit 100 --json author,number,title \
  --jq '.[] | select(.author.login | contains("copilot"))'
使用 Git 命令

列出 copilot 分支:

# Local and remote copilot branches
git branch -a | grep copilot

# Remote copilot branches only
git branch -r | grep copilot

搜索提交历史:

# Find commits with "copilot" in message
git log --all --grep="copilot" --oneline

# Find commits by copilot author
git log --all --author="copilot" --oneline

# Show graph with copilot-related commits
git log --all --grep="copilot" --oneline --graph

查找已合并的 copilot 拉取请求:

# Search for merge commits
git log --all --merges --grep="copilot" --oneline

# With PR numbers
git log --all --merges --oneline | grep -i copilot

常见的 Copilot Agent 拉取请求模式

gh-aw 仓库中的近期示例

根据对本仓库的分析,Copilot 编码 Agent 通常会处理以下事项:

  1. 重构和代码组织

    • 示例:“重构 ALL_TOOLS,将其拆分到独立的 JSON 文件并在运行时进行筛选”
    • 示例:“消除重复的 MCP 工具表格渲染逻辑”
  2. 文档改进

    • 示例:“在 schema 中说明严格模式的强制执行区域和 CLI 标志”
    • 示例:“添加全面的严格模式参考文档”
  3. 错误修复

    • 示例:“修复 loadAgentOutput 错误处理的 JavaScript 测试断言”
    • 示例:“移除重复的 formatFileSize() 函数”
  4. 测试增强

    • 示例:“为所有引擎中的 playwright MCP 配置添加集成测试”
  5. 安全修复

    • 示例:“修复 copilot-session-insights 工作流中的模板注入风险”
需要检查的拉取请求元数据

审查 Copilot 编码 Agent 创建的拉取请求时,请留意:

  • 分支名称:应遵循 copilot/descriptive-name 模式
  • 提交消息:通常包含 “Initial plan” 提交
  • 拉取请求说明:应解释问题和解决方案
  • 关联议题:可能会引用正在处理的议题

工作流提示

查找相关拉取请求
# Find PRs related to a specific feature
gh pr list --search "head:copilot/ refactor" --state all

# Find PRs in a date range
gh pr list --search "head:copilot/ created:>=2024-01-01" --state all

# Find PRs with specific labels
gh pr list --search "head:copilot/ label:enhancement"
审查 Copilot 拉取请求
# Check out a copilot PR locally
gh pr checkout <PR-number>

# View PR diff
gh pr diff <PR-number>

# View PR details
gh pr view <PR-number>

# View PR in browser
gh pr view <PR-number> --web
跟踪 Copilot 贡献
# Count merged copilot PRs
gh pr list --author "app/github-copilot" --state merged --json number --jq 'length'

# List recent copilot PRs with dates
gh pr list --author "app/github-copilot" --state all --limit 20 \
  --json number,title,createdAt,state \
  --jq '.[] | "\(.number): \(.title) (\(.state)) - \(.createdAt)"'

# Export to CSV for analysis
gh pr list --author "app/github-copilot" --state all --limit 100 \
  --json number,title,createdAt,state,author \
  --jq -r '.[] | [.number, .title, .state, .createdAt] | @csv' > copilot-prs.csv

故障排除

身份验证问题

如果看到 “gh auth login” 提示:

# Authenticate with GitHub CLI
gh auth login

# Or set token environment variable
export GH_TOKEN="your-github-token"
未找到结果

如果搜索没有返回结果:

  1. 确认你位于正确的仓库中
  2. 检查作者名称是否正确(尝试 app/github-copilot 或 github-copilot)
  3. 改为按分支前缀搜索:gh pr list --search "head:copilot/"
  4. 检查是否存在拉取请求:git branch -r | grep copilot
速率限制

如果遇到 GitHub API 速率限制:

# Check rate limit status
gh api rate_limit

# Use authenticated requests (higher limits)
gh auth login

最佳实践

  1. 在无法按作者搜索时,使用分支前缀搜索
  2. 定期导出拉取请求列表,用于跟踪和分析
  3. 审查提交历史,了解 Copilot 的实现方法
  4. 检查 “Initial plan” 提交,了解 Copilot 的规划过程
  5. 合并 Copilot 拉取请求前,确认测试通过
  6. 审查安全影响,尤其是工作流变更

其他资源

评论

支持 Markdown