关于 github-copilot-cli-expert
面向 GitHub Copilot CLI 用户的参考技能,涵盖安装、命令、Agent、权限、GitHub 工作流及交互或脚本用法,也介绍 MCP 配置与故障排查。
主要功能
- 01安装与更新指南
- 02斜杠命令和键盘快捷键
- 03自定义 Agent 与技能
- 04安全和权限设置
- 05交互式与脚本用法
- 06GitHub 工作流示例
适用场景
- 01安装或更新 Copilot CLI
- 02查找斜杠命令或快捷键
- 03配置 Agent 或 MCP 服务
- 04排查权限或 MCP 加载问题
MCP 相关
介绍在 Copilot CLI 中配置 MCP 服务,包括默认提供的 GitHub MCP 服务及配置文件。
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ rysweet/ amplihack --skill github-copilot-cli-expert安装后在 Claude Code 中输入/github-copilot-cli-expert确认已加载。
附带文件examples.mdreference.md
详细介绍
GitHub Copilot CLI 专家
全面掌握 GitHub Copilot CLI——原生运行于终端的 AI 编码助手。
注意:命令语法和模型可用性可能会发生变化。请在 Copilot CLI 中运行
/help,查看当前选项。
用途
此技能提供以下方面的专家指导:
- 安装和更新 GitHub Copilot CLI
- 所有斜杠命令和键盘快捷键
- 自定义 Agent、技能和 MCP 服务配置
- 安全性、权限和受信任目录
- 与 GitHub 工作流集成(PR、问题、Actions)
- 编程式和交互式使用模式
快速参考
安装(任选一种)
# Homebrew (macOS/Linux) - Recommended
brew install copilot-cli
# npm (all platforms, requires Node.js 22+)
npm install -g @github/copilot
# WinGet (Windows)
winget install GitHub.Copilot
# Install script (macOS/Linux)
curl -fsSL https://gh.io/copilot-install | bash
更新到最新版本
# Homebrew
brew upgrade copilot-cli
# npm
npm update -g @github/copilot
# WinGet
winget upgrade GitHub.Copilot
# Check version
copilot --version
首次使用前
要求:
- 有效的 GitHub Copilot 订阅(套餐)
- Node.js 22+(通过 npm 安装时)
- PowerShell v6+(Windows 用户)
身份验证:
# On first run, you'll be prompted to login
copilot
# Then: /login
# OR set environment variable
export GH_TOKEN="ghp_xxxxxxxxxxxx"
常用斜杠命令
| 命令 | 描述 |
|---|---|
/help | 显示所有命令和快捷键 |
/model | 选择 AI 模型(claude-sonnet-4-5、gpt-5 等) |
/mcp | 管理 MCP 服务配置 |
/agent | 浏览并选择自定义 Agent |
/delegate | 将任务交给 GitHub 上的 Copilot 编码 Agent |
/compact | 减少上下文窗口用量 |
/context | 显示令牌用量可视化 |
/usage | 显示会话指标 |
/diff | 检查会话中所做的更改 |
/share | 将会话导出到文件或 gist |
/skills | 管理技能以增强能力 |
键盘快捷键
| 快捷键 | 操作 |
|---|---|
@file | 将文件内容纳入上下文 |
!cmd | 直接执行 Shell 命令 |
Esc | 取消操作 / 退出提示词 |
Ctrl+C | 取消 / 清除 / 退出 |
Ctrl+L | 清屏 |
Ctrl+O | 展开/折叠时间线 |
↑/↓ | 浏览命令历史 |
何时使用此技能
自动触发:用户提及以下内容时:
- “copilot cli”“github copilot”“install copilot”
- “update copilot”“copilot version”“copilot commands”
- “mcp server”“custom agents”“copilot skills”
显式调用:
Skill(skill="github-copilot-cli-expert")
导航指南
何时阅读辅助文件
reference.md——以下情况请阅读:
- 需要查看所有斜杠命令的完整列表和详细选项
- 需要查看所有命令行标志和环境变量
- 需要了解详细的安全配置(受信任目录、工具权限)
- 需要查看编程模式示例和脚本编写模式
- 需要了解 MCP 服务配置 JSON 格式
examples.md——以下情况请阅读:
- 需要查看逐步工作流示例(创建 PR、代码审查)
- 需要查看自定义 Agent 的创建和调用示例
- 需要了解 GitHub 集成用例(问题、Actions、PR)
- 需要查看委派给 Copilot 编码 Agent 的工作流
核心功能
1. 交互模式与编程模式
交互模式(默认):
copilot
# Then type prompts naturally
编程模式(脚本编写):
copilot -p "Summarize recent commits" --allow-tool 'shell(git)'
2. 自定义 Agent
内置 Agent:explore、task、plan、code-review
自定义 Agent 的位置:
- 用户级:
~/.copilot/agents/ - 仓库:
.github/agents/ - 组织/企业:
.github-private/agents/
3. MCP 服务
默认包含 GitHub MCP 服务。添加更多服务:
/mcp add
# Fill details, Ctrl+S to save
配置存储于:~/.copilot/mcp-config.json
4. 安全模型
- 受信任目录:首次启动时确认
- 工具审批:修改文件时需要审批
- 路径权限:默认仅限当前目录和临时目录
- URL 权限:所有 URL 均需审批
常见模式
在提示词中包含文件
Explain @config/settings.yml
Fix the bug in @src/app.js
委派给 GitHub Agent
/delegate complete the API tests and create a PR
恢复之前的会话
copilot --resume # Cycle through sessions
copilot --continue # Resume most recent
允许工具无需提示即可使用
copilot --allow-all-tools
copilot --allow-tool 'shell(git)'
copilot --deny-tool 'shell(rm)'
版本信息
当前版本:使用 copilot --version 检查
预发布渠道:
brew install copilot-cli@prerelease
npm install -g @github/copilot@prerelease
winget install GitHub.Copilot.Prerelease
版本发布:https://github.com/github/copilot-cli/releases/
故障排查
身份验证问题
/login # In interactive mode
# Or use PAT with GH_TOKEN/GITHUB_TOKEN env var
上下文窗口已满
/compact # Summarize conversation
/context # View token usage
MCP 服务未加载
/mcp show # List configured servers
/mcp edit [name] # Edit configuration
工具权限被拒绝
- 检查受信任的目录:
~/.copilot/config.json→trusted_folders - 使用
--allow-all-paths或--allow-all-urls标志 - 在提示时逐一批准工具
首次设置问题
安装后提示“找不到 Copilot”:
- 安装后重启终端
- 检查 PATH 是否包含安装位置
- 运行
which copilot(Unix)或where copilot(Windows)
“无订阅”错误:
- 在 https://github.com/settings/copilot 验证
- 确保方案包含 CLI 访问权限
- 尝试执行
/logout,然后执行/login
相关技能
- mcp-manager:高级 MCP 服务配置
- agent-sdk:构建自定义 Agent
- documentation-writing:清晰的文档编写实践
官方资源
评论
支持 Markdown