← all writing
2026-06-18 · 4 min read

Loop engineering: the 5 pieces that make an AI agent work while you sleep

The five building blocks — automations, worktrees, skills, sub-agents, and memory — that turn a one-off prompt into a system that runs itself.

You are still typing prompts. The real shift in 2026 is building the system that prompts the agent for you.

The reel engine referenced throughout this piece is the social scraper & reply system. The build lives there.

Loop engineering is the next step after prompt engineering and context engineering. Prompt engineering is writing one good instruction. Context engineering is giving the model the right information around it. Loop engineering wraps both inside a system that runs on its own: it picks up work, does it, checks the result, and goes again until the goal is actually met.

You stop being the person who prompts the agent. You become the person who designs the loop that prompts it.

Here are the 5 pieces every working loop needs, each with a real example from how I run my own content agents.

1. Automations

What it is: the trigger that starts the loop without you sitting there. A schedule, a timer, or an event like a new commit or a new message. Why it matters: if you have to press go, it is not a loop, it is a tool. Automations are what let work happen while you are asleep or filming. My example: my reel engine pulls fresh Instagram numbers on a schedule every single day. I never open it and click fetch. By the time I look, the dashboard is already updated.

2. Worktrees

What it is: a separate copy of your project for each agent to work in, so they never overwrite each other or your real files. Why it matters: a loop that runs while you are not watching can also break things while you are not watching. Worktrees give it a safe sandbox, so an unattended run cannot wreck your actual work. My example: when I run agents in parallel, each one works in its own isolated copy of the project. One agent drafting a reel cannot step on another agent editing something else.

3. Skills

What it is: your knowledge written down in a form the agent reads every time, so it stops guessing. Think playbooks, rules, and rubrics it has to follow. Why it matters: without this, the agent reinvents your standards on every run and the output drifts. A skill makes the agent do it your way by default. My example: my /reel skill carries my voice rules, my scoring rubric, and my reel formulas. So the agent does not improvise a random reel. It builds one to the exact bar I set once.

4. Sub-agents

What it is: splitting the work across agents with different jobs, especially one that makes and a separate one that checks. Why it matters: the same agent that wrote something is the worst judge of it. A separate checker is the cheapest way to raise quality without you reviewing every line. My example: in /reel one agent writes the script, a second agent tries to tear it apart against the rubric, and a third picks the strongest hook. The draft only survives if it gets past the critic. I am not the first set of eyes anymore, the loop is.

5. Memory

What it is: an external file or board the agent reads before it starts, because it remembers nothing between runs on its own. Why it matters: the model forgets everything when a session ends. Memory is the thread that holds a multi-session loop together, so run fifty knows what run one learned. My example: every session my agent reads a memory file before it does anything. That file is the reason it writes in my voice and follows my rules, instead of sounding like a generic AI every time.

A project you can build with this

Here is one loop that uses all five pieces, simple enough to be your first real one: a daily idea scout.

Every morning it wakes up on its own, reads a short note on what your audience cares about, scouts a few sources, and drafts five content ideas. A second agent scores them against your rules and keeps only the best two. It remembers every idea it has already pitched you, so it never repeats. By the time you open your laptop, two fresh ideas are waiting.

Where each piece shows up:

  • Automations: it runs every morning on a schedule, you never start it.
  • Skills: a short file telling it your niche, your audience, and what a good idea looks like, so it stops suggesting generic junk.
  • Sub-agents: one agent scouts and drafts, a second one scores and trims to the best two.
  • Memory: a running list of every idea it has already sent you, so today's are always new.
  • Worktrees: when you grow it to also draft the posts, each draft runs in its own copy, so a bad run never touches your real files.

This is close to what actually feeds my reels. Start with just the morning trigger and one memory file, then add the rest as you start to trust it.

Your first loop

You do not need all five on day one. Start with the smallest real loop you can:

  1. Pick one boring task you repeat every week.
  2. Write down what done looks like for it, in one sentence. That is your skill.
  3. Give the agent a memory file with your rules and your voice.
  4. Run it once by hand and fix what it gets wrong.
  5. Only then automate it on a schedule and let it run without you.

The goal is not to automate everything at once. It is to stop being the one who presses go.

Go deeper