Skip to content

thefiredev-cloud/claude-code-autonomous-24-7

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Autonomous 24/7 Claude Code Setup

Complete autonomous operation system for Claude Code with time-based, event-based, and queue-based task processing.

πŸ“¦ What's Installed

MCP Servers

  1. scheduler-mcp - Time-based task triggers (cron expressions)
  2. bullmq-mcp - Task queue management with Redis
  3. sqlite - Persistent state storage
  4. webhook-mcp - Event-based triggers

Infrastructure

  • Redis - Running in Docker on port 6379
  • SQLite Database - autonomous-state.db for persistent storage

Scripts

  • orchestrator.py - Python orchestration engine
  • orchestrator.ts - TypeScript orchestration engine (alternative)
  • start.bat - Quick start script
  • test-task.bat - Test autonomous operation
  • manage-safety.bat - Safety controls management

Safety Controls

  • Rate limiting (20 tasks/hour, 200 tasks/day)
  • Circuit breaker (stops after 5 consecutive failures)
  • High-risk operation detection
  • Audit logging

πŸš€ Quick Start

Option 1: Test Mode (Recommended First)

cd C:\Users\Tanner\.claude\autonomous
.\test-task.bat

This runs a simple health check task to verify everything works.

Option 2: Start Orchestrator

.\start.bat

Choose Python (P) or TypeScript (T) version when prompted.

πŸ“‹ Architecture

Three Deployment Models

1. Simple Cron-Based ⭐ EASIEST

  • Uses Windows Task Scheduler
  • Claude Code CLI in headless mode
  • Each run is independent

Setup:

  1. Open Task Scheduler
  2. Create new task
  3. Set trigger (e.g., hourly)
  4. Action: claude -p "your task" --output-format stream-json

2. Always-On Service ⭐ RECOMMENDED

  • Orchestrator runs continuously
  • Monitors all trigger types
  • Full state management

Setup:

# Start the orchestrator
cd C:\Users\Tanner\.claude\autonomous
python orchestrator.py

# Or with PM2 for auto-restart:
npm install -g pm2
pm2 start orchestrator.py --name claude-autonomous
pm2 save

3. Hybrid

  • CLI for simple tasks
  • Service for complex workflows
  • Shared state via database

πŸ”§ Configuration

Safety Settings

Edit safety-config.json:

{
  "maxTasksPerHour": 20,
  "maxTasksPerDay": 200,
  "maxConsecutiveFailures": 5,
  "circuitBreakerThreshold": 10
}

Manage safety controls:

.\manage-safety.bat

MCP Configuration

MCPs are configured in .claude.json:

  • scheduler-mcp: C:\Users\Tanner\.claude\mcp-servers\scheduler-mcp
  • bullmq-mcp: Connected to Redis at redis://localhost:6379
  • sqlite: Database at C:\Users\Tanner\.claude\autonomous-state.db
  • webhook-mcp: Ready for webhook events

πŸ“Š Monitoring

View Logs

type C:\Users\Tanner\.claude\autonomous\orchestrator.log

Check Safety Status

.\manage-safety.bat
# Choose option 1: View Current Status

View Task History

Stored in SQLite database - use SQLite MCP to query.

πŸ”’ Safety Features

Rate Limiting

  • Hourly: Max 20 tasks
  • Daily: Max 200 tasks
  • Automatically resets every hour/day

Circuit Breaker

  • Opens after 5 consecutive failures
  • Requires manual reset
  • Prevents runaway operations

High-Risk Detection

Warns on operations like:

  • rm commands
  • Docker removals
  • Force git pushes
  • .env file modifications

Manual Reset

.\manage-safety.bat
# Choose option 2: Reset Circuit Breaker

πŸ“ Creating Custom Tasks

Schedule a Task

Use scheduler MCP to create cron-based tasks:

// Add to orchestrator
const task = {
  name: "daily_backup",
  cron: "0 0 * * *",  // Daily at midnight
  prompt: "Create a backup of important files and report status"
};

Add Queue Task

Use BullMQ MCP to add jobs:

// Via Claude Code
await bullmq.addJob({
  name: "process_data",
  priority: 1,
  data: { source: "api", destination: "database" }
});

Webhook Trigger

Configure webhook MCP with your webhook URL:

# Set environment variable
setx WEBHOOK_URL "https://your-webhook-service.com/notify"

🎯 Use Cases

1. Code Monitoring

Monitor GitHub repos for issues and auto-create PRs for fixes.

2. Content Pipeline

Scrape web β†’ analyze β†’ generate reports β†’ deploy to Netlify.

3. DevOps Automation

Monitor logs β†’ detect issues β†’ investigate β†’ fix automatically.

4. Data Processing

Scheduled ETL, analysis, and reporting.

5. Testing

Continuous test generation and execution.

🐳 Docker Redis Management

Start Redis

docker start redis-autonomous

Stop Redis

docker stop redis-autonomous

View Redis Logs

docker logs redis-autonomous

Redis Health Check

docker exec redis-autonomous redis-cli ping
# Should return: PONG

πŸ› οΈ Troubleshooting

Orchestrator Won't Start

  1. Check Redis is running: docker ps | grep redis
  2. Check Python dependencies: cd C:\Users\Tanner\.claude\mcp-servers\scheduler-mcp && .venv\Scripts\python -m pip list
  3. View logs: type orchestrator.log

Circuit Breaker Open

  1. Check logs for error pattern: type orchestrator.log | findstr ERROR
  2. Fix underlying issue
  3. Reset breaker: .\manage-safety.bat β†’ Option 2

Tasks Not Executing

  1. Check rate limits: .\manage-safety.bat β†’ Option 1
  2. Verify MCP servers: claude mcp list
  3. Test manually: .\test-task.bat

Redis Connection Failed

  1. Restart Redis: docker restart redis-autonomous
  2. Check port 6379 is available: netstat -an | findstr 6379
  3. Verify REDIS_URL in .claude.json

πŸ“š Documentation Links

πŸ” Security Best Practices

  1. Review All Tasks before enabling autonomous mode
  2. Set Conservative Rate Limits initially
  3. Monitor Logs Daily for first week
  4. Test in Isolation before production use
  5. Keep API Keys Secure - never commit to git
  6. Enable Audit Logging for all operations
  7. Use Manual Approval for high-risk operations

πŸ’° Cost Estimates

Basic Setup

  • Claude API: $3-15 per 1M tokens
  • Infrastructure: $0 (local Docker)
  • Total: ~$10-50/month depending on usage

Production Setup

  • Claude API: $50-200/month
  • VPS: $20-50/month
  • Monitoring: $20-50/month
  • Total: ~$90-300/month

πŸ“ž Support

For issues or questions:

  1. Check logs: orchestrator.log
  2. Run diagnostics: claude doctor
  3. View MCP status: claude mcp list
  4. Test manually: .\test-task.bat

πŸŽ‰ Next Steps

  1. Test the Setup: Run .\test-task.bat
  2. Create Your First Task: Modify orchestrator.py with your use case
  3. Monitor for a Day: Watch logs and safety status
  4. Gradually Increase Limits: As confidence grows
  5. Add More Tasks: Build your autonomous workflows

Version: 1.0.0 Created: 2025-10-07 Platform: Windows with Docker

Happy automating! πŸ€–βœ¨

About

Complete autonomous 24/7 operation system for Claude Code with MCPs, task scheduling, queue management, and safety controls

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors