Skip to content

Multi-agent AI pipeline that builds Next.js apps autonomously | Python orchestration, Claude Code API, Discord integration | 85%+ success rate, 15-20 min builds

License

Notifications You must be signed in to change notification settings

SamShahinDev/cge-automation-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

2 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

CGE Automation System - AI-Powered Development Pipeline

Multi-agent AI system that autonomously builds Next.js applications from blueprints through orchestrated specialized agents with Discord-based human oversight.

Python Node.js TypeScript Claude Code

๐ŸŽฏ Overview

CGE (Crowned Gladiator Enterprises) Automation System is a sophisticated multi-agent pipeline that transforms project blueprints into production-ready Next.js applications through AI orchestration. The system uses specialized agents coordinated via Discord, with human approval gates at critical decision points.

Key Achievement: Reduces 4-8 weeks of development work to ~15-20 minutes of automated execution with 85%+ build success rate.

๐Ÿ—๏ธ System Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                     DISCORD INTERFACE                            โ”‚
โ”‚            (Human Control & Approval Layer)                      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                            โ”‚
                            โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                  ORCHESTRATOR (Brain)                            โ”‚
โ”‚        Discord Bot coordinating all agents & workflow            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                            โ”‚
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ†“                   โ†“                   โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   PLANNING   โ”‚    โ”‚    PROMPT    โ”‚    โ”‚   BUILDER    โ”‚
โ”‚    AGENT     โ”‚โ†’   โ”‚  GENERATOR   โ”‚โ†’   โ”‚    AGENT     โ”‚
โ”‚  (Python)    โ”‚    โ”‚   (Python)   โ”‚    โ”‚  (Claude     โ”‚
โ”‚              โ”‚    โ”‚              โ”‚    โ”‚   Code API)  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                                โ†“
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ†“                          โ†“             โ†“
            โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
            โ”‚   ENHANCED   โ”‚          โ”‚  POST-BUILD  โ”‚  โ”‚  DISCORD  โ”‚
            โ”‚   CHECKER    โ”‚          โ”‚    FIXER     โ”‚  โ”‚  MONITOR  โ”‚
            โ”‚   (Python)   โ”‚          โ”‚   (Python)   โ”‚  โ”‚  (Node.js)โ”‚
            โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โœจ Core Components

1. Planning Agent

Location: cge sdk agents/automation-agents/claude-bridge-agent/

Purpose: Analyzes blueprints and generates optimal phase breakdowns

Features:

  • Reads project blueprints in markdown format
  • Breaks complex projects into 3-5 logical phases
  • Considers dependencies and build order
  • Outputs structured PHASES.md
  • Uses Claude API for intelligent analysis

Output Example:

# Phase 1: Project Foundation
- Initialize Next.js project with TypeScript
- Set up design system
- Create homepage structure

# Phase 2: Core Features
- Build pricing page
- Implement contact forms
...

2. Prompt Generator Agent

Purpose: Converts phases into detailed, executable prompts

Features:

  • Generates 4-8 specific prompts per phase
  • Each prompt is a complete instruction for Claude Code
  • Includes file paths, exact specifications, code examples
  • Maintains consistency across phases
  • References previous work for continuity

Output: PHASE_X_PROMPTS.md files with structured instructions

3. Builder Agent (Website Builder Bot)

Location: website/

Purpose: Executes prompts to build the actual application

Features:

  • Sequential automation of 16+ detailed prompts
  • Calls Claude Code API for each prompt
  • Smart completion detection (60-second file stability monitoring)
  • Progress persistence (resumes after interruptions)
  • Git integration (auto-commits per prompt)
  • Watchdog protection (detects stuck processes)

Technology:

  • Python-based orchestration
  • Anthropic Claude Code SDK
  • File-system monitoring
  • Subprocess management

Performance:

  • Average: 96 seconds per prompt
  • Total build time: 15-20 minutes for complete project
  • Success rate: 85%+ when properly configured

4. Enhanced Checker Agent

Purpose: Validates code quality and catches errors

Features:

  • 7 Validation Checks:

    1. File structure validation
    2. TypeScript compilation (tsc --noEmit)
    3. ESLint checking
    4. Dev server startup test
    5. Browser automation (Playwright)
    6. Console error detection
    7. Performance testing (optional Lighthouse)
  • Generates Reports:

    • JSON format (machine-readable)
    • Markdown format (human-readable)
    • Screenshots of runtime issues
    • Detailed error traces

Output: phase_X_validation.json, PHASE_X_ERRORS.md

5. Post-Build Fixer Agent

Purpose: Aggregates errors and proposes comprehensive fixes

Features:

  • Runs after all phases complete
  • Aggregates errors from all validation reports
  • Categorizes by type (TypeScript, ESLint, runtime)
  • Generates consolidated fix plan
  • Executes approved fixes automatically
  • Can call Claude Code for complex TypeScript fixes

Output: fixer_analysis.json + Discord approval message

6. Discord Bot Orchestrator

Location: cge sdk agents/cge-discord-bot/

Purpose: Provides human oversight and approval workflow

