A Claude Code harness is everything you build around the model so it can do real work without you watching: the thing that wakes it up, the instructions it reads, the permissions it runs under, the memory it keeps, and the alarm that goes off when it fails. Claude Code is already a harness around Claude. If you run it on a schedule, you end up writing a second one around Claude Code.
Quick disambiguation so nobody wastes a click. This post is not about Harness, the CI/CD company, or its tooling. It’s not about the open-source claude-code-harness plugin on GitHub, and it’s not about evaluation harnesses that score models on benchmarks. It’s about the runtime scaffolding that turns one claude -p call into a job that runs every night.
The explainers I read this week define the harness well, then show a toy example. Here’s the harness that runs my agent fleet instead, taken apart file by file, with logs from 419 unattended runs between 31 October and 30 November 2026, and scored against Anthropic’s own harness advice, including where it fails.
What Is a Claude Code Harness? (The 2-Sentence Answer)

Anthropic’s own definition is the cleanest one I’ve found. In Harnessing Claude’s intelligence, Lance Martin writes: “An agent harness is the software scaffolding around a model: the loop, tools, context management, and guardrails that turn raw intelligence into a working agent.”
By that definition, Claude Code itself is a harness. It owns the agent loop, the Bash and file tools, compaction, permission prompts, skills and memory files. When you type into it, you are the rest of the system: you decide when it runs, you read what it did, you notice when it breaks.
Take yourself out of that loop and you have to replace yourself with code. That code is what people mean by “my harness” in the Claude Code world. So there are really two layers:
- The inner harness is Claude Code, which Anthropic builds. You configure it with CLAUDE.md, settings, skills, hooks and a permission mode.
- The outer harness is yours. It covers the clock, the entry point, the credentials, the memory that lasts between runs, and whatever tells you a run went wrong.
Anthropic published a design guide on 13 November, Building always-on agents, that describes this outer layer as five primitives: an event inbox, timers, memory, permissions and an outbox. Its first line on the subject is the one I’d tattoo on every “24/7 AI employee” pitch: “An always-on agent is not actually ‘always on.'” It sleeps, wakes on an event, does a run, writes down what happened, and goes back to sleep. Mine does exactly that, 419 times last month.
If you want the discipline-level view of building systems like this, I cover that in agentic engineering for operators. This post sticks to the anatomy.
The 6 Parts of My Claude Code Harness, Mapped to Real Files

