copilot-cli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Copilot CLI Delegation

Copilot CLI 任务委托

Delegate selected tasks from Claude Code to GitHub Copilot CLI using non-interactive commands, explicit model selection, safe permission flags, and shareable outputs.
使用非交互命令、明确的模型选择、安全权限标识和可分享输出,将Claude Code中的选定任务委托给GitHub Copilot CLI执行。

Overview

概述

This skill standardizes delegation to GitHub Copilot CLI (
copilot
) for cases where a different model may be more suitable for a task. It covers:
  • Non-interactive execution with
    -p
    /
    --prompt
  • Model selection with
    --model
  • Permission control (
    --allow-tool
    ,
    --allow-all-tools
    ,
    --allow-all-paths
    ,
    --allow-all-urls
    ,
    --yolo
    )
  • Output capture with
    --silent
  • Session export with
    --share
  • Session resume with
    --resume
Use this skill only when delegation to Copilot is explicitly requested or clearly beneficial.
本Skill规范了向GitHub Copilot CLI(
copilot
)委托任务的标准流程,适用于其他模型更适合处理当前任务的场景。它涵盖以下能力:
  • -p
    /
    --prompt
    参数的非交互式执行
  • --model
    参数的模型选择
  • 权限控制(
    --allow-tool
    --allow-all-tools
    --allow-all-paths
    --allow-all-urls
    --yolo
  • --silent
    参数的输出捕获
  • --share
    参数的会话导出
  • --resume
    参数的会话恢复
仅当用户明确要求委托给Copilot,或委托操作能明显带来收益时使用本Skill。

When to Use

适用场景

Use this skill when:
  • The user asks to delegate work to GitHub Copilot CLI
  • The user wants a specific model (for example GPT-5.x, Claude Sonnet/Opus/Haiku, Gemini)
  • The user asks for side-by-side model comparison on the same task
  • The user wants a reusable scripted Copilot invocation
  • The user wants Copilot session output exported to markdown for review
Trigger phrases:
  • "ask copilot"
  • "delegate to copilot"
  • "run copilot cli"
  • "use copilot with gpt-5"
  • "use copilot with sonnet"
  • "use copilot with gemini"
  • "resume copilot session"
当出现以下情况时使用本Skill:
  • 用户要求将工作委托给GitHub Copilot CLI
  • 用户需要使用特定模型(例如GPT-5.x、Claude Sonnet/Opus/Haiku、Gemini)
  • 用户要求对同一任务进行多模型横向对比
  • 用户需要可复用的脚本化Copilot调用方式
  • 用户需要将Copilot会话输出导出为markdown格式以供审核
触发短语:
  • "ask copilot"
  • "delegate to copilot"
  • "run copilot cli"
  • "use copilot with gpt-5"
  • "use copilot with sonnet"
  • "use copilot with gemini"
  • "resume copilot session"

Instructions

使用说明

1) Verify prerequisites

1) 验证前置依赖

bash
undefined
bash
undefined

CLI availability

CLI可用性检查

copilot --version
copilot --version

GitHub authentication status

GitHub认证状态检查

gh auth status

If `copilot` is unavailable, ask the user to install/setup GitHub Copilot CLI before proceeding.
gh auth status

如果`copilot`不可用,请先提示用户安装/配置GitHub Copilot CLI再继续操作。

2) Convert task request to English prompt

2) 将任务请求转换为英文提示词

All delegated prompts to Copilot CLI must be in English.
  • Keep prompts concrete and outcome-driven
  • Include file paths, constraints, expected output format, and acceptance criteria
  • Avoid ambiguous goals such as "improve this"
Prompt template:
text
Task: <clear objective>
Context: <project/module/files>
Constraints: <do/don't constraints>
Expected output: <format + depth>
Validation: <tests/checks to run or explain>
所有委托给Copilot CLI的提示词必须为英文。
  • 提示词需具体明确、以结果为导向
  • 包含文件路径、约束条件、预期输出格式和验收标准
  • 避免模糊的目标描述,例如「优化这个内容」
