Most developers use AI agents reactively - you prompt, it responds, you move on.
But what if your agent kept working after you closed your laptop?
What if it reviewed the day's work, extracted lessons, updated its own instructions, and then picked up the next feature from your backlog?
That's what I've built: a nightly loop where my agent learns from every thread, compounds that knowledge into persistent memory, and then ships the next priority item - all while I sleep.
Here's how to set it up.
This setup builds on three open-source projects:
- Compound Engineering Plugin by @kieranklaassen - The original compound engineering skill for Claude Code. Install it to give your agent the ability to extract and persist learnings from each session.
- Compound Product - The automation layer that turns prioritized reports into shipped PRs. Includes the auto-compound.sh script, execution loop, and PRD-to-tasks pipeline.
- Ralph - An autonomous agent loop that can run continuously, picking up tasks and executing them until complete.
Using Claude Code? This guide uses Amp, but the same workflow works with Claude Code. Replace `amp execute` with `claude -p “...” --dangerously-skip-permissions`, and update AGENTS.md references to CLAUDE.md.
The Two-Part Loop
The system runs two jobs in sequence every night:
10:30 PM - Compound Review
Reviews all threads from the last 24 hours, extracts learnings, and updates AGENTS.md files.
11:00 PM - Auto-Compound
Pulls latest (with fresh learnings), picks #1 priority from reports, implements it, and creates a PR.
The order matters. The review job updates your AGENTS.md files with patterns and gotchas discovered during the day. The implementation job then benefits from those learnings when it picks up new work.