agentleFS
b1rdmaniab1rdmania/ghostclaw/.claude/skills/add-heartbeat/SKILL.md

add-heartbeat

Skill91 starsChanged 7 months agoMITView on GitHub

Add a heartbeat system that periodically checks a HEARTBEAT.md checklist and only alerts the user when something needs attention. Inspired by OpenClaw's heartbeat pattern.

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 6 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

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

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

    Check if groups/main/HEARTBEAT.md exists.

    line 20
  2. Distinctive:

    Use AskUserQuestion to ask:

    line 74
  3. Distinctive:

    Update HEARTBEAT.md with their answers.

    line 78
  4. Distinctive:

    Write an IPC task file to register the heartbeat:

    line 82
  5. Distinctive:

    Wait for the next cron trigger (or manually create a test by adding a failing check to HEARTBEAT.md), then check logs:

    line 101
  6. Distinctive:

    Check Gmail for emails from specific senders

    line 115
  7. Distinctive:

    Check crypto prices via API

    line 116

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “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

Add Heartbeat

Adds a periodic heartbeat that wakes the agent on a cron schedule, runs through a checklist of cheap checks, and only messages the user if something needs attention.

What it does

  1. Creates groups/main/HEARTBEAT.md with a template checklist
  2. Registers a scheduled task that runs the heartbeat on a cron (default: every 30 minutes)
  3. The agent reads the checklist, runs each check, and stays silent if everything is fine

Setup

1. Create HEARTBEAT.md (if not exists)

Check if groups/main/HEARTBEAT.md exists. If not, create it with this template:

# Heartbeat Checks

Run these checks silently. Only message the user if something actually needs their attention.

## Checks

### 1. Error Log

\`\`\`bash
tail -20 ~/nanoclaw/logs/errors.log
\`\`\`

- Each line is JSON with a `"time"` field (Unix ms).
- Calculate cutoff: `Date.now() - (35 * 60 * 1000)`.
- **Ignore** any entry where `time < cutoff`. Don't mention ignored entries at all.
- If the file is empty or all entries are old, this check passes silently.
- If recent errors exist, summarise the actual problem in one line.

### 2. Runaway Processes

\`\`\`bash
ps aux -r | head -5
\`\`\`

- Check if any process is using >90% CPU.
- Chrome/agent-browser processes that have been running for hours are zombies — kill them:
  \`\`\`bash
  pkill -9 -f "agent-browser-chrome"
  \`\`\`
- Alert the user: "Killed zombie Chrome process (was using X% CPU)."
- Also check load average (`uptime`). If load >4, mention it.

### 3. Disk Space

\`\`\`bash
df -h /
\`\`\`

- Alert if usage >80%. State the percentage and partition.

## Rules

- **Silent by default.** If everything is fine: `<internal>All checks passed</internal>` — nothing else.
- **Never explain your reasoning.** Just do the checks and report problems.
- **Never report old/filtered entries.** If an entry is too old, pretend it doesn't exist.
- When alerting, state the problem in plain English, one or two lines max.
- Don't repeat alerts already visible in recent conversation history.

2. Ask the user

Use AskUserQuestion to ask:

  • How often should the heartbeat run? (Every 30 minutes / Every hour / Every 2 hours)
  • Any specific checks to add? (URLs to ping, services to monitor, etc.)

Update HEARTBEAT.md with their answers.

3. Register the scheduled task

Write an IPC task file to register the heartbeat:

mkdir -p data/ipc/main/tasks
cat > "data/ipc/main/tasks/heartbeat_$(date +%s).json" << 'EOF'
{
  "type": "schedule_task",
  "prompt": "Read $GHOSTCLAW_GROUP_DIR/HEARTBEAT.md (or ./HEARTBEAT.md in the current directory) and run each check listed. Only message the user if something needs attention. If everything is fine, respond with <internal>All checks passed</internal> and nothing else.",
  "schedule_type": "cron",
  "schedule_value": "*/30 * * * *",
  "context_mode": "isolated"
}
EOF

Adjust the cron value based on the user's preference.

4. Verify

Wait for the next cron trigger (or manually create a test by adding a failing check to HEARTBEAT.md), then check logs:

grep -i "heartbeat\|All checks passed" ~/nanoclaw/logs/ghostclaw.log | tail -5

Customisation

Users can edit HEARTBEAT.md at any time to add, remove, or modify checks. The agent reads it fresh each time. No restart needed.

Examples of checks to add:

  • curl -s https://yoursite.com -o /dev/null -w '%{http_code}' — website uptime
  • gh pr list --state open --repo yourorg/yourrepo — open PRs
  • cat /path/to/some/log | grep ERROR | tail -5 — application errors
  • Check Gmail for emails from specific senders
  • Check crypto prices via API

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.