Insights

Context vs Harness vs Loop Engineering

Three terms, three layers. Each one wraps the one before it.

Context engineering decides what a model sees. Harness engineering shapes the environment one agent works in, context included, plus its tools, checks, and sandbox. Loop engineering designs the system that runs those harnessed agents again and again: what triggers a run, what work it picks up, who checks the result, and when it stops. Each layer wraps the one before it, and an AI software factory is loops running at scale.

A ghost with a laptop and a context scroll, a wooden harness frame hung with tools, and a loop track circling both

The three terms arrived about a year apart, each when the previous one stopped explaining where the leverage was. Here is what each one means, where it came from, and which to work on first.

The three layers side by side#

Context engineeringHarness engineeringLoop engineering
Unit of workOne session or model callOne agentMany runs over time
Core questionWhat does the model need to see?What does the agent need to act and check its work?When does an agent run, on what, and who decides it's done?
Main leversInstructions, retrieved files, examples, history, tool resultsTools, tests, linters, sandboxes, setup scripts, permissionsTriggers, schedules, work queues, separate checkers, memory, budgets
Typical artifactsAGENTS.md, CLAUDE.md, skills, promptsCI checks, custom lint rules, MCP servers, worktrees and containers/loop, /goal, scheduled agents, automations, manager agents
Typical failureThe agent guesses because something was missingThe agent can't tell whether it succeededThe loop drifts or burns tokens while nobody watches
PopularizedJune 2025, Tobi Lütke and Andrej KarpathyFebruary 2026, OpenAI's Ryan LopopoloJune 2026, Boris Cherny's remark, named by Peter Steinberger and Addy Osmani

Context engineering: what the model sees#

The term caught on in June 2025, when Shopify CEO Tobi Lütke said he preferred it to "prompt engineering" because it describes "the art of providing all the context for the task to be plausibly solvable by the LLM." Andrej Karpathy agreed, calling it the art and science of filling the context window with just the right information for the next step (Simon Willison's write-up).

For a coding agent, context means the instruction files it reads on startup, the files it retrieves, examples of how your team does things, the conversation so far, and what its tools return. Most "the agent is dumb" moments are context failures: it didn't know the test command, the naming convention, or the one module nobody may touch. The cheapest fix in all of agentic coding is a line in AGENTS.md.

Harness engineering: what the agent can do and check#

Harness engineering widens the frame from what the model reads to everything it works inside. OpenAI's February 2026 post described a team that shipped roughly a million lines with no hand-written code by treating the model as fixed and improving the environment instead: documentation in the repository, architectural constraints enforced by tests, and background agents that open small cleanup pull requests every day.

Birgitta Böckeler's article on martinfowler.com gives the most useful model: Agent = Model + Harness. Your harness adds guides that make the right result likely (instructions, examples) and sensors that catch the wrong one (tests, linters, structural checks, review agents). She calls building a user harness a specific form of context engineering, which is why the two terms blur. Context is the part of the harness the model reads; the harness also includes the parts that act and verify. Our harness engineering guide goes layer by layer.

Loop engineering: what runs, when, and who checks it#

Loop engineering moves up from one agent to a running system. Boris Cherny, who leads Claude Code at Anthropic, said in June 2026 that he no longer prompts Claude directly because loops do it for him; within days the practice had a name. Addy Osmani's Loop Engineering describes the parts: automations on a schedule, worktrees so parallel agents don't collide, skills, connectors, subagents that separate the maker from the checker, and memory that lives outside any single conversation.

Both big coding agents now ship loop primitives. Claude Code has /loop for prompts on an interval and /goal for running until a separate model confirms a condition; Codex has Automations and its own /goal (comparison). Our loop engineering guide covers the anatomy of a loop and three loops worth copying.

How the layers nest#

A useful way to keep them apart is to ask what you would change to fix a recurring problem:

  • The agent didn't know your test command. Context: add it to AGENTS.md.
  • The agent said it was done, but the build was broken. Harness: give it a fast check it must run, and a sensor that fails loudly.
  • The agent fixed the bug on Tuesday and nobody noticed the regression on Thursday. Loop: a scheduled run that re-checks, remembers what it saw, and reports.
  • Fifty loops ship more diffs than your team can review. Factory: change the line, not one station. See what is an AI software factory?

Prompt engineering didn't die; it became the smallest of these layers. A clear task description still matters, but the instructions, checks, and loops around it now decide more of the outcome.

Which one to work on first#

In order:

  1. Context first. It's the cheapest and fixes the most. Write down build, test, and lint commands, conventions, and no-go zones.
  2. Harness second. Make the agent's own work checkable: fast tests, lint rules for repeated corrections, a setup script so every fresh worktree runs, and a review agent as a second sensor.
  3. Loops last. Automate only what the harness can verify. A loop on a weak harness repeats mistakes faster and charges you for each one.

All three are layers of the same practice: agentic engineering, building software by directing and reviewing agents with the discipline you'd bring to a team. Agentastic is built for the harness and loop layers when you run more than one agent: every task gets its own worktree or container, review passes run before you read a diff, and scheduled agents and Manager Agents keep loops going across Claude Code, Codex, and other agents.

Sources#

Frequently asked questions#

What is the difference between context engineering and harness engineering?#

Context engineering decides what the model sees in a session: instructions, files, examples, history, and tool results. Harness engineering is broader. It covers context plus the tools an agent can call, the tests and linters that check its work, its permissions, and the environment it runs in. Martin Fowler's article on the topic calls building a user harness a specific form of context engineering.

What is the difference between loop engineering and context engineering?#

Context engineering works inside one session. Loop engineering works across many: it decides when agents run, what work they pick up, how their results are checked by something other than themselves, what gets remembered between runs, and when to stop.

What is the difference between harness engineering and loop engineering?#

A harness is the environment one agent works in. A loop is the system that runs harnessed agents repeatedly, with triggers, a work queue, a separate checker, memory, and a budget. Addy Osmani describes loop engineering as sitting one floor above the harness.

Is prompt engineering dead?#

No, but it shrank. Writing a clear task is still part of context engineering, and every loop still sends prompts. What changed is where the leverage is: the instructions, checks, and loops around a prompt now decide more of the outcome than the wording of any one prompt.

Which should I learn first: context, harness, or loop engineering?#

In that order. Fix what the agent sees first because it is cheapest, then add the tests, linters, and setup scripts that let it check itself, and only then automate it with loops. A loop on top of a weak harness repeats mistakes faster.

How does agentic engineering relate to these terms?#

Agentic engineering is the umbrella: building software by directing and reviewing coding agents with the same discipline you would apply to a team. Context, harness, and loop engineering are the three layers of that practice, and an AI software factory is what you get when loops run at scale.

About the Author

Adel Ahmadyan

Builds Agentastic.dev, the native macOS multi-agent IDE.