I was doing loop engineering before it had a name. Actually, I wanna talk with you about what loop engineering is and how you can actually make it practically useful for yourself. - So loops are sort of like as big as the step from source code to agents was, loops are the step from agents to the next thing. It's just as important and as big a step. And I think we're starting to get to the point in the industry where like a bigger and bigger percentage of the code is like expressed as loops and a bigger percentage of the work. And so for me personally, maybe at this point, like 30% of my code is written by loops on an average day. - This is better with Kent where we learn durable skills so that you can ship excellent software. And I'm excited to talk with you about what in the world loop engineering is. And no, I don't actually use the slash goal or slash loop skill or whatever. I actually came to loop engineering as a kind of natural thing. And I wanna take you through some of that natural process so that you have an idea of how you can fit it in to the processes that you already have. So first let's talk about what the loop actually is. So the idea is that you've got this trigger, some kind of trigger here that starts everything out. That could be a prompt, it could be an event, it could be some sort of state of a system, whatever. And then you end up with some sort of stop condition. So this is the part where the human does need to get in the loop and we're not going to get to a point anytime soon I think, where you can just say agent go make me a million dollars and let it do all of that on its own where there's no stop condition needed. I do think that the human does still need to be in the loop. And then you've got the actual loop here that kind of sits between these two things to actually perform useful work. And so inside of here you've got your act phase and then you have your observe phase. And so the point of the agentic loop is just to make it so that the agent can do things in more than one turn. Years and years ago it was just like, okay, send a message to the LLM and it will come back with a response and then you send another message, you come back. And then over time we started adding tools and so, okay, now the agent can actually perform some sort of action. So it's a trigger and then an action, then it comes back out. And then over time we were able to make it start looping on itself. And so all of the agents now could do multiple turns. You say, do this thing for me. It will perform some sort of MCP call or a CLI or an edit or whatever and it will kind of loop itself. And so the objective here is to just tighten that loop or really ensure that that loop is complete so that the agent can do more work for you before you get to the stop condition. That's all that the agentic loop is. And so loop engineering is just making it so that this loop can be as wide as possible to cover as much as you possibly need it to cover. And we have done a lot of things over the last several years to make it so that the agent can do more and more for you. And we're just now starting to get to the point where this trigger can be more than just a prompt from us but it can be a response to some event that's going on in the world. And we'll talk about that. So if you remember, like you probably experienced a year, maybe more ago, where you would actually use some of the ideas of TDD or at least generating a test first and then having the agent work on something to complete that test. That is a form of the agentic loop for expanding that agentic loop and letting it do more and more for you. And then we actually got even more of that when we got things like browser mode or even before browser mode came to cursor, we had the Playwright MCP where the agent could check its own work if you're building a web app, for example. And this was actually something I gave in my talk earlier this year, how I build web applications in 2026. You can check that out on my website. But the cool thing about this is that you have it all integrated into a singular experience where the agent can be controlling the browser and that goes back into the loop. And so it can check its own work and do more useful things. So this widening of the agentic loop is something that we've been doing for quite some time. And then a real unlock happened for me earlier this year when cursor added the whole environment for its cloud agents. So like in January, I started playing around with this. And now I use this all the time, especially for any visual thing. So the agents is actually able to have a full-on desktop experience where you can even like take over even though it's up in the cloud. And this has an entire environment. You can log into your application and save that environment. And every time a new cloud agent shows up, it will be logged in and continue from there. So it's really efficient. And I love it. I use it all of the time. It's a really awesome feature that helps to expand that agentic loop so that the agent can do more. And then when I'm reviewing stuff, I can be a lot more efficient with my time as well 'cause I can look at the experience and be like, okay, I see what this integrations page looks like. I can see there's, oh, maybe there's a little bug right there or whatever. I can have it fix that. And so by expanding that agentic loop, it not only helps the agent to check its own work, but it also helps me to check the agent's work and provide more feedback. So again, giving me back a lot of my time where I can use some of the judgment and the product decisions that I'm making as a product engineer. So this is really exciting. And then a little bit later on, I started using Cursor Cloud Agents in earnest just all of the time. And in the pull request, I realized that you could actually talk to Cursor right in the pull request. So I'd say, hey, the playwright test is failing in CI, please fix that. And then eventually I realized, you know what? I can just ask it to check CI because it can go look at CI by itself. And so I just say like, stuff is failing in CI, go fix it. And be a lot more open ended with my feedback because the agent was that much, like so much more capable. And then we take this a little bit further and I realized, you know what? It's kind of annoying for me to have to ask the agent to continuously check the feedback. And so eventually I decided and said like, okay, there's more feedback, more feedback. And then, you know what? Just continue on loop. Just repeat until all the valid feedback has been addressed. And so that gave me this really awesome experience that I have now where it will make a commit and then the AI feedback, whether that be CodeRabbit or BugBot will show up. The agent will then look at that feedback, address anything that's valid and then it will make another commit and it just keeps on going like this. So by the time it gets to me, I am looking at a pull request that is really solid. It's gone through all of these pieces of review with these increasingly capable AI review tools. And that has been a real unlock for me. Such so much that I actually do this all the time now. And I just have this in my clipboard to say, hey, wait for CI and then address any failures in CI and address any valid feedback from the AI reviewer bots. If there are no failures or anything, then break out of the loop. Otherwise, push your changes and then repeat. And this has worked out so well. And in fact, now I even add a little bit more to that to say, hey, when it's all looking good, then use Codey to send me a message on Discord. Codey is my personal assistant that has an MCP server that's installed. And it'll send me a message on Discord when it's done. So I don't even have to sit here babysitting this and waiting for it and like checking in on it. It will proactively reach out to me and bring me back into the loop, which is just like fabulous. I love this and I use this all the time. Hundreds of, I've got hundreds of instances of pasting this exact text in a cloud agent. At this point, I should probably just make it a skill or a slash command or something like that. But really the core of this is having some sort of loop so that I can get myself out of the loop and then come back in when it's necessary for me to come in. And now at this point, the PR feedback becomes the input and that's what keeps the loop going. And that's loop engineering. Like you are no longer the one prompting the agent, the agent is prompting it or another agent is so that you can be off doing something else useful. And with all of that, the stop condition is actually still very relevant and valuable. You do need to make sure that you have some boundaries. And if you recall my pocket OS story from a few videos ago, where somebody had a key on their computer that allowed the agent to do much more than they probably should have, this is not a great thing. So you do have to be mindful and careful about what your agents are able to do. And this is one of the reasons why I love cursor cloud agents so much because it gives an isolated environment every single time, which I think is really useful. Another thing that has really made this loop engineering quite possible is earlier this year, cursor came out with automations. And like to be clear, this is not a cursor ad or anything like that. This is not sponsored by cursor. I just personally use cursor, but I'm confident that codecs and quad code and all of these, like they have these capabilities of automations. But in the cursor case, I've got several automations here that act as a trigger for triggering a loop. So one case is like if prod deploys fail, like the CI job fails, then it automatically triggers a cursor cloud agent to figure out what's going on and make a pull request. So by the time I discovered that the prod CI is failing, I already have a pull request open to fix it. And I also noticed that agents like to treat your docs as like a change log. So they'll say like, it used to be this way and now it's this way. And so every night I have an agent that checks, hey, were there any changes in the last 24 hours? If there were, let's do a sweep over the docs to make sure that they don't have any of that temporal language or that negative language. Like we don't do it this way anymore. Don't do it that way. And I like to describe the system as it is today. And then testing as well, agents like to have a lot of regression tests. Like if you say, hey, we're not doing this anymore. We're removing that feature. They will add tests to make sure that that feature doesn't exist anymore, which is useful as part of the agentic loop to make sure that it's like verifying that its work is good. And so I don't want it to not do that, but I don't want to hang on to this old baggage of verifying a feature doesn't exist anymore. When like it, there's no way that it's going to exist. It was that code was deleted. And so having this agentic loop that is triggered without me just means that I wake up every morning with a pull request that has already done something that I find to be really useful. Now I've got to mention really quickly that this can be very expensive. So you need to make sure that the things that you're using this loop engineering for are actually worth the amount of money that they're costing you. So you really, you're trading compute for attention and that actually is a really valuable thing if the compute is doing something valuable. You wind up accomplishing a lot more. But again, that only matters if the things that you're doing are worth the amount that it's costing you. So if you're on a $20 a month plan, you're going to use up your usage very fast between Cloud machines and browser checks and CI review bots and retries and all of that stuff. It all adds up and it's going to be expensive. So you want to make sure that you're using loop engineering judiciously to avoid a very expensive surprise bill. So with this, I just want to leave you with your homework now. And that is, I want you to create one useful automation. So pick your preferred agent and automate one loop you already repeat by hand. Similar to how I was constantly telling cursor, hey, like go fix this. Now CI is broken, CI is broken, CI is broken. Like see if you can figure out a way to make the agent do that automatically so you don't have to bother doing that in the future. And with that, I hope you have a really good time with this. This has been Better with Kent, where we get better together by learning durable skills to make you a better product engineer and build better user experiences for your users. Good agents make code cheaper to generate and good loops make work cheaper to verify. That is hopefully what you've taken away from this. And I would like to invite you to please like, comment, subscribe, and share. And I would really love your feedback on this video and all the other videos and the videos I'm gonna do in the future. I invite you to give me ideas, whatever. Let's put it all in the comments. What are you doing with loop engineering? Are you using loop engineering? Or do you think it's just the next big fad thing that isn't all that useful? I think personally that this is a stepping stone to what we're going to get to. And the coding agents that we're using right now will integrate this as a part of the way that they operate. But doing this today gets you just a little bit ahead of that. And whenever the agents improve, we can take advantage of that more quickly. So with that, I'm gonna say goodbye. Thank you so much for watching Better with Kents. And thank you for getting better with me.