Features:

  • Slash Commands:

    • /setup-channels - Creates 14-channel server structure
    • /test-setup - Validates bot configuration
    • /bot-status - Real-time health monitoring
  • Channel Structure:

    • ๐ŸŽฏ Command Center (2 channels)
    • ๐Ÿค– Agent Workspace (7 channels)
    • ๐Ÿ“Š Monitoring (3 channels)
    • ๐Ÿ“š Archives (2 channels)
  • Approval Workflow:

    • Posts requests in #approvals channel
    • Uses Discord reactions (โœ…/โŒ) for approval
    • 15-minute timeout per approval
    • Prevents accidental execution

Technology:

  • Node.js + TypeScript
  • Discord.js v14
  • PM2 for process management
  • Health monitoring with auto-restart

๐Ÿš€ Key Features

Intelligent Orchestration

  • Phase-Based Execution: Breaks projects into manageable phases
  • Dependency Management: Ensures proper build order
  • Progress Persistence: Resumes from failures automatically
  • Session History: Tracks all execution attempts

Quality Assurance

  • Automated Testing: TypeScript, ESLint, runtime validation
  • Error Detection: Catches issues before human review
  • Comprehensive Reports: Machine + human readable formats
  • Fix Automation: Can auto-fix common issues

Human-in-the-Loop

  • Approval Gates: Human review at critical decision points
  • Discord Integration: Collaborative oversight via familiar interface
  • Progress Visibility: Real-time build monitoring
  • Error Transparency: Full trace of what was attempted

Performance

  • Fast Execution: 15-20 minutes for complete applications
  • Cost Effective: ~$6-9 per project (Claude API costs)
  • High Success Rate: 85%+ build success
  • Scalable: Can handle multiple concurrent projects

๐Ÿ“Š Performance Metrics

Typical Build Performance

Project: Custom software marketing site
Total Phases: 3
Total Prompts: 18
Build Time: 16 minutes
Success Rate: 100% (18/18 prompts)
Average per Prompt: 53 seconds
Cost: ~$8.50 (Claude API)

Comparison

Method Time Cost Quality
Manual Development 4-8 weeks $10,000+ Variable
Traditional Automation N/A N/A Poor
CGE System 15-20 min ~$9 85%+ success

๐Ÿ› ๏ธ Tech Stack

Orchestration

  • Python 3.10+ - Agent logic and coordination
  • Node.js 18+ - Discord bot and monitoring
  • TypeScript 5.3 - Type-safe bot development
  • Discord.js 14 - Discord API integration

AI/ML

  • Anthropic Claude API - claude-sonnet-4.5 model
  • Claude Code SDK - Autonomous code generation
  • Prompt Engineering - Structured instruction generation

Quality Tools

  • TypeScript Compiler - Static type checking
  • ESLint - Code quality validation
  • Playwright - Browser automation testing
  • Lighthouse - Performance auditing (optional)

Infrastructure

  • Git - Version control with auto-commits
  • PM2 - Process management for Discord bot
  • SQLite - Project state persistence
  • File System - Build monitoring via file changes

๐Ÿ“ Project Structure

cge-automation-system/
โ”œโ”€โ”€ cge sdk agents/
โ”‚   โ”œโ”€โ”€ automation-agents/
โ”‚   โ”‚   โ”œโ”€โ”€ claude-bridge-agent/     # Core agent framework
โ”‚   โ”‚   โ”œโ”€โ”€ multi-client-orchestrator/ # Multi-project management
โ”‚   โ”‚   โ”œโ”€โ”€ monthly-value-agent/     # Client value tracking
โ”‚   โ”‚   โ””โ”€โ”€ code-review-agent/       # Code quality agent
โ”‚   โ””โ”€โ”€ cge-discord-bot/             # Discord orchestration
โ”‚       โ”œโ”€โ”€ src/
โ”‚       โ”‚   โ”œโ”€โ”€ commands/            # Slash commands
โ”‚       โ”‚   โ”œโ”€โ”€ config/              # Channel structure
โ”‚       โ”‚   โ””โ”€โ”€ utils/               # Channel management
โ”‚       โ”œโ”€โ”€ launcher.js              # Health monitoring
โ”‚       โ””โ”€โ”€ setup.js                 # Interactive setup
โ”‚
โ”œโ”€โ”€ website/                         # Website Builder Bot
โ”‚   โ”œโ”€โ”€ ENHANCED_PROMPTS.md         # Prompt library
โ”‚   โ”œโ”€โ”€ build-website.sh            # Execution script
โ”‚   โ”œโ”€โ”€ show_prompt.py              # Prompt utilities
โ”‚   โ””โ”€โ”€ custom-software-site/       # Generated output
โ”‚
โ””โ”€โ”€ cge-enhanced-website/           # Enhanced build system
    โ””โ”€โ”€ project/                    # Build artifacts

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.10+
  • Node.js 18+
  • Anthropic API key
  • Discord bot token (optional, for monitoring)
  • Claude Code CLI

Installation

1. Clone repository:

git clone https://github.com/SamShahinDev/cge-automation-system.git
cd cge-automation-system

2. Set up Python environment:

cd "cge sdk agents/automation-agents/claude-bridge-agent"
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install anthropic

