Base: anatomy of the loop|INEMA.CLUB-PRO

Lesson 2 · 15 min

Harness: what sits around the model

The model alone only predicts text: it doesn't remember, can't see your files, can't act and can't check. The one doing the work in Claude Code and Codex is the harness, the program around the model. When the agent fails, the useful question is almost never "try again": it's which piece of the harness is missing. In this lesson you take inventory of yours.

Start the lesson
Processor chip at the center of a dark aluminum casing, surrounded by connectors, cables, a lock and a dial.

In this lesson you will

  1. 1What the model does on its own and what it doesn't
  2. 2The five pieces of the harness and the loop that ties them together
  3. 3Where each piece lives in your Claude Code and your Codex
  4. 4Reading an agent failure as a missing piece

Goal: list the pieces of the harness on your machine (context, memory, tools, verification, permissions) and say which one holds back each failure.

01The model and what sits around it

Click each block: what the piece does and where it lives on your machine.

Scroll the page: each step below lights up its part of the diagram.

  1. 1/7

    Context

    At the start of each session the model knows nothing about your project. The harness loads the rules (CLAUDE.md in Claude Code, AGENTS.md in Codex), the folder structure and what changed. You write it once; it reads it every session.

  2. 2/7

    Memory

    The longer the session, the fuller the context window. The harness compacts: it keeps the goal and shrinks the old steps. Compacting too much loses detail; that's why long loops keep state in a file (lesson 5) and course 2 covers the context bands.

  3. 3/7

    Tools

    The model only produces text. When that text is a tool request (read a file, run a command, edit), the harness executes it and hands the result back to the model. MCP is the standard way to plug in tools from other systems.

  4. 4/7

    Verification

    Without verification, the model looks at the code and says "looks good." With it, the model runs the test and reads the result. A real result is worth more than the AI saying it's fine. This is the piece the loop needs most (lessons 1 and 6; course 1).

  5. 5/7

    Permissions

    The harness checks each action before running it: editing goes through, deleting asks. Hooks run your scripts before and after tools; the sandbox limits what a command can reach. In a loop with nobody watching, this is what holds back the blast radius (course 4).

  6. 6/7

    Agent loop

    Putting it all together: the model thinks and asks for a tool, the permission check looks at it, the harness runs it, the result comes back, and the cycle continues until the goal is met. The harness doesn't make the model smarter; it makes it more useful.

  7. 7/7

    Failed? Find the piece

    Forgot the project rule: context. Lost the thread after hours: memory. Couldn't do it: tools. Said it was done when it wasn't: verification. Did something it shouldn't have: permissions.

Claude Code and Codex are harnesses. The same model in different harnesses gives different results.

02Two lessons from people who build harnesses

From public engineering posts (research from 10/19/2026).

1. Ask what's missing

In the post "Harness engineering," the central lesson is this: when the agent fails, ask which capability, context, or structure is missing, instead of telling it to try harder.

In practice: the fix goes into the harness (a rule in AGENTS.md, a tool, a test), not into a more emphatic prompt.

03Inventory of your harness

Read-only: nothing is changed. Run it on your machine and write down what shows up.

Terminal · context and memory
ls -la ~/.claude/CLAUDE.md ~/.codex/AGENTS.md 2>&1
wc -l ~/.claude/CLAUDE.md ~/.codex/AGENTS.md 2>/dev/null
ls CLAUDE.md AGENTS.md 2>&1   # in the current project
Terminal · tools (MCP) and skills
claude mcp list
ls ~/.claude/skills 2>/dev/null | wc -l
Terminal · Claude Code permissions and hooks (user and project; run in the project folder)
python3 - <<'PY'
import json, pathlib
for p in (pathlib.Path.home() / ".claude/settings.json",   # user
          pathlib.Path(".claude/settings.json"),            # project (goes to git)
          pathlib.Path(".claude/settings.local.json")):     # project, only on this machine
    if not p.exists():
        print(f"{p}: não existe")
        continue
    d = json.loads(p.read_text())
    perm = d.get("permissions", {})
    print(f"{p}: hooks {sorted(d.get('hooks', {})) or 'nenhum'} · allow {len(perm.get('allow', []))} · deny {len(perm.get('deny', []))}")
PY
Terminal · Codex sandbox and approval
grep -nE '^(sandbox_mode|approval_policy)' ~/.codex/config.toml || echo "padrão do Codex (sem chave no config)"
harness.md · template to fill in
# My harness — <date>
contexto: <files with the rules the agent reads on startup>
memória: <how I keep what can't be lost: handoff, state files, nothing>
ferramentas: <MCP and skills I actually use>
verificação: <the command that proves it worked in my main project>
permissões: <hooks and allow/deny rules; Codex sandbox>
peça mais fraca: <which one and why>

04Video: the harness from the inside

Context, memory, tools, verification, permissions, and the agent loop, one piece per chapter (10/10/2026).

AI harness: who does the AI's work · 5 min 58 sVideo page with script →

05Practice

On your machine. Only move on to the next one when the "done when" is true.

E1 · Inventory

15 min

Run the four inventory blocks and fill in harness.md with what showed up, one line per piece. Write the markers at the start of each line exactly as they appear in the template: the "done when" grep looks for them.

Done when: grep -cE '^(contexto|memória|ferramentas|verificação|permissões):' harness.md → 5, and grep -c '<' harness.md → 0 (no template placeholder was left unfilled).

E2 · Is the context actually read?

10 min

Add an easy-to-check rule to the project's CLAUDE.md (or AGENTS.md), for example "every answer ends with the word CONFERIDO". Open a new session and ask for anything.

Done when: The new session's answer ends with CONFERIDO without you asking. Then delete the rule: grep -c CONFERIDO CLAUDE.md → 0.

E3 · One failure, one piece

10 min

Think of a real agent failure from the past few weeks. In harness.md, write the line "peça mais fraca:" with the piece that owns the failure and the fix that goes into the harness, not into the prompt.

Done when: grep '^peça mais fraca:' harness.md → one line that names one of the five pieces and a concrete file, command, or tool.

06Lesson quiz

Question 1 of 4

Every new session the agent forgets that the project uses pnpm and runs npm. Which harness piece fixes this?competency

07In three sentences

The model decides, the harness doesContext, memory, tools, verification, and permissions sit around the model, and the loop ties them together.
A failure has an ownerBefore trying again, ask which piece was missing and fix it in the harness.
Re-evaluate with each modelEach piece encodes an assumption about the model; a new model calls for a review.

Going further

Previous lessonNext lesson