agentleFS
bradbushSFAIbradbushSFAI/nolty/skills/heartbeat/SKILL.md

heartbeat

Skill1 starsChanged 6 months agoMITView on GitHub

Nolty's every-30-min self-check during waking hours. Detects Claude Code version drift and self-heals. Scans urgent email + upcoming meetings, alerts via Telegram if something needs attention.

20 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use ecosystem-reference, fractal-delegation and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • naman10parikhSkill

    ecosystem-reference

    Quick-access directory of Claude Code ecosystem repos, skills, plugins, MCPs, and patterns. Use when improving the harness.

    Also in 5 projects that use this

  • naman10parikhSkill

    fractal-delegation

    Also in 5 projects that use this

  • roronoazoroshao369Skill

    memory-compression

    Also in 5 projects that use this

  • KirchliveSkill

    skill-routing

    Decides which of the installed skills a task needs and loads them before the work starts. This skill should be used at the beginning of any multi-step task — build, fix, refactor, migrate, review, plan, release, research, write, design, video — and again at every phase change, after context compaction, and when work moves into a different part of the codebase. Use it for requests like "let's build X", "fix this bug", "refactor Y", "plan the migration", "review this", and also when the user asks which skill applies, why a skill did not fire, or asks to check what is available.

    Also in 5 projects that use this

  • sublimotionSkill

    agent-runtime

    Launch and manage detached agent runs on EKS via the agent-runner CLI. Use when the user says "launch an agent run", "agent runtime", "agent-runner", "run this spec on the cluster", "check run status", "agent run logs", or "stop a run". Do NOT use for writing the agent-runner code itself (edit the sibling ../agent-runner repo), Terraform of the foundation (use terraform-automation), or GPU serving deployments (use infra-deployer).

    Also in 5 projects that use this

  • GoZippySkill

    repo-scout

    Also in 5 projects that use this

  • +5 more from naman10parikh

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 0 are distinctive, and 7 are very specific to this project.

  • 0

    Common

    Most of the 19 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    If you see a [cron model:X effort:Y] suffix, you were fired by cron-runner.py.

    line 10
  2. Very specific:

    If hour < 7 OR hour >= 23 → QUIET HOURS.

    line 27
  3. Very specific:

    Attribution rule: When reporting a thread, show who sent the most recent message — not the thread starter.

    line 121
  4. Very specific:

    Only flag if diff_min is between 1 and 60 (inclusive)

    line 141
  5. Very specific:

    Check memory/heartbeat-state.json → remindedEvents — if already reminded, skip

    line 142
  6. Very specific:

    If a meeting was alerted, append it to memory/heartbeat-state.json → remindedEvents as "<title> <YYYY-MM-DD>" to prevent repeat pings.

    line 151
  7. Very specific:

    If nothing urgent, respond with HEARTBEAT_OK <timestamp from STEP 0> and exit.

    line 157

“Common” is measured: kept by at least 6 in 10 of the 19 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Heartbeat

You are Nolty, running a scheduled heartbeat.

If you see a [cron model:X effort:Y] suffix, you were fired by cron-runner.py. Spawn a Task sub-agent with the specified model + effort. The sub-agent runs the steps below and has access to your reply MCP tool.

cron-runner fires this every 30 minutes, 24/7 — so the skill itself gates off-hours. Never send a Telegram outside the user's active hours (see USER.md), even if something seems urgent.


STEP 0 — Time gate (do this FIRST, before anything else)

Get the current hour in the user's timezone (look up Timezone in USER.md; default America/Chicago):

TZ='America/Chicago' date '+%Y-%m-%d %H:%M %Z (hour=%H, dow=%u)'

Parse the hour=HH value as an integer.

Decision:

  • If hour < 7 OR hour >= 23 → QUIET HOURS. Respond with the exact text QUIET_HOURS <timestamp> and exit. Make NO further tool calls. No file reads. No email checks. No Telegram. Nothing.
  • Otherwise, continue to STEP 0.5.

This rule is absolute. Customize the 7/23 bounds by reading active hours from USER.md if set.


STEP 0.5 — Claude Code version-drift self-heal

Claude Code auto-upgrades its binary symlink. When an upgrade lands, the supervisor daemon self-restarts but Nolty's tmux-resident process stays on the OLD binary — the Telegram plugin's bridge breaks (inbound still works, outbound reply fails silently). Detect drift and trigger a detached restart.

Run this block:

PANE_PID=$(tmux list-panes -t CC_running_like_OC -F '#{pane_pid}' 2>/dev/null | head -1)
CLAUDE_PID=$(pgrep -P "$PANE_PID" -f 'claude.*--channels' 2>/dev/null | head -1)
RUNNING=$(lsof -p "$CLAUDE_PID" 2>/dev/null | grep -oE 'versions/[0-9]+\.[0-9]+\.[0-9]+' | head -1 | cut -d/ -f2)
LATEST=$(ls -1 ~/.local/share/claude/versions/ 2>/dev/null | sort -V | tail -1)
echo "claude version: running=$RUNNING latest=$LATEST"

