GitHub Copilot 在 vscode 中使用之 Prompt

安装

GitHub Copilot

组件介绍

常用组件介绍:

  • copilot-instructions: AI 应遵守的项目规范,是总纲、长期规则;
  • Agent: 是把大模型的推理能力和本地操作能力连接起来的执行框架。完成 "观察 → 决策 → 操作 → 验证 → 修正" 的任务闭环;
  • prompt: 固定工作流,类似 Skill;
  • MCP(Model Context Protocol): 提供与外部服务的交互。没有MCP, AI 是一个会修代码的开发者,但只能看本地的项目; 有了MCP,AI 是一个开发者,同时有 GitHub、数据库、Jira、云平台权限等服务。
markdown 复制代码
copilot-instructions.md
        |
        | 告诉 AI:
        | "你应该怎么工作"
        v

Agent
        |
        | 执行任务
        v

prompt
        |
        | 告诉 Agent:
        | "这次具体做什么"
        v

MCP
        |
        | 提供额外能力
        v

外部系统(GitHub/DB/邮箱/Jira)

组件关系可以这样理解:

scss 复制代码
                 MCP
                  |
                  |
外部世界  <--------+


                  |
                  v

              Agent(角色型)
                  |
                  |
       +----------+----------+
       |
       |
   Prompt(流程型) / Instructions
   

Prompt

prompts 可以理解为可手动触发的 Copilot 任务模板 。这里以开发一个代码检查的 prompt 为例,文件目录位于 .github/prompts/rust-quality.prompt.md。

markdown 复制代码
---
agent: agent
description: Run Rust formatting and clippy checks for this workspace
---

# Rust Code Quality Check

## Purpose

Check Rust code quality using the project's existing Rust configuration and official tools.

## Toolchain

Before running any Rust command:

1. Check for:
   - `rust-toolchain.toml`
   - `rust-toolchain`

2. Use the configured Rust toolchain.
3. Do not upgrade the Rust version automatically.

## Formatting

Before running formatting checks:

1. Check for:
   - `.rustfmt.toml`
   - `rustfmt.toml`

2. If a rustfmt configuration file exists, respect its settings.

Run:

```bash
cargo fmt --all -- --check
```

If formatting issues are found:

- Report affected files.
- Include the rustfmt output.
- Run:

```bash
cargo fmt --all
```

After formatting, re-run:

```bash
cargo fmt --all -- --check
```

## Clippy

Run:

```bash
cargo clippy --all-targets --all-features --workspace --no-deps -- -D warnings
```

Check for:

- Rust lint warnings
- Common Rust mistakes
- Non-idiomatic Rust code
- Unnecessary allocations
- Unnecessary clones
- Unused code

Treat all warnings as errors.

## Clippy Fix

Do not automatically modify Rust source code using clippy.

Only when explicitly requested:

Run:

```bash
cargo clippy --all-targets --all-features --workspace --no-deps --fix --allow-dirty --allow-staged
```

After applying fixes:

1. Review all changes.
2. Run clippy again.
3. Report remaining issues.

## Workspace

For Cargo workspace projects:

1. Locate the workspace root `Cargo.toml`.
2. Run checks from the workspace root.
3. Include all workspace members.

## Output

Report:

### Configuration

- Rust toolchain version
- rustfmt configuration file
- workspace root

### Formatting Result

PASS or FAIL

### Clippy Result

PASS or FAIL

### Summary

Provide detected issues, applied fixes, and remaining problems.

在 ai 对话窗口执行此 prompt:

shell 复制代码
> 执行 rust-quality
> run rust-quality

意思表达准确即可。

相关推荐
Hello.Reader34 分钟前
一个开源项目,让 AI 做逆向不再靠猜reverse-skill 架构解析与本地实战
人工智能·架构·开源
wespaul1 小时前
VeapAI 自然语言操作实战|第 05 篇:向量与召回——从知识条目到可检索资产
大数据·数据库·人工智能·milvus
mingbaiceping1 小时前
复旦-华盛顿大学EMBA:2026年AI课程矩阵解析
人工智能
李福春2 小时前
技术思考问题17:上了LangChain框架就等于AI-Agent工程化吗?
大数据·人工智能·langchain·深圳同盟·腾讯云架构师技术同盟·llm应用架构·编排抽象
揽秀亭长2 小时前
AIGC 检测原理拆解与论文降 AI 率的可复现处理流程(2026版)
人工智能·aigc
羞儿2 小时前
【DSH】为什么需要-Harness
人工智能·大模型·harness·认知构建
JackLam4 小时前
AI-安装ChatGpt Codex
人工智能
强哥聊算力4 小时前
《算力江湖·英伟达传奇》第七集:ChatGPT出现前夜,英伟达发生了什么?
服务器·人工智能·算法·ai·chatgpt·gpu算力
吴佳浩5 小时前
Run:ai 开源了,我把 GPU 编排摆回 AI 栈里看了一遍
人工智能
IT_Octopus6 小时前
【零基础入门 LLM 开发 · Day 13】:LangChain 的对话记忆——Message 对象版
人工智能·python·langchain