type
status
date
slug
summary
tags
category
icon
password
在 VS Code 里的 GitHub Copilot(或 Copilot Chat)里,这几个模式的核心区别可以用一句话概括:
Ask = 问答解释Edit = 直接改你选中的代码Agent = 多步行动 + 自动帮你改多处/跑流程Plan = 先出方案/步骤,不急着动代码(更适合做设计与拆解)
下面我用更开发者视角讲清楚它们的边界和最佳用法 👇

1) Ask:聊天问答 / 解释型(不主动改代码)

你把它当“技术顾问”就行。
✅ 擅长:
  • 解释代码在干嘛、为什么报错
  • 给你多个方案对比(优缺点、复杂度、风险)
  • 让它给你示例代码(你自己决定放哪里)
  • 快速查概念:K8s、SQL、Swift、Vue、性能优化思路
⚠️ 特点:
  • 一般不会自动改动你的文件
  • 更像“回答 + 建议”
适合场景:
  • “这段 Swift concurrency 有什么问题?”
  • “这个 SQL 为什么慢?”
  • “Ingress vs Gateway API 怎么选?”

2) Edit:面向“选区/文件”的精准修改(直接产出 diff)

你把它当“代码手术刀”。
✅ 擅长:
  • 你选中一段代码,让它“按需求改”
  • 按你的规则重构(命名、拆分函数、抽象接口)
  • 把 A 写法改成 B(比如 callback → async/await)
  • 小范围修 bug
⚠️ 特点:
  • 它会改代码,而且通常只在你给定的范围内改
  • 目标明确、改动可控
适合场景:
  • “把这个方法改成可测试(依赖注入)”
  • “把这段 JS 改成 TypeScript 并补类型”
  • “把这段逻辑抽成一个 SwiftUI View”

3) Plan:先做方案/步骤(不急着动代码)

你把它当“技术方案评审 + 拆任务”。
✅ 擅长:
  • 做架构拆解、任务列表、迁移步骤
  • 大改动前先对齐:要改哪些文件、怎么改、风险点
  • 给出测试策略、回滚策略
⚠️ 特点:
  • 优先输出计划,不直接大动代码
  • 很适合你这种要“可控升级/重构”的开发方式
适合场景:
  • “我要把 iOS 项目从 CocoaPods 迁到 SwiftPM,怎么规划?”
  • “我要把单体拆成 3 个服务,拆分顺序怎么安排?”
  • “我要给 Vue 项目加权限系统+RBAC,先怎么设计?”

4) Agent:真正的“自动驾驶”(多步执行,跨文件改动)

你把它当“能自己跑流程的实习生/助手”。
✅ 擅长:
  • 多步任务:改代码 → 改配置 → 补测试 → 修编译
  • 跨多个文件搜索、替换、重构
  • 读项目结构后做整体修改(而不是只改你选中的一段)
  • 处理“修到能跑”为止的任务
⚠️ 特点:
  • 它会自己决定下一步做什么
  • 改动范围可能很大(但通常会给你变更预览 / diff)
  • 适合“目标明确,但步骤繁琐”的任务
适合场景:
  • “把这个模块全部换成新的 API,并修到编译通过”
  • “给项目加 ESLint/Prettier 并修复所有格式问题”
  • “把所有网络请求加上统一的重试和超时策略”
  • “把一堆重复代码抽成公共组件,并跑通”

一张“选择模式”的速记表

你想要的结果
选哪个
我想问清楚、理解原理
Ask
我想改这段代码(可控、小范围)
Edit
我想先对齐方案、拆步骤、评估风险
Plan
我想它自己跨文件把事情办完
Agent

实战建议(按效率排序)

  • 先 Plan(大改动必做)→ 你确认方向
  • 然后 Agent(让它执行)→ 它跑多步
  • 最后用 Edit(你对关键代码精修)
  • 遇到不懂/不确定 → Ask(快速补知识)

