鱼皮AI导航
鱼皮AI导航
  • 主页
  • 社区
  • AI工具
  • AI知识库
  • AI提示词
  • MCP
  • Skills
  • AI学习资源
  • AI资讯
  • GitHub开源
登录/注册

copilot-cli

通过自然语言指令驱动代码生成、项目分析与 GitHub 协作,支持目录上下文注入、多模型选择及 MCP 工具集成,可自动解析日志中的代码块与响应内容,并适配安全认证与企业级环境配置。

效率工具数据与分析开发运维
访问 GitHub
文档Skills.MD
name
copilot-cli
description
GitHub Copilot CLI Integration

GitHub Copilot CLI Integration

This file integrates with the GitHub Copilot CLI (@github/copilot) for agentic workflow execution. The Copilot CLI provides natural language processing capabilities and MCP (Model Context Protocol) server support.

GitHub Copilot CLI Overview

The GitHub Copilot CLI is an experimental AI-powered command-line interface that can:

  • Execute natural language prompts via copilot --prompt "your instruction"
  • Support MCP servers for tool integration
  • Generate code, documentation, and provide explanations
  • Work with file directories and project contexts
  • Integrate with GitHub API and repositories

Installation and Setup

The CLI is installed via npm and requires authentication:

▼
bash
复制代码
npm install -g @github/copilot

Environment Variables:

  • GITHUB_TOKEN or COPILOT_GITHUB_TOKEN: GitHub token for authentication
  • XDG_CONFIG_HOME: Configuration directory (defaults to /tmp/gh-aw/.copilot/)
  • XDG_STATE_HOME: State/cache directory (defaults to /tmp/gh-aw/.copilot/)

Note: The COPILOT_CLI_TOKEN environment variable is no longer supported as of v0.26+. Use COPILOT_GITHUB_TOKEN instead.

Core Command Structure

Basic Usage

▼
bash
复制代码
copilot --prompt "your natural language instruction"

Advanced Options

▼
bash
复制代码
copilot --add-dir /path/to/project \ --log-level debug \ --log-dir /tmp/gh-aw/logs \ --model gpt-5 \ --prompt "instruction"

Key Parameters:

  • --add-dir: Add directory context to the prompt
  • --log-level: Set logging verbosity (debug, info, warn, error)
  • --log-dir: Directory for log output
  • --model: Specify AI model (if supported)
  • --prompt: Natural language instruction (required to avoid interactive mode)

MCP Server Configuration

Copilot CLI supports MCP servers via JSON configuration at /tmp/gh-aw/.copilot/mcp-config.json:

▼
json
复制代码
{ "mcpServers": { "github": { "type": "local", "command": "npx", "args": ["@github/github-mcp-server"] }, "playwright": { "type": "local", "command": "npx", "args": ["@playwright/mcp@latest", "--allowed-hosts", "example.com"] }, "custom-server": { "type": "local", "command": "python", "args": ["-m", "my_server"], "env": { "API_KEY": "secret" } } } }

Server Types:

  • local: Local command execution (equivalent to stdio in other MCP configs)
  • http: HTTP-based MCP server
  • Built-in servers like GitHub are automatically available

Log Parsing and Output

Expected Log Format

