The Four Step Process to Loop Engineer ANYTHING (+ Why Prompt Engineering Isn't Dead)

CChase AI
Computing/Software

Transcript

00:00:00The conversation around loop engineering has completely lost the plot.
00:00:04Every single YouTube video in XThread has the exact same take.
00:00:08Prompt engineering is dead, and you should be doing nothing else but loop engineering.
00:00:12But the problem is, this is not only completely wrong, it's utterly backwards.
00:00:17And that's because a loop at its core is still a prompt.
00:00:20It's just a prompt that we are repeating over and over again with some additional scaffolding.
00:00:25And loops, just like a prompt, are simply tools.
00:00:29Just because we discovered what a wrench is yesterday doesn't mean we throw out the screwdriver.
00:00:34Each one has their place, and it's on you to understand when they fit the job.
00:00:39So in this video, we're going to cut through the hype, and I'm actually going to explain
00:00:42what you need to know about loop engineering, when we should be using them,
00:00:46how to actually build them, and what use cases make sense.
00:00:49So let's begin by defining loop engineering.
00:00:52Loop engineering is the idea that I'm going to go to CloudCode, Codex,
00:00:55whatever agent decoder I'm using, and I'm going to give it some sort of task.
00:00:58And instead of just saying, here's the prompt, go do it, I'm going to set this up in a way
00:01:03that it is going to complete the task by looping, by iteratively, over and over again,
00:01:09trying to complete this task until it hits some sort of defined success criteria.
00:01:15I'm going to say, hey, this is how you know you've done it right.
00:01:18And loop engineering is all about setting up this loop in a way that makes it efficient and
00:01:24effective and that it makes sense.
00:01:25That's it.
00:01:26And at its core, what is it?
00:01:28It's prompts.
00:01:29It's prompts stacked on top of prompts that we do over and over and over again until we
00:01:33complete the task.
00:01:34So the idea that prompt engineering is dead is a total misnomer, because at its core,
00:01:39it's just a bunch of prompts stacked on top of one another.
00:01:41That's it.
00:01:42And the rest of this video is going to be about, hey, how do we actually set up a loop
00:01:47in a way that makes sense to complete these sort of tasks?
00:01:49And furthermore, what tasks actually make sense to be, you know, attacked with loops?
00:01:56Because they don't always need to be done that way, obviously.
00:02:00Which again, is another hit to this whole like prompt engineering is dead thing.
00:02:03This isn't a one size fit all tool.
00:02:04We don't need to create a loop for everything, but sometimes we do.
00:02:07So it's a good thing to know.
00:02:08Now, every loop has four phases.
00:02:09We have the trigger phase, execution phase, the verification phase, and then state before
00:02:14it loops over and does it again.
00:02:16Now, phase number one is the trigger, and that's pretty self-explanatory.
00:02:19How are we actually going to get this thing kicked off and started?
00:02:21We have a number of options.
00:02:22We could do things like schedule tasks or routines inside of clawed code.
00:02:26I can make it a cron job, a web hook, whatever.
00:02:28Doesn't really matter.
00:02:29You just need some way to actually get it started.
00:02:31Because again, we want this to be automatic, ideally.
00:02:35Phase number two is the execution phase.
00:02:37This is where AI is actually doing stuff for us, usually in some sort of coding manner.
00:02:41But either way, we probably want this to be some sort of skill.
00:02:45Because skills are perfect for telling clawed code to do a specific thing in a specific way
00:02:51to get a specific output.
00:02:53And the whole idea of the loop is we're going for a specific output, which leads us into phase
00:02:59number three, which is the goal, the verification.
00:03:02Really, this is all about success criteria.
00:03:08Success criteria.
00:03:09What do I mean by success criteria?
00:03:11How do we know we actually completed this?
00:03:14This is a serious question and one people talk to, but then they give you examples where
00:03:18it doesn't make any sense.
00:03:19Okay?
00:03:19So when we talk about success criteria, sometimes it can be very clear.
00:03:23The success criteria for something like, I don't know, a Python application, and the goal
00:03:30is to make it run faster is very obvious.
00:03:33Well, it's runtime.
00:03:34Okay?
00:03:34So we could have a loop that over and over again tries to reduce its runtime.
00:03:38That's a clear goal with objective success criteria.
00:03:43However, not everything is like that.
00:03:45What if we are doing some sort of loop that has to do with content creation or we're trying
00:03:49to create LinkedIn articles?
00:03:51Okay?
00:03:51Part of our loop is we want to consistently go out on the web, find things about AI, turn
00:03:57it into a LinkedIn article, and then over time with this loop, create better LinkedIn articles.
00:04:03Well, how do we create better LinkedIn articles?
00:04:07Do you know?
00:04:08What is success here?
00:04:09Is it engagement?
00:04:10Is engagement always perfectly tied to how quote unquote good an article is?
00:04:16You know, it's very fuzzy.
00:04:18So you could have a loop with sort of like fuzzy success criteria, but understand it reduces
00:04:24its effectiveness if that's the case.
00:04:25And we'll talk a little bit more about what we can do if we have sort of, again, fuzzy goals
00:04:31here that aren't like, oh, a number that's very clear and obvious that we need to improve
00:04:35upon.
00:04:36And then phase four, what do we got?
00:04:37We have state.
00:04:38It's the idea of output and memory because loop engineering, the real sell for loop engineering
00:04:45is that we can have it improve upon itself every single loop and over time, improve upon
00:04:51itself every single run.
00:04:53You know, think again to the Python idea.
00:04:57Okay, the Python idea where we want to reduce the runtime, right?
00:05:01We want to make it faster.
00:05:03Well, what good is the loop if every loop is sort of in a silo and it's just trying different
00:05:08things every time?
00:05:08No, it needs some sort of document or database that it can look at and see, oh, this was the
00:05:15previous runtime.
00:05:16Here's the things we tried to reduce the runtime.
00:05:19Here's what worked.
00:05:20Here's what didn't.
00:05:21Okay, now I know what I need to try.
00:05:23Should sound very reminiscent to RALF loops.
00:05:27You know, a lot of loop engineering kind of goes back on these RALF loop concepts.
00:05:33So we need in any proper loop some way to figure out what our output was.
00:05:38We need to be able to record it.
00:05:40And for follow-on loops, this execution phase needs to be able to look and see, oh, here's
00:05:46what I did.
00:05:47Here's what worked.
00:05:48Here's what didn't, right?
00:05:49That's the only way you're going to make it self-improving in any sense of the word.
00:05:52And the last portion, which really isn't a phase, but it's part of it, is like, what
00:05:56is the stop criteria?
00:05:58When do we stop looping anymore?
00:06:01Now, in some cases, it's like, okay, we hit the goal.
00:06:03It's verified.
00:06:04Boom, we're done.
00:06:05But do you want it to just keep running and running and running and running and running
00:06:08and running and running until that happens?
00:06:11Probably not because, you know, AI isn't free.
00:06:15So do we want to have some sort of like hard stop built in, whether that's, hey, we're not
00:06:18getting more progress.
00:06:19Like maybe the Python runtime just isn't going down enough.
00:06:24Or maybe we have a hard stop like, hey, we're going to do eight iterations, you know, and
00:06:28then we'll kind of call it, these are the kind of things you need to think about, right?
00:06:33And so while loop engineering, like I said at the beginning, is relatively simple from
00:06:37a theoretical point of view, when we do get into the nitty gritty of like how we define
00:06:41the phases and engineer these loops themselves, there is some nuance and there is some questions
00:06:47you need to be able to answer.
00:06:48And that can be a lot to take on all at once.
00:06:51It can be kind of confusing.
00:06:52So if you get nothing else from this video, what I want you to think about really is the
00:06:57success criteria.
00:06:58And this will also play into the idea of does this task actually make sense to be part of
00:07:05a loop format?
00:07:07If the task you have is something that has very clear success criteria, especially if it's
00:07:14objective, like a number, then loops are great.
00:07:17Loop engineering is awesome.
00:07:18If that is not the case, if it's fuzzy, again, think of our LinkedIn article thing.
00:07:23Maybe, maybe it still makes sense.
00:07:26Maybe we need to have you more human in the loop at this part.
00:07:30Maybe there needs to be some sort of like hybrid approach, but that's just something you need
00:07:33to think of it going in because if you don't have a strong goal and you don't have clear
00:07:36success criteria, this is all pointless and you're just gonna be spinning your wheels and
00:07:39burning tokens.
00:07:40So just know that going in.
00:07:42If you get nothing else, success criteria, think about it.
00:07:46Now, before we dive into how you should go about setting up your own loops and your own personal
00:07:50loop engineering, a quick word from today's sponsor, me.
00:07:54So I just released my Claude code masterclass and it is the perfect place to go from zero to AI dev,
00:07:59especially if you don't come from a technical background.
00:08:02I update this every single week and it also includes a codex masterclass and an agentic
00:08:07OS masterclass.
00:08:09You can find it inside of chase AI plus there is a link to that in the pin comment.
00:08:13Now, real quickly, before we go into your own personal loop engineering sort of workflow,
00:08:17want to talk really quick about things like auto research and also forward slash goals,
00:08:21because you might've watched everything up until now and been like, well, why don't we
00:08:23just use something like Carpathy's auto research?
00:08:26Why don't we just use forward slash goals, which is a part of Claude code?
00:08:28Well, first of all, auto research is still great.
00:08:30A lot of what we talked about loop engineering is pretty much what something like auto research
00:08:35does automatically.
00:08:36The thing is though, when it comes to something like auto research, it explicitly needs that defined
00:08:41success criteria.
00:08:42Like we talked about, it cannot do fuzzy things.
00:08:46We can do loop engineering inside of Claude code with somewhat fuzzy success criteria.
00:08:50Not in the case with auto research.
00:08:52So auto research with that Python example, trying to make it faster.
00:08:55Perfect, perfect use case.
00:08:57But if that's not it, we're not talking about an objective, like to the number thing that
00:09:01we're trying to improve.
00:09:02You can't really deal with that with auto research.
00:09:04And when it comes to something like forward slash goal, forward slash goal is sort of loop
00:09:09engineering in a nutshell.
00:09:10It's you telling Claude code, I want to do this certain thing.
00:09:13And I want you to just iterate over and over until you reach a certain condition.
00:09:17The difference between forward slash goal and loop engineering at large is that forward slash
00:09:21goal, and this also applies to codex, is something in a single session, right?
00:09:26We're going to just complete this one thing and that's going to be it.
00:09:29Loop engineering is meant to have like an infinite horizon.
00:09:32It's almost like we're doing forward slash goal all the time.
00:09:36We're looping forward slash goal, right?
00:09:38There's a self-improvement aspect to it.
00:09:39Again, think of something like this LinkedIn article example.
00:09:42I cannot do a forward slash goal that says make me better LinkedIn articles for now and
00:09:47forever, right?
00:09:48It could try to make me one right now, again, in a silo a single time, but if this is something
00:09:54that I want to do every single week over and over, that's not what forward slash goal is
00:09:58for.
00:09:59Loop engineering is bigger picture, if that makes sense.
00:10:02And we'll talk about it a little bit more here.
00:10:04So let's now talk about what your journey should look like when it comes to loop engineering.
00:10:08How should you approach this?
00:10:10You have some sort of task in mind and you want to know, hey, how do I loop engineer this?
00:10:15Well, this is sort of like a hero's journey here you need to follow.
00:10:19And the first step in our journey is a purely manual process.
00:10:23So example, again, this LinkedIn article thing.
00:10:25I want to create LinkedIn articles.
00:10:27Well, what would you do?
00:10:28You would pull up cloud code and you would say research AI stuff and make a LinkedIn article
00:10:35for me.
00:10:37I'm not saying this as a joke.
00:10:39This literally has to be the first step.
00:10:40Why?
00:10:41Because we need to verify that what we're trying to do is even possible and AI can do it.
00:10:45Okay?
00:10:46So that's step one.
00:10:48We're actually making sure we can do this manually and we're being very, very hands-on.
00:10:52Once we've confirmed that we can actually do this and it's something we're going to want
00:10:55to improve upon in the future, well, we're going to codify it.
00:10:58So step two becomes turning it into a skill because nobody wants to sit there and say, hey,
00:11:04do all A, B, and C over and over again.
00:11:06I have a specific outcome I now have and I want to do it in a specific way.
00:11:10So we would turn this into a skill.
00:11:14That's step two.
00:11:15And again, this is where kind of a lot of people sit.
00:11:18Unfortunately, a lot of people really just sit on step one forever, which is manual.
00:11:21So we've validated the process.
00:11:23We've codified it into a skill.
00:11:25The next step is actually just to automate it, right?
00:11:28We just want to automate the skill because I'm so lazy.
00:11:30I don't even want to write forward slash LinkedIn article.
00:11:33I want to just do it on its own.
00:11:34Now, this is pretty easy to do in something like Cloud Code.
00:11:37We can go into routines.
00:11:39We can set up an automation called LinkedIn article.
00:11:42And in the instructions, we can just say, run the LinkedIn article skill, right?
00:11:48Run the description, run the skill.
00:11:51And hey, we're already going to figure out the trigger.
00:11:52We just schedule it however we want.
00:11:54We're going to do it daily at 9 a.m.
00:11:56And so before we even really got into the loop engineering part, we've sort of already figured
00:12:01out the trigger and kind of done part of the execution.
00:12:06So if we then want to go from this automated skill into a true, you know, loop engineered
00:12:11construct, well, what are we going to need to do now?
00:12:14Well, now we need to think about self-improvement.
00:12:17We need to think about success criteria.
00:12:19And we need to think about state, right?
00:12:22What is the definition of success?
00:12:24How are we going to record and therefore improve upon it?
00:12:27So when we're at step three, we're now thinking about this entire second half.
00:12:32And so moving up here, this skill is probably working, but we need to add some things to
00:12:37this skill before we move on to step four.
00:12:40And so what are we going to add?
00:12:42Well, we need to add the success stuff we talked about, right?
00:12:46And we also need to add some sort of like state logging.
00:12:53Again, state logging.
00:12:54What am I saying?
00:12:55Where is this information going?
00:12:57Sure, you posted to LinkedIn, but are you able to scrape the engagement statistics?
00:13:01Because let's say we say success is defined by engagement statistics.
00:13:05We'll just say likes.
00:13:06Well, we need some way to harvest those likes, see what the metrics are, and then we need to
00:13:11put them somewhere.
00:13:12And it is by that that we can then further improve upon this stuff and pull out, hey, here's
00:13:17what worked with this article.
00:13:18Here's what didn't.
00:13:19This hook was good.
00:13:20This hook wasn't bad.
00:13:20This CTA worked, et cetera, et cetera.
00:13:23So while before in the original step one, two, and three, we didn't have that, if we want
00:13:27to move on to step four, which is loop engineering, what do we need?
00:13:31We need these two things.
00:13:32And this applies to anything you do, right?
00:13:36And now comes the question at this point, well, do we even need step four?
00:13:40If you can define success in some way, even if it's sort of fuzzy like this, and you have
00:13:44a way to record the state, then you're going to be okay.
00:13:47Now, let's talk about the success criteria a little bit more, because I think there's sort
00:13:51of like five tiers of verification here.
00:13:54First three are kind of where we want to live.
00:13:56And this is like, hey, you have success criteria that's very clear, right?
00:14:00Ideally, it's deterministic.
00:14:01It's like a yes or no, like that's perfect.
00:14:04Or there's some sort of like rule or constraint, right?
00:14:06When we talked about the Python application running fast, well, that's sort of like a rule
00:14:10or constraint we're trying to improve upon.
00:14:12But if we don't have those, and we're kind of in like tier three through five, where again,
00:14:15it's fuzzy, this is where you need to start thinking, how do I judge the success?
00:14:20Now, if we have something like likes or engagement, that is a number, and that kind of puts us
00:14:24in number three, right?
00:14:26And if you're happy with that, you can continue to make this completely automatic.
00:14:29But if there's something that does require some nuance and judgment in terms of what is
00:14:33good, you need to have like kind of a discussion between you and yourself and probably cloud
00:14:38code of like, okay, are we going to have the large language model as the judge, right?
00:14:44If cloud code is the one who is writing the articles, do we want cloud code to judge the articles?
00:14:51The answer is probably not.
00:14:52You may want to create something in your loop where something like codex comes in.
00:14:56And takes a look at it.
00:14:57Like I have a whole video on things like this, where we use codex to sort of judge cloud
00:15:01codes outputs.
00:15:01Because remember, one of the issues with cloud code and really all AI systems is they tend
00:15:05to really like their own work.
00:15:07So anytime you're like, oh, I'm going to have the AI judge something in my loop.
00:15:11Be careful, especially if subjective.
00:15:14The other option you have is you bring in you into the loop.
00:15:18Now this makes it less autonomous.
00:15:19And this is where you begin to question, does this actually need to be a loop?
00:15:23But it might make sense.
00:15:24There are scenarios where we need some sort of human intervention.
00:15:28And this can be the most powerful, right?
00:15:31Especially in our example of like LinkedIn articles, like, was it good?
00:15:34Did the engagement make sense for the topic I spoke on?
00:15:37You know, you can have an article with tons of engagement and it can have nothing to do
00:15:40with the quality of the article.
00:15:41It was just the timing and the subject that worked well for you.
00:15:44And it's like, do we want to necessarily pull, you know, the information about how we wrote
00:15:49said article as like this gold standard for things going forward?
00:15:51Again, a lot of nuance.
00:15:53There's a lot of nuance.
00:15:54You know, these are the decisions you need to make.
00:15:56And this is what is going to define if your loop is engineered correctly or not.
00:16:00And there's no perfect answer here as well.
00:16:02This is all case by case.
00:16:03And it's something that's going to require experimentation on your part to figure out.
00:16:07But for our example, for now, we're going to say, okay, we're going with likes.
00:16:11That's good enough for us.
00:16:11If it has a lot of likes, we're saying that's a good article.
00:16:14And that's what we're going to base this all on.
00:16:15So when we look at our loop now, we have a trigger at 9 a.m., we have an execution via
00:16:20a skill, we've defined our goal as getting the most likes as possible.
00:16:27We're able to verify this with some sort of scraper, and we're able to put all this into
00:16:33some sort of database that records the article with the amount of likes.
00:16:40Now, this will then loop essentially every day at 9 a.m.
00:16:44Now, you might notice some issues here right away, because with this thing, this isn't going
00:16:49to just be one loop, is it?
00:16:52Because there's going to be a delay between, hey, when I write the article to where I get
00:16:58likes.
00:16:59So there's also going to be a delay for how well this actually works in reality.
00:17:02We're going to have to wait some time and build a database of actual data showing our articles
00:17:08and likes.
00:17:09Or this video, let's pretend we've sort of been running this for like a month, and we already
00:17:14have a treasure trove of like, here's articles I've written with the likes.
00:17:18So the idea would be, at this point, every morning at 9 a.m., we get the trigger, the skill
00:17:25executes, it looks up things for AI, and it begins to write the article.
00:17:30Now, what it's also going to bring in isn't just AI news, right?
00:17:35It's now going to look at that database of previous articles and previous likes and sort
00:17:40of just some analysis, like what's been trending lately?
00:17:43What did we try in terms of hooks?
00:17:45What was our CTA, et cetera, et cetera?
00:17:48It will then bring in that information into its execution, and that would be all baked into
00:17:52the skill.
00:17:53That's sort of the self-improvement part.
00:17:55From there, hey, it sees what it did.
00:17:59It records the likes.
00:18:01Boom, boom, boom, boom, boom.
00:18:02In reality, you would also have a second loop running outside that just like scrapes the likes
00:18:06every, you know, 24 hours and make sure it's updated.
00:18:11And you can see right away, this sort of fuzzy thing with the likes does increase the
00:18:15complexity of how we engineer our loops versus something as simple as like, hey, I want my
00:18:21Python app to be faster.
00:18:23Okay, well, this triggers, you know, every 10 minutes, it runs the app.
00:18:29We want it to be faster, so it checks the time.
00:18:33It has some sort of handoff doc that has the times with the code changes, right?
00:18:40We just have the diff there, and then it just keeps running over and over and over and over
00:18:45again, right?
00:18:46And it changes the code each time to see if it lowers the time and sees what diffs has worked.
00:18:51So all's that to say, if you have clear success criteria, loop engineering becomes much, much
00:18:56easier.
00:18:57And hopefully this thoroughly confused you at this point.
00:19:01But I thought it was good to kind of go through this sort of like LinkedIn chaos fuzzy thing
00:19:07because truth be told, for a lot of people who use cloud code and want to do these loops,
00:19:11they actually tend to be in this place more often than not in sort of this fuzzy area.
00:19:15Not everything is clearly defined as, you know, something you could throw into auto research.
00:19:20So that is loop engineering in a nutshell.
00:19:23We have a trigger.
00:19:24We're going to execute via skills.
00:19:26It's all about our goals and can we verify our success?
00:19:29And then we're logging everything all the time so that this becomes a self-improving loop.
00:19:34And ideally, at the execution phase with that skill, it needs to be looking at its previous
00:19:40state and figuring out, okay, what have we tried?
00:19:44What do we still need to try?
00:19:45What's worked?
00:19:46What hasn't?
00:19:47So that's where I'm going to leave you.
00:19:48As always, let me know what you thought of this video.
00:19:51I think it's a super interesting topic, but don't get lost and confused by everyone saying
00:19:55prompt engineering is dead.
00:19:56That is not the case.
00:19:58And make sure to check out Chase AI Plus if you want to get your hands on my Cloud Code
00:20:02Masterclass.
00:20:02But besides that, I'll see you around.

Key Takeaway

Loop engineering relies on prompts structured across four distinct phases—trigger, execution, verification, and state—to build self-improving workflows that require clear success criteria.

Highlights

  • Loop engineering consists of four phases: trigger, execution, verification, and state.

  • Prompt engineering remains foundational because loops are simply prompts stacked and repeated with scaffolding.

  • Auto-research requires objective numerical success criteria and cannot handle fuzzy goals.

  • Implementing loop engineering requires a four-step progression from manual execution to automated skills and self-improvement.

  • Verification tiers range from deterministic binary checks to subjective LLM judgment or human intervention.

Timeline

Defining Loop Engineering and Prompt Foundations

  • Loop engineering repeats prompts iteratively until reaching a defined success criteria.
  • Prompt engineering is not dead because loops are fundamentally prompts layered with additional scaffolding.
  • Loops serve as specialized tools rather than universal solutions for every development task.

Popular commentary incorrectly declares prompt engineering dead in favor of loop engineering. A loop functions merely as a prompt executed repeatedly with structural support. Each tool has specific applications, and developers must determine when loop structures fit the operational requirement.

The Four Phases of Every Loop

  • Phase one handles the trigger mechanism through cron jobs, webhooks, or scheduled routines.
  • Phase two utilizes skills during the execution phase to direct coding agents toward specific outputs.
  • Phase three establishes verification through objective or subjective success criteria.
  • Phase four maintains state using output logs and memory databases for self-improvement across runs.

Every loop operates through four distinct stages: trigger, execution, verification, and state management. The trigger initiates the process automatically. The execution phase performs the task, often via specialized skills. Verification measures the output against predefined goals, such as reducing application runtime. State tracking records previous runs, allowing subsequent iterations to analyze historical successes and failures.

Auto-Research, Slash Goals, and the Implementation Journey

  • Auto-research automates loops but strictly requires objective numerical success criteria.
  • Single-session slash goals operate within isolated runs, whereas loop engineering maintains an infinite horizon.
  • The implementation journey progresses from manual execution to codifying skills, automating routines, and adding self-improvement.

Auto-research automates optimization tasks like Python runtime reduction but fails with fuzzy metrics. Slash goals handle single sessions, whereas loop engineering pursues ongoing self-improvement. Adopting this methodology requires a four-step journey: executing tasks manually to validate feasibility, codifying the process into a skill, automating execution via routines, and finally adding state logging and verification.

Verification Tiers and Fuzzy Success Criteria

  • Verification spans five tiers ranging from deterministic binary checks to subjective human judgment.
  • Fuzzy goals like content engagement require careful handling to avoid flawed feedback loops.
  • Self-improving loops must ingest historical performance data during the execution phase.

Success criteria vary from deterministic rules to subjective evaluations. Using metrics like likes for content creation introduces complexity because engagement does not always reflect absolute quality. Systems relying on AI judges risk bias because models favor their own outputs, making human intervention or cross-agent validation necessary for subjective domains.

Community Posts

View all posts