What a harness is and how to build one with Claude Agent SDK
- Host
- Claire Vo
- Date
TLDR
A harness is custom code wrapped around an AI agent to constrain it to a specific workflow with deterministic steps, opinionated tools, and repeatable outcomes. The host builds a Sentry bug-debugging harness for ChatPRD using the Claude Agent SDK, an Ink terminal UI, and custom adapters for Sentry, Linear, GitHub, and Vercel to enforce permissions, gather evidence, triage root causes, and generate structured artifacts without human prompting. The process reveals that general-purpose coding agents like Claude Code or Codex are insufficient when you need to micromanage a specific job, encode tool policies, or guarantee follow-up actions, and that building one requires explicitly forcing the AI model to sit inside scaffolding rather than letting it generate purely deterministic scripts.
Key takeaways
A harness is just code around an AI agent, not necessarily AI itself, that supplies specific context, actions, and outcomes to make the agent effective at one job. The host defines a harness as code that may or may not contain AI, whose sole purpose is to improve the agent for a specific use case. It combines deterministic and nondeterministic steps into a repeatable workflow such as debugging, incident management, or research, rather than leaving the agent to infer intent from an open-ended prompt.
Build a harness when a workflow repeats, requires specific setup, and demands consistent follow-up actions that general-purpose agents cannot guarantee. The host chose Sentry debugging because it involves a standard process, custom internal context, and mandatory outcomes like Linear tickets and team docs. General-purpose tools like Claude Code force the user to repeatedly explain intent and babysit follow-ups, whereas a harness encodes the job once and executes it the same way every time.
Opinionated adapters beat generic MCP access because they constrain what data the agent sees and how it uses external tools. Instead of letting the agent wander through Sentry traces via a generic MCP, the host built a Sentry adapter that pulls only the fields relevant to bug triage. Similar custom integrations for Linear, GitHub, and Vercel replace open-ended tool use with precise API calls tailored to the debugging workflow, reducing noise and preventing off-task exploration.
Tool policies and permission flags let you encode safety and scope boundaries that prompt engineering cannot reliably enforce. The harness supports flags like investigate-only, which prevents the agent from modifying source code, and requires explicit approval for actions like messaging customers. These hardcoded constraints live in the harness logic, not in a prompt that the model might ignore or forget across a long context window.
Custom prompts hardcoded into the harness workflow replace system prompts and skills that might be invoked inconsistently. Rather than relying on Claude Code's generic persona or copy-pasting instructions, the host embeds ChatPRD-specific prompts at exact steps in the harness, telling the model what artifacts to treat as source of truth and what output format to return. This guarantees the model receives the right context at the right time without depending on the agent to recall or retrieve a skill.
The harness architecture separates the human interface, the agent core, and the tool layer while maintaining an artifact store for stateful memory. The front end is an Ink-based terminal UI, but could be a web app or CLI. The core runs on the Claude Agent SDK with Sonnet 4.6, while opinionated adapters connect to external APIs. Crucially, the harness writes evidence, logs, and reports to a local artifact store that future agent runs can read, creating a persistent source of truth across investigations.
Current AI coding agents must be explicitly forced to embed AI calls inside deterministic scaffolding when building a harness. The host used GPT-5.5 and Claude Opus to generate the harness code, but both models initially resisted embedding AI calls and instead produced fully deterministic scripts. Success only came after very specific prompting about workflow steps, tool boundaries, and where custom prompts belong, suggesting that today's coding agents default to traditional automation unless pushed to orchestrate other agents.
The highest leverage comes from giving an orchestrator agent a portfolio of single-purpose harnesses instead of using open-ended chat for every task. The host notes that while the TUI is designed for humans, the long-term value is in letting a general-purpose agent invoke specialized harnesses for specific jobs. This shifts work from hoping a general model does good work in an open chat to constraining sub-agents within structured scaffolding that guarantees process, artifacts, and outcomes.
Insights and implications
Any repeatable business workflow sustained by checklist discipline or tribal knowledge is harness-shaped, not just software engineering tasks. The host lists nontechnical use cases like research consolidation and support escalations alongside coding and incident management. This reframes the harness from a developer tool into general business infrastructure: if a job requires the same context, actions, and artifacts every time, wrapping an agent in hardcoded process logic turns ephemeral human habit into scalable, auditable automation.
The industry pejorative "wrapper" describes exactly the same architecture as a harness, which rehabilitates the economic value of opinionated AI products. The host explicitly hypothesizes that wrappers are just harnesses. If the defining feature of a harness is prescriptive code that constrains an agent to a specific workflow with custom tool adapters and guaranteed artifacts, then so-called wrappers are not thin, commoditized layers around a model. They are the actual mechanism by which generic AI becomes reliable enough to replace structured human labor.