Skip to content
Back to skills

Heartbeat

ASecurity

Keep a Claude Code session making progress on its own between operator messages - a session-only cron job fires every ~20 minutes, and each fire follows a fixed protocol (count, orient from a state file, run checks, zoom out against the goal every few fires, take one verified step, record STATE and findings) against a per-work file holding goal, constraints, escalation, checks and an ordered queue. Survives compaction and resume through a registry and a hook. Invoke as /heartbeat start, pause...

  • 2 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 12, 2026
ai-agentspythonrustgoexpress

Works with

  • claude code

Security analysis

A100/100

Pro scans all 6 files and shows the line behind each finding

Scanned November 26, 2026

npx -y skills add BarzinL/barzins-cc-improvements --skill heartbeat --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Heartbeat?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Heartbeat
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/barzinl-heartbeat/badge)](https://www.skillsdirectory.com/skills/barzinl-heartbeat)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: heartbeat
description: Keep a Claude Code session making progress on its own between operator messages - a session-only cron job fires every ~20 minutes, and each fire follows a fixed protocol (count, orient from a state file, run checks, zoom out against the goal every few fires, take one verified step, record STATE and findings) against a per-work file holding goal, constraints, escalation, checks and an ordered queue. Survives compaction and resume through a registry and a hook. Invoke as /heartbeat start, pause, resume, cadence, status or stop, or when the operator asks the agent to keep working autonomously, check in periodically, or carry a long task forward unattended. Not for watching one process's output (use Monitor) or a single reminder (use a one-shot CronCreate).
---

# /heartbeat - unattended progress, one verified step at a time

A heartbeat has three parts:

- **A file** for the work, made from `template.md`: goal, done condition, constraints, what is allowed without
  asking, escalation, checks, an optional knowledge log, an ordered queue, and STATE lines. It is the only state a
  fire relies on, so the work survives compaction.
- **A cron job** in the session (session-only, recurring) whose prompt names the heartbeat and points at
  `protocol.md` and the file. Every fire follows `protocol.md`, so improving the protocol improves every heartbeat.
- **A registry entry** (`heartbeat.py`, in `~/.claude/heartbeats/registry.json`). The hook reads it at SessionStart,
  to have the session re-create jobs that died with a restart or expire after 7 days, and at PreCompact, to make the
  summary carry unrecorded state and findings.

`HB` below is `python3 ~/.claude/skills/heartbeat/heartbeat.py`.

## One-time setup

The hook must be registered once in `~/.claude/settings.json`, for both `SessionStart` and `PreCompact`, as the
command `python3 ~/.claude/skills/heartbeat/heartbeat.py hook`. Check with `grep heartbeat.py ~/.claude/settings.json`;
add it if missing (the update-config skill covers editing settings). Without it a heartbeat stops at the first
compaction or restart.

## Reaching the operator

`HB notify "TITLE" --body "TEXT"` is how every heartbeat contacts the operator outside the session. It runs the
channels in `$HEARTBEAT_HOME/notify.json` in order and stops at the first that delivers: a channel delivers when it
exits 0 and, if it names an `ok` field, prints JSON whose field is at least 1 (a push that reached no device has not
reached anyone). `{title}`, `{body}` and `{short}` (title and body, cut to the channel's `max`) are filled into
`argv`. Put the free channel first and a paid one after it as the fallback:

```json
{"channels": [
 {"name": "push", "ok": "sent", "argv": ["/path/to/push-command", "{title}", "--body", "{body}"]},
 {"name": "sms", "max": 160, "argv": ["/path/to/sms-command", "{short}"]}
]}
```

A title over 80 characters or a body over 240 is refused before any channel runs, so a message too long for the
first channel never falls through to a paid one.

## Commands

**start NAME** (or "keep working on this while I'm away"):

1. Draft the file from `template.md`, filling it from the conversation: the goal as the operator stated it, the
   constraints they have given, how they want to be reached. Put it where the work lives (a repository's docs, or a
   working directory the operator uses for notes); not in /tmp.
2. Show the operator the Goal, Done when, Constraints, Allowed without asking and Escalation sections inline and ask
   them, in prose, to correct anything. These decide what the agent does unattended, so do not start on guesses for
   them. Checks and the queue can be the agent's own first draft.
3. Register: `HB start NAME --file PATH [--cron '7,27,47 * * * *' ...] [--log PATH] [--zoom-every 6] [--at WHEN]
   [--exact]` (the session id is read from `CLAUDE_CODE_SESSION_ID`). `--cron` repeats for a heartbeat that fires on
   several schedules (hourly by day, every half hour by night). `--at WHEN` queues the start ("YYYY-MM-DD HH:MM", or
   "HH:MM" for the next such time): the heartbeat waits paused and its first fire is at WHEN. `--exact` fires on the
   crons' minutes on the dot (below). It prints the crons, the prompt and `create`, the jobs to make.
4. CronCreate each job in `create` with that prompt (durable false, recurring or one-shot as given). Then
   `HB renewed NAME --job ID1 [--job ID2 ...]` with every job's id.
5. Tell the operator the job's next run time from CronCreate's result, that it runs only while this session is open
   and idle, and how to pause it.

**pause NAME [until WHEN]**: finish and record the step in progress, CronDelete its jobs (ids in `HB status`, or from
CronList), then `HB pause NAME`, or `HB pause NAME --until WHEN` when the operator names when to continue. For the
latter, CronCreate the one-shot in the output's `create` and run `HB renewed NAME --job ID`: the first fire at WHEN
resumes the heartbeat.

The agent pauses a heartbeat on its own only through `HB idle NAME --blocked q1=REASON ...` (protocol.md step 5),
which refuses while a queue item has no stated blocker or a Fallback work command lists an item; its STATE line
records what was checked.

**resume NAME**: `HB resume NAME`, then CronCreate each job in its `create` with `HB prompt NAME`, then
`HB renewed NAME --job ID1 [--job ID2 ...]`.

**cadence NAME CRON ...**: `HB cadence NAME --cron CRON [--cron CRON2 ...] [--exact | --no-exact]` (keeps the fire
count, log and zoom-out interval), CronCreate each job in the `create` it prints with its prompt, CronDelete the old
jobs, `HB renewed NAME --job ID1 [--job ID2 ...]`.

**status**: `HB status` and CronList side by side; say which registered heartbeats have no live job and why
(paused, or needing re-creation).

**stop NAME**: CronDelete its jobs, `HB stop NAME`, and add a final STATE line to the file saying it was stopped and
why.

## Exact times, queued starts and restarts

The scheduler shifts a recurring job by up to half its period (an hourly job on minute 0 fired at :11). When the
operator wants fires on the dot, use `--exact`: the heartbeat then holds one one-shot job at a time, at the crons'
next minute (a one-shot runs at most 90 s early), and every fire's `tick` names the next one in `create`, which the
fire creates first (protocol.md, step 1), so the chain is kept by code. `HB next 'CRON' [--after WHEN]` shows when a
cron expression next matches.

Jobs are session-only. The SessionStart hook reads the registry and tells the session that registered a heartbeat
which jobs to create after a restart that resumes it: the recurring jobs, the next exact one-shot (the next slot, not
the missed ones), or the one-shot at the end of a timed pause or queued start (at once when that time passed while
the session was down). A new session does not take over another session's heartbeats.

## Choosing the cadence

Pick minutes off :00 and :30 unless the operator asks for them. Twenty minutes suits work with runs or reviews to watch; hourly suits slow external
waits. The protocol slows a job down after three quiet fires in a row.

## Limits to tell the operator

- It runs only while the Claude Code session is open, and a fire waits until the session is idle. It survives a
  restart that resumes the session (the hook re-creates its jobs), not a new session.
- Every fire costs tokens, quiet ones included.
- Tool permissions must already allow the work, or each fire stops at a prompt nobody answers.
- The agent acts within the file's Constraints and Allowed sections; anything else waits for the operator.

## Maintaining this skill

`heartbeat.py` is checked by `python3 ~/.claude/skills/heartbeat/test_heartbeat.py` (each check on a temporary
registry). Run it after any change, and see a check fail on a wrong version before trusting a new one.

Files in this skill

  • README.md3 KB
  • SKILL.md4.9 KB
  • heartbeat.py12.1 KB
  • protocol.md5.8 KB
  • template.md1.9 KB
  • test_heartbeat.py9 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.