你可能会踩的坑(提前避雷)

  • Edit 很适合“我指定范围”,但不要指望它帮你全局收尾
  • Agent 很强但可能改得多,建议你:
    • 提前让它“每一步都给 summary + diff”
    • 要求它“不要改业务逻辑,只做重构”
  • Plan 不是磨叽:它是在帮你避免“越改越炸”的重构事故

eg. iOS 开发Copilot 四模式的常用提示词模板

「iOS 实战级」Copilot 四模式提示词模板能落地、少废话、适合中大型 iOS 项目(UIKit / SwiftUI / Swift Concurrency)
你可以当成 Copilot 的“操作系统” 来用 👇

✅ iOS · Ask(理解 / 诊断 / 技术判断)

适合:看懂代码、定位问题、技术选型

1️⃣ 理解旧代码 / 陌生模块

Explain what this code does, including threading model, memory implications, and potential issues.

2️⃣ 并发 / async-await 诊断

Analyze this async/await code for race conditions, main-thread violations, and cancellation safety.

3️⃣ UIKit / SwiftUI 性能分析

Review this view code and point out potential performance issues (layout, rendering, state updates).

4️⃣ 架构判断(MVC / MVVM / TCA)

Evaluate whether this module follows MVVM properly and suggest improvements without overengineering.

✂️ iOS · Edit(精准修改 / 可控重构)

适合:你已经选中代码,只想“按要求改好”

1️⃣ completion → async/await

Refactor this API from completion-handler based to async/await, keeping behavior unchanged.

2️⃣ 主线程安全

Ensure all UI updates happen on the main actor and explain any changes.

3️⃣ SwiftUI State 修正

Fix state management issues in this SwiftUI view (avoid unnecessary re-renders).

4️⃣ 提升可测试性

Refactor this code to improve testability using dependency injection.

5️⃣ 命名 & 可读性

Improve naming and readability without changing logic.

🧠 iOS · Plan(方案设计 / 大改动前必用)

适合:迁移、重构、引入新技术前

1️⃣ UIKit → SwiftUI 渐进迁移

Create a step-by-step plan to gradually migrate this UIKit module to SwiftUI with minimal risk.

2️⃣ CocoaPods → SwiftPM

Propose a migration plan from CocoaPods to Swift Package Manager, including risks and rollback.

3️⃣ 引入 Swift Concurrency

Plan how to introduce async/await into this networking layer safely.

4️⃣ 架构升级(不折腾)

Design a lightweight MVVM structure for this app without introducing heavy frameworks.

5️⃣ 性能专项优化

Create a plan to optimize launch time and scrolling performance, including measurement strategy.

🤖 iOS · Agent(多步执行 / 跨文件自动化)

适合:你已经想清楚“要啥”,懒得自己跑流程
⚠️ 建议加约束,不然它真的会“太勤快”

1️⃣ 网络层现代化

Migrate the networking layer to async/await, update all call sites, and fix compile errors. Do not change API behavior. Provide a summary of changes.

2️⃣ SwiftLint 全量接入

Add SwiftLint to this project, configure common rules, and fix violations without changing logic.

3️⃣ 统一错误处理

Introduce a centralized error handling mechanism and update existing code to use it.

4️⃣ SwiftUI 性能修复

Identify unnecessary view updates and refactor to improve rendering performance.

5️⃣ 模块级重构

Refactor this feature into a self-contained module with clear public interfaces.

🧩 一个「高成功率」组合用法(强烈推荐)

Plan → Agent → Edit → Ask
例子(真实可用):
  1. Plan
    1. Plan a safe migration of this feature to async/await.
  1. Agent
    1. Execute the plan step by step. Stop if behavior changes.
  1. Edit
    1. Clean up this specific ViewModel for readability and testability.
  1. Ask
    1. Is there any remaining technical debt or hidden risk?

⚠️ iOS 项目里 Agent 的三条保命约束(建议必加)

你可以直接复制:
  • Do not change business logic
  • Prefer minimal diff
  • Explain each major change briefly

🎯 什么时候别用 Agent?

  • UI 细节 / 动画 / 交互体验(你自己更准)
  • 核心业务规则(容易“改对但不符合产品语义”)
  • 需要强主观判断的设计