Meta资深工程师教你如何审查AI代码
字幕摘录
| 时间 | 英文 | 中文 |
|---|---|---|
| 0:00 | Well, hello there. | 嗯,你好吗? |
| 0:01 | So are you even reading your code these days, or do you just send it off and | 所以,你甚至读 你的代码这些天, 或者你只是发送它关闭 |
| 0:05 | just let your vibe coded AI slop code just into the wild without any review? | 就让你的氛围 编码AI的破解码 刚刚进入野外,没有任何审查? |
| 0:10 | Or are you still in the camp of reading all your code? | 还是你还在营地里读你的代码? |
| 0:13 | In my opinion, this topic of code review is very split right now. | 我认为,这个代码审查的话题 现在非常分裂。 |
| 0:18 | The community is very split. | 社区非常分裂. |
| 0:20 | There's a group of people who say if you're reading your code still, | 有人说如果你还在读密码 |
| 0:23 | then you're not moving fast enough. | 那你动作不够快 |
| 0:25 | The agents are probably already better at reviewing code than you are. | 特工可能已经比你更擅长审查密码了 |
| 0:29 | So why are you reading your code? | 那你为什么读你的代码? |
展开字幕全文(375 条)
| 序号 | 英文 | 中文 |
|---|---|---|
| 1 | Well, hello there. | 嗯,你好吗? |
| 2 | So are you even reading your code these days, or do you just send it off and | 所以,你甚至读 你的代码这些天, 或者你只是发送它关闭 |
| 3 | just let your vibe coded AI slop code just into the wild without any review? | 就让你的氛围 编码AI的破解码 刚刚进入野外,没有任何审查? |
| 4 | Or are you still in the camp of reading all your code? | 还是你还在营地里读你的代码? |
| 5 | In my opinion, this topic of code review is very split right now. | 我认为,这个代码审查的话题 现在非常分裂。 |
| 6 | The community is very split. | 社区非常分裂. |
| 7 | There's a group of people who say if you're reading your code still, | 有人说如果你还在读密码 |
| 8 | then you're not moving fast enough. | 那你动作不够快 |
| 9 | The agents are probably already better at reviewing code than you are. | 特工可能已经比你更擅长审查密码了 |
| 10 | So why are you reading your code? | 那你为什么读你的代码? |
| 11 | You know, there's that camp. | 你知道,那里有营地。 |
| 12 | The other camp is people who are saying, no, the AI agents are still not great yet. | 另一个阵营是那些说,不,AI特工还不算大的人. |
| 13 | It's not perfect. | 亦不圆满. |
| 14 | It makes dumb mistakes and you're creating a lot of AI slop and you really | 它犯了愚蠢的错误 而你制造了很多AI sloop 你真的 |
| 15 | need to tone it down and review the stuff that you're writing. | 需要调低音调 并审查你正在写的东西。 |
| 16 | So there's these two camps. | 故有此二营. |
| 17 | And in this video, we're going to talk about what I think of this topic. | 在这个视频中,我们将谈谈我对这个话题的看法。 |
| 18 | And I'm also going to give you my strategies on how I navigate and review | 我也会给你我的策略 关于我如何导航和审查 |
| 19 | my own code and land high quality code into the production. | 我自己的代码 和土地 高质量代码进入生产。 |
| 20 | So yeah, that's what we'll cover in this video today. | 所以是的,这就是我们今天在视频中要覆盖的内容。 |
| 21 | So if you're new to this channel, my name is John. | 如果你是新来这个频道的 我叫约翰 |
| 22 | I'm a senior staff software engineer at Meta. | 我是Meta的高级员工软件工程师 |
| 23 | And on this channel, I talk about AI tech news, AI tech tutorials, | 在这个频道,我谈论AI技术新闻,AI技术辅导, |
| 24 | anything to do with AI is my fun side hobby to dig into all of this. | 和人工智能有关的一切 都是我探索这一切的乐趣爱好 |
| 25 | But yeah, a lot of you guys are not subscribed. | 但是你们很多人都不认购 |
| 26 | You guys watch a lot of my videos, but for some reason don't subscribe. | 你们看了很多我的视频, 但出于某种原因,不订阅。 |
| 27 | So do a brother a favor and subscribe. | 做一个兄弟的忙 并订阅。 |
| 28 | I get a ton of like tokens if people subscribe. | 如果别人认购,我就会得到一吨象徵物 |
| 29 | I don't actually, but please subscribe. | 我其实没有,但请订阅。 |
| 30 | So let's get right into this video. | 让我们直接进入这个视频。 |
| 31 | So as usual, I made some slides, just some simple slides to have | 和往常一样 我做了一些幻灯片 只是一些简单的幻灯片 |
| 32 | some talking points over all of this. | 一些谈话要点 关于这一切。 |
| 33 | And for this video, I also created just a simple website that like you can | 对于这段视频,我还创建了一个简单的网站,像你这样 |
| 34 | swipe essentially to vote whether something is AI or not, and they will | 偷窥主要是投票 东西是不是AI, 他们会 |
| 35 | tell you like if it's AI or not, it's just a simple demo app and it's really | 告诉你,如果它是AI或不是, 它只是一个简单的演示应用 它真的 |
| 36 | there so I could showcase some of the tools and like things that I'm thinking | 这样我就可以展示一些工具 和我想的东西 |
| 37 | about for the video. | 关于视频。 |
| 38 | So let's start off with the obvious. | 因此,让我们从明显的开始。 |
| 39 | I think we can all safely say with the advent of AI coding, the amount of code | 我想我们可以安全地说,随着AI编码的出现, 代码的数量 |
| 40 | that people are generating is going through the roof. | 人们正在产生 正在进入屋顶。 |
| 41 | It's like so much more code. | 这就像更多的代码。 |
| 42 | People are writing a lot more features. | 人们正在写更多的特征。 |
| 43 | They're writing more tests. | 他们正在写更多的测试。 |
| 44 | They're just doing a lot more because one person can split up multiple | 他们只是做了更多 因为一个人可以分开多个 |
| 45 | agents and generate a ton of code. | 代理和生成一吨代码。 |
| 46 | And to be honest, it's almost impossible of a task for a single engineer to | 老实说,一个工程师几乎不可能完成 |
| 47 | review even their own code, let alone do code reviews for other people. | 更别提为其他人做代码审查了 |
| 48 | So where do I stand right now personally for code reviews? | 我个人的代码审查站在哪? |
| 49 | And the answer is it depends. | 答案是要看情况 |
| 50 | I think like any good answer to any hard problem answer is really it depends | 我认为,像任何好的答案 任何困难的答案是 它真的取决于 |
| 51 | because the reality of code reviews is a gradient. | 因为代码审查的现实是一个梯度. |
| 52 | It really depends on the code that you're reviewing. | 这真的取决于你正在审查的代码。 |
| 53 | So when you're writing code and when you're building a feature, the AI | 所以,当你写代码 当你建立一个功能,AI |
| 54 | agents should be part of the entire code's journey to production from planning, | 特工应该成为整个代码 从计划到生产的过程的一部分, |
| 55 | building, reviewing, and launching every single part of this. | 建造、审查和推出其中的每一部分。 |
| 56 | You should actually include your AI agents throughout the whole process, right? | 整个过程你都应该包括你的人工智能特工 对吧? |
| 57 | Whether it's planning out a spec to build out, making sure things are a feature | 是否计划建立一个小区 确保事情成为特色 |
| 58 | complete and making sure you have like evaluations and like validation criteria | 完成和确保你有 喜欢的评价和像验证标准 |
| 59 | is that you're thinking about ahead of time. | 你是在提前考虑 |
| 60 | And when you're building the code, you want to have agentic validation so that | 当你建立代码时,你想有代理验证 这样, |
| 61 | the AI can self validate and self fix itself and then get the code right a lot | 人工智能可以自我验证和自我修复 然后经常修正代码 |
| 62 | more often. | 更常见. |
| 63 | And then we have the review, which is like what we're talking about | 然后我们有评论, 这就像我们所说的 |
| 64 | today. | 今时. |
| 65 | And we're going to talk about some strategies on how you should do this. | 我们来谈谈你应该怎么做的策略。 |
| 66 | And then when you're launching, I think this also should be part of it. | 然后当你发射的时候, 我认为这也应该是其中的一部分。 |
| 67 | You want to feature gate and run experiments on your code and all of these | 您想要设置门 并运行实验 您的代码和所有这些 |
| 68 | things, I think, tied together to answer the question when and how much should | 事情,我认为,捆绑在一起, 回答一个问题,什么时候,应该多少 |
| 69 | you review a code? | 你审查一个代码? |
| 70 | So it really depends, right? | 所以这真的取决于,对不对? |
| 71 | Now, the big concept that I want to let you guys know about today is that I think | 我想让你们知道今天的大概念是 |
| 72 | of the code base like a tree and like a tree, there are different parts of the | 代码基像树 和树一样, 有不同的部分 |
| 73 | tree that is more important. | 这棵树更重要 |
| 74 | So think of like kind of the trunk, the root, the main part of the code. | 想想树干 根 密码的主要部分 |
| 75 | That's like your main entry points, like your app dot JS that has all of the | 这就像你的主要切入点, 就像你的应用点 JS 拥有所有 |
| 76 | different helpers that are like added to it. | 各种援助者,犹如加在其中一样。 |
| 77 | And then your infrastructure code, like image processing, networking, and all | 然后,你的基础设施代码, 像图像处理,联网,和所有 |
| 78 | these things that if something goes wrong in that code base, it can affect the | 这些东西,如果事情出错 在代码基础, 它可能影响 |
| 79 | entire app. | 整个应用程序。 |
| 80 | I think of that as like a trunk piece of code. | 我觉得这就像一个后备密码 |
| 81 | And then there's like leaf notes and we're going to get into more of this topic | 然后有像叶子笔记, 我们要进入更多的这个话题 |
| 82 | throughout this video, but start thinking about your code base as a trunk. | 整个视频,但开始思考 你的密码基础作为一个后备箱。 |
| 83 | And as soon as you start thinking about this, then the obvious next thing that you | 一旦你开始想这个, 那么很明显的下一个事情,你 |
| 84 | naturally think about is that the review depth, the depth that your own effort | 自然而然的思考是,审查的深度, 你自己的努力的深度 |
| 85 | level on reviewing a certain code, it should really be based on like the blast | 关卡审查某个代码, 它真的应该基于 像爆炸 |
| 86 | radius of that code change. | 代码的半径改变。 |
| 87 | As an example, if you're touching something that's like core image rendering | 举个例子,如果你碰的东西 像核心图像渲染 |
| 88 | infrastructure that touches all the different image renderings, and there's a | 基础设施可以触及所有不同的图像渲染, |
| 89 | lot of downstream dependencies, then I will spend a lot of time reading that | 很多下游的依赖, 然后我会花很多时间阅读 |
| 90 | piece of code, for example. | 比如说,一个代码。 |
| 91 | And then for any like one-off leaf node code, you could probably just have agents | 然后,任何像一次性叶节点代码, 你可能只是有代理人 |
| 92 | do simple validations like component testing or snapshot testing and just | 进行简单的验证,如组件测试或快照测试,以及公正 |
| 93 | visually validate the PR as long as they have proof in the PR. | 只要他们在公关里有证据 就可以通过视觉验证公关 |
| 94 | So this concept of like changing your effort level, depending on the importance | 因此,这个概念 就像改变你的努力水平, 根据重要性 |
| 95 | of the code, I think really matters a lot. | 代码,我认为真的很重要。 |
| 96 | And you should actually do this planning from the beginning. | 你从一开始就应该做这个计划。 |
| 97 | So when you're planning the entire feature, you actually want to feature gate it. | 所以当你计划整个功能时, 你其实想要设置门。 |
| 98 | Now, if you don't know what feature gating is, is essentially adding a branching | 现在,如果你不知道什么是吉丁, 本质上是增加分支 |
| 99 | logic in your code base where you can say, Hey, this feature is on or off. | 密码底部的逻辑,你可以说,嘿,这个功能是打开或关闭的。 |
| 100 | So there's a concept called feature toggling, a really popular option. | 因此,有一个概念叫做特征的移动, 一个非常受欢迎的选择。 |
| 101 | It's called launch starkly. | 这被称为"严酷发射". |
| 102 | And you can have feature gating. | 你可以有特色的标语。 |
| 103 | There's a lot of actually infrastructure that you need to do feature gating | 有很多基础设施,你需要做 特色吉他 |
| 104 | properly, but you can start out really simple by just adding a | 说得好,不过你只要加个 |
| 105 | Boolean flag in your code base. | 密码底部的布尔旗 |
| 106 | It's a gating code and you just turn things on and off. | 那是个标语码 你打开和关闭它 |
| 107 | So from the beginning, if you're planning a new feature, think in broad strokes | 因此,从一开始,如果你计划一个新的特征, 思考在大字 |
| 108 | and gate all of the things out and then think a lot about the integration pieces. | 然后把所有的东西都打开 然后想了很多关于整合的部分。 |
| 109 | So you want to separate out leaf nodes, things that doesn't touch any of the | 所以,你想分离 叶节点,的东西 不触及任何 |
| 110 | existing code bases, and then you want to think about integration separately. | 已存在的代码基础,然后您想要单独考虑整合。 |
| 111 | You really want to like gate those integration layers. | 你真的喜欢把那些融合层的门打开。 |
| 112 | So once you have like a good solid plan and a good like roadmap and they have | 因此,一旦你有了一个很好的 坚实的计划和好的 像路线图,他们有 |
| 113 | like good feature gating, like ready to go, then you can start coding. | 喜欢好的特征 喜欢准备去, 然后你可以开始编码。 |
| 114 | And then this coding part is like, you know, just use agents to build the code out. | 然后这个编码部分就像,你知道的,只是使用代理来构建代码。 |
| 115 | And then you can just use the agents to like, you know, make atomic changes. | 然后,你可以只是使用 剂喜欢,你知道, 做原子变化。 |
| 116 | I have a ton of videos around using agents to code, but you know, we're not | 我有一大堆视频 使用代理密码,但你知道,我们不是 |
| 117 | covering that particular topic, but once you're ready for PR, what should | 但一旦你准备好公关,什么应该 |
| 118 | go in that PR? | 去公关? |
| 119 | So let's think about that. | 因此,让我们考虑一下。 |
| 120 | So in my opinion, for your diffs to be really like solid, your PRs to be like | 所以,在我看来,你的 diffs 真的像固体, 你的公关像 |
| 121 | rock solid, you really want to anchor and push your agents to give you proof. | 坚固的岩石,你真的想 锁定和推动你的代理人给你的证据。 |
| 122 | And there's many different types of proof that the agents could give you. | 特工可以给你很多不同类型的证据 |
| 123 | There can be just straight up unit tests. | 可以直接进行测试 |
| 124 | So as an example, something like this, it's just a straight up unit test, very | 举个例子,像这样的, 这只是一个直升单元测试,非常 |
| 125 | simple, a lot of tests, and this is like just reading the test names and just | 简单,很多测试, 这就像只是读 测试名称,只是 |
| 126 | giving the test and the asserts. | 给出测试和断言。 |
| 127 | You could quickly get some like good sense of, oh, there's like good | 你可以很快得到一些像 良好的感官,哦,有像好 |
| 128 | logic testing that's happening. | 逻辑测试正在发生 |
| 129 | One side note is you want to be careful here when the agents are writing tests, | 其中一个方面是 当特工们在写测试时 你要小心 |
| 130 | you should probably make your own skill around not writing useless tests. | 你应该让自己的技能 围绕不写无用的测试。 |
| 131 | That's like a little side tip. | 这就像一个小侧尖。 |
| 132 | And then you also want runtime evidence. | 然后,你还需要运行时间的证据。 |
| 133 | So let's say that you have a lot of like runtime logs. | 假设你有很多像运行时日志的。 |
| 134 | And I talk about this in my engine tech engineering video, where you want to | 我在引擎技术工程录影带里谈到这个,你想在这里 |
| 135 | anchor on giving more visibility and more eyes for the agents. | 坚持让更多人能见度和更多人能见度 |
| 136 | So you can have runtime evidence and then you can have visual evidence where | 因此,你可以有运行时间的证据, 然后,你可以有视觉证据在哪里 |
| 137 | maybe it's a screenshot. | 也许是截图 |
| 138 | And then I also ask the agents to give a confidence level on their code and | 然后我也要求特工们 对其密码给予信任 |
| 139 | their gating and like different parts of the code. | 和代码的不同部分 |
| 140 | So you really want to push your agents when you're ready to like push out a | 所以,你真的想推 你的特工 当你准备好喜欢推出一个 |
| 141 | PR on these kinds of things. | 公关关于这种事情。 |
| 142 | It's like, do you have evidence? | 就像 你有证据吗? |
| 143 | Obviously you want to build these into your skills. | 很明显,你想要把这些建在你的技能。 |
| 144 | So let's take a look at like UI proof, right? | 所以让我们看看 像UI的证据,对不对? |
| 145 | So one of the things I like to do every time I make changes with the AI, I | 所以我喜欢做一件事 每次我修改AI,我 |
| 146 | always ask it to have a video or a UI screenshot, right? | 总是要求它有 视频或UI截图,对不对? |
| 147 | So for this one, this lets the player save a card, right? | 因此,对于这一个,让玩家保存一张牌,对不对? |
| 148 | So you can see right here, there is a save button. | 所以,你可以看到在这里, 有一个保存按钮。 |
| 149 | So I can see that, oh, okay, this was saved. | 所以,我可以看到, 哦,好吧,这是保存。 |
| 150 | And here's some like simple code changes. | 这里有一些像简单的代码更改。 |
| 151 | And then it looks roughly right. | 然后它看起来大概是正确的。 |
| 152 | But the point is I see a visual proof. | 但重点是我看到了一个视觉证据。 |
| 153 | So immediately I'm a lot more believing of this AI's code output, right? | 所以,立即我更相信 这个AI的代码输出,对不对? |
| 154 | So if you have the visual proof and if you know that it's safe, | 所以,如果你有视觉证据 如果你知道它是安全的, |
| 155 | then it's a lot safe to land. | 那样就能安全着陆了 |
| 156 | So having proof and having more proof lets you move faster because you don't | 所以,有证据和更多的证据 让你移动得更快 因为你没有 |
| 157 | have to manually check these proofs. | 需要手动检查这些证明。 |
| 158 | And this is really around agentic validation. | 这其实是关于代理验证的。 |
| 159 | And I talk about that in my agentic engineering video, but agentic | 我在代理工程的视频里谈到了这一点 但代理 |
| 160 | validation is a core concept of being able to read less code. | 验证是能够读得更少代码的核心概念. |
| 161 | Because if you have a lot of these proof upfront on the PR, then you | 因为如果你在公关前有很多这些证据 那你 |
| 162 | don't have to read as much code. | 不需要读那么多代码 |
| 163 | Now the next big concept, and this is kind of in the tree concept is leaf code. | 现在下一个大概念, 这是树的概念就是叶码。 |
| 164 | A leaf code is really code that is written in isolation, or it's completely | 叶码其实是单独写出来的, 或者是完全的 |
| 165 | gated off in a feature gate. | 门关在特色门。 |
| 166 | So this can mean like one-off components that you can just validate with like | 因此,这可能意味着像一次性组件 你可以只是验证 像 |
| 167 | a component test or a snapshot test, right? | 组件测试或快照测试,对不对? |
| 168 | Or maybe it's new infrastructure, new logic, maybe a new endpoint that | 或者是新的基础设施 新的逻辑 也许是新的终点 |
| 169 | you're integrating with. | 你正在和他们融合 |
| 170 | And you could just validate that with, you know, unit tests or integration tests. | 你可以通过单位测试或整合测试来验证这一点。 |
| 171 | And as long as they're not integrated to the main production code base, you | 只要它们没有融入主生产代码基地 你 |
| 172 | could move really quickly. | 动作很快 |
| 173 | And then I'll cover later what you should be doing. | 然后,我以后会报道你应该做什么。 |
| 174 | So for me, when I'm reviewing leaf like code, I spend a lot less time. | 所以对我来说,当我像代码一样审查叶子时, 我花的时间要少得多。 |
| 175 | I'm almost just mainly skimming the code and making sure things are not like very | 我几乎只是 轻描淡写代码 确保事情不是非常 |
| 176 | off or like something is just obviously wrong. | 关闭或喜欢的东西 只是明显是错误的。 |
| 177 | And for example, what can be a trunk is like, you know, in the reducer, reducer | 举例来说,什么可以是一个树干 就像,你知道,在减速器,减速器 |
| 178 | has a lot of shared state. | 有很多共享状态。 |
| 179 | So let's say you change some behavior here in this like game action advance | 因此,让我们假设你改变一些行为 在这里像游戏动作推进 |
| 180 | cards, maybe there's like a new card type or something like that, and you're | 牌,也许有像 新牌类型什么的, 而你 |
| 181 | changing existing behavior. | 改变现有的行为。 |
| 182 | And if that behavior is not gated out, then I would spend a lot more time | 如果那样的话,我会花更多的时间 |
| 183 | reviewing it because that changes production, right? | 因为它改变了生产,对不对? |
| 184 | And then this has trickle down effects and side effects and all these things | 然后,这有 滴滴的效果和副作用 和所有这些东西 |
| 185 | can really matter and affect production code, right? | 能够真正重要 并影响生产代码,对不对? |
| 186 | So you're really anchoring on safety. | 所以,你真的 锚的安全。 |
| 187 | So we kind of covered like thinking about code as like this gradient and how you | 所以,我们有种覆盖 喜欢思考代码 像这个梯度和如何你 |
| 188 | should anchor on changing your effort level, right? | 应该坚持改变你的努力水平,对不对? |
| 189 | And in my opinion, everything should be anchored on safety. | 我认为,一切应该建立在安全的基础上。 |
| 190 | What is the control experience that should not change? | 不应该改变的控制经验是什么? |
| 191 | And if this change went wrong, how bad can it be? | 如果这个改变出了问题,会有多糟? |
| 192 | And then can I roll this change back? | 然后,我可以滚回这个变化? |
| 193 | And then that really just depends on future gaining, right? | 然后这真的取决于 未来获得,对不对? |
| 194 | So if you can answer these questions, especially the last one, then you can | 如果你能回答这些问题,尤其是最后一个问题,那么你可以 |
| 195 | spend a lot less time reviewing each individual code. | 花更多的时间审查每个代码。 |
| 196 | Now, one other thing that is like not that important in my opinion, these days | 现在,还有一件事,我认为 不那么重要,这些天 |
| 197 | that is part of like usually reviews is like knits and like little like different | 这就像通常的审查 就像织物 和小像不同 |
| 198 | ways of writing. | 写作的方式。 |
| 199 | And I would just leverage like static checking here to be able to do a lot of | 我会像静态检查一样 来做很多 |
| 200 | that work. | 这工作。 |
| 201 | So like type checking, linting, and all those kinds of things. | 所以,像类型检查,林丁, 和所有这些事情。 |
| 202 | And agents are really good at doing stuff like this. | 特工们都擅长做这种事 |
| 203 | So we have a codex reviewer here and it's like seeing some linting issues. | 因此,我们有一个代码审查器在这里, 它就像看到一些闪烁的问题。 |
| 204 | So it's like saying we should fix it as an example. | 所以,这就像说 我们应该把它作为例子。 |
| 205 | And here's some like stylistic changes, right? | 这里有一些像 结构变化,对不对? |
| 206 | So one big thing about code review is that I think the old days of like having | 所以,一个重要的事情 关于代码审查 我认为过去的日子 像有 |
| 207 | your knits and they're like, oh, the code should look this way. | 你的织布和它们一样, 哦,代码应该看起来这样。 |
| 208 | This is my favorite way of writing code. | 这是我最喜欢的写密码的方法 |
| 209 | I think that's kind of dead. | 我觉得这有点死。 |
| 210 | I think we write so much code and code is being a lot more fluid and refactors are | 我认为我们写这么多代码和代码 是更多的流体 和重构是 |
| 211 | happening a lot more often. | 经常发生 |
| 212 | And it's a lot easier to do, especially once like there's good validations for | 做起来容易很多, 特别是一旦有很好的验证 |
| 213 | the code that you want to refactor. | 您想要重构的代码 。 |
| 214 | I think these kinds of knits don't really belong in the conversation of code | 我觉得这些织物 不属于密码的话题 |
| 215 | reviews anymore. | 复议了。 |
| 216 | So going back to the original question is, do I read the code? | 回到原来的问题,我读过密码吗? |
| 217 | The simple answer is yes. | 简单的答案是肯定的。 |
| 218 | I still read a lot of code. | 我仍然读了很多代码。 |
| 219 | I think I read more code than I did before, but I definitely have this like | 我想我读了比以前更多的代码, 但我肯定有这样的 |
| 220 | knob where I, I first asked myself, is this a core change, like a trunk change? | 我第一次问自己,这是核心变化吗? |
| 221 | And is it touch? | 是触摸吗? |
| 222 | It's like an infrared. | 如红外线. |
| 223 | Does it have a lot of like dependencies? | 它有很多相似的依赖性? |
| 224 | If so, I increase it. | 如果有的话,我就会增加 |
| 225 | And then I say, is it safe? | 然后我说,它安全吗? |
| 226 | Is there gating? | 有吗? |
| 227 | If something went wrong, like what can happen? | 如果出事了 会发生什么事? |
| 228 | So all of these things really change how much I review the code, right? | 所以所有这些事情 真正改变 我审查代码,对不对? |
| 229 | And then the more dangerous it is, the more I spend time. | 然后越危险,我就越花时间。 |
| 230 | More of that changes a one-way door. | 更多的情况改变了单向的大门。 |
| 231 | I spend more time reviewing, right? | 我花更多的时间审查,对不对? |
| 232 | Now let's get kind of to the fun parts of like looking at how you can use agents | 现在让我们去玩玩吧 就像看你如何使用特工 |
| 233 | to kind of help you review your code. | 帮助你检讨你的代码 |
| 234 | Now, in my opinion, AI is really good at reviewing code already. | 现在,我认为,AI真的 擅长审查代码已经。 |
| 235 | I actually do think it's better than most humans. | 我确实认为它比大多数人类更好。 |
| 236 | The issue is a lot of people are doing it wrong. | 问题是很多人都做错了 |
| 237 | And in my opinion, there's a few things that you should really anchor on doing. | 在我看来,有些事情你应该坚持去做。 |
| 238 | One, you should have a really good review skill. | 第一,你应该有很好的审查技巧 |
| 239 | I think both clock code and Codex have really good built reviews. | 我认为时钟代码和Codex 都有很好的设计评论 |
| 240 | And then here is the review agent right here. | 然后这里是审查代理 就在这里。 |
| 241 | And then for clock code, it's slash code review. | 而对于时钟代码,则是斜线代码审查. |
| 242 | So these are all both really good review agents in my opinion. | 在我看来,他们都是很好的审查人员。 |
| 243 | But one thing that's kind of important to do is to use a new sub agent or a | 但有一点很重要的 就是使用一个新的子代理 |
| 244 | different agent, an agent that doesn't have the context of the code that it was | 不同的特工,一个没有 代码背景的特工,它是 |
| 245 | used to create the code because the agents will cheat, you know, the, all the | 用来创建代码 因为特工会欺骗,你知道,所有 |
| 246 | context that you gave it, it will cheat. | 你给它的背景, 它会欺骗。 |
| 247 | And then, and they will really try to anchor on like a lot of the previous | 然后,他们真的会像以前一样坚持下去 |
| 248 | conversation. | 谈话。 |
| 249 | So you really want to review the code with like a different sub agent or like | 所以,你真的想审查代码 与不同的子代理或喜欢 |
| 250 | a separate agent that it's called an adversarial review agent. | 一个单独的代理人,它被称为对抗性审查代理人。 |
| 251 | And when you have an agent write a diff or thing, just have like a good template | 当你有代理 写一个diff或东西, 只是有像一个好的模板 |
| 252 | that the agent can pull from. | 特工能从中抽身 |
| 253 | So your PRs look the same, they feel the same, they have the important bits. | 所以,你的公关看起来是一样的, 他们的感觉是一样的, 他们有重要的位点。 |
| 254 | If you don't give any guidance on what the agent should really have, it will | 如果你不给任何指导 特工应该有什么,它会 |
| 255 | write you like a giant paragraph, like a story. | 写你像一个巨大的段落, 像一个故事。 |
| 256 | And honestly, that's my biggest pet peeve right now is when people submit PRs or | 老实说,这是我最大的宠物尿尿,现在是 当人们提交公关或者 |
| 257 | diffs to review where the summary and test plan is longer than the code changes | diffs 用于审查概要和测试计划比代码变化长的地方 |
| 258 | itself. | 它本身。 |
| 259 | So don't be that guy. | 所以不要做那个家伙。 |
| 260 | Now I showed this off a little bit, but all the agent stuff that I've been | 现在,我展示了这一点一点点, 但所有经纪人的东西,我一直 |
| 261 | talking about was during runtime, during the generation of the code. | 说到的是运行时间 代码生成期间 |
| 262 | And that's what you're running. | 而汝所运行. |
| 263 | But then Codex actually offers this integration right here, where you can add | 但Codex实际上就在这里提供这种整合,在那里你可以添加 |
| 264 | a Codex reviewer on to get up and it could run on new get up, like, you know, | 一个Codex评论员 起来,它可以运行 在新的起来,喜欢,你知道, |
| 265 | PR opens, or you could also like just add Codex here like that. | PR打开,或者你也可以喜欢 只是添加Codex在这里这样。 |
| 266 | And essentially it's this Chachapiti Codex connector. | 基本上就是这个Chachapiti代码连接器。 |
| 267 | And I think there's a separate model slightly that is custom trained just for | 我觉得有一个不同的模型 稍稍地是定制训练的 |
| 268 | like reviewing. | 喜欢回顾。 |
| 269 | Now all of this costs money, right? | 现在这一切 花费钱,对不对? |
| 270 | But yeah, that's an example. | 但是,这是一个例子。 |
| 271 | Another thing you can do is actually use goals as an example. | 另一种可以做的是把目标作为例子。 |
| 272 | So one of the common issues that people will run into when they start having | 所以当人们开始有 |
| 273 | these agentic systems that are reviewing their code on GitHub is that after you | 在GitHub上审查密码的代理系统 就是在你之后 |
| 274 | submit a PR, the agent will go do stuff and then it'll give you a bunch of | 提交公关,代理会去做一些事情 然后它会给你一堆 |
| 275 | comments that you need to fix. | 需要修改的评论。 |
| 276 | And sometimes there'll be a lot of back and forth. | 亦时有前后无量. |
| 277 | You fix it and then like you resubmit and then it'll be like back and forth. | 你修复它,然后像 你重新提出,然后 它会像前后。 |
| 278 | So a thing you can do is like just use goals to babysit a PR. | 你可以做的就是用目标来照顾公关 |
| 279 | So let's say we had this like random PR. | 所以,让我们假设我们有 这像随机公关。 |
| 280 | This is a draft, but you could just say for this PR, can you babysit it every | 这是一个草稿,但你可以只是说 这个公关,你能照顾它每一个 |
| 281 | hour, check it every hour and make sure that you address any changes requests | 小时,每个小时检查一次,确保您满足任何更改请求 |
| 282 | from the Codex agent. | 从代码代理。 |
| 283 | It misspelled it, but you get the point. | 拼错了,但你明白我的意思 |
| 284 | So what this will do is every hour it will check that PR and then it will fix | 所以,它会做一个小时 它会检查公关 然后它会修复 |
| 285 | any issues, rerun your local validations, agentic validations, update the PR | 任何问题,请重新运行本地验证,代理验证,更新 PR |
| 286 | notes, and then resend it. | 注释,然后重新发送。 |
| 287 | So these are the kinds of things that you should build into your own | 这些是你们自己应该建造的东西 |
| 288 | skill if you haven't done so. | 技术,如果你还没有这样做。 |
| 289 | But yeah, so those are kind of like the high level, like useful tools. | 但是,是的,所以这些 有点像高级, 像有用的工具。 |
| 290 | In my opinion, it's just really important to use adversarial agent. | 在我看来 使用对抗性特工是非常重要的 |
| 291 | In my opinion, have good review skills. | 我认为,有良好的审查技能。 |
| 292 | Actually just like the default, like skill reviewers have a template for | 其实就像默认, 像技能审核员有一个模板 |
| 293 | your PRs and you can use my template if you want, but just have a template. | 公关和我的模板,如果你需要,但只要有一个模板。 |
| 294 | So it conforms your PRs to that template. | 让你的公关符合这个模板 |
| 295 | And then it adds like validation proof. | 然后它又增加了像验证证明。 |
| 296 | You know, we talked about the different types of validation. | 你知道,我们谈到 不同类型的验证。 |
| 297 | You really want to anchor on the agents, giving you proof that will actually | 你真的想锁定特工, 给你证据,实际上 |
| 298 | help your AI coding, by the way. | 顺便帮你的人工智能编码 |
| 299 | And then you just submit all of that. | 然后你只是提交 所有这一切。 |
| 300 | And then you make sure you anchor on safety and gating. | 然后你确保你锚在安全 和吉丁。 |
| 301 | So these are kind of the high level things that I think about before we end | 所以,这些都是一种高层次的事情 我思考 在我们结束之前 |
| 302 | this video, I also want to talk about what it means if you're coding like | 这段录像,我也想谈谈 如果你像编码 |
| 303 | this, where you're reading some of the code deeply and you're reading like | 这个,你读一些代码 深入,你读像 |
| 304 | leaf notes, kind of like skimming it as you're going the end product of that | 叶子笔记,有点像 滑动它,当你去 端产品 |
| 305 | higher feature at the end of your coding session, like you're like, Oh, I'm done. | 高级的功能 在你的编码会议结束时, 就像你喜欢, 哦,我完成了。 |
| 306 | If you actually code in this way, you'll be only actually like 80% done. | 如果你真的用这种方式编码, 你实际上只会像 80%完成。 |
| 307 | So here I'm saying, even if it's merge ready, I don't think it's launch ready. | 所以,我在这里说, 即使它已经合并了, 我认为它还没有准备好。 |
| 308 | So what I like to do is I call this initial step of like getting | 所以,我喜欢做的是,我称这个初始步骤 像得到 |
| 309 | everything gated and landed. | 一切都关闭和着陆。 |
| 310 | I call that like broad strokes. | 我管这叫大打大打 |
| 311 | I'm doing like broad strokes of the code changes. | 我做得很像 广义的代码改变。 |
| 312 | And then this last like 20% or so is really getting something launch ready. | 然后,这持续了20%左右 真正得到的东西 发射准备。 |
| 313 | And this is where a lot of my human like effort comes in. | 我的许多人类都在这里努力 |
| 314 | And I do a lot of refactoring here and kind of like cleaning up of the code base. | 我在这里做了很多重构工作 就像清理了密码基础 |
| 315 | Right. | 对 |
| 316 | So I actually have a bunch of agents before I do any launch. | 所以,实际上我有一堆特工 在我做任何发射前。 |
| 317 | I like audit the entire code that it was written. | 我喜欢审计整个代码 这是写。 |
| 318 | And then I think about it from high level. | 然后从高处想. |
| 319 | And I think about like important things like performance, a bug security, you | 我想到一些重要的事情 比如表演 窃听器安全 你 |
| 320 | know, and then whether the feature actually works to spec and that I'm really | 知道,然后该功能是否真的 工作到Spec 而我真的 |
| 321 | like detailing the animations or anything like that until this last 20% actually | 就像详细描述动画之类的东西 直到最后20% |
| 322 | takes as long as the first 80%, but it's actually the thing that is the most | 需要的时间与前80%一样长, 但实际上这是最 |
| 323 | important and in my opinion, you're able to move so quickly in the beginning, but | 在我看来,你一开始能这么快地行动,但是... |
| 324 | this last 20% still requires a lot of like, like human taste factor. | 这最后的20%仍然需要很多类似的东西 比如人类的品味因素 |
| 325 | So you still need to look at it. | 所以你还是需要看看它。 |
| 326 | And this is where my code kind of becomes a lot more clean and production ready. | 这就是我的代码 变得更干净 生产就绪。 |
| 327 | Now, finally, when you're ready to launch the feature, I highly encourage | 现在,最后,当你准备好 推出这个功能,我大力鼓励 |
| 328 | you to try to run experiments. | 你尝试运行实验。 |
| 329 | So you could like validate that the code is actually working. | 所以你可以验证代码是否有效。 |
| 330 | Now, if you have a small user group, then you can't really run a sizable experiment. | 现在,如果你有一个小用户组, 那么,你就不能真正运行一个巨大的实验。 |
| 331 | You don't have statistical like power to even like run a legitimate AB testing, | 你连做一个合法的AB测试的能力都没有 |
| 332 | but I still recommend running AB tests or doing like Canary deployments, because | 但我还是建议进行AB测试 或者像加那利部署一样 |
| 333 | what that helps you is if you trickle your traffic for your new feature through | 如果你把交通引向新的特色 那对你有什么帮助? |
| 334 | like future gating, then you're able to very quickly see bugs or crashes or | 就像未来玩游戏,你就能很快看到虫子或坠落 |
| 335 | alerts that fire. | 警告火势 |
| 336 | And that's the whole point. | 这才是重点 |
| 337 | You want to anchor always on safety when you're using agents to code because | 你想在使用特工进行密码时 总是锁定安全 |
| 338 | physically you won't be able to physically read everything in detail. | 身体上,你无法 身体上阅读所有细节。 |
| 339 | It's just impossible now. | 现在不可能了 |
| 340 | So the idea of high level is you want to create like an agent to safeguard | 所以,高水平的想法是,你想创造 像代理来保障 |
| 341 | and like an agent to garden where you have a lot of tests, you have a lot of | 就像一个经纪人到花园 在那里你有很多测试,你有很多 |
| 342 | validation and you have a lot of agents doing a lot of work to make sure your | 验证,你有很多代理 做很多工作确保你的 |
| 343 | code is good. | 密码很好 |
| 344 | But at the same time, you want to anchor on safety and make sure you can take | 但与此同时,你却想 锁定安全,确保你可以采取 |
| 345 | back bad decisions with gating. | 背负着恶毒的决定 |
| 346 | So do I review code? | 那我该审查一下密码吗? |
| 347 | I think the simple answer is yes, but it really depends and it's a gradient. | 我认为简单的答案是肯定的, 但是它真的取决于它是一个梯度。 |
| 348 | But in my opinion, the models are getting better and better. | 但在我看来,模型越来越好。 |
| 349 | So you will probably review less code, but you should really anchor on | 所以,你可能会审查更少的代码, 但你真的应该坚持 |
| 350 | validation, agentic validation. | 审定,代理审定. |
| 351 | And then the agent should like have a lot of validation and proof and | 然后代理应该有很多 验证和证明, |
| 352 | evidence of the proof, like whether it's video recording or logs or like just | 证据,比如是录像还是日志 |
| 353 | screenshots, whatever it is. | 截图,不管是什么 |
| 354 | And then you gate and then you like start trusting the agents more. | 然后,你门,然后你喜欢开始信任 特工。 |
| 355 | And as long as you have like controls to take things back with gating, then | 只要你喜欢控制器 将东西拿回来 与吉丁,那么 |
| 356 | it should be safe to go. | 它应该是安全的离开。 |
| 357 | So yeah, I hope you guys enjoyed this video on agentic code reviewing and | 所以,我希望你们喜欢这视频 关于代理代码审查 |
| 358 | like my thoughts on code reviewing. | 喜欢我的想法 代码审查。 |
| 359 | The thing is this topic keeps changing for me right now. | 问题是这个话题现在一直在改变 |
| 360 | I'm comfortable with the skimming of some code depending on like where it is | 我对暗号的微调很满意 视其位置而定 |
| 361 | in the like tree concept that I talked about, but maybe after another few | 在像树的概念,我谈到, 但也许再过几个 |
| 362 | generations of the model, I might say, you know what, you don't need to read | 一代又一代的模特,我可以说, 你知道吗,你不需要阅读 |
| 363 | any of the code, so who knows? | 任何代码, 那么谁知道? |
| 364 | But right now I think you still need to like read some of the code and have | 但现在我觉得你还是需要 读一些代码,并且有 |
| 365 | like a fine tuned opinion of it. | 像一个很好的调制 的意见它。 |
| 366 | Now, one last thing that I forgot to mention is that if you understand your | 现在,我忘了提的最后一件事是 如果你理解你的 |
| 367 | codebase, it's actually easier to review the code because you can very quickly | 代码库,实际上比较容易审查代码 因为你可以非常快 |
| 368 | spot what's touching like the dangerous zones of your code base and what's like | 注意你暗号底部的危险地带 以及是什么样子 |
| 369 | really simple and leaf notes, right? | 非常简单和叶子笔记,对不对? |
| 370 | So yeah, that wraps up this video. | 所以,这是结束这个视频。 |
| 371 | I hope you guys enjoyed it. | 我希望你们喜欢它。 |
| 372 | I do a ton of these videos. | 我做了一吨这些视频。 |
| 373 | I did a video on like codex and clock code, which I think will be very | 我做了一个视频 像代码和时钟代码, 我认为这将是非常 |
| 374 | relevant for this video. | 与此视频相关。 |
| 375 | So feel free to check that out, but until I see you on the next one, bye. | 随便你看看,但下次见,再见 |
该视频共有字幕 375 条。解锁更多字幕为会员功能,请移动到 价格
