---
name: harness-first
description: Diagnose and fix an unreliable, expensive, or unsafe LLM agent by auditing its harness (golden set, judge, cost caps, data layer, action approvals, tracing) before blaming or swapping the model. Use when someone says an agent is "burning tokens", "hallucinating", "brittle", gives inconsistent answers, asks whether to switch to a cheaper/better model, or wants to ship an agent or prompt change to customers.
title: harness-first
canonical_url: https://skilld.dev/gh/getedgehq/skills/harness-first
last_updated: 2026-09-28T16:34:14.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [agents/openai.yaml](https://skilld.dev/api/skills-raw/getedgehq/skills/harness-first/agents/openai.yaml), [DERIVATION.json](https://skilld.dev/api/skills-raw/getedgehq/skills/harness-first/DERIVATION.json), [EVALS.md](https://skilld.dev/api/skills-raw/getedgehq/skills/harness-first/EVALS.md), [LICENSE](https://skilld.dev/api/skills-raw/getedgehq/skills/harness-first/LICENSE).
>
> If the user asked to install this Skill, run `npx skilld install getedgehq/skills/harness-first`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/harness-first`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/getedgehq/skills/harness-first) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/harness-first`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/harness-first --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/harness-first --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Harness first

A model is an engine. Most "model problems" are a missing harness: nothing defines a correct output, nothing checks changes, nothing caps spend, the data has no agreed definitions, actions have no approval, and there are no traces to find the bad call. Audit that before touching the model.

## 1. Reproduce the symptom from evidence, not vibes

- Read the agent code the symptom touches: the loop, tool definitions, prompt assembly, data access, side-effecting tools.
- Read whatever logs/traces/transcripts exist. Aggregate them (per conversation, per tool, per error): who spends the tokens, which calls fail, which answers are wrong. A few outliers usually dominate.
- State the root cause as a mechanism with evidence (file:line, log ids, numbers you computed). "The model is bad" is not a mechanism.

Common mechanisms:
- **Token burn:** loop with no max-iterations, retry on a deterministic error, full history or a huge tool result resent every turn, no caching of stable context.
- **"Hallucination":** the agent faithfully used an ambiguous or wrong source (two tables/fields with the same name and different meaning, stale doc). Recompute both numbers yourself to prove it.
- **Brittleness:** prompt changes shipped with no regression set; behavior that only the author checked by hand.

## 2. Score the six harness parts

For each, mark **present / partial / missing** with the evidence you found:

| Part | Present means |
|---|---|
| Golden set | ~20+ cases with expected answers/constraints, drawn from real traffic, incidents, and edge cases |
| Judge | deterministic checks first (numbers, policy rules, forbidden content), LLM-rubric only for what code can't check; runs on every prompt/model/tool change |
| Cost governance | hard token/cost caps per user and per workflow, max iterations per run, graceful stop with a message |
| Data layer | read-only credentials for reads, a data dictionary that defines each metric/field the agent may use |
| Action safety | irreversible or external actions (send, pay, delete, write, refund) are reversible or gated by human approval |
| Tracing | every model and tool call logged with conversation id, workflow, input, output, tokens, cost, latency, error |

## 3. Decide before building

- **Never recommend a model swap without eval evidence.** If someone asks "should we switch models?", the answer is: fix the mechanism, then run the golden set on both models and compare quality and cost. Say what the fix alone is expected to save, with your numbers.
- **Never approve shipping a prompt/agent change without a golden-set run.** If recorded outputs exist, score them against the expected answers yourself and report failures by case id.
- Safety gaps (ungated side effects, write access on a read path, leaking internal data) are blocking, even when nobody asked about them.

## 4. Build the minimum harness, in this order

1. **Stop the bleeding:** max iterations, no retry on non-transient errors, truncate/summarize large tool output, hard per-run cost cap.
2. **Gate side effects:** approval step or draft mode for irreversible tools; read-only connection for query tools.
3. **Golden set file** (`evals/golden.jsonl` or similar): input, expected answer or constraints, source (log id / incident / policy clause). Include the cases that just failed.
4. **Judge script** that runs the golden set and prints pass/fail per case plus totals. Deterministic checks before LLM grading.
5. **Data dictionary** for every metric the agent reports (definition, source table/field, exclusions).
6. **Tracing** fields listed above, if missing.

Write real files, not a description of files. Run what can run and report the result.

## 5. Report

- One-line answer to the question actually asked (e.g. "Don't switch models yet: 3 runs stuck in a retry loop spent 71% of tokens").
- Root cause with evidence and numbers.
- Harness scorecard (the six parts).
- What you changed or created, and what you ran.
- Blocking risks, then a short prioritized next-steps list.

## Credit

The method this Skill follows comes from a public post by Mark Ajzenstadt (@mardehaym): https://x.com/mardehaym/status/2099562230647804152. The argument is theirs; the procedure, the wording and the evaluation here are Edge's own, and the author did not review them.
