github copilot code review instruction 分享

众所周知,github copilot 除了便宜没有优点,基本已经没人用了
有个ai cr 的功能好像暂时没见别的 ai ide 有过,这里分享下个人自用的提示词

使用方法参考:Custom instructions for GitHub Copilot in VS Code

其实就是配置文件直接添加即可


[
  {
    "text": "Code clarity and readability: Naming conventions, appropriate comments, consistent formatting."
  },
  {
    "text": "Functional correctness: Does the code work as intended? Are edge cases handled?"
  },
  {
    "text": "Performance efficiency: Are there any performance bottlenecks? Is resource usage reasonable?"
  },
  {
    "text": "Maintainability: Is the code structure clear? Is it easy to modify and extend?"
  },
  {
    "text": "Testability: Is the code easy to test? Are unit tests sufficiently comprehensive?"
  },
  {
    "text": "Security: Are there any security vulnerabilities? Is sensitive data handled properly?"
  },
  {
    "text": "Consistency: Does it follow the project's established coding standards, style guidelines, and architectural patterns?"
  },
  {
    "text": "Simplicity (KISS): Avoid unnecessary complexity—is there a simpler implementation?"
  },
  {
    "text": "Avoid repetition (DRY): Are functions, classes, or modules effectively used to encapsulate reusable logic?"
  },
  {
    "text": "Constructive feedback: Review comments should be objective, respectful, and focused on the code rather than the author."
  },
  {
    "text": "Scope of review: Focus on the current changes and avoid unrelated large-scale refactoring suggestions."
  }
]

中文翻译:

[
  {
    "text": "代码清晰易懂:命名规范,注释恰当,格式统一。"
  },
  {
    "text": "功能正确性:代码是否按预期工作?是否处理了边界情况?"
  },
  {
    "text": "性能效率:是否存在性能瓶颈?资源使用是否合理?"
  },
  {
    "text": "可维护性:代码结构是否清晰?是否易于修改和扩展?"
  },
  {
    "text": "可测试性:代码是否易于测试?单元测试是否覆盖充分?"
  },
  {
    "text": "安全性:是否存在安全漏洞?敏感数据处理是否得当?"
  },
  {
    "text": "一致性:是否遵循项目既定的编码规范、风格指南和架构模式?"
  },
  {
    "text": "简洁性 (KISS):避免不必要的复杂性,是否有更简单的实现方式?"
  },
  {
    "text": "避免重复 (DRY):是否有效利用函数、类或模块封装了可复用逻辑?"
  },
  {
    "text": "建设性反馈:评审意见应客观、尊重,聚焦代码本身而非作者。"
  },
  {
    "text": "关注范围:评审应聚焦于本次变更的内容,避免不相关的大范围重构建议。"
  }
]

也不建议全部启用,可以按需选择一部分。

不过说实话,暂时感觉心里安慰居多,主要目前太久没上班了,没太多生产环境的大变更。


这也是一个好处吧,这个功能的话确实如果功能没明显问题也不会提示
也是坏处,目前如果没实际代码修改上的建议,则不会提。其实很多架构上的虽然不改,但是也能了解到一些东西

佬们有什么更好的也可以分享下。

顺便分享下加 commit message 的吧,不过这个就比较常规了

"github.copilot.chat.commitMessageGeneration.instructions": [
    {
      "text": "first line use proper emoji + type(like `feat: `), and Succinctly summarise what the main changes are."
    },
    {
      "text": "second line to describe the changes in detail."
    }
  ],
3 Likes

no,新版vscode有完整的agent功能了,效果还挺好
而且新版有语义搜索代码的功能,embedding做的,目前其他方案还没有代码语义搜索啊

1 Like

用了新版 copilot 我已经把 cursor 扔了,虽然有时候会截断,但他不降智啊

2 Likes

基本已经没人用这个结论是如何得出的

2 Likes

感谢佬!

1 Like

语义搜索代码是指哪个功能
我感觉直接chat里问让他自动选多少行到多少行那个都一直挺乱的

身边没什么用,用了都感觉低人一等 :innocent:

https://mp.weixin.qq.com/s/1nsQlLtN37enol8eqE920Q

很多功能要自己开

1 Like

建议使用roo code或者cline,可以调用copilot的claude api

1 Like

居然还能这样,用cocopilot吗,还是有别的工具

学习了,有些确实没看到

vscode直接可以下载roo code拓展,api来源选择vs LLM api,用法和cursor差不多,五月前是没有claude使用次数的限制的,五月后10刀pro只能300次调用了,不过学生可以直接送一个pro

1 Like

一直没用roocode 原来还能这样 copilot居然这么大方直接开放了 谢谢佬分享

不建议用cline
cline是非常傻地把所有代码一起发给llm的,所以token消耗很逆天,效果还不好
我一律推荐aider

1 Like

copilot是计算次数的,不算token的,效果不算太差,claude是有处理长文本的能力的
而且aider基本上调用不了copilot的免费claude

1 Like

和问题不相关的代码给ai会干扰它,还会造成大量不必要的计算
所以只应该把和问题相关的代码给ai,要么embedding要么语法树地图,所有代码一起给ai是非常愚蠢的
可能你写的项目比较小,效果还行,试一下几十万行代码的项目,cline用不了一点
然后你说的claude是github models吗?这个和copilot不是一个。github models上下文很小,是给你测试用的,不是让你在真实场景下用的

2 Likes

不是,claude是指vscode 内的copilot插件提供的仅供插件的api,拥有不降智力的claude3.5,和80k的上下文

1 Like