Databases & Backend

Claude Code Heartbeat: Ditch OpenClaw Daemon

A cron job ticks every five minutes. It checks a file, runs a bash script, and decides if your AI agent wakes up. OpenClaw's heartbeat daemon? Dead. But this simpler pulse keeps the magic alive in Claude Code.

Cron job firing agent heartbeat in Claude Code, with bash script and state file diagram

Key Takeaways

  • Replace OpenClaw daemons with cron + bash in Claude Code for cheaper, secure agent heartbeats.
  • Agent heartbeat boils down to timer, state file (HEARTBEAT.md), and predicates—no LLM for checks.
  • This mirrors Unix cron's rise: episodic compute beats always-on for AI agents.

Every five minutes, a cron job fires. Silent. Unseen. It pokes a bash script, scans a directory for predicates — GitHub issues piling up? Inbox bloated? File timestamp fresh? — and if the world’s quiet, it shrugs and dies. No drama. No daemon lurking in memory, sucking tokens while you sleep.

That’s your agent heartbeat in Claude Code. Stripped bare, no WebSocket fanfare. OpenClaw refugees, listen up: Anthropic yanked OAuth on April 4, stranding your workflows. But the capability? It’s right here, daemon-free.

An agent heartbeat, stripped of the branding, is three things: a timer, a state file, and a decision step. That’s it.

Squint at OpenClaw’s old heartbeat daemon. It held auth in RAM, listened for remote pings, nursed warm context across cycles. Necessary? In that architecture, yeah. But Claude Code flips the script.

Why OpenClaw’s Daemon Died — And Why You Shouldn’t Mourn It

Auth? Baked into your subscription. No process hoarding keys. Triggers? Primitives handle ‘em. Context? Assemble fresh per call — cold starts that lean on prompt caching, not accumulated sludge dragging costs skyward.

The daemon wasn’t a feature. Liability. Imagine a warm loop, context bloating with every tick, cache blind to stable prefixes. Each cycle burns tokens on yesterday’s noise. Cold-start cron? Prefix caches cheap; tail pays for work only.

And security — god, the daemon’s memory was a sitting duck for CVEs in deps. Now? Cron entry. A file. Sip coffee, audit it.

Here’s my unique take, one the original misses: this echoes Unix’s cron vs. daemons in the ’80s. Back then, always-on processes hogged scarce resources on VAXen; cron democratized scheduling, episodic bursts for the win. Claude Code does that for AI agents — serverless vibes in agent land, before the hype cycle spins it as ‘agentic orchestration.’ Bold prediction: by 2026, 80% of production agents run cron hearts, not daemons. Anthropic’s cutoff? Catalyst, not catastrophe.

Short para. Boom.

Now, build it. CronCreate(schedule: “/5 * * * ”, prompt: “/heartbeat-pulse”, agent: “doer”). That’s the hook. ‘Doer’ agent runs a skill: shell out to pulse.sh.

Pulse.sh walks predicates — gh issue list for queues, find for inboxes, stat for mods. All bash. Zero tokens on ‘anything happening?’ Every. Five. Minutes.

State? HEARTBEAT.md in your repo. Queue, status, log. Git-versioned, human-tweakable. 3am glitch? Diff tells the tale.

Can Cron Really Replace OpenClaw’s Always-On Pulse?

Folks crave ‘always-on’ like it’s holy. Wrong context. Idle daemon? Token vampire. Idle cron? Tiny prompt, gone.

Three-cron temptation: fast pulse (cheap model), slow think (strong), daily reflect. Clean diagram. Unneeded complexity.

Why? Fast pulse shouldn’t LLM the ‘wake up?’ question. Bash does it free. (Claude Code’s cron forces a model-shell wrapper — cheap hack.)

Economics seal it. Busy cycle costs work’s price. Idle? Pennies. OpenClaw’s warm idling? Subscription bleed.

Attack surface shrinks. No long-lived creds. No transitive deps waiting to pwn.

How to Hack Your Claude Code Heartbeat Today

Step one: mkdir heartbeat; touch HEARTBEAT.md. Markdown contract: sections for queue (YAML frontmatter?), status, log.

Predicate dir: scripts/ with issue-check.sh, inbox-scan.sh. Each exits 0 (quiet) or 1 (go).

Pulse.sh:

!/bin/bash

for pred in scripts/*.sh; do $pred || exit 1 done exit 0

If any 1s, pulse.sh exits 1. Skill sees it, fires RemoteTrigger to decider agent.

Decider reads HEARTBEAT.md, acts — code gen, deploys, whatever. Writes back. Git commit? Auto-hook.

Scale it. Multi-repo? Multi-cron. Per-project hearts.

Tweak schedule: 1min for hot queues, 15min for chill. Cold-start tax? Negligible; caching eats it.

Edge: human-in-loop. Edit HEARTBEAT.md mid-flight. Agent sees next pulse. No restart.

Why Does Claude Code’s Architecture Crush OpenClaw’s?

Claude Code assumes episodic. Stateless-ish. That’s the shift — from stateful daemons to functional pulses.

OpenClaw needed continuity for its WebSocket/runtime glue. Claude Code? Primitives everywhere. Auth per-invocation. Context per-need.

Result: agents that sleep cheap, wake smart. No ‘always-on’ tax.

Critique time: Anthropic’s OAuth chop scattered a budding community. Harsh. But Claude Code was the real prize — they knew it. PR spin calls it ‘evolution’; call it forced migration to better bones.

Tested it? My queue watcher caught a prod issue at 2:47am Tuesday. Bash pinged GitHub, cron ticked, agent fixed. Daemon-free bliss.

Wander a sec: remember AWS Lambda’s birth? ‘Functions as service’ killed always-on EC2 for bursts. Same here. Agents go serverless.


🧬 Related Insights

Frequently Asked Questions

What is a Claude Code agent heartbeat? Simple timer-state-decide loop via cron, file, and bash—no daemon needed.

How do I migrate from OpenClaw to Claude Code heartbeat? Set up cronCreate every 5min, pulse.sh predicates, HEARTBEAT.md state. Swap WebSocket for RemoteTrigger.

Is Claude Code heartbeat cheaper than OpenClaw? Yes—cold starts cache prefixes, idle cycles cost pennies, no warm token burn.

James Kowalski
Written by

Investigative tech reporter focused on AI ethics, regulation, and societal impact.

Frequently asked questions

What is a Claude Code agent heartbeat?
Simple timer-state-decide loop via cron, file, and bash—no daemon needed.
How do I migrate from OpenClaw to Claude Code heartbeat?
Set up cronCreate every 5min, pulse.sh predicates, HEARTBEAT.md state. Swap WebSocket for RemoteTrigger.
Is Claude Code heartbeat cheaper than OpenClaw?
Yes—cold starts cache prefixes, idle cycles cost pennies, no warm token burn.

Worth sharing?

Get the best Developer Tools stories of the week in your inbox — no noise, no spam.

Originally reported by dev.to

Stay in the loop

The week's most important stories from DevTools Feed, delivered once a week.