Never worry about failed deployments again. AutoFix is a production-ready autonomous platform that monitors your Vercel deployments 24/7, automatically detects failures, uses Claude AI to analyze errors and generate fixes, commits changes to GitHub, and re-triggers deployments until success—all without any user intervention.
- 🔄 Continuous Autonomous Monitoring: Polls Vercel deployments every 60 seconds
- 🤖 AI-Powered Analysis: Uses Claude 3.5 Sonnet to analyze build logs and identify root causes
- 🔧 Automatic Fixes: Generates precise code changes and commits to GitHub automatically
- 🚀 Self-Healing Deployments: Triggers new deployments and monitors until success
- ♻️ Intelligent Retries: Attempts up to 5 fixes per failure with exponential learning
- 📧 Smart Notifications: Email alerts for successful fixes and max retry failures
- 🔒 Enterprise Security: Token encryption, file whitelisting, dangerous code detection
- 📊 Real-time Dashboard: Monitor deployment health and fix attempts in beautiful UI
Deployment Fails → AutoFix Detects → AI Analyzes → Fix Generated →
Committed to GitHub → New Deployment → Monitor Status →
Success ✅ or Retry (up to 5x)
- Frontend: Next.js 15 (App Router), React 19, TypeScript, Tailwind CSS
- Backend: Next.js API Routes, Vercel Cron Functions
- Database: Supabase PostgreSQL with pgcrypto encryption
- AI: Claude 3.5 Sonnet via Anthropic API
- Integrations: GitHub REST API, Vercel REST API, Resend (email)
- Infrastructure: Vercel deployment with cron scheduling
Before setting up AutoFix, you need:
- GitHub Account - For OAuth and App installation
- Vercel Account - For deployment and API access
- Supabase Account - For PostgreSQL database
- Anthropic API Key - For Claude AI access
- Resend API Key - For email notifications
git clone <your-repo>
cd deployment
npm install- Create a new project at supabase.com
- Go to SQL Editor and run the migration:
# Copy the contents of migrations/001_initial_schema.sql and execute in Supabase SQL Editor- Note your Project URL and API keys from Settings → API
- Go to GitHub Settings → Developer Settings → OAuth Apps → New OAuth App
- Set Application name:
AutoFix - Homepage URL:
https://your-domain.vercel.app - Authorization callback URL:
https://your-domain.vercel.app/api/auth/github-callback - Note the Client ID and generate a Client Secret
- Go to GitHub Settings → Developer Settings → GitHub Apps → New GitHub App
- GitHub App Name:
AutoFix-YourName(must be unique) - Homepage URL:
https://your-domain.vercel.app - Callback URL:
https://your-domain.vercel.app/api/auth/github-callback - Setup URL:
https://your-domain.vercel.app/setup/connect-repo - Webhook: Leave blank (we use polling)
- Permissions (Repository):
- Contents: Read & Write
- Pull Requests: Read & Write
- Deployments: Read
- Checks: Write
- Click Create GitHub App
- Note the App ID
- Generate a Private Key and download it
- Copy the private key contents (you'll need to format with
\nfor newlines)
Copy .env.example to .env.local:
cp .env.example .env.localFill in all values:
# App Configuration
NEXT_PUBLIC_APP_URL=https://your-domain.vercel.app
# GitHub OAuth
GITHUB_CLIENT_ID=your_oauth_client_id
GITHUB_CLIENT_SECRET=your_oauth_client_secret
# GitHub App
GITHUB_APP_ID=123456
GITHUB_APP_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nYour\nKey\nHere\n-----END PRIVATE KEY-----"
# Supabase
SUPABASE_URL=https://xxx.supabase.co
SUPABASE_ANON_KEY=eyJ...
SUPABASE_SERVICE_ROLE_KEY=eyJ...
# Encryption (generate a random 32-character string)
ENCRYPTION_KEY=your_random_32_char_encryption_key
# Anthropic
ANTHROPIC_API_KEY=sk-ant-...
# Resend
RESEND_API_KEY=re_...
# Vercel Cron Secret (generate a random string)
VERCEL_CRON_SECRET=your_random_cron_secret# Install Vercel CLI
npm i -g vercel
# Login
vercel login
# Deploy
vercel --prodAfter deployment, add all environment variables:
# Set each variable
vercel env add GITHUB_CLIENT_ID
vercel env add GITHUB_CLIENT_SECRET
# ... repeat for all variablesAfter deployment, update your GitHub App settings:
- Callback URL:
https://your-actual-domain.vercel.app/api/auth/github-callback - Setup URL:
https://your-actual-domain.vercel.app/setup/connect-repo
- Go to Vercel Dashboard → Your Project → Cron
- Verify
/api/cron/monitoris scheduled to run every minute - Check logs to see autonomous monitoring in action
- Visit your deployed AutoFix URL
- Click "Connect with GitHub" and authorize
- Install the GitHub App on your repository
- Go to Dashboard → Connect Repository
- Enter Vercel Project ID and API Token
- Done! AutoFix will start monitoring immediately
- Dashboard: View connected repos and recent failures
- Failures Page: See all deployment failures with status
- Failure Detail: View AI analysis, fixes applied, and deployment results
All API tokens (GitHub, Vercel) are encrypted using PostgreSQL's pgcrypto extension before storage.
AI can only modify:
- Files in
src/directory next.config.ts/jspackage.jsontsconfig.json.eslintrcfilesmiddleware.tstailwind.config.ts/js
Automatically blocks AI-generated code containing:
child_processusageexec()callseval()functions- File deletion operations
- Environment variable writes
- Shell command injections
- Every 60 seconds: Cron job checks all Vercel projects
- Failure Detected: Extracts deployment ID and build logs
- AI Analysis: Claude analyzes logs and repository files
- Fix Generation: Creates precise code changes
- Validation: Checks file whitelist and dangerous patterns
- GitHub Commit: Creates branch and commits fixes
- Deployment: Triggers new Vercel deployment via API or hook
- Monitoring: Polls deployment every 15s for up to 30 minutes
- Decision:
- ✅ Success: Update status, send success email
- ❌ Failed & attempts < 5: Create new failure, retry from step 3
- ❌ Failed & attempts ≥ 5: Mark as failed, send detailed failure email
users
├── id (UUID)
├── email
├── github_username
└── github_access_token (encrypted)
github_installations
├── id (UUID)
├── user_id (FK)
├── installation_id
├── repo_owner
├── repo_name
└── installation_token (encrypted)
vercel_projects
├── id (UUID)
├── user_id (FK)
├── github_installation_id (FK)
├── project_id
├── vercel_token (encrypted)
└── last_checked_deployment_id
failure_records
├── id (UUID)
├── vercel_project_id (FK)
├── deployment_id
├── logs
├── status (enum)
└── attempt_count
fix_attempts
├── id (UUID)
├── failure_record_id (FK)
├── attempt_number
├── ai_response (JSONB)
├── files_changed (JSONB)
├── applied_branch
└── deployment_status- Create a test repository with an intentional error:
// src/app/page.tsx
export default function Page() {
return <div>{undefinedVariable}</div>; // This will fail
}- Deploy to Vercel
- Watch AutoFix:
- Detect the failure (within 60 seconds)
- Analyze with AI
- Generate and commit fix
- Redeploy automatically
- Send success email
- Check Vercel Dashboard → Cron tab
- Verify
vercel.jsonis at project root - Check environment variable
VERCEL_CRON_SECRETis set
- Verify
ANTHROPIC_API_KEYis valid - Check Anthropic account has credits
- Review logs in Vercel Dashboard
- Verify GitHub App has correct permissions
- Check installation token hasn't expired
- Ensure repository access is granted
- Verify Vercel token has correct permissions
- Check project ID is correct
- Try setting a deploy hook URL
All operations are logged with structured JSON:
{
"timestamp": "2024-01-06T12:00:00Z",
"level": "info",
"message": "Deployment fixed successfully",
"failureRecordId": "uuid",
"attempt": 2
}View logs in:
- Vercel Dashboard → Your Project → Logs
- Filter by
/api/cron/monitorfor monitoring logs
- Anthropic API: ~$0.015 per failure analysis (Claude 3.5 Sonnet)
- Vercel: Free tier supports cron jobs
- Supabase: Free tier sufficient for most use cases
- Resend: 100 emails/day on free tier
Estimated monthly cost for 10 failures/day: ~$5-10
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Commit changes
- Push to the branch
- Create a Pull Request
MIT License - see LICENSE file for details
- Anthropic - For Claude 3.5 Sonnet AI
- Vercel - For hosting and cron infrastructure
- Supabase - For PostgreSQL database
- Next.js Team - For the amazing framework
Built with ❤️ by the AutoFix Team
For support, email: support@autofix.dev