Agent Loop
Run Clew Code autonomously with a 24/7 background agent loop.
Overview
The autonomous agent loop runs Clew Code continuously in the background, processing tasks from a persistent queue. It's ideal for monitoring, scheduled maintenance, automated code review, and recurring development workflows.
Loop Commands
❯ /loop start # start the autonomous loop
❯ /loop stop # stop the loop
❯ /loop status # check loop status and queue depth
Loop Skill
Use the built-in loop skill to run recurring requests:
❯ /loop 5m /check-status # run /check-status every 5 minutes
❯ /loop 1h "summarize recent changes"
Default interval is 10 minutes if not specified.
Task Queue
The loop integrates with the daemon's persistent task queue:
- Lease-based concurrency — up to 3 workers run simultaneously
- Exponential backoff — retries with increasing delays on failure
- Dead-letter queue — failed tasks are stored for later analysis
Cron Scheduling
Schedule recurring tasks with cron expressions:
❯ /task add "0 9 * * 1-5" "weekday morning review"
❯ /task add "0 0 * * 0" "weekly cleanup"
Use Cases
- Automated code review on schedule
- Dependency update checks
- Performance monitoring and alerting
- Scheduled documentation generation
- Automated testing and regression checks