Sprint 6 · Harness Engineering & Claude Code Mastery

Harness engineering: stability from the execution environment, not the prompt

Build

Concept

Stability comes from the harness, not a cleverer prompt

When an agentic coding session goes wrong — the model edits the wrong file, hallucinates an API that does not exist, or makes a change that breaks ten things it did not know were connected — the instinct is to write a better prompt. That instinct is usually wrong. The underlying problem is almost never that the model misunderstood the instruction. It is that the execution environment gave the model too little information before it started acting and too little structure to channel its actions safely afterward.

Harness engineering is the discipline of building that execution environment: the scaffolding, gates, and conventions that sit around the model and make agentic coding reliable regardless of how complex the repository is. This sprint covers four pillars of harness engineering — repository impact maps, the plan-first protocol, worktree isolation, and the judgment-vs-determinism boundary — and shows how each maps directly onto the tools Claude Code provides: subagents, skills, plan mode, and git worktrees.

Pillar 1: Repository impact maps

Before any file is modified, the agent needs to know what it is about to touch and what depends on it. Without this knowledge, the model is navigating a large codebase by assumption — and assumptions about import paths, function signatures, and module boundaries are the primary source of hallucinated edits in agentic coding.

A repository impact map is a structured pre-flight that answers three questions before any edit is made: which files define the symbols the task touches, which other files call or import those symbols, and which tests cover that surface. The map is built deterministically — by grepping for definitions, tracing import graphs, and listing test files — before the model is given any write access. The model then reasons over this map rather than over its training-time assumptions about the codebase.

The practical effect is significant. When the model knows the exact paths and signatures of the functions it will change, it cannot hallucinate them. When it knows which callers exist, it cannot ignore a ripple effect. The impact map transforms the model's task from "infer the structure of this codebase" — which it will do imperfectly — to "reason about this concrete, verified map" — which it does well.

Pillar 2: The plan-first protocol

The most expensive mistakes in agentic coding happen early: the model makes an architectural decision in the first edit that constrains every subsequent edit, and by the time the problem is visible, a significant amount of work needs to be undone. The plan-first protocol prevents this by separating reasoning from action into an explicit two-phase sequence.

In the first phase, the agent produces a structured plan: the list of files to change, the specific modifications at each file, the order of changes, and the verification steps that will confirm each change is correct. No files are modified. The plan is written to a markdown document and presented for review.

In the second phase, the plan is approved — either by a human reviewer or by a gate that checks it against known constraints — and only then does the agent begin editing. If the plan is wrong, it costs a few seconds to revise. If the edit is wrong, it may cost hours to untangle.

Claude Code implements this pattern natively as plan mode: when activated, Claude reads, explores, and produces a plan but does not write any files until explicitly granted permission. This makes the plan-first protocol a first-class workflow in the tool rather than a discipline you have to enforce manually.

Pillar 3: Worktree isolation

Parallel agentic tasks — where multiple subagents work on independent parts of a codebase simultaneously — create a coordination hazard: if two agents modify the same files, one agent's changes will silently overwrite the other's, or a merge conflict will appear at integration time with no clean record of which change was intentional.

Worktree isolation eliminates this hazard by giving each parallel task its own git worktree: a full working tree checked out at the same commit, isolated from all other worktrees, where one agent can make and test changes without touching any other agent's work. When a task is complete and verified, its worktree is merged into the integration branch. Nothing is integrated before it is verified; nothing is verified in a shared state that another agent is also modifying.

Claude Code's subagents are the mechanism for parallel task execution. Each subagent can be launched with its own worktree, run to completion independently, and integrated after verification — a pattern that makes parallel agentic development safe at scale without requiring complex conflict resolution.

Pillar 4: Judgment vs. determinism

The fourth pillar is a boundary, not a tool. Every task in an agentic coding session can be classified as either requiring judgment — synthesis, design, interpretation, trade-off reasoning — or being fully deterministic — parsing, linting, running tests, grepping for symbols, computing checksums. The boundary matters because the model is the right executor for the first class and the wrong executor for the second.

When you ask a model to run a linter, it will simulate running a linter: it will produce output that looks like linter output, based on its training, and that output may be wrong. When you run the linter as a tool and feed the result back as an observation, the output is accurate by construction. The same applies to test runners, build systems, import graph tracers, and any other deterministic operation. As Anthropic's guidance on building effective agents frames it: the reliability and maintainability gains from a well-structured agentic system come from keeping the model in its lane — synthesis and judgment — while letting tools handle the deterministic work.