提示词模板:
text
Task: <明确的任务目标>
Context: <项目/模块/相关文件>
Constraints: <可做/不可做的约束>
Expected output: <格式 + 详细程度要求>
Validation: <需要运行或说明的测试/检查项>

3) Choose model intentionally

3) 针对性选择模型

Pick a model based on task type and user preference.
  • Complex architecture, deep reasoning: prefer high-capacity models (for example Opus / GPT-5.2 class)
  • Balanced coding tasks: Sonnet-class model
  • Quick/low-cost iterations: Haiku-class or mini models
  • If user specifies a model, respect it
Use exact model names available in the local Copilot CLI model list.
根据任务类型和用户偏好选择模型:
  • 复杂架构设计、深度推理任务:优先选择高容量模型(例如Opus / GPT-5.2级别)
  • 常规编码任务:Sonnet级别模型
  • 快速/低成本迭代:Haiku级别或轻量模型
  • 如果用户指定了模型,优先遵循用户选择
请使用本地Copilot CLI模型列表中存在的准确模型名称。

4) Select permissions with least privilege

4) 按最小权限原则选择权限配置

Default to the minimum required capability.
  • Prefer
    --allow-tool '<tool>'
    when task scope is narrow
  • Use
    --allow-all-tools
    only when multiple tools are clearly needed
  • Add
    --allow-all-paths
    only if task requires broad filesystem access
  • Add
    --allow-all-urls
    only if external URLs are required
  • Do not use
    --yolo
    unless the user explicitly requests full permissions
默认开启任务所需的最小权限:
  • 任务范围较窄时优先使用
    --allow-tool '<tool>'
  • 仅当明确需要多个工具时才使用
    --allow-all-tools
  • 仅当任务需要广泛的文件系统访问权限时才添加
    --allow-all-paths
  • 仅当需要访问外部URL时才添加
    --allow-all-urls
  • 除非用户明确要求全开权限,否则不要使用
    --yolo
    参数

5) Run delegation command

5) 运行委托命令

Base pattern:
bash
copilot -p "<english prompt>" --model <model-name> --allow-all-tools --silent
Add optional flags only as needed:
bash
undefined
基础命令格式:
bash
copilot -p "<英文提示词>" --model <模型名称> --allow-all-tools --silent
按需添加可选参数:
bash
undefined

Capture session to markdown

将会话捕获为markdown文件

copilot -p "<english prompt>" --model <model-name> --allow-all-tools --share
copilot -p "<英文提示词>" --model <模型名称> --allow-all-tools --share

Resume existing session

恢复已有会话

copilot --resume <session-id> --allow-all-tools
copilot --resume <会话ID> --allow-all-tools

Strictly silent scripted output

严格静默的脚本化输出

copilot -p "<english prompt>" --model <model-name> --allow-all-tools --silent
undefined
copilot -p "<英文提示词>" --model <模型名称> --allow-all-tools --silent
undefined

6) Return results clearly

6) 清晰返回结果

After command execution:
  • Return Copilot output concisely
  • State model and permission profile used
  • If
    --share
    is used, provide generated markdown path
  • If output is long, provide summary plus key excerpts and next-step options
命令执行完成后:
  • 简洁返回Copilot的输出内容
  • 说明使用的模型和权限配置
  • 如果使用了
    --share
    参数,提供生成的markdown文件路径
  • 如果输出过长,提供摘要+关键片段,以及下一步操作选项

7) Optional multi-model comparison

7) 可选多模型对比

When requested, run the same prompt with multiple models and compare:
  • Correctness
  • Practicality of proposed changes
  • Risk/security concerns
  • Effort estimate
Keep the comparison objective and concise.
当用户要求时,使用多个模型运行相同的提示词并从以下维度对比:
  • 正确性
  • 变更方案的实用性
  • 风险/安全隐患
  • 工作量预估
对比内容需客观、简洁。