Copilot CLI logs contain:

  • Command execution traces
  • Tool call information
  • Code blocks with language annotations (```language)
  • Error and warning messages
  • Suggestions and responses

Log Parsing Patterns

When parsing logs in parse_copilot_log.cjs:

  • Look for command patterns: copilot -p, github copilot
  • Extract code blocks between ``` markers
  • Capture responses with Suggestion: or Response: prefixes
  • Identify errors with error: and warnings with warning:
  • Filter out timestamps and shell prompts

Error Handling

Common Error Patterns

  • Authentication failures: Missing or invalid GITHUB_TOKEN
  • MCP server connection issues
  • Tool execution timeouts
  • Invalid prompt formatting
  • Directory permission issues

Best Practices

  • Always use --prompt parameter to avoid interactive blocking
  • Set appropriate timeouts for long-running operations
  • Validate MCP server configurations before execution
  • Handle authentication errors gracefully
  • Log detailed error information for debugging

Integration with GitHub Agentic Workflows

Engine Configuration

▼
yaml
复制代码
engine: copilot # or engine: id: copilot version: latest model: gpt-5 # defaults to claude-sonnet-4 if not specified

Tool Integration

  • GitHub tools are built-in (don't add to MCP config)
  • Playwright uses npx launcher instead of Docker
  • Safe outputs use dedicated MCP server
  • Custom tools require proper MCP server configuration

Authentication

  • Use COPILOT_GITHUB_TOKEN secret for GitHub token
  • GitHub Actions default token is incompatible with Copilot CLI
  • Must use Personal Access Token (PAT)
  • Ensure token has appropriate permissions for repository access
  • Token is passed via environment variables to CLI

Note: The COPILOT_CLI_TOKEN secret name is no longer supported as of v0.26+.

Development Guidelines

When Working with Copilot Engine Code

  • Follow MCP server configuration patterns in copilot_engine.go
  • Use "local" type instead of "stdio" for MCP servers
  • Handle built-in tools (like GitHub) by skipping MCP configuration
  • Ensure proper environment variable setup
  • Test with various tool combinations

Log Parser Development

  • Parse both structured and unstructured log output
  • Handle multi-line code blocks correctly
  • Extract meaningful error and warning information
  • Generate proper markdown for step summaries
  • Account for CLI-specific output formats

Testing Considerations

  • Mock CLI responses for unit tests
  • Test MCP configuration generation
  • Validate log parsing with various output formats
  • Ensure timeout handling works correctly
  • Test authentication scenarios

Command Examples

Basic Code Generation

▼
bash
复制代码
copilot --prompt "Generate a Python function to calculate fibonacci numbers"

File Analysis

▼
bash
复制代码
copilot --add-dir /project --prompt "Analyze the code structure and suggest improvements"

GitHub Integration

▼
bash
复制代码
copilot --add-dir /repo --prompt "Create an issue summarizing the recent changes"

With Logging

▼
bash
复制代码
copilot --add-dir /tmp/gh-aw \ --log-level debug \ --log-dir /tmp/gh-aw/logs \ --prompt "Review the code and suggest optimizations"

Security Considerations

  • Validate all prompts before execution to prevent injection
  • Restrict directory access using --add-dir carefully
  • Ensure MCP servers are from trusted sources
  • Log sensitive operations for audit trails
  • Use least-privilege tokens for authentication
  • Sanitize log output before displaying to users

Troubleshooting

CLI Not Found

  • Verify npm global installation: npm list -g @github/copilot
  • Check PATH includes npm global bin directory
  • Try reinstalling: npm uninstall -g @github/copilot && npm install -g @github/copilot

Authentication Issues

  • GitHub Actions Token Incompatibility: The default GITHUB_TOKEN does NOT work with Copilot CLI
  • Verify you're using a Personal Access Token in COPILOT_GITHUB_TOKEN secret
  • Verify the token is associated with a Copilot-enabled GitHub account
  • For GitHub Enterprise, contact admin for Copilot CLI token access

MCP Server Issues

  • Validate JSON configuration syntax
  • Check server command availability
  • Verify network connectivity for HTTP servers
  • Review server logs for connection errors

Performance Issues

  • Reduce directory scope with targeted --add-dir
  • Lower log level to reduce I/O overhead
  • Set appropriate timeouts for operations
  • Monitor token usage and rate limits
效率工具
数据与分析
开发运维

快捷安装

复制到终端去安装 Skill

npxskillsaddgithubnext/gh-aw--skill"copilot-cli"
站长:程序员鱼皮 老鱼简历 商务合作 增值电信业务经营许可证
2026 鱼皮AI导航 | 沪ICP备19026706号-6
站长:程序员鱼皮 老鱼简历 商务合作 增值电信业务经营许可证
2026 鱼皮AI导航 | 沪ICP备19026706号-6
🔥热门工具
朱雀AI检测朱雀AI检测
朱雀AI检测助手朱雀AI检测助手
LovartLovart
老鱼简历老鱼简历
WritePass官网WritePass官网
面多多面多多
CursorCursor
星月写作星月写作
朱雀AI检测助手朱雀AI检测助手
零感AI零感AI
Skills 推荐
retrieving-developer-knowledge
retrieving-developer-knowledge 用于搜索、获取和整合 Google 官方开发者文档,覆盖 Google Cloud、AI/Gemini、Android、Chrome、Web、Flutter、Go、Firebase 等平台,适用于查询 gcloud CLI 命令、API 语法、IAM 权限或架构对比等场景。
diff-intake
diff-intake 读取 PR 或分支差异,生成结构化 YAML 变更摘要,用于下游 analytics instrumentation 技能。适用于用户提交 PR 链接、分支对比或原始 diff 后需理解变更内容、评估分析覆盖或启动埋点流程的场景。
load-balancer-configurator
根据用户需求自动生成各类负载均衡器的生产级配置,覆盖 ALB、NLB、Nginx 和 HAProxy 等主流类型,适配不同协议、端口、健康检查及后端服务拓扑,支持直接集成到基础设施即代码流程中。
webapp-testing
提供本地 Web 应用的端到端测试能力,支持页面导航、元素交互、表单填写、动态等待、断言验证、截图捕获、浏览器日志收集及网络请求拦截,适用于前端功能验证与 UI 行为调试。
definition-of-done-generator
自动生成项目完成标准的规范定义与配置文件,提供符合企业级工作流要求的最佳实践指导,输出可直接投入生产环境的代码和验证结果,适用于需要标准化流程审批、合规审查及跨系统集成的复杂项目管理场景。