foryourhealth111-pixel/Vibe-Skills / bundled/skills/autonomous-builder
autonomous-builder
FlaggedFull-stack software development agent for design, implementation, testing, and deployment. Use when the user explicitly asks for end-to-end project creation, feature development, bug fixing, or code refactoring.
assets/auto-continue.sh
View on GitHub#!/bin/bash
# =============================================================================
# Auto-Continue Supervisor Script
# Generated by: autonomous-builder skill
# Purpose: Self-supervising long-running autonomous operation
# =============================================================================
# Configuration (will be replaced with actual values during initialization)
PROJECT_DIR="{{PROJECT_DIR}}"
BUILDER_DIR="$PROJECT_DIR/.builder"
STATE_FILE="$BUILDER_DIR/state.json"
SUPERVISOR_CONFIG="$BUILDER_DIR/supervisor.json"
LOG_FILE="$BUILDER_DIR/supervisor.log"
# Default monitoring settings
CHECK_INTERVAL=60
SESSION_TIMEOUT=300
MAX_RESTART_ATTEMPTS=10
RESTART_COOLDOWN=5
# =============================================================================
# Utility Functions
# =============================================================================
log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" | tee -a "$LOG_FILE"
}
load_config() {
if [ -f "$SUPERVISOR_CONFIG" ]; then
# Parse JSON config (simple grep-based parsing)
CHECK_INTERVAL=$(grep -o '"check_interval_seconds"[[:space:]]*:[[:space:]]*[0-9]*' "$SUPERVISOR_CONFIG" | grep -o '[0-9]*$')
SESSION_TIMEOUT=$(grep -o '"session_timeout_seconds"[[:space:]]*:[[:space:]]*[0-9]*' "$SUPERVISOR_CONFIG" | grep -o '[0-9]*$')
MAX_RESTART_ATTEMPTS=$(grep -o '"max_restart_attempts"[[:space:]]*:[[:space:]]*[0-9]*' "$SUPERVISOR_CONFIG" | grep -o '[0-9]*$')
RESTART_COOLDOWN=$(grep -o '"restart_cooldown_seconds"[[:space:]]*:[[:space:]]*[0-9]*' "$SUPERVISOR_CONFIG" | grep -o '[0-9]*$')
fi
}
get_project_status() {
if [ -f "$STATE_FILE" ]; then
grep -o '"status"[[:space:]]*:[[:space:]]*"[^"]*"' "$STATE_FILE" | head -1 | cut -d'"' -f4
else
echo "not_initialized"
fi
}
get_last_activity() {
if [ -f "$STATE_FILE" ]; then
grep -o '"last_activity"[[:space:]]*:[[:space:]]*"[^"]*"' "$STATE_FILE" | cut -d'"' -f4
else
echo ""
fi
}
get_pending_features_count() {
if [ -f "$STATE_FILE" ]; then
# Count pending features
python3 -c "
import json
with open('$STATE_FILE') as f:
state = json.load(f)
pending = [f for f in state.get('features', {}).get('pending', []) if f]
print(len(pending))
" 2>/dev/null || echo "0"
else
echo "0"
fi
}
get_session_count() {
if [ -f "$STATE_FILE" ]; then
grep -o '"session_count"[[:space:]]*:[[:space:]]*[0-9]*' "$STATE_FILE" | grep -o '[0-9]*$'
else
echo "0"
fi
}
update_statistics() {
local sessions=$1
local restarts=$2
if [ -f "$SUPERVISOR_CONFIG" ]; then
# Update statistics in config
python3 -c "
import json
with open('$SUPERVISOR_CONFIG', 'r') as f:
config = json.load(f)
config['statistics']['total_sessions'] = $sessions
config['statistics']['total_restarts'] = $restarts
config['statistics']['last_restart_time'] = '$(date -Iseconds)'
with open('$SUPERVISOR_CONFIG', 'w') as f:
json.dump(config, f, indent=2)
" 2>/dev/null
fi
}
# =============================================================================
# Health Check Functions
# =============================================================================
check_progress_stall() {
local last_feature=$1
local current_feature=$(grep -o '"current_feature"[[:space:]]*:[[:space:]]*"[^"]*"' "$STATE_FILE" | cut -d'"' -f4)
if [ "$last_feature" = "$current_feature" ] && [ -n "$current_feature" ]; then
# Same feature, check operations since progress
local ops=$(grep -o '"operations_since_progress"[[:space:]]*:[[:space:]]*[0-9]*' "$STATE_FILE" | grep -o '[0-9]*$')
if [ -n "$ops" ] && [ "$ops" -gt 10 ]; then
return 0 # Stalled
fi
fi
return 1 # Not stalled
}
check_error_spike() {
if [ -f "$BUILDER_DIR/errors.json" ]; then
local recent_errors=$(grep -c '"timestamp"' "$BUILDER_DIR/errors.json" 2>/dev/null || echo "0")
if [ "$recent_errors" -gt 5 ]; then
return 0 # Error spike detected
fi
fi
return 1 # No error spike
}
# =============================================================================
# Main Supervisor Loop
# =============================================================================
main() {
log "=========================================="
log "Autonomous Builder Supervisor Started"
log "=========================================="
log "Project: $PROJECT_DIR"
log "Check Interval: ${CHECK_INTERVAL}s"
log "Session Timeout: ${SESSION_TIMEOUT}s"
log "Max Restart Attempts: $MAX_RESTART_ATTEMPTS"
log ""
local restart_count=0
local last_feature=""
local stall_count=0
while true; do
load_config
# Check 1: Project completion
local status=$(get_project_status)
if [ "$status" = "completed" ]; then
log "✅ Project completed! Supervisor exiting."
log "Total sessions: $(get_session_count)"
log "Total restarts: $restart_count"
exit 0
fi
# Check 2: Pending features
local pending=$(get_pending_features_count)
if [ "$pending" -eq 0 ] && [ "$status" != "not_initialized" ]; then
log "✅ All features completed! Project done."
exit 0
fi
# Check 3: Progress stall
if check_progress_stall "$last_feature"; then
stall_count=$((stall_count + 1))
log "⚠️ Progress stall detected (count: $stall_count)"
if [ $stall_count -ge 3 ]; then
log "🔴 Too many stalls. Pausing for user intervention."
log "Type 'resume' to continue, or 'abort' to stop."
read -t 60 user_input
if [ "$user_input" = "abort" ]; then
log "User aborted. Exiting."
exit 1
fi
stall_count=0
fi
else
stall_count=0
fi
# Check 4: Error spike
if check_error_spike; then
log "⚠️ Error spike detected. Recording for analysis."
fi
# Check 5: Max restart attempts
if [ $restart_count -ge $MAX_RESTART_ATTEMPTS ]; then
log "🔴 Max restart attempts reached ($MAX_RESTART_ATTEMPTS)"
log "Please investigate manually. Supervisor pausing."
sleep 300 # Wait 5 minutes before retry
restart_count=0 # Reset counter
fi
# Start/Resume Claude Session
log "🚀 Starting Claude session #$((restart_count + 1))..."
log " Pending features: $pending"
log " Current status: $status"
# Update statistics before session
update_statistics $(get_session_count) $restart_count
# Run Claude with auto-continue flag
# Note: --dangerously-skip-permissions enables unattended operation
# WARNING: This bypasses all permission prompts - use only in trusted environments
claude --skill autonomous-builder --project "$PROJECT_DIR" --dangerously-skip-permissions 2>&1 | tee -a "$LOG_FILE"
local exit_code=$?
# Session ended
log "Session ended with code: $exit_code"
# Update restart count
restart_count=$((restart_count + 1))
# Record current feature for stall detection
last_feature=$(grep -o '"current_feature"[[:space:]]*:[[:space:]]*"[^"]*"' "$STATE_FILE" | cut -d'"' -f4)
# Cooldown before restart
log "Waiting ${RESTART_COOLDOWN}s before next session..."
sleep $RESTART_COOLDOWN
done
}
# =============================================================================
# Signal Handlers
# =============================================================================
cleanup() {
log "Supervisor stopped by signal. Saving state..."
update_statistics $(get_session_count) $(cat /tmp/autonomous_restarts 2>/dev/null || echo "0")
exit 0
}
trap cleanup SIGINT SIGTERM
# =============================================================================
# Entry Point
# =============================================================================
# Validate project directory
if [ ! -d "$PROJECT_DIR" ]; then
echo "Error: Project directory not found: $PROJECT_DIR"
exit 1
fi
# Create .builder directory if not exists
mkdir -p "$BUILDER_DIR"
# Initialize log file
touch "$LOG_FILE"
# Run main loop
main
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |