Harness Primitives for Long-Running Claude Agents
Claude Code's built-in /goal command gives you a generator/evaluator loop out of the box: set a completion condition and a separate fast model checks it after every turn until it's met. This repo ships the same underlying primitives as short, readable hooks and a subagent, so you can see how each mechanism works and assemble a harness tuned to your project. The patterns come from Effective Harnesses for Long-Running Agents (Nov 2025) and Harness Design for Long-Running Application Development (Mar 2026). We recommend trying both the in-product features and a custom harness to see which fits your workflow.
| In-product | Custom harness (this repo) | |
|---|---|---|
| What runs the loop | /goal |
the primitives below + a loop you write |
| Who judges "done" | a separate fast model checking your condition | your agents/evaluator.md with your prompt |
| Where it works | Claude Code interactive, -p, Remote Control |
Claude Code, headless, or Agent SDK |
Three primitives form the quality loop:
- Default-FAIL contract. Every criterion starts
false; the agent can't mark it passing without opening evidence first. - Fresh-context evaluator. A separate agent with no Write/Edit tools grades the work from a context window that never saw the build.
- Agent-maintained handoff. The agent writes its own progress notes and commits to git so the next session picks up cleanly.
Two more operator-control hooks are included for when you want to watch or intervene. The same patterns translate directly to PreToolUse/Stop callbacks in the Agent SDK.
Built as the take-home for the Long-Running Agents station at Code with Claude 2026. These are example ingredients, not a turnkey harness. Event demo; not maintained and not accepting contributions.
How to use this repo
Read and cherry-pick. Each primitive is one standalone file with no dependency on the others. The quality-loop table below maps every one to its example here and its Agent SDK equivalent. Open the file, see how the mechanism works, copy what fits.
Or copy all of them as a starting point. In your project, run claude and paste:
Clone github.com/anthropics/cwc-long-running-agents into /tmp, copy its
claude-code-config/.claude/directory into this project's root, make the hook scripts executable, then walk me through what each hook and the evaluator subagent does and what I'll need to adapt for this project.
or do it yourself:
cp -r claude-code-config/.claude /path/to/your/project/
chmod +x /path/to/your/project/.claude/hooks/*.sh
Either way, this gives you all the examples wired into .claude/ at once. Before relying on them: point RESULTS_FILE at your project's actual results file, adjust the evidence-file pattern in track-read.sh, and run claude from the directory that contains .claude/ (hooks are not loaded when launching from a subdirectory).
If you're on the Agent SDK, this repo is a pattern reference. The shell hooks here translate one-to-one to PreToolUse/Stop callbacks. To scaffold an SDK agent from inside Claude Code, install the agent-sdk-dev plugin and ask Claude to build an agent that implements whichever of these primitives you want. For a hand-written starting po