Token导航 LogoToken导航TokenDH.com
Copilot Guardrails logo
开发工具未说明官方级别未说明来源级核验

Copilot Guardrails

MCP Server

GitHub Copilot Guardrails System 是一个为GitHub Copilot设计的代码质量保障系统,通过强制执行零容忍错误、研究驱动开发、测试优先等规则,将AI编程助手转变为专业的开发伙伴。适用于个人开发者、团队和企业,确保代码质量、安全性和可维护性。

工具数

0

提示词数

0

GitHub Stars

0

资源数

0
代码质量VS Code开发工具VS Code

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

dstorey87

提供方

dstorey87

最后核验

2026/5/17 20:22

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

GitHub Copilot 边界系统

将GitHub Copilot转变为一个零容忍、以研究为导向的专业AI开发者

![License: MIT](https://opensource.org/licenses/MIT) ](https://github.com/features/copilot) ![MCP Compatible](https://modelcontextprotocol.io)

这是什么?

这个仓库包含了一套全面的 护栏 对于GitHub Copilot,它强制实施专业软件开发实践。这些不是建议——它们是 硬连线规则 造就Copilot的(特性/因素):

✅ 表示“正确”或“完成”。 对错误零容忍 - 循环直到问题解决\ ✅ 以研究为导向 - 在实施前寻找最佳实践\ ✅ 痴迷于测试 - 要求所有代码的覆盖率达到80%以上\ ✅ 文档优先 - 自动维护清单和文件\ ✅ 注重安全 - 在发货前检查漏洞\ ✅ 情境感知的 - 管理复杂性并建议仓库拆分

为什么你需要这个

问题

跳出常规思维,GitHub Copilot 能够:

  • ❌ 编写有错误的代码然后继续
  • ❌ 使用训练数据中过时的模式
  • ❌ 完全跳过测试
  • ❌ 留下文档不全的项目
  • ❌ 忽视安全最佳实践
  • ❌ 创造难以维护的混乱局面

解决方案

有了这些护栏,Copilot就变成了一个 自律的专业开发者 that: (这个短语在中文中通常不单独翻译,因为它是一个指示代词,用于指代前文提到的某个事物或情况。在翻译时,需要根据上下文来确定其具体含义。例如,如果前文提到“这本书”,那么“that”可以翻译为“那本书”。)

  • ✅ 遇到错误时停止,并在继续之前修复它们
  • ✅ 在实施前研究当前的最佳实践(2025年10月)
  • ✅ 为每个功能编写全面的测试
  • ✅ 保持清晰的文档和货运单据
  • ✅ 在每一步都验证安全性
  • ✅ 主动管理技术复杂性

快速入门

选项1:在您现有的存储库中使用

# 1. Navigate to your repository
cd your-project

# 2. Create .github directory if it doesn't exist
mkdir -p .github/instructions

# 3. Download the guardrails
curl -o .github/copilot-instructions.md \
  https://raw.githubusercontent.com/dstorey87/copilot-guardrails/main/.github/copilot-instructions.md

# 4. Download specific instruction files
curl -o .github/instructions/zero-tolerance.instructions.md \
  https://raw.githubusercontent.com/dstorey87/copilot-guardrails/main/.github/instructions/zero-tolerance.instructions.md

curl -o .github/instructions/testing.instructions.md \
  https://raw.githubusercontent.com/dstorey87/copilot-guardrails/main/.github/instructions/testing.instructions.md

curl -o .github/instructions/research.instructions.md \
  https://raw.githubusercontent.com/dstorey87/copilot-guardrails/main/.github/instructions/research.instructions.md

curl -o .github/instructions/documentation.instructions.md \
  https://raw.githubusercontent.com/dstorey87/copilot-guardrails/main/.github/instructions/documentation.instructions.md

# 5. Create your manifest
touch manifest.md

选项2:在有保障措施的情况下启动新项目

# 1. Clone this repository as a template
git clone https://github.com/dstorey87/copilot-guardrails.git my-new-project
cd my-new-project

# 2. Remove the git history and start fresh
rm -rf .git
git init

# 3. Customize for your project
# Edit manifest.md, README.md, etc.

# 4. Start coding with guardrails active!

包含内容

核心指令文件

.github/copilot-instructions.md

Copilot 用于所有操作的主指令文件。包括:

  • 零容忍缺陷政策
  • 以研究为先的使命
  • 测试驱动开发需求
  • 显式系统
  • 通信协议

.github/instructions/zero-tolerance.instructions.md

严格执行零容忍政策,不容忍任何错误:

  • 缺陷严重程度分类(P0-P3)
  • 错误循环协议(修复直至验证通过)
  • 检测与验证方法
  • 应避免的反模式(或不良实践)

.github/instructions/testing.instructions.md

授权进行全面测试:

  • 最低80%的覆盖率要求
  • 单元测试、集成测试和端到端(E2E)测试标准
  • 测试质量指南(AAA模式,独立性)
  • 模拟最佳实践
  • 持续集成/持续交付(CI/CD)集成

.github/instructions/research.instructions.md

实施前需进行研究:

  • 何时搜索(总是!)
  • 如何有效搜索
  • 信息来源验证(官方文档 > 博客)
  • 三来源规则
  • 研究文档格式

.github/instructions/documentation.instructions.md

保持全面文档记录:

  • Manifest.md 模板及更新要求
  • 组件文档标准
  • 代码注释指南
  • 架构决策记录(ADRs)

支持文件

manifest.md

关键清单文件的模板,该文件:

  • 追踪项目结构和组件
  • 记录文档依赖关系及其目的
  • 记录当前状态和已知问题
  • 提供设置说明
  • 维护架构决策

MCP-SETUP.md

配置模型上下文协议服务器的分步指南:

  • 官方GitHub MCP服务器
  • 用于测试的Playwright MCP
  • 网页搜索集成
  • 用于库文档的Context7

它是如何工作的

指令层次结构

.github/copilot-instructions.md          # Global rules for all files
│
├── .github/instructions/*.instructions.md  # Specific guidelines
│   ├── zero-tolerance.instructions.md    # Bug handling
│   ├── testing.instructions.md             # Test requirements
│   ├── research.instructions.md            # Research mandate
│   └── documentation.instructions.md       # Docs standards
│
└── manifest.md                          # Project map

GitHub Copilot 会自动读取这些文件,并在以下情况下遵循指示:

  • 生成代码
  • 回答问题
  • 以代理模式工作
  • 创建拉取请求

The Loop Protocol(环路协议)

当Copilot遇到错误时:

Bug Detected → STOP → Categorize → Document → Analyze Root Cause
     ↑                                                      │
     │                                                      ↓
     │                                              Implement Fix
     │                                                      │
     │                                                      ↓
     │                                              Write Tests
     │                                                      │
     │                                                      ↓
     │                                              Run Test Suite
     │                                                      │
     │                                                      ↓
     │                                                   Pass?
     │                                                   /    \
     │                                                 No      Yes
     │                                                 /          \
     └─────────────────────────────────────────────────────┘            Done

在错误修复并验证之前,它无法摆脱这个循环。

MCP服务器集成

为何MCP至关重要

模型上下文协议(MCP)服务器为Copilot提供访问以下内容:

  • 实时网页搜索 对于当前的最佳实践
  • GitHub 操作 用于仓库管理
  • 浏览器自动化 用于端到端(E2E)测试
  • 库文档 来自官方渠道

推荐的MCP服务器(2025年10月)

必不可少的

  1. GitHub MCP(注:MCP在此处可能代表某个特定项目、组织或概念的缩写,但根据上下文无法确定具体含义,因此直接保留原样) - 官方GitHub集成

- 管理仓库、问题、拉取请求(PRs) - 在GitHub上搜索代码 - 访问组织数据

  1. 网页搜索 - 当前信息检索

- 研究最佳实践 - 查找安全公告 - 验证方法

  1. 剧作家MCP - 官方微软浏览器自动化

- 端到端测试(E2E testing) - 用户界面自动化 - 截图捕获

强烈推荐

  1. 上下文7/Upstash MCP(注:MCP可能是一个特定项目、产品或概念的缩写,根据上下文具体含义可能有所不同,此处保留原样) - 库文档

- 最新的官方文档 - 框架引用 - API文档

  1. Microsoft Learn MCP(注:MCP在此处可能代表“Microsoft Certified Professional”或特定的认证路径,但根据上下文无法确定具体含义,因此直接保留原英文缩写) - 微软生态系统文档

- Azure 文档 - .NET 引用 - VS Code API(应用程序编程接口)

设置指南

MCP-SETUP.md 翻译为中文是:“MCP-设置指南/配置文件(Markdown格式)”。不过,具体翻译可能会根据上下文和文件的实际内容有所调整,但基本意思是表示这是一个关于MCP(可能是指某种系统、软件或设备的配置/设置)的设置或配置说明文件,且使用Markdown格式编写 用于详细的安装和配置。

快速设置:

# Open VS Code settings
code --install-extension GitHub.copilot

# Configure MCP servers in settings.json
# See MCP-SETUP.md for full configuration

使用示例

示例1:错误检测与修复循环

// Copilot writes code
function processPayment(amount: number) {
  return amount * 1.1; // Add 10% fee
}

// Test fails: negative amounts not handled
// Copilot STOPS, enters bug loop

// Fixed version:
function processPayment(amount: number): number {
  if (amount  {
  expect(() => processPayment(-10)).toThrow('Amount cannot be negative');
});

test('processPayment handles zero', () => {
  expect(processPayment(0)).toBe(0);
});

test('processPayment adds fee correctly', () => {
  expect(processPayment(100)).toBe(110);
});

// All tests pass ✓
// Copilot proceeds to next task

示例2:实施前进行调研

# User asks: "Implement password hashing"

# WITHOUT guardrails:
def hash_password(password):
    return hashlib.sha256(password.encode()).hexdigest()
# ❌ Wrong! SHA-256 is too fast, vulnerable to brute force

# WITH guardrails:
# Copilot searches: "password hashing best practices Python 2025"
# Finds: Use bcrypt or argon2, never plain SHA-256
# Source: OWASP Password Storage Cheat Sheet

import bcrypt

def hash_password(password: str) -> str:
    """
    Hash password using bcrypt with OWASP-recommended salt rounds.
    
    RESEARCH: "password hashing best practices 2025"
    SOURCE: https://owasp.org/www-community/Password_Storage_Cheat_Sheet
    REASONING: bcrypt is designed to be slow, resistant to brute force
    
    Args:
        password: Plain text password to hash
        
    Returns:
        Hashed password with salt
    """
    salt = bcrypt.gensalt(rounds=12)  # OWASP recommended
    return bcrypt.hashpw(password.encode('utf-8'), salt).decode('utf-8')

# Tests included:
def test_hash_password_produces_valid_hash():
    hashed = hash_password("test123")
    assert hashed.startswith('$2b$')
    assert len(hashed) == 60

def test_hash_password_produces_different_hashes():
    hash1 = hash_password("test123")
    hash2 = hash_password("test123")
    assert hash1 != hash2  # Different salts

def test_verify_password():
    password = "test123"
    hashed = hash_password(password)
    assert bcrypt.checkpw(password.encode('utf-8'), hashed.encode('utf-8'))

示例3:自动生成文档

// Copilot creates a new service
// manifest.md is automatically updated:

// Added to Component Inventory:
/*
#### PaymentService
- **Location**: `src/services/payment-service.ts`
- **Purpose**: Handles payment processing via Stripe API
- **Dependencies**: stripe, logger, database
- **Tests**: `src/services/payment-service.test.ts`
- **Coverage**: 92%
- **Status**: ✅ Complete
*/

// Added to Dependencies:
/*
| stripe | ^15.0.0 | Payment processing | https://stripe.com/docs |
*/

// ADR created:
/*
docs/adr/0003-use-stripe-for-payments.md
- Why Stripe over PayPal
- Security considerations
- Cost analysis
- Integration complexity
*/

定制化

特定语言的说明

为特定语言创建额外的指令文件:

.github/instructions/
├── python.instructions.md      # Python-specific rules
├── typescript.instructions.md  # TypeScript-specific rules
├── react.instructions.md       # React-specific rules
└── security.instructions.md    # Security-specific rules

示例 python.instructions.md

# Python-Specific Instructions

**Applies To**: `**/*.py`

## Style Guide
- Follow PEP 8
- Use Black for formatting
- Maximum line length: 100 characters
- Use type hints everywhere

## Testing
- Use pytest
- Test files: `test_*.py` or `*_test.py`
- Minimum coverage: 80%

## Dependencies
- Use Poetry for dependency management
- Pin exact versions in poetry.lock
- Regular security audits with pip-audit

项目特定覆盖(或项目专属重写)

您可以为特定项目覆盖全局规则:

# .github/copilot-instructions.md

# Custom rules for this project

## Overrides
- Minimum test coverage: 90% (higher than default 80%)
- All functions must have docstrings (not just public APIs)
- Commit messages must follow Conventional Commits

好处;益处

为独立开发者设计

一致性 - 代码质量不会因你的心情而改变\ ✅ 学习 - Copilot 研究并教你最佳实践\ ✅ 速度 - 后续无需调试,因为错误立即被捕获\ ✅ 文档 - 你未来的自己感谢你

适用于团队

标准 - 大家都遵守同样的规则\ ✅ 入职培训/融入(新团队/组织的过程) - 新开发者可以看到良好实践的示例\ ✅ 代码审查 - 花在基本问题上的时间减少\ ✅ 知识 - 研究成果得到记录和分享

对于企业

✅(对号,表示正确、确认或完成) 安全 - 在合并前发现的漏洞\ ✅ 合规 - 强制执行文件要求\ ✅ 可维护性 - 代码库随时间推移保持健康状态\ ✅ 培训 - AI自动执行公司标准

常见问题解答(FAQ)

问:这会减慢开发进度吗?

A.起初,可能只是稍微快一点。从长远来看,它要快得多,因为:

  • 之后不再有调试会话
  • 不要重构设计不佳的代码
  • 未针对漏洞提供安全补丁
  • 没有补交文件

问:我可以自定义规则吗?

A.当然!根据您的需求编辑指令文件。这些文件是Markdown格式的,非常易于阅读。

问:这个功能与GitHub Copilot的所有功能都兼容吗?

A.是的!兼容:

  • Copilot 聊天
  • Copilot 代理模式
  • Copilot 代码补全
  • 在命令行界面(CLI)中的Copilot
  • IDE中的Copilot

问:如果Copilot忽略了指令该怎么办?

A.罕见,但有可能发生。解决方案:

  1. 使说明更加明确
  2. 使用更强烈的措辞(“必须”与“应该”)
  3. 添加示例
  4. 如果问题持续存在,请向Copilot团队报告

问:我可以将这个与其他AI编码助手一起使用吗?

A.指令格式是GitHub Copilot特有的,但这些原则适用于任何AI助手。你需要根据自己的情况进行格式调整。

问:我怎么知道它起作用了?

A.你会注意到:

  • Copilot 问:“我应该先研究最佳实践吗?”
  • Copilot 提到“我会在继续之前修复这个错误”
  • 代码出现时,测试也随之自动出现
  • 文档已更新

做出贡献

欢迎投稿!请:

  1. 为这个仓库创建分支
  2. 创建一个特性分支
  3. 在进行更改时要进行测试
  4. 更新文档
  5. 提交拉取请求

\CONTRIBUTING.md\ 翻译成中文是:“贡献指南/贡献说明文件”。这个文件通常用于说明如何为某个项目做出贡献,包括提交代码、报告问题、参与讨论等指南 详情请见。

路线图/时间表

  • \[ \] 添加特定语言的指令模板
  • \[ \] 创建VS Code扩展以简化设置
  • \[ \] 添加预提交钩子以进行验证
  • \[ \] 构建合规跟踪仪表板
  • \[ \] 制作教程视频
  • \[ \] 添加更多MCP服务器配置

许可证

MIT 许可证 - 详见 许可证 详情如下。

致谢

  • GitHub Copilot团队负责指令文件功能
  • 模型上下文协议创作者
  • 开源社区,汇聚最佳实践

支持

  • 🐛 表示“虫子”或“错误(bug)”。在中文里,这个表情符号通常用来指代计算机程序中的错误或小故障,也可以泛指任何小问题或瑕疵。 报告问题
  • 💡 灯泡或创意的图标,常用于表示想法、灵感或提示。 请求功能
  • 📚 书籍 阅读文档
  • ⭐ 如果这个仓库对你有帮助,请给它点个星吧!

相关项目

______________________________________________________________________

用心打造,AI加持

*将您的AI编码助手从有帮助升级为专业级。*

目录标签

目录标签

代码质量VS Code开发工具本地部署AI编程助手测试驱动开发安全编码文档自动化

支持客户端

VS Code

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明none部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP