Nightly Learn-and-Ship Loop — Make Your Agent Learn While You Sleep
Summary
A two-phase nightly automation loop that separates learning from execution:
- 10:30 PM — Compound Review: reviews all Claude Code threads from the last 24 hours, extracts patterns, gotchas, and learnings, then writes them into AGENTS.md / CLAUDE.md instruction files.
- 11:00 PM — Auto-Compound: pulls latest code (now containing fresh learnings), picks the #1 priority task from reports, implements it, and opens a PR.
Mental model: the nightly loop is a two-stroke engine. First stroke compresses the day’s experience into fuel (updated instructions). Second stroke burns that fuel to do real work. The order is the insight — if you reverse them, the implementation job runs on yesterday’s knowledge instead of today’s.
Built on three projects: Compound Engineering Plugin (@kieranklaassen), Compound Product (the automation layer), and Ralph (the autonomous agent loop that executes).
Why This Was Bookmarked
This is what we’re building toward with the 4am restart + /check-board. The two-phase pattern — learn first, then execute — is the missing piece. Our current setup restarts and picks up tasks, but doesn’t have a structured “extract learnings from the day” step before execution begins.
Key Ideas
- Sequence matters: review job updates instructions before the implementation job runs, so new work benefits from fresh learnings
- Separation of concerns: learning and shipping are different jobs on different schedules (30 min gap)
- CLAUDE.md as compounding artifact: instruction files get smarter every night without human intervention
- Three-project stack: plugin (Compound Engineering) + automation layer (Compound Product) + agent loop (Ralph) — each layer has a clear responsibility
- Thread review as data source: the raw material for learning is the day’s conversation history, not just code diffs
Connections
Direct extension of 06-reference/2026-04-04-compound-engineering — Kieran’s plugin provides the “Compound” step, and this wraps it in a nightly automation. The four-step loop (Plan > Work > Review > Compound) is now running unattended.
This is 06-reference/concepts/compounding-knowledge in its purest automated form. The knowledge base literally improves itself every night.
Connects to our infrastructure at 04-tooling/2026-03-29-infrastructure-decisions — we already have the LaunchAgent + tmux + 4am restart pattern. Adding a “compound review” phase before /check-board would give us the same two-stroke architecture.
See SOUL.md operating model layer 3 (dedicated instances via LaunchAgent + tmux) — this nightly loop is exactly the kind of always-on worker we’re designed for.
The thread review concept relates to 06-reference/2026-04-04-karpathy-llm-wiki-idea-file — both are about extracting durable knowledge from ephemeral interactions. Karpathy’s idea file is manual; this automates the extraction.
See 06-reference/concepts/skills-as-building-blocks — the three-project stack (plugin + automation + agent) is a layered skill architecture. Each piece is reusable independently.
See also 06-reference/2026-04-04-superpowers-plugin-analysis — another plugin-based approach to extending Claude Code. The Compound Engineering Plugin is narrower in scope but deeper in its domain.
Open Questions
- Can we add a “compound review” step to our 4am restart, running before /check-board?
- What’s our equivalent of “review all threads from last 24 hours”? Do we have access to session history programmatically?
- Should the learnings go into CLAUDE.md (global) or into vault docs (searchable, linked)?
- The 30-minute gap between review and execution — is that necessary, or could they chain directly?
- How do we avoid instruction bloat? CLAUDE.md getting longer every night needs a pruning mechanism.
- Could our vault compilation pass (/compile-vault) serve as the “compound review” if we extend it to read session logs?