AI Writings · Agentic

Loop Engineering.

The next step beyond vibe coding: instead of hand-prompting one step at a time, you design the entire loop so the agent plans, edits code, verifies results and self-corrects until it's done. Prompt engineering handles the input; loop engineering handles the whole process around the model.

Phases 05 Tool groups 04 Read ~6 min

Loop engineering is the practice of designing, running and improving feedback loops so an agent plans, changes code, observes results and adjusts until the work is done.

The power isn't in any single step — it's in closing the loop. A failing test isn't just an error; it's new context. A type error isn't just a blocker; it's a signal that an assumption was wrong.

01 · The core loop

Five phases.

A basic loop has five steps — run over and over until the result is accepted or you hit a blocker that needs a human.

1Intent

Intent

Define the desired outcome very concretely.

"Improve the dashboard" is vague. "Cut load time by deferring non-critical charts while keeping the filters intact" is what creates a tight feedback loop.

2Context

Context

Load enough code, docs, logs and constraints.

Too little and the agent guesses; too much and the model gets noisy. Context should explain how the project works, not just fill the context window.

3Action

Action

Edit files, run commands, call tools, write a plan.

Small, reversible diffs are easy to verify and easy to fix. Large rewrites make it hard to tell which assumption broke when something fails.

4Observation

Observation

Collect real evidence.

Test results, compiler errors, runtime output, diffs, review comments. If the agent can't "see" the result, it's running blind.

5Adjustment

Adjustment

Update the plan, then loop again.

Based on what it observed, the agent changes its approach and keeps going — until validation passes or it hits a blocker that needs a human's permission, data or decision.

02 · The toolkit

Four tool groups.

The picture as of mid-2026. Many teams run 2–3 tools at once — say Cursor for the daily flow, Claude Code for complex refactors that need deep codebase understanding.

ACLI

Terminal-first

Claude Code, Codex, Gemini CLI, Aider.

Agent-first: you hand over a goal, the agent plans, edits many files, runs tests and reports back. Direct access to the filesystem, shell and git. You review afterward.

BIDE

AI-native IDE

Cursor, Windsurf, Antigravity, Zed.

IDE-first: you drive the editor and review each diff inline. Cursor has the most polished native parallel-agent experience and the largest community.

CSpec

Spec-driven

Kiro, Spec Kit, BMAD, OpenSpec.

The opposite of pure "vibe": define requirements, design and tasks in a structured spec, then the agent follows it. The spec is "Intent" written out explicitly.

DCloud

Cloud / async agents

Devin, OpenHands, Jules.

Run background tasks in a remote VM, then open a PR. Good for running in parallel without tying up your machine — you review via the pull request.

03 · Putting it into practice

Six steps.

From picking a task to packaging a reusable loop — the human keeps the judgment seat throughout.

1

Start with a narrow task

"Fix the failing tax-calculation test at checkout" beats "debug checkout." A narrow task tells the agent which files matter.

2

Write the Intent + constraints

State the user-visible behavior, the relevant file areas, what must not change, and the validation command that has to pass.

3

Load context before editing

Let the agent read the surrounding code, existing patterns, and the project's rule files (CLAUDE.md, .cursor/rules) so it respects your conventions.

4

Tell it how to self-verify

The step people skip. Give it a specific test command, endpoint or acceptance scenario — so the agent doesn't stop right after generating code without checking it.

5

Let it run tight loops

Small edit → run the targeted test/type check → read the output → fix → repeat. Favor reviewable changes.

6

Keep the human in the judgment seat

Automate evidence-gathering and mechanical fixes; keep product decisions, architecture and final review for people. When a process works well, package it into a standard pattern.

04 · Pitfalls

Four failure modes.

Each maps to a missing part of the loop. The common fix: a clear goal, small diffs, scope-limited tools, and manual approval for risky actions.

Thrashing

Endless edits that never converge — caused by a vague goal or diffs that are too large.

Overfitting to the test

Tests pass but miss the real requirement — the validation doesn't reflect the actual intent.

Context drift

The agent acts on stale assumptions and misses edits made by someone else.

Unsafe autonomy

Running destructive commands, overwriting files, or pushing unreviewed changes — you need permissions and stop rules.

05 · Business impact

Engineering shifts, business follows.

If the engineering layer gets this much cheaper and faster, how does the business layer move — who wins, who gets squeezed? Split it two ways: tech companies and non-tech businesses.

Side 01

Tech companies

  • Build faster, cheaper

    The barrier to shipping a product all but disappears — maybe those "$100 websites" ads weren't so far off after all.

  • Customers have more choices

    Hundreds of amateur devs appear overnight. Without a moat — proprietary data, high migration cost, network effects — customers will happily switch vendors.

  • The quality race gets exposed

    When anyone can ship something that works, the difference concentrates in refinement, reliability and experience — the hard-to-copy parts.

  • Value moves away from writing code

    Code becomes a commodity; distribution, brand, integration and support are what retain customers. Smaller teams, but more senior.

  • Tokens are the new marginal cost

    Software margins are no longer ~0. Whoever runs cheaper per outcome gets a durable pricing advantage.

Side 02

Non-tech businesses

  • More options, but plenty of junk

    More choice comes with a flood of low-quality products — you have to choose carefully whom to trust. Reputation, real case studies and warranties become the filter.

  • An automation arms race

    Businesses race to automate, faster and more aggressively. But whether it actually cuts cost / grows revenue has to be measured carefully — don't bolt on AI just for show.

  • The gap is in redesigning the process

    Bolting AI onto old processes creates little value. The winners redesign how they operate around AI, not whoever buys the most tools.

  • Data leaks & security surface

    The more agents touch your data, the bigger the leak and compliance risk. Risk governance becomes a competitive capability, not an overhead cost.

  • Phase 2 after mass adoption

    Once everyone can do it, the lower-token, cheaper, more efficient approach wins. The edge tilts toward whoever owns proprietary data and customer relationships.

Common thread

Both sides move the same direction: value leaves the act of creating the product (ever cheaper) and concentrates in judgment, distribution, trust and proprietary data — the things AI can't yet copy.

06 · Synthesis

Prompts handle the input; the loop handles the whole process.

Choose the feedback signal by task: test-driven for bug fixes, compiler-driven for migrations, review-driven when human comments are the observation source, runtime when you need logs and screenshots. The agent runs the loop fast; the human still owns product intent, risk tolerance and the final review.

"Don't prompt step by step — design the loop and let the agent run until validation passes."