Skip to content
<Notes of dev/>

Harness engineering proves your AI works

13 min read

A glass test chamber holding a code block and a document card, wired to gauges and a goal checklist, printing a verified report

An eval harness scores AI output on faithfulness and relevance, flags stale context in CI, and replaces the feeling that your workflow is faster with numbers.

Part 6 of 6 in the "Context Engineering in 2026" series

TL;DR

Context engineering makes AI output better, but a feeling that it is better does not scale or pass an audit. Harness engineering adds an evaluation loop that scores the output, catches stale context, and runs in CI, so you can trust AI work because you measured it.

If you have followed this series, you have set up context seeds, extended them to your team, and picked a framework. Your AI writes better code and everything feels great.

But "it feels faster" is not a metric. Harness engineering replaces the feeling with a continuous integration (CI) pipeline that fails when your agent invents a function that does not exist, and a number that says whether your AI setup helps.

Three phases of AI-assisted work

The industry went through three phases in roughly 18 months.

Phase 1: vibe coding (early 2025). You ask an AI to build a landing page, it works, and you ship it. Nobody checks the output.

Phase 2: context engineering (mid 2025 to early 2026). The AI writes better code when you give it structured context: CLAUDE.md files, spec-driven development, team context systems. Quality improves a lot, but validation stays manual.

Phase 3: harness engineering (2026 onward). You can show that the output meets your standards, consistently, at scale. You stop saying "it seems better" and start saying "our evaluation suite verified 94.3% spec compliance before any human touched this pull request" (an illustrative number).

A progression from Vibe to Context to Harness, ending with code, context and a passing check
Three phases of AI-assisted work

What an eval harness is

An eval harness (evaluation harness) is a statistical validation loop that measures the quality of AI-generated output. It is not a test suite. A test is binary: pass or fail. A harness scores how good the output is on several axes at once.

The core metrics are these:

  • Faithfulness — Is the output grounded in the context you provided? If the AI calls processPayment(), does that function exist in your codebase?
  • Retrieval precision — Did the AI pull the right context, or drown in irrelevant information?
  • Relevance — Does the output answer the question that was asked?
  • Context utilization — How much of the injected context did the AI use? If you feed 10,000 tokens and it uses 2,000, the rest costs money and dilutes attention.

Use a stronger model as the judge

The LLM-as-judge pattern uses a stronger model to grade the output of your cheaper, specialized agents (LLM stands for large language model).

Say your workflow uses Sonnet (fast, affordable) for code generation. Your harness uses Opus to read the spec, the code, and the project context, then score faithfulness, relevance, and standards compliance from 0 to 3.

A judge is still a model, so calibrate it. Anthropic's guide on evals for AI agents says model-based graders need frequent calibration against expert human judgment. Its advice: give the judge a structured rubric, grade one dimension per call, let it answer "Unknown" when the evidence is thin, and read many of its transcripts yourself.

For simpler checks you do not need a judge: does the code compile, do the referenced functions exist? Anthropic's guide calls these code-based graders: cheap and reproducible, but brittle when a valid answer looks different from what the check expects.

A spec and an output scored against a rubric to produce a graded report, the LLM-as-judge pattern
A stronger model grades the cheaper model's work

Context rot: stale seed files

You wrote your CLAUDE.md three months ago. It references a validateOrder() function that became verifyOrder() in Sprint 7, and it describes an architecture you dropped when you moved from REST to tRPC. The seed is now wrong, and the AI follows it faithfully. The output looks right because it matches the seed.

This is context rot, the context engineering version of technical debt. The defense is automated validation that runs regularly in continuous integration and delivery (CI/CD).

This script checks that every function named in backticks in CLAUDE.md still exists in the source tree, and exits non-zero so CI can fail on it:

bash
#!/usr/bin/env bash
# check-stale-context.sh
set -euo pipefail
stale=0
for func in $(grep -oE '`[A-Za-z_][A-Za-z0-9_]*\(\)`' CLAUDE.md | tr -d '`()' | sort -u); do
  if ! grep -rqw --include='*.ts' "$func" src/; then
    echo "STALE: $func is named in CLAUDE.md but not found in src/"
    stale=1
  fi
done
exit $stale

It only sees name() in backticks, and it also flags old names you mention on purpose.

Two code windows where validateOrder() and verifyOrder() are linked by a broken chain, with a warning note pointing back
Context rot: stale seed files

Context drift: a growing conversation

Rot means the seed is wrong. Drift is gradual: each correction ("Use Zod, not Yup", "Forget what I said about error handling") adds tokens, and the original context gets buried under amendments.

The fix is the artifact-driven workflow from Part 3. Brainstorm in conversation, distill the result into a document, and start a fresh session with it. Superpowers (Part 4) does the same through subagent isolation: each worker receives only the context its task needs.

Run evaluation in CI/CD

