Everyone talks about giving an AI agent a better prompt. After months of running autonomous agents on a production multi-tenant SaaS, I'm convinced the prompt is the least important layer. What actually determines whether an agent is safe to leave unsupervised is the harness around it — the deterministic machinery that decides what the agent is allowed to do, records what it did, and judges whether the result is real.
This post is a teardown of devin-harness, the open-source harness I extracted from that production work. It is not a prompt collection and it is not a wrapper. It is an operating system for agentic repos: lifecycle hooks, review gates, a dispatch contract, a skills library, and a written pattern corpus.
Most agent disasters are not crashes. A crash is loud and recoverable. The dangerous class is the gray failure: the session ends "successfully" while a queue silently stops draining, a deploy reports green while a migration never ran, an edit touches a secret file and nothing notices. A diff review cannot catch these, because the damage is not in the diff — it is in what the agent didn't do.
The design consequence is the core thesis of the harness:
A rule enforced at the tool-call boundary beats a rule the agent might remember from a prompt.
Every component below exists to move a class of failure from "the model might avoid it" to "the model cannot do it."
Modern agent harnesses expose lifecycle events — moments where the host can inject code around the agent's actions. devin-harness wires five of them:
| Hook | Event | What runs |
|---|---|---|
session-start.mjs | SessionStart | Dirty-tree detection, stale locks, open review obligations, incident index — the session begins already informed about repo state. |
agent-guard.mjs | PreToolUse | Exec guard: deterministic regex rules that block dangerous shell commands before they run. Sub-50ms, zero model calls. |
file-guard.mjs | PreToolUse (edit/write) | Blocks writes to secret files, migration files, and runtime-state files at the boundary. |
agent-ledger.mjs | PostToolUse | Appends every tool call — secrets redacted — to action-log.jsonl. The session becomes auditable as a trace, not just a diff. |
prompt-guard.mjs | UserPromptSubmit | Detects questions that require external knowledge and injects a mandatory source-verification instruction. |
claim-guard.mjs | Stop | If files changed but no test ran afterward, the session ends with a loud "unverified" advisory instead of a silent green. |
Two design choices matter here. First, the guards are deterministic: regex and path rules, not model judgments. They cost microseconds and cannot be persuaded. Second, they fail closed — a blocked command produces an error the agent must route around legitimately, not a warning it can ignore.
Prevention is only half the system. The other half is judgment — deciding whether what the agent produced is actually good. The gate stack runs in escalating cost order:
gate.mjs — deterministic suppression and secret scanning
across the diff. Free, instant, catches the mechanical failures.dep-audit.mjs — npm supply-chain audit on dependency
changes. Catches the "agent added a typosquatted package" failure class.jev-gate.mjs — a typed LLM judgment over the diff:
14 typed constraints, plan-drift aware, backed by a persistent state.json
so findings the author already resolved never re-block. This is the interesting piece:
the judge has memory, which turns review from a stateless opinion into a
tracked obligation.predeploy.example.mjs — the deploy-gate skeleton that
composes the above into a promotion check.The pattern worth stealing: cheap deterministic checks first, expensive model judgment last, and persistent state so judgment accumulates instead of repeating.
ops/dispatch/ contains devin-session.mjs and
dispatch-rules.md — a contract for delegating work to autonomous sessions.
This is where the harness stops being "guardrails for one agent" and becomes an
orchestration layer: rules for when a task is dispatchable, what context the child
session receives, and how results are verified before merging.
The repo ships eleven domain skills under .devin/skills/ — SEO, ads-ops,
copywriting, landing pages, CRO, ICP research, audience research, quality judging, and
verify-with-sources, which forces primary-source research before answering
external-knowledge questions. Skills are the harness's answer to "the agent doesn't know
my domain": packaged, versioned expertise the agent auto-invokes.
Alongside them sits docs/ — roughly thirty pattern documents covering
agent orchestration, agent memory, agent perception, context engineering, decision
models, observability, on-call playbooks, release engineering, security-and-CI,
testing strategy, OSS adoption, and harness-vs-labs comparisons. The skills teach the
agent how to do a task; the docs teach it how this organization thinks.
templates/ ships AGENTS.root.template.md,
AGENTS.subtree.template.md, an ADR template, and an incident template —
the organizational memory of how work gets specified, decided, and reviewed. Combined
with AGENTS.example.md (the multi-tenant data rules, gray-failure doctrine,
secret registry, deploy-gate rule), the harness encodes operating doctrine, not
just tooling.
Three properties make it hold up in production:
The repo is MIT-licensed and installs in one command:
node setup.mjs /path/to/your/repo. The bet I'm making is that the next
generation of engineering leverage doesn't come from better models alone — it comes
from better harnesses around them.