Sleep Agent
A nightly agent that reads the day's work, checks what it learned against live sources and rewrites its own long-term memory.
Abstract
An AI assistant forgets everything when a session ends. The Sleep Agent is the fix I run on my own machine: every night it reads the day's sessions, pulls out what should last, checks each claim against live sources and writes the result into a long-term memory that the next session loads.
It runs without me. Edits that pass the evidence rules are applied on the spot, anything that would change the agent's own configuration stays a proposal, and every night can be undone with one command.
Technical overview
- Schedule
- A scheduled job on macOS at 02:25, running Claude Code without a window and under its own restricted permissions.
- Edit rules
- Edits touch memory folders only. No deletes, a replace needs one exact match, and every edit carries its evidence.
- Memory
- Two layers: plain Markdown notes as the source of truth, mirrored into a local SQLite index with semantic search.
- Recall
- A hook retrieves the best matching notes for every new prompt, so the right memory arrives before the answer.
- Safety
- A snapshot before each apply, one-command undo, and 67 self-tests on the apply and scheduling scripts.