Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Covers the agent harness (loop, tools, memory, retries, budgets) and context as a token budget: compaction, retrieval, cache ordering.
95% 95%0 ptsof test cases passed
Passed 21 of 22 test cases with the skill, and 21 of 22 without it.
3 of 3 safety checks passed
Prompt engineering optimizes the string you send the model. Harness and context engineering optimize everything else: the loop that decides when to call the model, the tools it can reach, what gets retrieved and assembled into the window, what gets remembered across turns, how failures retry, and what budgets cap it. In production agent systems the harness — not the prompt — is the dominant lever on reliability. A perfect prompt inside a loop with no retry, no tool error-handling, no token budget, and a stale context will fail; a mediocre prompt inside a disciplined harness ships.
The mental model that organizes this whole skill: the context window is the model's working memory, and it is a managed budget, not a bucket you fill. Every token you spend on a tool definition is a token you can't spend on retrieved evidence or conversation history. Context engineering is the discipline of allocating that scarce budget — assembling, ordering, compacting, and evicting — so the right tokens are present at the right position for each model call. This skill is the playbook for both the harness around the model and the context inside it.
Modern sources to anchor on: Anthropic's Building effective agents (2024) and Effective context engineering for AI agents (2025); the "lost in the middle" finding (Liu et al., TACL 2024); Chroma's Context Rot report (2025); the ReAct loop (Yao et al., 2022); and the prompt-caching mechanics from the major providers (cross-reference the prompt-caching skill for the cache-specific depth).
| Prompt engineering | Harness engineering | |
|---|---|---|
| Unit of work | The text in one request | The code around every request |
| Optimizes | Phrasing, examples, format, role | Loop, tools, retries, budgets, memory, routing |
| Failure it fixes | "model misunderstood the instruction" | "model called a broken tool and the loop hung" |
| Tested by | eval on prompt variants | integration tests on the control loop + failure injection |
| Owns reliability | a little | most of it |
The harness is the deterministic scaffolding: a state machine that calls the model, parses its output, dispatches tools, handles tool errors, enforces a step/token/wall-clock budget, decides when to stop, and assembles the next context. The prompt is one input to one node of that machine.
Why the harness dominates reliability. LLM calls are non-deterministic, occasionally malformed, and bounded by a finite window. The harness is where you make a non-deterministic component behave like a dependable one: validate every output, retry transient failures, degrade gracefully when a tool 500s, cap runaway loops, and keep the window coherent over long horizons. None of that lives in the prompt. The single highest-leverage realization for a team that has been "prompt-tuning" for weeks: most of your remaining failures are harness bugs wearing a prompt costume.
loop(goal, ctx):
for step in range(MAX_STEPS):
if budget.exceeded(): return halt("budget")
msg = model(assemble_context(ctx)) # one call
plan = parse_or_repair(msg) # validate; reprompt on schema miss
if plan.is_final: return plan.answer
obs = dispatch_tool(plan.tool, plan.args) # adapter: timeout, retry, error-as-value
ctx = update_context(ctx, plan, obs) # append + compact if near budget
return halt("max_steps")
Everything interesting in production is in parse_or_repair, dispatch_tool, assemble_context, update_context, and budget — not in model.
Skills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.