Here is the whole thing. Every row is a file or process that exists in the container right now. The line counts are from 1 December 2026.
| Harness part | What it does | My real file | Size |
|---|---|---|---|
| 1. Clock | Decides when a run starts | schedule.json + scheduler.py (kept alive by supervisord) | 12 daily + 10 active weekly slots; 429 lines |
| 2. Front door | Turns a slot into one Claude Code call | cron-dispatcher.sh + get-current-task.py | 204 + 124 lines |
| 3. Permissions | What the agent may touch and with which keys | --dangerously-skip-permissions, a Docker container, env-var credentials | 1 flag, 1 container |
| 4. Instructions and skills | What the agent knows before it starts | CLAUDE.md + .claude/skills/*.md + overrides/ | 485 lines + 39 skill files |
| 5. Memory | What carries over from one run to the next | MEMORY.md + observations.md + backups | 1,359 lines (313 KB) + 371 KB |
| 6. Outbox and supervision | How a human finds out what happened | SKILL_RESULT line, telegram-alert.sh, Asana review cards, a nightly watchdog, a daily auth canary | 46-line alert script, 23:37 watchdog, 03:00 canary |
The model isn’t in the table on purpose. It’s the one part I don’t build; everything else is mine to get wrong.
Twenty job types run on this Claude Code harness, including the blog writer that produced this post. How they hand work to each other is covered in AI agent orchestration without a platform.
The month in one line: 419 runs in 31 days, 37.7 hours of actual work, a median run of 4.0 minutes, the longest 49.1. Every one exited with code 0, which turns out to be the most misleading number in the system.
The Clock and the Front Door: Scheduler, Dispatcher and Bypass Mode

Anthropic’s always-on guide says timers “live in their own durable store” and that a scheduler polls that store and fires anything that’s due. That describes my setup almost line for line.
The clock: schedule.json and scheduler.py
schedule.json holds 12 daily slots and 16 weekly ones, 10 of them active. Each slot names a skill file and a timeout. The blog writer gets 5,400 seconds; email triage gets 1,800. scheduler.py checks the clock every 30 seconds and fires a slot if it’s within 2 minutes of its time.
The important design choice is boring: it runs one job at a time and waits for it to finish. Anthropic’s guide says the same thing about workers: “An inbox should only have one active worker at a time.” Two agents editing the same memory file at once is how you lose a day of notes.
The price of that choice is real, though. A slot that comes due while another job is still running gets skipped, and it leaves no log line. I measured exactly that failure in the timeout-vs-gap check. A watchdog that ran 37 minutes on 6 October ate the next night’s blog slot.
The front door: cron-dispatcher.sh
Every run goes through one 204-line Bash script. It asks get-current-task.py which skill belongs to this slot, writes a lock file so a second dispatcher can’t run the same slot twice, adds a brand override file to the instructions if one exists, and then makes the only call that matters, on line 182:
claude --print --dangerously-skip-permissions -p "$INSTRUCTION" < /dev/null >> "$LOG_FILE" 2>&1
That’s the whole bridge between the outer harness and the inner one. The instruction is a short template (date, task, “read the skill file and execute the complete pipeline”, a few hard rules); everything specific lives in the skill file.
Why the permission flag is bypass
Headless runs can’t answer permission prompts, so an unattended harness has to decide in advance. I chose bypass mode inside a container. The container is the real boundary: one brand, one project folder, its own keys, a 2 GiB memory cap. The flag only decides how much the agent asks inside that box, and the answer is “never”.
Two notes if you’re building this today. My container runs CLI 2.1.292, and the permission-mode docs I read on 30 November say that from 2.1.302, -p with no mode starts in Manual, which denies anything needing approval. Pass the mode explicitly, or a CLI update can quietly turn your agent into one that refuses everything. And bypass isn’t the only option: the minimal harness further down uses dontAsk with an allow-list. How the flags behave headless is covered in my Claude Code cheat sheet.

Get the AI Playbook
The playbook behind my harness: which job to hand to an agent first, how to make it report a result you can check, and how to catch a run that quietly stopped working. Free, unsubscribe anytime.
Instructions, Skills and Memory: The Harness Parts That Look Like Prompts

These files look like prompts, but they’re harness. They decide what the agent knows before it does anything, which is why the same model can write a post at midnight and triage email at 11:00 without mixing them up.
CLAUDE.md: identity and hard rules
Every run loads the same 485-line CLAUDE.md: who the brand is, which tables live where, the image pipeline, and twelve non-negotiable rules (“never invent data — if a queue is empty, skip gracefully”). I wrote up what belongs in that file, and what doesn’t, in CLAUDE.md best practices.
Skills: one file per job
There are 39 skill files in .claude/skills/. The dispatcher hands the agent exactly one of them per run. This matches Anthropic’s first pattern, lean on the model: skills are plain Markdown that Claude reads with its file tool, and every API call inside them is a curl or a short Python script that Claude runs through Bash. There’s no custom tool layer. The model already knows Bash, and it shows.
Brand-specific behaviour goes in overrides/<skill>.md, which the dispatcher tells the agent to read first, so one template skill works across brands.
Memory: where my harness is weakest
The always-on guide says memory “should only hold what the agent can’t look up again,” and that past a certain size you keep an index and load details on demand. My MEMORY.md does the opposite. It’s an append-only diary that every job writes to: 1,359 lines and 313 KB today, plus a 371 KB observations.md.

⚡ GET THE AI EDGE
Weekly AI tips that actually save you time and money. No fluff, no hype — just what works.
On 9 November that design broke. One run rewrote MEMORY.md from 2,421,795 bytes and 10,460 lines down to a single 8-line entry. Nine later runs noticed it and noted it. None of them restored it, and the watchdog still graded the night as a pass. The full story is in the memory-file shrink alarm post. The file you’re reading about today is the post-truncation version, and the shrink alarm that post recommended is still not built. It’s on my list, not done.
What preserved the old content was a different harness habit: every job copies the memory files to a timestamped backup before it writes. That habit has its own cost. The project root now holds 1,329 backup files, about 3.0 GB, with no cleanup step. If you want the full tour of how Claude Code’s own memory layers work, compared with this hand-rolled one, see Claude Code memory, explained.
Anthropic’s long-running agents research makes a point I learned the hard way. In Effective harnesses for long-running agents, they kept a feature list in JSON because “the model is less likely to inappropriately change or overwrite JSON files compared to Markdown files.” My memory is Markdown. The one file that got overwritten was Markdown.
The Outbox and the Watchdog: Why 419 Exit Codes of 0 Told Me Nothing

Here’s the statistic I promised. Between 31 October and 30 November, 419 of 419 runs exited with code 0. Here’s what actually happened in those runs:
| What the run said it did | Runs | Exit code |
|---|---|---|
| success | 406 | 0 |
| fail | 8 | 0 |
| skip | 1 | 0 |
| no result line at all | 4 | 0 |
Claude Code exits 0 when the session ends cleanly, not when the job worked. An agent that politely reports “the newsletter failed to send” has, from the shell’s point of view, succeeded. If your harness alerts on exit codes, it will stay green through every one of those eight failures.
All eight came from one place: the weekly newsletter writer and the weekly list sync, four Fridays and four Sundays in a row, both tripping over the same Sendy list setting. I’ve written that up in my AI workforce numbers. Fixing it is on my list, not done. The four runs with no result line did finish their work; a late background notice printed after the result line and pushed it out of the expected spot.
What actually tells me something
- A required result line. Rule 6 in
CLAUDE.md: every run ends withSKILL_RESULT: success|skip|fail | summary | url. That one greppable line is my typed output. Anthropic’s third pattern says to promote actions to dedicated tools so the harness gets “structured arguments it can log, trace, and replay.” I don’t have tools for that. I have a line of text with a contract, which is the cheapest version of the same idea. - A watchdog at 23:37. A separate skill checks that every slot dispatched, reads each result line and retries what it safely can. Last night it graded 16 of 16.
- An auth canary at 03:00. One real
claude --printcall a day, so an expired login shows up before the midnight jobs hit it. - Telegram for pings, Asana for anything a human should review.
telegram-alert.shis 46 lines, and 24 skill files call it.
The outbox is where I disagree with my own design. The always-on guide says “it’s better for the agent to start quiet and then earn more of the user’s attention over time.” Mine started loud. On 29 November the review queue held 288 cards since June, 284 of them still open. An outbox that nobody can keep up with works about as well as no outbox. One more trap: telegram-alert.sh exits 0 quietly if its credentials are missing. That’s polite, and it also means a misconfigured outbox fails in total silence. Check your alert path the same way you check the job.
Anthropic’s Harness Advice, Scored Against My Live Fleet

Two Anthropic pieces give a clean scorecard: the three harness patterns from Harnessing Claude’s intelligence and the five primitives from Building always-on agents. Here is my Claude Code harness against both, graded honestly. Where a row says “gap”, nothing has been fixed yet.
| Anthropic’s advice | What my harness does | Verdict |
|---|---|---|
| Lean on the model: give it tools it knows (Bash, file editing) | Skills are Markdown; every integration is curl or Python run through Bash | Matches |
| Strip it down: “what can I stop doing?” | Several parts are dead weight (list below) | Overdue |
| Set boundaries with dedicated tools for security and audit | Everything goes through Bash; the only structured output is the result line | Gap |
| Event inbox: a durable queue with one worker | No real inbox; runs start only from the clock. Human requests sit in an Asana section that gets read once a night | Weakest part |
| Timers: a durable store plus a polling scheduler | schedule.json + scheduler.py, one job at a time, lock files. The agent can’t set its own follow-up timer | Mostly matches |
| Memory: only what can’t be looked up again; index first | An append-only 1,359-line diary every job writes to | Fails |
| Permissions: a credential proxy outside the agent’s environment | Bypass mode in a container; keys are environment variables the agent can read | Gap |
| Outbox: start quiet, earn attention | Telegram pings plus 284 open review cards | Too loud |
What I’d strip, by Anthropic’s own test
The question to keep is “what can I stop doing?” Anthropic’s own example is a context reset they built because one model got “context anxiety” near its limit; with the next model the behaviour was gone and the resets were “dead weight.” Here’s my dead weight:
- The hard-coded Asana inbox block in the dispatcher. It only fires between 10:58 and 11:02, and only if two env vars are set. Those env vars aren’t set, and since 6 September the email slot has started at 11:05, outside the window. So it never runs and never logs. I wrote up the receipts in the env-var check.
- The “always read MEMORY.md” rule. At 313 KB, no run reads the whole thing anyway. It should be a short index plus per-topic files, which is what the always-on guide describes.
- 1,329 backup copies. One rolling snapshot per file per day would have caught the 9 November truncation just as well.
None of these are done yet. This is the list, not the changelog.
What I’d add
First, a real credential boundary: the guide recommends a proxy that injects credentials into outgoing requests so the agent never holds them. Mine holds them as environment variables, which is why the container boundary matters so much. Second, a tiny event inbox, so a request from me starts a run within minutes instead of waiting for the 22:07 check. That nightly check executed zero operator tasks in 30 nights. The only open card was the same one each night, escalated again and still waiting on me.
If your team is weighing a harness like this against a vendor platform, that’s the conversation I have most often. You can book an automation strategy session and we’ll map your first unattended job to these six parts before anyone writes code.
Build Your First Claude Code Harness: The Minimum Version for One Scheduled Agent

You don’t need my six-part fleet to start. You need five things around one job: a clock, a lock, a timeout, a permission decision, and an alert that reads the result line, not the exit code. Here’s the smallest Claude Code harness I’d leave running overnight:
# crontab -e (runs at 00:05 every night)
5 0 * * * /srv/agent/run-agent.sh
#!/bin/bash
# /srv/agent/run-agent.sh
set -u
cd /srv/agent
LOG="logs/$(date +%F_%H-%M).log"
# 1. One worker at a time
exec 9>/tmp/agent.lock
flock -n 9 || { echo "already running" >> "$LOG"; exit 0; }
# 2. Timeout + explicit permission mode + allow-list
timeout 30m claude -p "$(cat task.md)" \
--permission-mode dontAsk \
--allowedTools "Read,Edit,Write,Bash(curl *)" \
>> "$LOG" 2>&1
RC=$?
# 3. Judge the result line, not the exit code
RESULT=$(grep -o 'RESULT: [a-z]*' "$LOG" | tail -1)
case "$RESULT" in
"RESULT: success"|"RESULT: skip") ;;
*) curl -s "https://api.telegram.org/bot$TG_TOKEN/sendMessage" \
-d chat_id="$TG_CHAT" \
-d text="agent rc=$RC ${RESULT:-no result line} $LOG" ;;
esac
And the last two lines of task.md, which turn the model into something a script can grade:
If there is nothing to do, stop and say so. Never invent work.
End with exactly one line: RESULT: success|skip|fail - one-sentence summary
Before you trust it, check three things:
- Run the exact command by hand once.
dontAskdenies anything not on the list, so a too-tight allow-list fails loudly now instead of at 3 a.m. - Make it fail on purpose. Point it at an empty queue and confirm you get
RESULT: skip, not an invented result. Then break a credential and confirm the alert fires. - Add memory last. Start with none. When a second run needs to know what the first one did, add one small progress file and tell the agent to read it first and update it last. That’s the
claude-progress.txtpattern from Anthropic’s long-running research, and it’s enough for a while.
When you outgrow one job, you’ll want a schedule file and a dispatcher instead of crontab lines. That’s the point where the autonomy ladder and the headless test are worth reading, because a harness can’t fix a job that was never safe to run unattended.
Claude Code Harness FAQ

Is a harness the same as a framework or an SDK?
No. A framework or SDK, like the Claude Agent SDK, is a set of parts for building a harness. The harness is the assembled thing that actually runs your agent. Anthropic calls the Agent SDK itself “a powerful, general-purpose agent harness”, which shows how blurry the line is. In practice, if it decides when the agent runs, what it can touch and how you find out what happened, it’s harness.
Is the claude-code-harness repo on GitHub official?
No. Chachamaru127/claude-code-harness is a community project. When I read it on 1 December, it installed as a Claude Code plugin called harness that runs a plan, work and review cycle, and it also supports Codex CLI, Cursor and Grok accounts. From its README, it’s aimed at interactive coding sessions, which is the inner layer, not the outer one. Check the repo on the day, because its plugin ID has already changed once.
Is this about Harness the CI/CD company?
No. Harness (harness.io) is a software delivery platform, and some searches for this term land on its tooling. If that’s what you wanted, their developer docs are the right place. Here, “harness” means the scaffolding around a model.
Does a better model make the harness smaller?
Usually, yes. Anthropic says harnesses encode assumptions about what the model can’t do, and those assumptions go stale. The outer layer doesn’t shrink, though: a model can’t schedule itself or tell you its container is down.
What happens to my harness when the model is retired?
Pin versions and you get a deadline; don’t, and you get silent behaviour changes. More in the model deprecation FAQ.
Final Thoughts: The Harness Is the Part You Actually Own
The model gets better whether I do anything or not. The harness only gets better when I fix it. In 31 days it ran 419 jobs without me. It also hid 8 failures behind exit code 0 and built a review queue one person can’t clear, and in November it lost a 10,460-line memory file without raising an alarm.
That’s the honest case for building your own Claude Code harness. It isn’t magic. It’s a clock, a front door, a permission decision, instructions, memory and an outbox, and each of them can fail quietly in its own way. Start with one job, judge it by its result line, and add each part only when a real run shows you need it.
Then do what Anthropic recommends and I’m still catching up on: every few months, ask what you can stop doing.

Get the AI Playbook
Every week: one real job my agents ran unattended, what it cost, and what broke anyway. Receipts, not predictions. Unsubscribe anytime.

📥 FREE: THE AI PLAYBOOK
The exact tools and workflows I use to run a one-person agency. 25 years of marketing experience distilled into an actionable guide. Yours free.
