From clayworks-lite
Reference for the heartbeat pattern — a cadenced loop of observe + reflect + update that keeps an agent's state coherent across sessions. Use when the user asks about agent self-observation, daily/weekly cycles, reflection cadences, the "heartbeat" pattern, drift detection, or how to make Claude Code reflect on its own state between sessions. Concept reference only — production implementation ships in the paid Clayworks bundle; this doc is enough to roll your own.
How this skill is triggered — by the user, by Claude, or both
Slash command
/clayworks-lite:clayworks-lite-heartbeat-conceptThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
A **heartbeat** is a structured, cadenced loop that keeps an agent's state coherent over time. Without it, what was "current" two weeks ago feels like "current" now — and drift accumulates silently until something breaks.
A heartbeat is a structured, cadenced loop that keeps an agent's state coherent over time. Without it, what was "current" two weeks ago feels like "current" now — and drift accumulates silently until something breaks.
This document explains the pattern. The full production implementation — telemetry schema, trust ledger, three-tier observability, daily-cycle templates — ships in the paid Clayworks bundle. You do not need that to start. A minimum-viable heartbeat takes one file and three lines of discipline.
Every heartbeat — regardless of cadence or sophistication — does three things on a repeating schedule:
NOW.md-style anchor. The reflection escapes the conversation and survives the next compaction.Skip any of the three and the pattern degrades:
If you use Claude Code (or any agent) for real work over weeks, you've hit these:
A heartbeat addresses all four. It's the discipline of deliberate re-anchoring on a schedule, instead of hoping the right memory surfaces when needed.
Different problems need different beats. Use what fits the work:
clayworks-lite-nudge skill is one example)LITE scaffolding: hooks/examples/userpromptsubmit.sh is the contract reference for this cadence — payload shape, common patterns, exit behavior. The Nudge skill ships a working consumer of that contract.
Good for: keeping context fresh without per-prompt overhead the user feels.
LITE scaffolding: hooks/examples/stop.sh is the contract reference — payload shape, the gated 24h trigger pattern, and how to spawn background work without blocking CC's exit.
Good for: catching regressions and silent failures before they accumulate.
LITE scaffolding: hooks/examples/sessionend.sh is the contract reference for the evening tail. Pair with hooks/examples/sessionstart.sh for the session-open counterpart that surfaces unfinished threads at the next session's open — the closest CC-native approximation of a morning beat.
Good for: clean session boundaries. Single highest-impact cadence if you only have time for one.
LITE scaffolding: Daily beats run outside CC's hook lifecycle — schedule via cron (macOS/Linux) or Task Scheduler (Windows). For session-coupled approximations (fire on session open/close instead of fixed clock time), see hooks/examples/sessionstart.sh and hooks/examples/sessionend.sh. Weekly and monthly beats are also out-of-CC; same scheduler options apply.
Good for: turning the agent into something between a journal and an operations runner. The daily pair is where most users feel the biggest leverage.
Good for: pattern recognition and rule promotion. Stops CLAUDE.md drift.
Good for: preventing the agent's "model of you" from going stale as your life evolves.
You don't need three tiers, a trust ledger, or telemetry to start. Begin with:
One file: ~/agent/STATE.md (or wherever you keep "what's current"). Plain markdown.
One discipline: at the end of each working session, run a three-step prompt:
~/agent/STATE.mdThat's it. Three lines, one file, no plugins. The pattern works.
Starter template ships in this repo at templates/STATE.md.example — copy to ~/agent/STATE.md (or wherever you want it) and customize. Five sections: What's current / Open threads / Decisions made recently / Pending decisions / Stale items pruned this session. Each section's HTML comment explains what belongs there.
When the discipline holds: add a morning beat (read STATE.md → set focus for the day) before opening any project. Then a weekly beat (review past 7 days of STATE.md history → prune + promote rules). Each addition compounds.
What NOT to make a heartbeat do:
LITE ships this concept doc; the full production heartbeat system is in the paid Clayworks bundle:
You can build all of this yourself from the pattern above. The bundle ships one version of it that's been hardened over months of daily use.
Trigger conditions:
clayworks-lite-nudge — provides the cadence-trigger mechanism (time-based pings via UserPromptSubmit hook). A morning beat scheduled via Nudge fires reliably without depending on the user remembering.clayworks-lite-memory-routing — the heartbeat's "update" step has to write somewhere. Routing decides which memory layer absorbs each piece of consolidated state.The three LITE skills compose: routing answers where state goes, Nudge answers when the beat fires, heartbeat-concept answers what the beat does.
Fetches up-to-date documentation from Context7 for libraries and frameworks like React, Next.js, Prisma. Use for setup questions, API references, and code examples.
Applies a firm's KYC/AML rules grid to parsed onboarding records: assigns risk rating, checks required documents, outputs rule outcomes with citations, and routes for escalation.
Generates daily or weekly digests of activity from connected sources (chat, email, docs, tasks, CRM), highlighting action items, decisions, mentions, and project updates.
npx claudepluginhub clayboicardi/clayworks-lite --plugin clayworks-lite