Treat context like code: version it, test it, and review it in pull requests (PRs).

  • Run eval suites after every change to prompts, context files, or retrieval logic. If a CLAUDE.md edit lowers your metrics by more than 5%, the build fails.
  • Track metrics over time. A dashboard of faithfulness, relevance, and context utilization shows whether your practice is improving or degrading.
  • Agree on score thresholds as a team. An output scoring 2.7/3.0 on faithfulness is probably fine; one scoring 1.2/3.0 needs investigation.

Which tool runs it

You do not need to build the runner.

Pick one. The metric matters more than the tool.

Example: one eval run, with numbers

A team keeps 25 representative prompts. The judge extracts about 8 claims from each output, 200 in total. Faithfulness is claims the current code supports, divided by total claims.

On Monday the baseline supports 184 of 200 claims, a score of 0.92. On Tuesday someone edits CLAUDE.md to add a section on the new payments module. The run now supports 166 of 200, a score of 0.83. The relative drop is (0.92 − 0.83) / 0.92, about 9.8%. The gate allows 5%, so the build fails.

The score says something broke but not what. The stale-context script answers that: the new section names chargeCard(), renamed three sprints ago, and the agent copied the old name into 18 claims. Fix the seed, and the next run supports 183 of 200 (0.915), a drop of about 0.5% that passes.

A minimal CI config

This workflow runs the stale-context script and the eval as two parallel jobs. promptfoo exits with code 100 when a test fails, and PROMPTFOO_PASS_RATE_THRESHOLD sets the share of cases that must pass. The 5% drop rule above also needs a stored baseline score to compare against.

yaml
name: context-evals
on:
  pull_request:
    paths: ["CLAUDE.md", "AGENTS.md", "evals/**", "src/**"]
permissions:
  contents: read
jobs:
  stale-context:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - run: ./check-stale-context.sh
  eval:
    runs-on: ubuntu-latest
    env:
      ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
      PROMPTFOO_PASS_RATE_THRESHOLD: "90"
    steps:
      - uses: actions/checkout@v7
      - uses: actions/setup-node@v7
        with:
          node-version: "24"
      - run: npx promptfoo@0.123.1 eval -c evals/promptfooconfig.yaml --no-cache

The matching config mixes two rule-based checks with one judge assertion. Replace YOUR_MODEL_ID with a model you can call:

yaml
prompts:
  - "{{context}}\n\n{{task}}"
providers:
  - id: anthropic:messages:YOUR_MODEL_ID
tests:
  - vars:
      context: file://../CLAUDE.md
      task: "Check order 42 using the project's order helper"
    assert:
      - type: contains
        value: verifyOrder
      - type: not-contains
        value: validateOrder
      - type: llm-rubric
        value: "Only references functions that exist in the provided context"

A gate nobody trusts gets bypassed, so pin the judge model and tool version, store the baseline in the repo, and quarantine cases that flip between runs. And skip the judge gate below about 20 real cases: with 10 prompts, one flipped answer moves the score 10% and your 5% threshold fires on noise.

Contain agent mistakes before production

OpenAI published a write-up on this in February 2026: Harness engineering: leveraging Codex in an agent-first world. A small team shipped a product of roughly a million lines with about 1,500 merged pull requests and no hand-written code, and the article credits the environment around the agent more than the model. Mitchell Hashimoto stated the core rule the same month: whenever an agent errs, engineer a fix "such that the agent never makes that mistake again".

Three parts of OpenAI's setup transfer to any team:

  • A short AGENTS.md as a map. It points to deeper docs instead of holding every rule, because a giant instruction file goes stale.
  • Linters whose error messages teach. A failed architectural check tells the agent how to fix the violation, so the correction lands in its context.
  • Background cleanup agents. They scan for drift between code and docs and open small pull requests.

This maps to the Superpowers workflow from Part 4: two-stage code review, mandatory test-driven development (a failing test comes before the implementation), and a verification step before anything is called done.

Your eval harness starter kit

  1. Define metrics. Faithfulness, standards compliance, and test coverage for code; relevance and completeness for other output.
  2. Build a ground truth set. Collect 20-30 real prompts from your work, with the expected quality for each.
  3. Automate the easy checks. Compile, lint, and scan context files for stale references. These catch 40-60% of issues at zero LLM cost.
  4. Add LLM-as-judge for subjective checks. Score 0-3 and log everything.
  5. Run it in CI/CD on every PR that touches context files, and run the rot check weekly.
A loop of Context, Work and Evidence, where evidence feeds an update back into the context document
From solo context files to measured team workflows

How the series fits together

Across the series: Post 1 gave the "why", Post 2 covered solo seed files, Post 3 the team, Post 4 the frameworks including AgentKit (formerly ClaudeKit), and Post 5 the lifecycle and the security step. This post adds validation.


Without measurement, you cannot tell whether your AI setup helps or only feels like it does. Pick one metric this week (faithfulness is the easiest) and run it on your next PR.

To go deeper, see AgentKit for team orchestration and Superpowers for execution methodology.


*This is Part 6 of the "Context Engineering in 2026" series. Part 1 | Part 2 | Part 3 | Part 4 | Part 5