3. Configure API key:

cp .env.example .env
# Edit .env and add your ANTHROPIC_API_KEY

4. Set up Discord bot (optional):

cd ../../cge-discord-bot
npm install
cp .env.example .env
# Add DISCORD_TOKEN and GUILD_ID
npm start

Running a Build

1. Prepare your blueprint:

# MyProject Blueprint

## Phase 1: Homepage
Build a modern homepage with hero section...

## Phase 2: Features
Create feature pages with...

2. Run the automation:

cd website
./build-website.sh

3. Monitor progress:

  • Watch console output
  • Check Discord #build-monitor channel (if configured)
  • Review generated files in custom-software-site/

4. Review results:

  • Check validation reports: PHASE_X_ERRORS.md
  • Review git history: git log
  • Test the build: cd custom-software-site && npm run dev

๐Ÿ“ˆ Use Cases

1. Rapid Prototyping

  • Turn ideas into working applications in minutes
  • Test concepts before full development investment
  • Generate demo-ready code for pitches

2. Client Projects

  • Accelerate project kickoff
  • Generate consistent quality baselines
  • Reduce time-to-first-demo

3. Internal Tools

  • Build custom dashboards rapidly
  • Create admin panels automatically
  • Generate CRUD interfaces from specs

4. Learning & Experimentation

  • Study how Next.js projects are structured
  • Learn best practices from generated code
  • Experiment with different architectures

๐Ÿ”’ Security Considerations

Current Implementation:

  • API keys in environment variables
  • No authentication on Discord bot (for internal use)
  • Projects stored in filesystem
  • Agents run with user permissions

Production Recommendations:

  • Add Discord user authentication
  • Encrypt API keys in database
  • Implement rate limiting
  • Add project access controls
  • Enable audit logging

๐ŸŽ“ Key Innovations

1. File-Based Completion Detection

Problem Solved: Process monitoring caused premature completion detection

Solution: Monitor actual file system changes with 60-second stability window

Impact: Improved success rate from ~40% to 85%+

2. Multi-Agent Specialization

Innovation: Each agent has a single, focused responsibility

Benefits:

  • Easier to debug and improve individual agents
  • Can swap implementations without affecting others
  • Parallel agent development possible

3. Human-in-the-Loop Approval

Design: AI automation with human oversight at key decision points

Balance:

  • Maintains AI speed advantages
  • Preserves human judgment for critical decisions
  • Prevents costly mistakes from autonomous execution

4. Progress Persistence

Feature: Resume from any interruption point

Implementation:

  • JSON-based state storage
  • Session history tracking
  • Automatic skip of completed work

Impact: Enables multi-hour builds that can survive crashes/interruptions

๐Ÿ”ฎ Future Enhancements

Planned Features

  1. Intelligent Auto-Fixer

    • Use Claude Code to fix TypeScript errors automatically
    • Semantic understanding of error messages
    • Test fixes before applying
  2. Multi-Language Support

    • Python/FastAPI backends
    • React Native mobile apps
    • Vue.js frontend
  3. Testing Agent

    • Generate unit tests automatically
    • E2E test creation
    • Test coverage reports
  4. Deployment Agent

    • Auto-deploy to Vercel
    • Set up CI/CD pipelines
    • Domain configuration
  5. Iteration Agent

    • Handle change requests
    • Update existing projects
    • Maintain code history

๐Ÿค Comparison to Other Tools

Tool Approach CGE Automation
GitHub Copilot Autocomplete for individual files โœ… Builds entire applications
Cursor AI IDE with AI assistance โœ… Autonomous end-to-end pipeline
v0.dev Single component generation โœ… Full multi-page applications
Replit Agent Single-session builds โœ… Persistent, resumable, multi-phase

Unique Advantages:

  • Human approval gates (safer than fully autonomous)
  • Multi-agent architecture (specialized agents)
  • Discord integration (team collaboration)
  • Quality validation (automated testing)
  • Post-build fixing (comprehensive error handling)

๐Ÿ“Š Real-World Results

Project: Dirt Free CRM Website

  • Input: 50-page blueprint document
  • Output: Production marketing site
  • Phases: 5 (Homepage, Services, Locations, Contact, About)
  • Total Prompts: 47
  • Build Time: 42 minutes
  • Success Rate: 89% (42/47 prompts succeeded)
  • Manual Fixes: 3 hours (vs 2 weeks manual development)
  • Total Cost: $18 (API calls)

Project: Custom SaaS Dashboard

  • Input: Technical specification + mockups
  • Output: Admin dashboard with CRUD operations
  • Phases: 4
  • Total Prompts: 28
  • Build Time: 28 minutes
  • Success Rate: 93%
  • Manual Fixes: 2 hours
  • Total Cost: $12

๐Ÿ‘ค Author

Hussam Shahin
LinkedIn | GitHub


Built for Crowned Gladiator Enterprises LLC | Demonstrating advanced AI orchestration, multi-agent systems, and autonomous software development at scale

About

Multi-agent AI pipeline that builds Next.js apps autonomously | Python orchestration, Claude Code API, Discord integration | 85%+ success rate, 15-20 min builds

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •