Autonomous Daemon Mode

Run Claude Code as a 24/7 background daemon — task queue, agent loop, health checks, and supervisor auto-respawn for unattended autonomous operation.

The autonomous system lives in src/services/autonomous/ and consists of four main components: the task queue, agent loop, daemon entry point, and supervisor integration.

Architecture

  ┌─ Task Queue (taskQueue.ts)
  │    File-backed persistent queue
  │    Priorities · Leases · Dead-letter
  │
  ├─ Agent Loop (agentLoop.ts)
  │    Dequeue → Spawn worker → Monitor → Retry
  │
  ├─ Daemon Mode (daemonMode.ts)
  │    Background process entry point
  │
  └─ Supervisor (supervisorIntegration.ts)
       Health checks · Auto-respawn · State tracking

Task Queue

The file-backed persistent queue (src/services/autonomous/taskQueue.ts) is the foundation of the autonomous system:

Agent Loop

The continuous agent loop (src/services/autonomous/agentLoop.ts) runs in the background:

  1. Dequeue — Pull the highest-priority ready task
  2. Spawn worker — Launch a worker session for the task
  3. Monitor — Track progress, streaming output, and resource usage
  4. Retry or complete — On failure, retry with backoff; on success, record result
  5. Repeat — Check for new tasks and repeat the cycle

Daemon Entry Point

src/services/autonomous/daemonMode.ts provides the background process entry point. When started in daemon mode, Claude Code:

Supervisor Integration

src/services/autonomous/supervisorIntegration.ts ensures the daemon stays running:

Commands

CommandDescription
/daemonOpen interactive control panel; subcommands: start, stop, status, restart
/taskCreate scheduled or recurring tasks via interactive form
/task listList queued, running, and completed tasks
/loopRun a prompt or command on a recurring interval (/loop 5m /check-deploy)
/agentsManage agent configurations and daemon worker pools
/tasksList and manage background agent tasks

Task Scheduling

Scheduled tasks can be created through the interactive /task form or programmatically. Storage modes:

Recurring tasks auto-expire after 30 days. One-shot tasks auto-delete after firing. Custom cron expressions are supported (standard 5-field format).

/task
  Name: Deploy health check
  Schedule: Daily
  Time: 09:00
  Prompt: Check deployment status and report
  Storage: Durable

Architecture Files

FileRole
src/services/autonomous/taskQueue.tsPersistent task queue with priorities, leases, dead-letter
src/services/autonomous/agentLoop.tsContinuous 24/7 agent loop
src/services/autonomous/daemonMode.tsBackground daemon entry point
src/services/autonomous/supervisorIntegration.tsHealth checks, auto-respawn, state tracking