In the previous article, we explored how Claude Code’s UltraCode feature can flexibly dispatch multiple Agents based on task size. When there are multiple Agents working in a team at the same time, the biggest fear is that they will interfere with each other or make changes that are not in line with expectations. At this time,Harnessplayed a vital role.
What is Harness?
Harness (test framework/control script) can be imagined as a "work isolation area" and "acceptance standard" tailored for each Agent. It defines:
This Agent'senterWhat is it?
it is allowed to modifyworking boundariesWhere?
itsoutputWhat verifications must be passed?
Core Principles for Writing Harness
To write a perfect and safe harness, follow these three principles:
Clear input and output specifications (I/O Specification):
Each dispatched Agent should receive only the context it needs, not the entire project history. This not only reduces token consumption, but also prevents the model from hallucinations.Strict State Isolation:
When multiple Agents work in parallel, you must ensure that they operate in independent workspaces (Workspaces) or Git branches. This avoids code conflicts and dirty states.Unattended Automated Validation:
Harness must include a set of validation scripts (such as unit tests or linters). Before the Agent submits its work results, the system will automatically execute this set of scripts; if the verification fails, the Agent must repair itself until it passes.
Implementation example
The following is a simplified Harness setup example where we define a variable named frontend-expert Agent, and configure dedicated testing and independent branches for it:
// harness.config.ts
export const uiComponentHarness = {
name: "UI Component Generation",
agents: ["frontend-expert"],
workspace: "branch:feat-new-ui",
context: ["src/components/ui/button.tsx", "src/styles/globals.css"],
validation: "npm run test:ui && npm run lint",
retryLimit: 3
};Conclusion
Well-written Harness can not only greatly improve the accuracy of AI Agent's work, but is also an indispensable part of moving towards a "fully automated development pipeline". Through a complete isolation and verification mechanism, even if we face complex projects, we can safely hand over the task to the AI team!