An AI harness is a structured set of files, rules, skills, workflows, and project context that surrounds an AI coding agent.
Instead of repeating the same instructions in every prompt, the harness gives the agent a consistent way of working across tasks and sessions.
And that's the key idea:
Prompting tells the agent what to do. A harness tells it how to work.
If you've spent any time pairing with an AI coding agent, you've probably seen the same problems:
So you keep writing prompts like:
"Remember to use Policies for authorization."
"Run the tests before you're done."
"Don't modify unrelated files."
"Follow our existing service architecture."
These instructions are valuable.
But they shouldn't have to live in your prompt every time.
They should live in the environment around the agent.
That's where an AI harness comes in.
An AI harness is the structured layer around an AI coding agent that defines:
The model provides the reasoning.
The harness provides the discipline.
Think about a simple task:
"Add an endpoint for publishing posts."
Without a harness, the process might look like:
Understand request
β
Explore project
β
Guess conventions
β
Implement
β
Run some tests
β
"Done"
With a harness:
Identify task
β
Load relevant rules
β
Load project context
β
Select required skills
β
Follow workflow
β
Implement smallest change
β
Validate
β
Test
β
Review
β
Verify requirement
β
Done
The difference isn't necessarily a smarter model.
It's a more reliable operating environment.
A prompt is ideal for task-specific intent.
A harness is ideal for persistent engineering knowledge.
| Plain Prompt | AI Harness |
|---|---|
| Instructions rewritten when needed | Instructions persist in the project |
| Consistency depends on the prompt | Same rules across sessions |
| Project knowledge gets repeated | Project knowledge is stored |
| Rules and context are often mixed | Responsibilities are separated |
| Human decides when it's "done" | Definition of Done can be explicit |
| Safety depends heavily on instructions | Approval gates can be defined |
| Harder to reuse | Structure can be reused across projects |
For example, instead of writing this every time:
"Use Form Requests for validation, Policies for authorization, feature tests for endpoints, don't touch unrelated files, and run
php artisan test
."
You can store those decisions once.
Then your actual prompt can remain simple:
"Add an instant-publish button to the post editor."
The harness supplies the engineering context.
A practical harness can look like this:
ai-harness/
βββ AGENTS.md # Entry point / index
βββ agents/ # WHO acts
βββ skills/ # HOW to handle a concern
βββ rules/ # WHAT must always be true
βββ workflows/ # IN WHAT ORDER to work
βββ context/ # WHAT is true about this project
βββ adapters/ # Tool-specific integration
These components have different responsibilities.
Defines roles and authority.
agents/
βββ developer.md
βββ reviewer.md
βββ debugger.md
For example, a Developer may implement changes while a Reviewer focuses on inspecting them.
Not every project needs multiple agents. Start with one if that's enough.
Reusable engineering knowledge.
skills/
βββ testing-strategy.md
βββ api-design.md
βββ database-design.md
βββ code-review.md
A testing skill can explain how the project approaches tests, factories, edge cases, and assertions.
Rules are constraints.
rules/
βββ core-rules.md
βββ approval-gates.md
βββ definition-of-done.md
Examples:
Do not modify unrelated files.
Do not bypass authorization.
Do not introduce unnecessary dependencies.
Do not declare a task complete without validation.
Destructive operations require human approval.
A workflow defines the sequence for a type of task.
For example:
workflows/
βββ feature-development.md
βββ bug-fix.md
βββ release.md
A feature workflow could be:
Understand
β
Inspect
β
Plan
β
Implement
β
Test
β
Review
β
Verify
Context contains project-specific facts.
context/
βββ project.md
βββ architecture.md
βββ domain.md
βββ conventions.md
For example:
project.md
β Laravel 11
β PHP 8.3
β MySQL
β Redis
architecture.md
β Form Requests
β Policies
β Services
β Feature Tests
This is the part that changes most from project to project.
One instruction can actually contain four different concepts.
Take:
"Always run tests before finishing."
It can become:
php artisan test
.This separation is important.
It prevents one giant instruction file from becoming the place where everything lives.
Imagine a Laravel CMS with:
The repository could look like:
laravel-cms/
βββ AGENTS.md
βββ ai-harness/
β βββ AGENTS.md
β βββ agents/
β βββ skills/
β βββ rules/
β β βββ core-rules.md
β β βββ approval-gates.md
β β βββ definition-of-done.md
β βββ workflows/
β βββ context/
β β βββ project.md
β β βββ architecture.md
β β βββ domain.md
β β βββ conventions.md
β βββ adapters/
βββ app/
βββ database/
βββ tests/
βββ ...
Now imagine the task is:
"Add an instant-publish button for a post from the admin panel."
The harness can guide the agent through:
Task arrives
β
Identify task type
β
Feature Development workflow
β
Load core Rules
β
Load relevant Context
β
Select required Skills
β
Check Approval Gates
β
Implement smallest possible change
β
Run validation
β
Run tests
β
Review changes
β
Verify original requirement
β
Done
Notice that the agent doesn't necessarily need every project document.
A good harness can instruct it to load only the context relevant to the task.
For this feature, that might mean:
project.md β
architecture.md β
domain.md β
conventions.md β
payments.md β
The exact behavior depends on the coding tool, but the harness should make the intended boundaries explicit.
One of the biggest benefits of a harness is defining what "done" actually means.
Creating the button isn't enough.
The agent should verify:
β Button exists
β Correct users can access it
β Authorization is enforced
β Post becomes published
β Invalid states are handled
β Relevant tests pass
β No unrelated files were changed
β Original requirement is satisfied
That's what a:
rules/definition-of-done.md
can establish.
The goal is simple:
"Code exists" β "Task is complete."
Some operations are routine.
Others are risky.
Imagine the agent receives:
"Delete this category and all its posts."
That's potentially destructive.
The harness can define an approval gate:
Potentially destructive operation
β
Explain impact
β
Stop
β
Request human approval
β
Continue only after approval
This is an important distinction:
A good agent shouldn't only know how to continue. It should also know when to stop.
Whether a particular tool can technically enforce every gate depends on the tool, but the policy itself belongs in the harness.
The harness should remain tool-agnostic.
Your engineering rules shouldn't need to change because you switched from Codex to Cursor.
Only the entry point changes.
Conceptually:
Shared AI Harness
β
ββββββββββββ΄βββββββββββ
β β
Codex Cursor
β β
AGENTS.md .cursor/rules/
For Codex, keep the repository-level AGENTS.md
thin:
## Laravel CMS β Agent Entry Point
Before performing engineering work in this repository,
read and follow `ai-harness/AGENTS.md`.
The harness defines the project's:
- Agents
- Skills
- Rules
- Workflows
- Context
Do not duplicate the harness content here.
For Cursor, use its project rules under:
.cursor/
βββ rules/
βββ harness.mdc
That rule can simply point the agent toward the shared harness.
The principle is:
One source of truth. Thin tool adapters.
Don't copy your entire engineering system into both AGENTS.md
and Cursor rules.
When you're unsure where an instruction belongs, ask:
| Question | Put it in |
|---|---|
| "This must always be true." | rules/ |
| "This is how we do this." | skills/ |
| "These steps must happen in this order." | workflows/ |
| "This is true about this project." | context/ |
| "This role has specific authority." | agents/ |
| "This is how Cursor/Codex connects." | |
adapters/ / entry point |
This simple distinction prevents the harness from becoming another giant instruction dump.
You don't need a huge framework on day one.
A useful starting point could be:
ai-harness/
βββ AGENTS.md
βββ rules/
β βββ core-rules.md
β βββ definition-of-done.md
βββ workflows/
β βββ feature-development.md
β βββ bug-fix.md
βββ skills/
β βββ testing-strategy.md
βββ context/
βββ project.md
βββ architecture.md
Then grow it when you notice repetition.
If you keep explaining the same thing to the agent, that's a signal that the knowledge probably belongs in the harness.
An AI harness isn't just a bigger prompt.
It's a structured engineering environment that gives an AI coding agent:
The goal isn't to make the model smarter.
It's to make the model more predictable and reliable inside your project.
The strongest principle is:
Don't put more instructions in the prompt. Put persistent engineering knowledge in the environment around the agent.
Prompting tells the agent what you want.
Harness engineering tells it how to work.
And that's the real shift:
From prompting an AI to engineering the environment in which the AI works.