A smart, fully automated coding pipeline built inside n8n that leverages Cursor AI to write, refactor, review, and optimize code projects — triggered by a webhook, schedule, or manual prompt. Every output is versioned, stored, and delivered with a detailed review report.
🎯 What's the Goal?
Eliminate the repetitive overhead of writing boilerplate code, performing code reviews, and refactoring legacy code manually. This workflow turns a plain-text task description into production-ready, reviewed, and optimized code — automatically and at scale — using Cursor AI's deep coding intelligence inside n8n.
💡 Why Does It Matter?
Software teams lose hundreds of hours to boilerplate writing, manual code reviews, and inconsistent refactoring. AI-assisted coding with Cursor is powerful, but still requires manual triggering. By wiring Cursor into n8n, you get a repeatable, auditable, hands-free coding pipeline that integrates directly with your Git repos, Slack, and storage — making AI code generation a true part of your CI/CD culture, not just a one-off tool.
⚙️ How It Works
- Webhook or Schedule triggers the flow with a coding task description
- Task is classified (Generate / Review / Refactor / Optimize)
- Cursor AI API is called with the appropriate system prompt & task
- Raw code output is received and parsed
- A second Cursor pass performs automated code review & scoring
- If quality score passes threshold → code is committed to GitHub
- If score is below threshold → Cursor runs an optimization pass
- Final code + review report saved to Google Drive
- Summary logged to Google Sheets
- Slack notification sent with code snippet preview & Drive link
🔧 Configuration Requirements
- Cursor AI API key (via Cursor developer access or proxy endpoint)
- GitHub Personal Access Token (for auto-commit & PR creation)
- Google Drive OAuth2 (for storing code files & reports)
- Google Sheets OAuth2 (for logging task history & quality scores)
- Slack Bot Token (for team notifications)
- Optional: OpenAI API key (for task classification fallback)
🚀 Setup Guide
- Import this workflow into your n8n instance
- Connect all credentials: Cursor API, GitHub, Google Drive, Google Sheets, Slack
- Open the Set Task Config node and fill in:
repo_owner and repo_name (your GitHub target repo)
target_branch (e.g. ai-generated or main)
quality_threshold (score 0–100, recommended: 75)
storage_folder (Google Drive folder name)
log_sheet_id (Google Sheets document ID)
- Test with a manual webhook POST containing
{ "task": "Write a Python FastAPI CRUD endpoint for users" }
- Review output in Drive and check Slack notification
- Activate the webhook for live use
- Optionally activate the daily schedule for batch processing queued tasks
- Monitor quality scores in Google Sheets and tune the threshold as needed