A level 3 agentic harness built by following Agentic Programming by Jerod W. Wilkerson. The harness is a story execution system: stories enter with an approved plan, move through implementation, testing, documentation, and verification, retry when verification fails, and end completed or escalated — or pause, when capacity runs out or an agent cannot log in, and continue where they stopped.
About the name. The name is aspirational. What you'll find here is a level 3 harness, but level five is where the ladder leads, and the repository is built to grow in that direction.
This repository tracks Agentic Programming through level 3. Part 3 (Chapters 12–19) explains how an agentic harness works, and Appendix A, "Building a Sample Level 3 Harness," builds this one from an empty directory to a working system, including the real escalations that happened along the way.
The book is at agenticprogrammingbook.com.
The appendix is the starting point, not the finish line. It stops at a deliberately small harness so the essential structure stays readable, and then hands you a roadmap: harden first, following Chapter 18, then scale, following Chapter 19. This repository is walking that roadmap. Every improvement arrives the way the book says it should — as a story the harness plans, executes, verifies, and documents itself.
The exact harness Appendix A describes is tagged appendix-a. If you are reading the appendix and want to check your own build against it, or want to start where the appendix stops, use that tag:
git clone https://github.com/jerodw/level-five.git
cd level-five
git checkout appendix-a
main has moved past it. The appendix's code excerpts — the workflow definition, the implementer prompt, the coordinator's routing loop — match the tag, and the differences on main are the point rather than drift.
Everything below arrived as a story the harness planned, executed, verified and documented itself. Where the book argues for a capability, the chapter is named. The largest addition since the appendix is inspection: every story's change is read by a second agent before it is judged.
Planning. l5-plan interviews you and turns a request into a story plan. The request can be typed text or a brief the harness filed earlier, named by its key (l5-plan 464). Before writing the plan, the session settles which workflow the work belongs under, sweeps the code, documents and tests for everything the change touches, and works through a standing set of questions about what the change could break. A problem it finds in the part of the system the story changes becomes part of the story. Anything left out is listed with your reason, and a gap the plan leaves is filed as a brief. The session ends on a short screen and a menu: read the full plan, approve, approve and run, or reject. Approving commits and pushes the plan. A session that ends with only a draft can be kept and gone back to. (Ch. 15, Ch. 18)
Execution. The Story Coordinator walks a story through its workflow's stages (implementer, tester, documenter, verifier), assembling each stage's context, rendering its prompt and invoking the agent headlessly. Two workflows ship: one for stories, and one for refactors, whose claim is that behaviour is unchanged. Each run works on its own branch in its own worktree, so several stories can run at once, and their test suites share the machine rather than taking turns. (Ch. 12–17, Ch. 19)
Governance. Each writing stage declares what it may change: the tester only the tests, the documenter only the architecture documents, and the implementer may not create tests. After every turn the coordinator checks what that turn actually changed. An edit outside a stage's limits is undone where the suite passes without it, and handed to the stage that owns that work where it does not, because a stage may not write the tests that judge its own code. Each invocation also carries a deny-only tool guard. (Ch. 15, Ch. 18)
Verification and routing. The verifier judges the work against the plan, the repository's standards and the evidence, and the coordinator routes from its verdict: advance, retry, or escalate. A retry goes to the stage that owns the defect, carrying guidance on what to fix. A verdict may also say that no retry can finish the work, which escalates without spending one, and may name the stage the work should resume at once the blocker is cleared. Smaller findings on a passing verdict are fixed in the run without spending a retry. Where a fix needs a design choice the plan left open, the verifier makes it only where an existing source settles it, such as a standard, the architecture document or how the code already solves the same problem, and the decision is recorded for your review. The exception is the unfinished edge of code the story itself wrote: there the harness checkpoints the work first and keeps the repair only if it touched nothing older. On a passing verdict the suite runs again in a fresh clone with the story committed, and a completed run pushes its branch. (Ch. 17–18)
Inspection. Before the verifier judges a story, the Inspector, an agent of its own, reads the story's change: the files it changed, the architecture documents it changed, and what sits directly beside them. Findings about the story's own change go to the verifier as evidence, and the run fixes them itself, by a retry or a repair pass. Findings about the code around the change, and anything the run could not fix, are filed as briefs when the run completes. Each brief opens in plain English and carries a category, a severity, a confidence, the area of the system it concerns and the verifier's judgement of it, so it lands in the backlog already triaged. No finding goes quiet: the completion report says which were fixed, which were filed and why, and which were dropped, and a damaged record costs only the findings it could not read. Sections of a design document marked planned are kept as intent rather than reported as drift. l5-inspect runs the same inspection over any part of the code on demand. What an inspection spends is recorded, but never counted against the run's spending limit. (Ch. 18)
Pausing and resuming. A run whose agent hits a usage limit or cannot log in pauses instead of failing: no retry is spent and the work is committed. At a terminal, a usage limit offers to wait for the reset, stop, or carry on now; a login pause says to log in again and re-run. Running l5-run for the story again picks up where it stopped, whether it paused, escalated, could not run a check, ran out of disk or lost its process. An escalated run resumes at the stage it stopped at, or, where the verifier named the stage the work picks up at, at that one; --stage overrides either. The stage it resumes in is told why it is running and what is still outstanding, and an inspection a pause may have interrupted is made again. A lock keeps two processes from running the same story, and l5-run and l5-inspect keep the machine from idle sleep while they work. (Ch. 19)
The outbox. Work to file externally goes to a durable local queue first and reaches a tracker on a sweep, so a provider that is slow or unreachable can never turn a finished story into a failed one. Entries are deduplicated, and a partly-filed entry says so. (Ch. 17)
Observability. l5-status lists every story in flight, named by the brief it was planned from, and says where each one is: being planned, waiting for approval, running and at which stage, paused, escalated, or waiting to be merged. A run says up front how long the story should take, from the history of earlier runs, and announces each long step with its expected time. Every run keeps its state, an event log, its retries, its costs and each stage's artifacts. A completed run's report says what became of every finding and lists every decision it made on your behalf, costliest to get wrong first. (Ch. 18)
The roadmap, in the order it is being worked:
- Running on Windows.
- Issue trackers through adapters, with GitHub and GitLab built in and today's script setup kept as the fallback for any other tracker (from Ch. 17).
- Story review and pull request creation as part of the story and refactor workflows.
- A watcher script that follows a run's detailed logs as it goes.
- Multiple models and providers, with each workflow stage able to use its own (from Ch. 16).
- Remote harness execution (from Ch. 13).
Further out, from Chapters 18 and 19: a fuller hook-based tool policy in place of the static allowed_tools allowlist, an adjudicator, and a real initialization library.
Every capability above arrived as a numbered story, and each story's commit is titled with the behaviour it produced. So the list of what has changed since the appendix is one command rather than a document somebody maintains:
git log appendix-a..main --oneline --grep="^story-"
The approved plan behind each is committed in .harness/stories/, and the reasoning — why a thing is the way it is, and what it deliberately does not do — is in .harness/docs/ARCHITECTURE.md, which the documenter maintains as a stage of every run.
Run directories are execution state rather than source, so .harness/runs/ is gitignored and does not travel with a clone. The runs worth keeping — the escalations, and the runs preserved for what they showed — are copied into .harness/runs-archive/.
The harness runs on macOS and Linux. It does not run on Windows yet: planning and runs take their locks with fcntl, the coordinator bounds every configured command with a POSIX process group and links build state into worktrees with symlinks, and the reference tracker script is bash with jq. Windows support is first on the roadmap (see What's next). WSL is untested.
- Claude Code CLI (
claude) with an active subscription, and a long-lived token for runs to log in with — see How runs log in - Python 3 (3.10+)
- Git
The harness itself has no third-party runtime dependency — it uses only the Python standard library. Running its test suite needs what requirements-dev.txt declares; see Tests.
Every stage of a run is a separate Claude agent, started by the harness as its own claude -p process, and each one logs in with whatever login your machine has at that moment. If you rely on the login you use interactively, that login expires now and then and is refreshed in the background. When a refresh fails while runs are in flight, each of them stops in the stage it is running, because that stage's agent cannot log in, and nothing continues until someone logs in again. A run that stops this way is paused rather than failed (see Pausing and resuming under What the harness does now), but it still waits for you.
So give runs a long-lived token instead, and they stop depending on your interactive login.
1. Create the token. It needs a Claude subscription:
claude setup-token
This prints a token. Treat it like a password: anyone holding it can use your subscription. Do not paste it into a chat, an issue or a commit.
2. Store it somewhere safe. Keep it in your operating system's secret store, and read it into your environment from your shell profile, so it is never written in plain text.
On macOS, store it in the Keychain. Put -w last, so security prompts for the token instead of taking it on the command line, where it would land in your shell history:
security add-generic-password -a "$USER" -s claude-code-oauth-token -U -w
On Linux, store it with a Secret Service tool such as secret-tool (from libsecret), which also prompts for it:
secret-tool store --label="Claude Code token for l5 runs" service claude-code-oauth-token
If you have neither, keep it in a file only you can read, outside any repository — for example, create ~/.config/l5/claude-token, make it readable by you alone with chmod 600, and paste the token into it with an editor.
3. Hand it to runs. The CLI reads the token from the CLAUDE_CODE_OAUTH_TOKEN environment variable. Export it in your shell profile (~/.zshrc, ~/.bashrc or similar), so it is set in every shell you start l5-plan and l5-run from. Use the line that matches where you stored it:
# macOS Keychain
export CLAUDE_CODE_OAUTH_TOKEN="$(security find-generic-password -a "$USER" -s claude-code-oauth-token -w)"
# Linux Secret Service
export CLAUDE_CODE_OAUTH_TOKEN="$(secret-tool lookup service claude-code-oauth-token)"
# A file only you can read
export CLAUDE_CODE_OAUTH_TOKEN="$(cat ~/.config/l5/claude-token)"
The harness never reads, stores or passes the token itself. It starts each agent with the environment it was started from, unchanged, so the variable reaches every stage of every run. It also reaches any claude session you start from the same shell, which is harmless: it is your own login.
4. Check it. Open a new shell and run:
claude auth status --text
It names CLAUDE_CODE_OAUTH_TOKEN as the token in use when the variable is set. If it does not, the variable is not reaching that shell.
Where the token must never go. Not into any repository, not into .harness/config.yaml, and not into anything a run commits — a run commits the working tree it ran in, so a file placed inside a repository can end up in a commit. Do not write the token itself into your shell profile either: the lines above fetch it each time a shell starts, so the profile holds no secret if it is ever shared or synced.
When the token expires or is revoked. A run whose agent cannot log in pauses at the stage it was in. Its console, its events.log and its pause commit say the agent could not log in and carry what the CLI reported; no retry is spent and nothing is escalated. Create a new token with claude setup-token, replace the stored one the same way you stored it, open a new shell so the variable is read again, and run l5-run with the story's brief key, or l5-run --story <story-id>, to continue the run from the stage it paused at. Running l5-run again before replacing the token pauses again at once and spends nothing.
All harness capabilities are invoked through l5- scripts in scripts/:
| Script | Purpose |
|---|---|
l5-init |
Initialize a .harness/ structure in a target repository |
l5-plan |
Plan a story interactively, from request text or a filed brief named by its key (l5-plan 464); approving commits and pushes the plan. --resume goes back to a session that was kept with only a draft |
l5-run |
Execute an approved story through its workflow, named by its brief key (l5-run 464) or with --story, or chosen from a list at a terminal; a completed run pushes its branch |
l5-status |
List every story in flight, or show one story's run |
l5-assist |
Launch the interactive assist agent with harness context and the skills the harness ships |
l5-check |
Report whether a stage's required outputs are present, fresh and valid — the coordinator's own check, reachable while the turn is still open. It decides nothing |
l5-inspect |
Inspect a scope of the code deliberately and file what it finds as briefs |
l5-sync |
Drain the outbox, reporting what landed, what is pending, and what no sweep will clear on its own |
l5-prune |
Prune the cross-run history to history_retention_days on the default branch and commit the rewritten files; a run only reports what is past the bound |
Example:
scripts/l5-plan "Add a --dry-run flag to l5-run"
scripts/l5-plan 464 # plan the brief filed under 464
scripts/l5-plan --resume 464 # go back to its kept planning session
scripts/l5-run 464 # the story planned from brief 464
scripts/l5-run --story story-001 # a story by its number
scripts/l5-run # choose from a list, at a terminal
scripts/l5-status
workflows/ workflow definitions: stages, artifact routes, retry rules
schemas/ JSON Schemas for the structured artifacts, plus their manifest
prompts/ reusable agent prompt templates ({{placeholder}} injection)
plugin/ the skills the harness loads into the sessions it starts
orchestration/ the Story Coordinator and its supporting modules
rules/ execution rules enforced by the coordinator
scripts/ thin l5- entry points
hooks/ the deny-only tool guard each invocation carries, and the
turn-end check that asks a stage for the outputs it owes
templates/ starter files l5-init copies into a new target repository
tests/ the coordinator's test suite, run without model calls
.harness/ target-repository state: config, standards, stories and
the architecture documents under docs/; plus runs, logs
and the outbox queue, which are gitignored execution state
The harness pieces are reusable across target repositories. The .harness/ directory is target-repository state; run l5-init to create it in any other repository you want the harness to work on.
This repository is both the harness repository and its own first target repository. Every demo story is a real harness feature, so the harness participates in building itself from the start.
Looking for the architecture document? It is .harness/docs/ARCHITECTURE.md, not a top-level docs/. Its location is a configuration value rather than a fixed part of the layout: architecture_docs in .harness/config.yaml names it, and the coordinator injects whatever that key names into the implementer's context on every run. The key may name more than one document, and this repository also names .harness/docs/model-accounts.md, a design written before it is built. A configured document may carry sections marked planned, which state what the harness is designed to do rather than what it does, and which are kept as written until a story builds them; how a section is marked planned or built, and what a run may do to a planned one, is stated once in prompts/section-status-layer.md. A section carrying no mark is maintained as before. It sits beside .harness/standards/ because both are agent context, and a target repository is free to keep them elsewhere.
- Plan.
l5-planinterviews you, writes the story artifact, and offers a numbered menu: read the full plan, approve and exit, approve and run, or reject. An approval validates, commits and pushes it, and approve and run starts the run. - Enter.
l5-runhands the story to the Story Coordinator, which stands the run on a story branch in a worktree of its own and creates a run directory under.harness/runs/<story-id>/. - Advance. The coordinator walks the workflow's stages, assembling context, rendering the stage prompt and invoking the agent. After each turn it checks what the stage produced: the required artifacts are present, they were written by this attempt, they satisfy their schemas, and what the stage changed is what it was allowed to change.
- Judge. The documenter runs before verification, so what it writes is judged rather than taken on trust. Where the workflow declares an inspection, as each shipped workflow does, the story's change is inspected before the verifier on every attempt, and what it finds about the change is handed to the verifier. The verifier writes a verdict; the coordinator routes from it.
- Repair or retry. A failing verdict routes to the stage that owns the defect. A passing verdict carrying small findings re-enters a stage to act on them without spending a retry. A stage that failed mechanically runs again in place.
- Confirm. On a passing verdict the suite runs again in a fresh clone with the story committed, because the working tree is the one place that commit does not yet exist.
- Inspect or file. Where the workflow declares no inspection before the verifier, the completed story is inspected once, after its completion commit, and what it finds is filed. Where it declares one, nothing is inspected again here: what the inspections found about the code around the change, and what the verifier left unfixed, is filed once, from the final attempt.
- Push. A completed run pushes its story branch, never forcing, and confirms the remote holds it. Where the push fails, the run still completes and says what the remote is missing and how to send it. Where a
suite_pass_commandis configured, the run also publishes its passing suite run so CI can skip running the suite again; see Letting CI trust a pass the harness already made. Opening and merging the pull request stay with you.
Every one of these steps has a reason, a boundary and a set of things it deliberately does not do. Those are in .harness/docs/ARCHITECTURE.md, which the documenter maintains as a stage of every run.
Before a story's branch can be merged, the harness has already run your whole suite on it, in a fresh clone with the story committed. Without this section's setup your CI runs the suite again on the pull request and again after the merge, usually on exactly the same files. With it, one passing run counts wherever it happened: the harness records its pass on the commit it pushed, your CI looks for a trusted pass of exactly the files it would test, and it runs the suite only where it finds none.
What a pass vouches for. When the fresh-clone check's suite passes, the harness writes down git's tree hash of the files it tested and a fingerprint: that tree with the harness's record directories left out — the history, run and log directories your configuration names (history_dir, runs_dir, logs_dir, or their defaults under .harness/), wherever they lie beneath the repository root. The harness writes those directories after its suite has run, so a pushed commit with the same fingerprint holds exactly the files that were tested. That is only true if your suite never reads those directories — a test that read .harness/history/ could pass on the tested files and fail on the pushed ones, and the pass would vouch for something it did not test. One changed character anywhere else changes the fingerprint, so a needed run is never skipped. The pass also records the first line your test runner printed when asked --version, and the publish skips a run that was narrowed to part of the suite or that failed.
Configuring the publish. Name the command in .harness/config.yaml:
suite_pass_command: .harness/scripts/github.sh pass
l5-init installs .harness/scripts/github.sh. Its pass job puts a commit status, under the context l5/suite-pass, on the pushed commit in the repository the push landed on, with a text naming the tree and the runner's version. It runs gh, so the account gh is authenticated as must be allowed to write commit statuses on the repository — on GitHub that is write access to the repository, or for a fine-grained token the Commit statuses: read and write permission. suite_pass_timeout_seconds bounds how long the command may run (60 seconds unset). With no suite_pass_command configured, nothing is invoked and nothing is said. A command that fails or times out changes nothing about the run: it is reported in one line on the terminal and the run completes as it would have. Nothing is published for a push that did not land or a repository with no remote, because a status can only go on a commit the remote holds; a branch you push later by hand carries no record, and CI simply runs the suite for it.
Making CI honour a pass. This repository's own .github/workflows/tests.yml is the reference. It is one job, named tests, on the oldest interpreter the project supports. It works out the tree it would test — the merge commit's for a pull request, the pushed commit's for a push — and runs .harness/scripts/github.sh lookup, handing it that tree, a required version prefix and the commits to look on: the pull request's head commit, or for a push the pushed commit, its parents and the heads of the pull requests associated with it, which covers merge, squash and rebase merges. Where the lookup finds a trusted pass the job succeeds without installing or running anything and names the record it trusted. Otherwise it runs the suite and, on a first-attempt pass, records its own pass through the same pass job, so the push after merging a pull request it already tested is skipped too. Any failure to look runs the suite, and a record it cannot post — as with the read-only token a contributor's fork gets — is a warning that changes nothing. The job's permissions are contents: read, statuses: write and pull-requests: read, and it hands gh the job's own token.
A pass counts only on the interpreter version CI runs. The workflow requires the pass's runner version to begin with its own interpreter's major and minor version, so a pass the harness made under a different version is not trusted and the suite runs. Point the harness's fresh-clone check at the same version CI uses — this repository sets verification_runner to a 3.10 interpreter and runs CI on 3.10. A pass recorded without a version, because the runner did not answer --version, is never trusted by a workflow that requires one.
Naming trusted accounts. The lookup trusts a pass only where it is a status in the repository it was asked about, under the l5/suite-pass context, in the success state, whose text names exactly the tree asked about and the required version — and whose creator is the repository's owner, GitHub's Actions bot (github-actions[bot]), or an account you name. A contributor's fork cannot post a status in your repository, so it cannot make a pass the lookup trusts. An organisation cannot post a status itself, so an organisation-owned repository names the accounts that post its passes in L5_PASS_TRUSTED_ACCOUNTS, space-separated, at the top of its copy of .harness/scripts/github.sh or in the environment the lookup runs in.
Requiring the check before merging is your decision. Nothing here makes GitHub's merge button wait for the tests check. If you want it to, make that check required: in the repository's settings, add a branch protection rule or a ruleset for main that requires the status check tests to pass, or from the command line, for example gh api --method PUT repos/OWNER/REPO/branches/main/protection --input protection.json with a body whose required_status_checks.contexts lists tests. Then a pull request cannot be merged until the check is green. On a private repository this needs a paid GitHub plan. Without it, whoever merges is responsible for waiting until the tests check is green.
The Story Coordinator is deterministic and fully unit-tested without any model calls (a fake runner plays back scripted stage artifacts). Run the suite with:
.venv/bin/python -m pytest tests/ -q -n auto
The harness's own gates — the revert check, the coordinator's suite run in the tree, and the clean-clone check — run the command test_command in .harness/config.yaml names, so running that command is running what a gate runs. The command above runs the same suite and is not a copy of the configured one, which can carry options of its own. -n auto reads the core count of whatever machine it lands on, so no core count is written down anywhere.
The dependencies that command needs are declared in requirements-dev.txt, and it has to be installed into both interpreters this repository configures — the one you run the suite in and the one verification_runner names:
.venv/bin/pip install -r requirements-dev.txt
.venv310/bin/pip install -r requirements-dev.txt
Install it into only the first and your local suite is green while the clean-clone check dies on an unrecognized argument, because that check runs the same command under the second interpreter. That is the failure this instruction exists to prevent.
A test that asserts something is absent carries a demonstration that it can fail: the same check, run again over a case where the thing it looks for is present. That negative case is a mutation of a shipped file or of the reader, read back through the same reader the positive assertion runs — never a string the test built by concatenating the searched-for text onto it, which asserts a property of Python and stays green through any edit to the subject. A standing check reports that shape rather than leaving it to the rule: a test that plants a phrase into a value and then asserts that same phrase against that same value, without handing the result to the check it claims to demonstrate, is named by the suite. It reads what a test does rather than what it calls itself, so a control that never uses the word "control" carries no exemption.
This repository tracks the book through level 3, so its scope is what Part 3 and Appendix A describe. Small fixes — genuine bugs, or errors in the code and its docs — are welcome via pull request. Improvements the book's roadmap calls for are welcome as issues; they are best planned and executed through the harness itself, which is the whole point of it. Changes that would take the harness past level 3, or in a direction the book does not argue for, are out of scope here.
Found a bug in the harness code? Open a GitHub issue. For anything about the book's content — typos, unclear passages, errata — please use the feedback form at agenticprogrammingbook.com/feedback rather than GitHub Issues.