我为AI代码审查助手设计的小型工作流程
我想分享一个我觉得很有用的小工作流程,这个流程我并没有在其他地方看到过。我并不总是希望在代码审查时使用人工智能的帮助,但在某些情况下,它确实可以提供帮助,因此我使用以下方法。
1. 下载原始的 PR 差异文件。在 GitHub 上,你可以通过在拉取请求的 URL 末尾添加 '.diff' 来轻松实现,然后保存生成的页面。
2. 前往你喜欢的支持文件附件并能访问你代码库的人工智能聊天工具或集成开发环境(IDE),我个人比较喜欢使用 Cursor。
3. 如果你还没有在功能分支上,请执行 Git checkout 切换到该分支。
4. 在人工智能聊天中附上差异文件,并发送一条消息,比如“帮我审查这个 PR,附上差异文件,我们在功能分支上”。
就这样。有时我会让聊天消息更具相关性,告诉它一些任务的背景,并询问我感兴趣的拉取请求的具体部分,但十有八九我只是使用上面非常简单的消息,它就能很好地工作。
当然,它有时会输出一些无用的信息,但也确实捕捉到了一些非常明显和不明显的错误。
我喜欢这个方法的地方在于,与 bugbot 相比,除了 bugbot 需要额外付费之外,它使得继续对话变得简单,也方便在 IDE 中查看文件和差异。
希望这个工作流程对某些人有所帮助。
查看原文
I wanted to share a small workflow I find helpful that I haven't necessarily seen mentioned elsewhere. I don't always want AI assistance for a code review but it can sometimes be helpful and for those cases I use the below method.<p>1. Download the raw PR diff file. In GitHub you can do this very easily by adding '.diff' to the end of the pull request url and then saving the resulting page.<p>2. Go to your preferred AI chat/ide that accepts file attachments and has access to your codebase, I like Cursor for this.<p>3. Git checkout the feature branch if you aren't on it already.<p>4. In the AI chat attach the diff file and a message like "help me review this pr, diff attached, we are on the feature branch"<p>That's it. Sometimes I make the chat message more relevant, tell it some background about the task, and ask it for specific parts of the pull I am interested in checking, but nine times out of ten I just use the very simple message as above and it works fine.<p>It certainly spouts out some garbage, but it has also caught some very obvious and non-obvious bugs.<p>What I like about this method as opposed to say bugbot, apart from the fact that bugbot costs extra, is it makes it easy to continue the conversation and also to look through the files/diffs in the ide.<p>Hope this workflow is helpful to someone.