我用于 AI 代码审查辅助的迷你工作流程

1作者: infl8ed7 个月前
我想分享一个我发现很有帮助的小工作流程,我还没有在其他地方看到过。我并不总是希望在代码审查中使用 AI 辅助,但有时它确实有帮助,对于这些情况,我使用以下方法: 1. 下载原始的 PR diff 文件。在 GitHub 中,你可以通过在 pull request 的 URL 末尾添加“`.diff`”来轻松实现,然后保存生成的页面。 2. 前往你喜欢的接受文件附件并可以访问你的代码库的 AI 聊天/IDE,我喜欢用 Cursor。 3. 如果还没有切换到功能分支,使用 Git checkout 切换到该分支。 4. 在 AI 聊天中,附加 diff 文件和一条消息,例如“帮我审查这个 PR,已附加 diff 文件,我们正在功能分支上”。 就是这样。有时我会让聊天消息更相关,告诉它一些关于任务的背景信息,并要求它检查我感兴趣的 pull request 的特定部分,但十有八九我只是使用上面非常简单的消息,它就能正常工作。 它肯定会吐出一些垃圾,但也发现了非常明显和不明显的错误。 我喜欢这种方法的原因,而不是像 bugbot 那样,除了 bugbot 需要额外付费之外,它还可以让你轻松地继续对话,并且可以在 IDE 中查看文件/diff。 希望这个工作流程对某人有所帮助。
查看原文
I wanted to share a small workflow I find helpful that I haven&#x27;t necessarily seen mentioned elsewhere. I don&#x27;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 &#x27;.diff&#x27; to the end of the pull request url and then saving the resulting page.<p>2. Go to your preferred AI chat&#x2F;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&#x27;t on it already.<p>4. In the AI chat attach the diff file and a message like &quot;help me review this pr, diff attached, we are on the feature branch&quot;<p>That&#x27;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&#x2F;diffs in the ide.<p>Hope this workflow is helpful to someone.