if [ -n "$RUNNING" ] && [ -n "$LATEST" ] && [ "$RUNNING" != "$LATEST" ]; then
  NOLTY_HOME="${NOLTY_HOME:-$HOME/Documents/CodingProjects/nolty}"
  nohup "$NOLTY_HOME/clawd-restart.sh" > /tmp/heartbeat-restart-$(date +%s).log 2>&1 &
  disown 2>/dev/null
  echo "VERSION_DRIFT_RESTART_TRIGGERED running=$RUNNING latest=$LATEST"
  exit 0
fi

Decision:

  • RUNNING empty (couldn't detect) → continue. Don't fail just because detection failed.
  • RUNNING == LATEST → continue.
  • RUNNING != LATEST → restart triggered. Tmux session (and you) will die within seconds. Do NOT do other steps. Exit with VERSION_DRIFT_RESTART_TRIGGERED.

nohup ... & is critical — the restart script must survive the kill of its parent.


STEP 0.6 — Bun listener presence check

The Telegram plugin spawns a bun child process that long-polls Telegram for inbound messages. It dies silently under several conditions: Mac sleep/wake severs the TCP connection, CC binary swaps leave it zombie, the plugin's "experimental" channel gets unreliable over long uptime. When bun is dead, the main claude process is still alive — but inbound Telegram messages don't reach the agent. No error is surfaced anywhere.

Same self-heal pattern as STEP 0.5, but on a different signal.

Run this block:

NOLTY_HOME="${NOLTY_HOME:-$HOME/Documents/CodingProjects/nolty}"
BUN_PID=$(pgrep -f 'bun.*telegram' 2>/dev/null | head -1)
if [ -z "$BUN_PID" ]; then
  echo "BUN_LISTENER_MISSING — triggering restart"
  nohup "$NOLTY_HOME/clawd-restart.sh" > /tmp/heartbeat-bun-restart-$(date +%s).log 2>&1 &
  disown 2>/dev/null
  echo "BUN_RESTART_TRIGGERED"
  exit 0
else
  echo "bun listener alive (PID $BUN_PID)"
fi

Decision:

  • bun process found → continue to STEP 1.
  • bun process missing → detached restart triggered. Tmux + main claude + your own sub-agent will die within seconds when clawd-restart.sh kills the session. Do NOT continue. Exit with sentinel BUN_RESTART_TRIGGERED.

Same nohup ... & discipline as STEP 0.5 — the restart script must outlive its parent.

This catches the silent-Telegram-death failure mode within 30 min (the heartbeat cadence), the same way STEP 0.5 catches version drift.


STEP 1 — Identity refresh (only during active hours)

Briefly read these to stay grounded:

  • SOUL.md
  • IDENTITY.md
  • MEMORY.md

STEP 2 — Urgent unread email

/opt/homebrew/bin/gog gmail search "is:unread" --limit 10 --account YOUR_EMAIL@example.com

(Replace YOUR_EMAIL with the value from USER.md. If you don't use gog, substitute mcp__claude_ai_Gmail__search_threads.)

Flag only:

  • Client replies
  • Meeting reschedules / confirmations
  • Time-sensitive items (invoices due, deadlines, urgent requests from known contacts)

Skip: newsletters, promotions, automated notifications, OOO auto-replies, LinkedIn/Apollo summaries, LinkedIn InMail messages (any email from LinkedIn with "InMail" in subject or body).

Attribution rule: When reporting a thread, show who sent the most recent message — not the thread starter. Parse the From header of the newest unread message in the thread.


STEP 3 — Upcoming meeting (next 60 min)

/opt/homebrew/bin/gog calendar list --today --account YOUR_EMAIL@example.com

Compute time delta in bash — do NOT do mental math. For each event:

now_epoch=$(TZ='America/Chicago' date +%s)
meeting_time="HH:MM"  # replace with actual start time from calendar
meeting_epoch=$(TZ='America/Chicago' date -j -f "%Y-%m-%d %H:%M" "$(TZ='America/Chicago' date +%Y-%m-%d) $meeting_time" +%s)
diff_min=$(( (meeting_epoch - now_epoch) / 60 ))
echo "$diff_min minutes until meeting"
  • Only flag if diff_min is between 1 and 60 (inclusive)
  • Check memory/heartbeat-state.json → remindedEvents — if already reminded, skip
  • Skip all-day events and events already in progress (diff_min <= 0)

STEP 4 — Alert (only if anything from steps 2-3 needs attention)

Combine into ONE concise Telegram (under 300 chars, Markdown supported) and send via the reply MCP tool with chat_id from USER.md. Start with "❗" so the user sees urgency at a glance.

If a meeting was alerted, append it to memory/heartbeat-state.json → remindedEvents as "<title> <YYYY-MM-DD>" to prevent repeat pings.


STEP 5 — Silence

If nothing urgent, respond with HEARTBEAT_OK <timestamp from STEP 0> and exit. Do NOT send a silent Telegram.


Hard rules

  1. Quiet hours are absolute. Outside active hours → QUIET_HOURS and exit, no tool calls.
  2. Use the reply MCP tool for Telegram, not send-telegram.sh.
  3. Never send a silent "nothing to report" Telegram. Silence = HEARTBEAT_OK response only.
  4. Deduplicate meeting reminders via remindedEvents.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.