{"id":276,"date":"2026-11-23T16:20:10","date_gmt":"2026-11-23T21:20:10","guid":{"rendered":"https:\/\/blog.alangaelrojas.com\/?p=276"},"modified":"2026-11-23T16:20:11","modified_gmt":"2026-11-23T21:20:11","slug":"harness-engineering","status":"publish","type":"post","link":"https:\/\/blog.alangaelrojas.com\/index.php\/2026\/11\/23\/harness-engineering\/","title":{"rendered":"Harness Engineering: This is how I use it in 2026"},"content":{"rendered":"\n<p>If you use a coding agent every day, you have probably noticed that the same model performs very differently from one project to another. The difference is rarely the model. It is what surrounds it: the instructions it reads, the tools it can use, the controls that constrain it, and the feedback it gets after each change.<\/p>\n\n\n\n<p>That whole setup has a name: the <strong>harness<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/blog.alangaelrojas.com\/wp-content\/uploads\/2026\/11\/f29b6334-1089-4a74-9bba-5d7f8ad96df6-1024x576.png\" alt=\"\" class=\"wp-image-277\" srcset=\"https:\/\/blog.alangaelrojas.com\/wp-content\/uploads\/2026\/11\/f29b6334-1089-4a74-9bba-5d7f8ad96df6-1024x576.png 1024w, https:\/\/blog.alangaelrojas.com\/wp-content\/uploads\/2026\/11\/f29b6334-1089-4a74-9bba-5d7f8ad96df6-300x169.png 300w, https:\/\/blog.alangaelrojas.com\/wp-content\/uploads\/2026\/11\/f29b6334-1089-4a74-9bba-5d7f8ad96df6-768x432.png 768w, https:\/\/blog.alangaelrojas.com\/wp-content\/uploads\/2026\/11\/f29b6334-1089-4a74-9bba-5d7f8ad96df6-1536x864.png 1536w, https:\/\/blog.alangaelrojas.com\/wp-content\/uploads\/2026\/11\/f29b6334-1089-4a74-9bba-5d7f8ad96df6.png 1672w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Agent = model + harness<\/h2>\n\n\n\n<p>The formula that keeps coming up in recent writing is simple: <strong>Agent = Model + Harness<\/strong>. The harness is everything that isn&#8217;t the model. It includes the loop that executes actions, the tools the agent calls, context management, safety controls, subagent orchestration, and the extension points where you configure behavior.<\/p>\n\n\n\n<p>The term is used loosely, so it helps to draw some boundaries:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>It is not a framework.<\/strong> A framework such as LangChain is a library you import to build an agent. A harness is the environment you work inside, already built. Some vendors, LangChain included, now call their agent layer a harness, which blurs the line.<\/li>\n\n\n\n<li><strong>It is not a scaffold.<\/strong> A scaffold is the structural code, such as the loop and the tool registry. A harness is the product that embeds it, like Claude Code with its terminal UI, permissions, and plugin ecosystem.<\/li>\n\n\n\n<li><strong>It is not an evaluation harness.<\/strong> When someone mentions the &#8220;SWE-bench harness&#8221;, they mean the tooling that applies a model&#8217;s proposed patches and runs the repository&#8217;s tests on them. It does not wrap the agent. An agent harness does the opposite: it wraps the model so that it can act.<\/li>\n<\/ul>\n\n\n\n<p>In this article I treat tools as part of the harness, because they are the arms the agent acts with and the harness decides how they are used. A Berkeley lecture on software harness design separates them as their own layer (model, harness, tools, environment). Both readings are valid, but pick one and stick with it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">From prompt engineering to harness engineering<\/h2>\n\n\n\n<p>The Berkeley lecture on software harness design frames three levels of work, which are often confused:<\/p>\n\n\n<figure class=\"wp-block-table\">\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Discipline<\/th><th>Question it answers<\/th><\/tr><\/thead><tbody><tr><td>Prompt engineering<\/td><td>How do I phrase the instruction?<\/td><\/tr><tr><td>Context engineering<\/td><td>What enters the agent&#8217;s working window?<\/td><\/tr><tr><td>Harness engineering<\/td><td>What runtime governs how it acts and how it checks its work?<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>When an agent fails because it loses state, does not check its own work, or acts unsafely, the bottleneck is usually the runtime around it, not the wording of the prompt. That is the core idea of this article: <strong>designing the harness is an engineering task<\/strong>, with the same demands as any other system: clear inputs, explicit controls, and measurable feedback.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Guides: what steers the agent before it acts<\/h2>\n\n\n\n<p>A useful way to organize the harness, following Birgitta B\u00f6ckeler&#8217;s article on harness engineering on martinfowler.com, is to separate <strong>guides<\/strong> from <strong>sensors<\/strong>. Guides are <em>feedforward<\/em> controls: they anticipate the agent&#8217;s behavior and steer it before it acts. Sensors are <em>feedback<\/em> controls: they observe the result and allow correction.<\/p>\n\n\n\n<p>Guides are the files the agent reads when a session starts:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>CLAUDE.md<\/code> and <code>AGENTS.md<\/code>.<\/strong> Persistent project instructions: test commands, conventions, and where things live. Claude Code reads <code>CLAUDE.md<\/code> at the start of every session and falls back to <code>AGENTS.md<\/code> when there is no <code>CLAUDE.md<\/code>. Devin reads both <code>AGENTS.md<\/code> and <code>CLAUDE.md<\/code> by default.<\/li>\n\n\n\n<li><strong>Skills.<\/strong> Procedures the agent loads only when they are relevant, instead of keeping them in context all the time.<\/li>\n\n\n\n<li><strong><code>DESIGN.md<\/code>.<\/strong> The same role as <code>AGENTS.md<\/code>, but for visual decisions: palette, typography, spacing, and components. Google Labs publishes an open, alpha-stage format spec with a token schema and a linter. Shopify&#8217;s version is free-form Markdown. Either way, the file records each project&#8217;s own design decisions.<\/li>\n<\/ul>\n\n\n\n<p>A minimal <code>CLAUDE.md<\/code> looks like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># CLAUDE.md\n\n## Commands\n- Tests: `npm test`. Run them before marking a task as done.\n- Lint: `npm run lint`.\n\n## Conventions\n- API handlers live in `src\/api\/handlers\/`.\n- Don't add dependencies without asking.<\/code><\/pre>\n\n\n\n<p>Claude Code&#8217;s documentation recommends concrete, verifiable instructions and keeping the file under about 200 lines. &#8220;Format the code properly&#8221; does not help much. &#8220;Use 2-space indentation&#8221; does.<\/p>\n\n\n\n<p>Skills use the same base <code>SKILL.md<\/code> format in both tools, although each one adds its own frontmatter fields. Here is a Devin example, with its tools pre-approved:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>---\nname: review\ndescription: Review changes before committing\nallowed-tools:\n  - read\n  - grep\n  - glob\n  - exec\n---\n\nReview the current diff (`git diff --staged`) and look for logic errors,\nmissing error handling, and security issues.<\/code><\/pre>\n\n\n\n<p>Skills cost little while they are unused. That is why Devin&#8217;s guidance is to keep rules short and move procedures into skills.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><\/blockquote>\n\n\n\n<p>Sensors observe what the agent did. This is where tests, linters, type checks, and <strong>hooks<\/strong> come in.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Sensors: what checks the agent after it acts<\/h2>\n\n\n\n<p>One distinction changes how you should design the harness: instructions in <code>CLAUDE.md<\/code> are context, not enforced configuration. Claude Code&#8217;s documentation says so explicitly. To block an action without relying on the model&#8217;s decision, use a hook.<\/p>\n\n\n\n<p>The examples in this section are adapted from the official Claude Code and Devin CLI hook references. A Claude Code hook that blocks <code>rm -rf<\/code> is configured in <code>.claude\/settings.json<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n  \"hooks\": {\n    \"PreToolUse\": &#91;\n      {\n        \"matcher\": \"Bash\",\n        \"hooks\": &#91;\n          {\n            \"type\": \"command\",\n            \"command\": \"${CLAUDE_PROJECT_DIR}\/.claude\/hooks\/block-rm.sh\"\n          }\n        ]\n      }\n    ]\n  }\n}<\/code><\/pre>\n\n\n\n<p>The script reads the event from <code>stdin<\/code> and returns a decision as JSON (it requires <code>jq<\/code>):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\nCOMMAND=$(jq -r '.tool_input.command')\n\nif echo \"$COMMAND\" | grep -q 'rm -rf'; then\n  jq -n '{\n    hookSpecificOutput: {\n      hookEventName: \"PreToolUse\",\n      permissionDecision: \"deny\",\n      permissionDecisionReason: \"Destructive command blocked by hook\"\n    }\n  }'\nelse\n  exit 0\nfi<\/code><\/pre>\n\n\n\n<p>Devin uses an equivalent mechanism. In <code>.devin\/hooks.v1.json<\/code> you declare the event and the script, and exit code <code>2<\/code> blocks the action:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n  \"PreToolUse\": &#91;\n    {\n      \"matcher\": \"exec\",\n      \"hooks\": &#91;\n        { \"type\": \"command\", \"command\": \".\/scripts\/check-command.sh\" }\n      ]\n    }\n  ]\n}<\/code><\/pre>\n\n\n\n<p>Devin also reads hooks from <code>.claude\/settings.json<\/code>. That file nests hooks under a <code>\"hooks\"<\/code> key, so the <code>hooks.v1.json<\/code> file above is not interchangeable with it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Tools, permissions, and subagents<\/h2>\n\n\n\n<p>Tools are the actuators: shell, editor, search, and MCP servers. The harness decides what the agent can use and under which conditions. This is where permissions come in.<\/p>\n\n\n\n<p>In Devin, rules are evaluated in a fixed order: <code>deny<\/code> first, then <code>ask<\/code>, then <code>allow<\/code>, and if none applies, the agent asks. A <code>deny<\/code> always wins. Example in <code>.devin\/config.json<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n  \"permissions\": {\n    \"allow\": &#91;\"Exec(git status)\", \"Exec(npm run lint)\"],\n    \"deny\": &#91;\"Exec(sudo)\", \"Write(.env*)\"]\n  }\n}<\/code><\/pre>\n\n\n\n<p>Subagents are the third element. Each one has its own context window and returns only a summary to the main agent, so a long search does not fill the conversation. They also let you restrict tools and pick a cheaper model for read-only work.<\/p>\n\n\n\n<p>In Claude Code, subagents are Markdown files with frontmatter in <code>.claude\/agents\/<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>---\nname: code-improver\ndescription: Reviews files and suggests readability and performance improvements. Use after modifying code.\ntools: Read, Grep, Glob\nmodel: sonnet\n---\n\nYou are a code reviewer. Always cite the file and line for each finding.<\/code><\/pre>\n\n\n\n<p>Devin has the same model in <code>.devin\/agents\/<\/code>, with <code>allowed-tools<\/code> and <code>model<\/code>. Devin&#8217;s documentation marks custom subagents as experimental, so the format may change. Mind the cost: each subagent makes its own model calls. Devin&#8217;s documentation says they are billed separately, and Claude Code&#8217;s says their requests count toward the same usage limits. Either way, each subagent adds cost.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>A task where a subagent helped you, and one where it did not.<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">How it looks in Claude Code and Devin<\/h2>\n\n\n\n<p>The two tools have equivalent pieces:<\/p>\n\n\n<figure class=\"wp-block-table\"><\/figure>\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Layer<\/th><th>Claude Code<\/th><th>Devin CLI<\/th><\/tr><\/thead><tbody><tr><td>Always-on instructions<\/td><td><code>CLAUDE.md<\/code> or <code>AGENTS.md<\/code><\/td><td><code>AGENTS.md<\/code>, <code>CLAUDE.md<\/code><\/td><\/tr><tr><td>On-demand knowledge<\/td><td><code>.claude\/skills\/&lt;name&gt;\/SKILL.md<\/code><\/td><td><code>.devin\/skills\/&lt;name&gt;\/SKILL.md<\/code><\/td><\/tr><tr><td>Hooks<\/td><td><code>.claude\/settings.json<\/code><\/td><td><code>.devin\/hooks.v1.json<\/code><\/td><\/tr><tr><td>Subagents<\/td><td><code>.claude\/agents\/*.md<\/code><\/td><td><code>.devin\/agents\/*.md<\/code><\/td><\/tr><tr><td>Permissions<\/td><td>Permission settings<\/td><td><code>allow<\/code>, <code>deny<\/code>, and <code>ask<\/code> in <code>.devin\/config.json<\/code><\/td><\/tr><tr><td>External tools<\/td><td>MCP servers<\/td><td>MCP servers<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Devin reads <code>.claude\/<\/code> files, and Claude Code reads <code>AGENTS.md<\/code>. The formats are converging, which makes it easier to move a harness from one tool to another.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Principles for designing your harness<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Start from repeated failures.<\/strong> If you correct the same thing twice, it should become a rule, a skill, or a hook.<\/li>\n\n\n\n<li><strong>Separate advice from obligation.<\/strong> What must always happen goes in a hook. What is a preference goes in <code>CLAUDE.md<\/code> or <code>AGENTS.md<\/code>.<\/li>\n\n\n\n<li><strong>Keep rules short.<\/strong> Long procedures go into skills, and folder-specific instructions into path-scoped rules.<\/li>\n\n\n\n<li><strong>Give the agent feedback it can read.<\/strong> A concrete test command and a clear error message are worth more than a generic instruction like &#8220;check your work&#8221;.<\/li>\n\n\n\n<li><strong>Apply least privilege.<\/strong> Each subagent should have only the tools it needs.<\/li>\n\n\n\n<li><strong>Treat the harness as code.<\/strong> Version it, review it, and audit it from time to time. Claude Code includes <code>\/doctor prompt-audit<\/code> to find outdated or conflicting instructions.<\/li>\n<\/ul>\n\n\n\n<p>When an agent fails, before you rewrite the prompt, ask what its environment is missing: a rule it does not have, a check it does not run, or a permission that is closed for no good reason.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Useful links<\/h2>\n\n\n\n<p>Claude Hooks: <a href=\"https:\/\/code.claude.com\/docs\/es\/hooks\" target=\"_blank\" rel=\"noopener\" title=\"\">https:\/\/code.claude.com\/docs\/es\/hooks<\/a><br>Claude: Harness by design: <a href=\"https:\/\/www.anthropic.com\/research\/harness-design-long-running-apps\">https:\/\/www.anthropic.com\/research\/harness-design-long-running-apps<\/a><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Agent = model + harness. What a harness is, how AGENTS.md, skills, hooks and permissions fit together, with examples from Claude Code and Devin.<\/p>\n","protected":false},"author":2,"featured_media":274,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[71],"tags":[29],"class_list":["post-276","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai","tag-programming"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/blog.alangaelrojas.com\/index.php\/wp-json\/wp\/v2\/posts\/276","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.alangaelrojas.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.alangaelrojas.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.alangaelrojas.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.alangaelrojas.com\/index.php\/wp-json\/wp\/v2\/comments?post=276"}],"version-history":[{"count":1,"href":"https:\/\/blog.alangaelrojas.com\/index.php\/wp-json\/wp\/v2\/posts\/276\/revisions"}],"predecessor-version":[{"id":278,"href":"https:\/\/blog.alangaelrojas.com\/index.php\/wp-json\/wp\/v2\/posts\/276\/revisions\/278"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.alangaelrojas.com\/index.php\/wp-json\/wp\/v2\/media\/274"}],"wp:attachment":[{"href":"https:\/\/blog.alangaelrojas.com\/index.php\/wp-json\/wp\/v2\/media?parent=276"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.alangaelrojas.com\/index.php\/wp-json\/wp\/v2\/categories?post=276"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.alangaelrojas.com\/index.php\/wp-json\/wp\/v2\/tags?post=276"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}