In Claude Code, this boundary is expressed through skills: reusable SKILL.md files that encode a process the agent follows, with tool calls embedded at the deterministic steps. A skill can specify "grep for all callers of this function" (deterministic — use Grep) and "decide which callers need to be updated given this change" (judgment — the model) as separate, explicit phases. The skill does not blur the boundary; it documents it.

The Golden Rule

Never ask an LLM to do something a deterministic function can do reliably. Applied to harness engineering: build the impact map with grep and static analysis, not model inference. Run tests with the test runner, not model simulation. Gate plan-to-edit transitions with explicit approval, not implicit model self-control. Reserve the model for synthesis, judgment, and the decisions that genuinely require reasoning over ambiguous context.

How the four pillars compose in a real session

A well-harnessed agentic coding session moves through these pillars in sequence. First, a deterministic impact map is built — symbols found, callers traced, tests listed — before the model plans anything. Second, the model produces a structured plan over that map, with explicit file-change and verification steps. Third, if the session is parallel, each task is isolated in its own worktree and subagent. Fourth, every deterministic operation (lint, test, build) is run as a tool call and its output fed back as a concrete observation rather than simulated by the model. The result is a session where the model's judgment is applied to real information, its actions are staged and reviewable, and its outputs are verified by the same tooling you would use in a human engineering workflow.

Build

What to build this sprint

The reference artifact at projects/sprint-6/ is not Python — it is a set of markdown documents. The deliverable is a real, installable Claude Code skill (skill/SKILL.md) that encodes the plan-first harness, a PROCESS.md documenting how the harness works, and a README.md explaining what the skill is and how to install it. Read all three before authoring your own version.

  1. Read the skill. Open projects/sprint-6/skill/SKILL.md. Verify that it has valid frontmatter (a leading --- block with name: and description: fields, then a closing ---) and a substantive body. The body encodes the full plan-first harness: impact-map phase, plan phase, approval gate, edit phase, and verification phase. Each phase calls out which steps are deterministic (tool calls) and which require model judgment.
  2. Read the process doc. Open projects/sprint-6/PROCESS.md. It documents the harness in prose: why each phase exists, what specific questions each phase answers, and what failure mode each phase prevents. Read it alongside the skill body to see how the two documents complement each other — the skill encodes the process as instructions the model follows; the process doc explains the reasoning behind those instructions.
  3. Install the skill locally. Copy skill/SKILL.md to your ~/.claude/skills/plan-first-harness/SKILL.md (create the directory if needed). In a Claude Code session, type /plan-first-harness before any editing task. Confirm that Claude enters plan mode: it reads the relevant files, produces a structured plan with explicit file-change steps, and pauses for approval before modifying anything.
    bash
    $ mkdir -p ~/.claude/skills/plan-first-harness
    $ cp agentic-engineering/projects/sprint-6/skill/SKILL.md ~/.claude/skills/plan-first-harness/SKILL.md
    # In a Claude Code session:
    # /plan-first-harness
    # Claude will now build an impact map, write a structured plan,
    # and pause for your approval before editing any file.
  4. Use the skill on a real task. Pick a small, self-contained change in any codebase — a function rename, a config update, a new utility function. Invoke the skill and let Claude produce the impact map and plan. Read the plan: does it list the correct files? Are the change descriptions specific enough to be verified? Is the verification step concrete (run this test, grep for this symbol) rather than vague? If the plan is wrong, correct it before approving — that is the protocol working as designed.
  5. Classify your own dev loop. After using the skill, answer the question in the ship checklist: which parts of your development loop are deterministic (lint, test, build, grep) and where does agent judgment actually add value? Write your answer as a short note — two to four sentences — and add it as a comment block at the bottom of your local copy of PROCESS.md. That classification is the deliverable that demonstrates you have internalised the judgment-vs-determinism boundary.
When you are done

You have read and understood the plan-first skill and the process doc. You have installed the skill locally and invoked it on a real task. You have seen Claude produce a structured impact map and plan, and you have reviewed that plan before approving. You have written a short classification of your own dev loop — deterministic steps vs. judgment steps. That is the Sprint 6 ship condition.