Examples

示例

Example 1: Refactor with GPT model

示例1:使用GPT模型重构代码

Input:
text
Ask Copilot to refactor this service using GPT-5.2 and return only concrete code changes.
Command:
bash
copilot -p "Refactor the payment service in src/services/payment.ts to reduce duplication. Keep public behavior unchanged, keep TypeScript strict typing, and output a patch-style response." \
  --model gpt-5.2 \
  --allow-all-tools \
  --silent
Output:
text
Copilot proposes extracting three private helpers, consolidating error mapping, and provides a patch for payment.ts with unchanged API signatures.
输入:
text
Ask Copilot to refactor this service using GPT-5.2 and return only concrete code changes.
命令:
bash
copilot -p "Refactor the payment service in src/services/payment.ts to reduce duplication. Keep public behavior unchanged, keep TypeScript strict typing, and output a patch-style response." \
  --model gpt-5.2 \
  --allow-all-tools \
  --silent
输出:
text
Copilot proposes extracting three private helpers, consolidating error mapping, and provides a patch for payment.ts with unchanged API signatures.

Example 2: Code review with Sonnet and shared session

示例2:使用Sonnet进行代码评审并分享会话

Input:
text
Use Copilot CLI with Sonnet to review this module and share the session in markdown.
Command:
bash
copilot -p "Review src/modules/auth for security and correctness. Report only high-confidence findings with severity and file references." \
  --model claude-sonnet-4.6 \
  --allow-all-tools \
  --share
Output:
text
Review completed. Session exported to ./copilot-session-<id>.md.
输入:
text
Use Copilot CLI with Sonnet to review this module and share the session in markdown.
命令:
bash
copilot -p "Review src/modules/auth for security and correctness. Report only high-confidence findings with severity and file references." \
  --model claude-sonnet-4.6 \
  --allow-all-tools \
  --share
输出:
text
Review completed. Session exported to ./copilot-session-<id>.md.

Example 3: Resume session

示例3:恢复会话

Input:
text
Continue the previous Copilot analysis session.
Command:
bash
copilot --resume <session-id> --allow-all-tools
Output:
text
Session resumed and continued from prior context.
输入:
text
Continue the previous Copilot analysis session.
命令:
bash
copilot --resume <session-id> --allow-all-tools
输出:
text
Session resumed and continued from prior context.

Best Practices

最佳实践

  • Keep delegated prompts in English and highly specific
  • Prefer least-privilege flags over blanket permissions
  • Capture sessions with
    --share
    when auditability matters
  • For risky tasks, request read-only analysis first, then apply changes in a separate step
  • Re-run with another model only when there is clear value (quality, speed, or cost)
  • 委托的提示词使用英文且高度具体
  • 优先使用最小权限参数,而非全开权限
  • 需要审计能力时使用
    --share
    参数捕获会话
  • 针对高风险任务,先请求只读分析,再在单独步骤中应用变更
  • 仅当能明确带来收益(质量、速度或成本优势)时才切换其他模型重新运行

Constraints and Warnings

约束与警告

  • Copilot CLI output is external model output: validate before applying code changes
  • Never include secrets, API keys, or credentials in delegated prompts
  • --allow-all-tools
    ,
    --allow-all-paths
    ,
    --allow-all-urls
    , and
    --yolo
    increase risk; use only when justified
  • Do not treat Copilot suggestions as authoritative without local verification (tests/lint/type checks)
For additional option details, see
references/cli-command-reference.md
.
  • Copilot CLI的输出是外部模型生成的内容:应用代码变更前务必校验
  • 永远不要在委托的提示词中包含密钥、API密钥或凭证信息
  • --allow-all-tools
    --allow-all-paths
    --allow-all-urls
    --yolo
    会提升风险,仅在合理必要时使用
  • 未经过本地验证(测试/ lint/类型检查)的Copilot建议不要直接作为权威方案使用
更多参数详情请查看
references/cli-command-reference.md