A nighttime maintenance cycle for agents that wake up smarter, cleaner, and ready to work.
Every day, Claude Code accumulates a little more entropy. Stale memory entries. Unused hooks. Bloated CLAUDE.md files. Repeated frustrations that never get addressed.
Today, this configuration rot is your problem. You're the one who notices the agent keeps making the same mistake. You're the one who cleans up.
"Token anxiety" — the nagging feeling that your agents are doing nothing while you're sleeping.
But in biology, every organism has a solution to entropy. It's called sleep.
During sleep, your brain runs the most sophisticated maintenance cycle in nature:
Sleep is the price the brain pays for plasticity. Without it, the system degrades. With it, the system compounds.
Your immune system never attacks on a single signal. It requires co-stimulation — two independent signals confirming the threat before deploying a response.
Our sleep agent follows the same principle:
This prevents hallucinated improvements from single-session noise.
Two signals = 0.65 confidence. Three+ signals = 0.85. Cross-session + cross-pattern = 0.95.
Ant colonies coordinate through pheromone trails. Popular paths get reinforced. Abandoned paths evaporate. No central coordinator needed.
Every artifact in our system has a relevance score that decays each cycle:
relevance = 0.9 × previous + reinforcement
Used artifacts get reinforced (+1.0). Unused artifacts fade. Below 0.2? Pruned.
This mirrors Tononi's synaptic homeostasis hypothesis: sleep exists to downscale synaptic strength, keeping only what matters.
Daytime — Braintrust CC plugin captures every session automatically. Online scorers analyze each trace in real-time.
Nighttime — The sleep cycle runs:
Each stage gets escalating capability. Haiku does cheap measurement. Sonnet does focused repair. Opus does creative synthesis.
Structured JSON output at every stage. Least-privilege tool access. Full traceability in Braintrust.
Same task. Before sleep and after. Measured in Braintrust.
The sleep agent created targeted memory entries, pruned stale context, and added rules that eliminated redundant tool calls. The agent woke up knowing things it had to rediscover before.
Built in one hackathon day, using Claude Code itself.
300+ sources across neuroscience, immunology, ecology, and distributed systems:
The bridge isn't in any of the stones. It's in the leaning.
Your agents are healing. Your agents are growing.