What is harness engineering?
2025 was the foundational year for AI agents. In 2026, the engineering focus is shifting from AI models themselves to their surrounding operational control environments.
Harness engineering is the discipline of designing "everything outside the AI agent model"—constraints, tool connectivity, feedback loops, and verification systems. Deriving its name from equestrian harnesses, it refers to environmental design that steers powerful yet unpredictable AI agent outputs in intended directions.
Martin Fowler codified this concept in 2026, proposing two primary axes of control:
- Guides (proactive controls): Steer agent behavior using documentation, architectural guidelines, AGENTS.md, and similar mechanisms
- Sensors (reactive controls): Verify and adjust agent outputs using linters, automated tests, and AI reviews
The 4-layer harness architecture
A practical harness consists of the following four layers.
Constraint layer
Explicitly defines what the agent is permitted to do and what it is forbidden from doing.
<!-- AGENTS.md の例 -->
## 禁止事項
- 本番データベースへの直接クエリ
- force push
- .env ファイルの読み取り・変更
## 権限
- テストの実行: 許可
- ファイルの作成・編集: 許可(src/ 配下のみ)
Information layer
Provides structured context that the agent needs to know. This includes files such as CLAUDE.md, AGENTS.md, and system design specifications.
Verification layer
Mechanisms that automatically validate agent outputs, including linting, type-checking, test suites, and automated AI code reviews.
Recovery layer
Designs rollbacks, retry logic, and iteration caps when agents encounter failures. Preventing infinite loops is especially critical.
Harness implementation in Claude Code
Claude Code has evolved into a platform providing six extension points tailored for harness engineering.
| Extension point | Role | Layer |
|---|---|---|
| Hooks | Event-driven shell commands (PreToolUse / PostToolUse) | Verification |
| Skills | Defining reusable workflows in Markdown | Information |
| Plugins | Bundled distribution of commands, skills, hooks, and MCP servers | All layers |
| Sub-agents | Parallel collaborative execution across multiple sessions | Constraints / Information |
| CLAUDE.md | Defining project-specific constraints and conventions | Constraints / Information |
| MCP | Protocols for connecting with external services | Information |
Hooks in practice
{
"hooks": {
"PreToolUse": [
{
"matcher": "Write",
"command": "python3 scripts/security_check.py"
}
],
"PostToolUse": [
{
"matcher": "Write",
"command": "npx eslint --fix $FILE"
}
]
}
}
Running security audits before file writes and automatically executing linters afterward ensures agent output quality without manual human intervention.
Pinterest's MCP adoption: Saving 7,000 hours per month
Pinterest serves as a high-profile case study for large-scale production adoption of harness engineering.
Architecture
- Operating domain-specific MCP servers (integrating infrastructure tools such as Presto, Spark, and Airflow)
- Centralizing server discovery and authorization validation through a unified registry
- Ensuring security via dual authentication with JWT and mesh IDs
Results
- Approximately 66,000 invocations per month
- 844 active users (representing roughly 30% of their engineering organization)
- Estimated 7,000 hours of development time saved monthly
Architectural considerations
High-risk operations (such as database writes and production environment modifications) require human-in-the-loop approval. Safety is maintained through workflows where the agent proposes changes and a human confirms them.
Ralph Loop: An autonomous agent iteration pattern
The Ralph Loop (formally the Ralph Wiggum Loop) is a technique that runs AI agents iteratively and autonomously within a bash loop.
# 基本形
while :; do
cat PROMPT.md | claude-code
# テストが通ったら終了
npm test && break
done
While it relies on a simple approach of repeating execution until mechanical completion criteria (such as passing tests) are met, running it without an appropriate harness (constraint, verification, and recovery layers) risks uncontrolled execution.
Keys to success
- Keep scope small: Assign one loop per individual issue
- Evaluate completion using test-driven criteria: Determine success via passing test suites rather than subjective completion checks
- Limit maximum iterations: Put guardrails in place to prevent infinite loops
- Manage context freshness: Mitigate stale context degradation during extended loop executions
Getting started: A 3-step adoption guide
Step 1: Author CLAUDE.md / AGENTS.md
Place constraint and information definition files in your project root. Starting with explicit "prohibited actions" and "coding standards" is highly effective.
Step 2: Automate verification with Hooks
Inject automated checks before and after agent operations using PreToolUse and PostToolUse hooks. Existing tools for security audits, linting, and type-checking can be integrated directly.
Step 3: Connect external tooling via MCP
Expose workplace tools—such as databases, GitHub, and Slack—to agents via MCP servers. Restrict permissions explicitly through server manifests.
Conclusion
Harness engineering is the discipline answering the pivotal question of 2026: "How do we steer and control AI agents?"
- Model performance is already sufficiently advanced; the real bottleneck lies in the design of the surrounding control environment
- Design your harness around a 4-layer architecture (constraints, information, verification, recovery)
- Start small: Roll out iteratively in sequence: CLAUDE.md creation → Hooks → MCP
- Focus human oversight on requirements definition and approvals
As AI agents evolve from "handy utilities" into full-fledged "team members," harness engineering has become an indispensable competency for every engineering team.
For teams embarking on business AI adoption, we recommend establishing a foundation by first reading our ChatGPT Business Adoption Guide.









