Skip to main content
The Code Agent now focuses on generating full-stack TypeScript web applications (Next.js + Prisma + Tailwind). Python code generation is no longer supported.
First time here? Complete the Setup guide first to install GAIA and its dependencies.
The GAIA Code Agent turns a natural-language prompt into a working Next.js application. It designs the data model, builds Prisma schemas, generates REST API routes with Zod validation, creates React pages, applies Tailwind styling, validates TypeScript, and iterates until the app builds successfully.
End-to-end generation and auto-debugging for a full-stack app usually takes 10–20 minutes. Timing depends on how much context is created and how many debugging loops are needed. We prioritize output quality while continuously improving speed, and contributions that enhance either are welcome in the GAIA repository.

Key Features

Full-Stack Generation

Next.js apps with API routes, React pages, and Tailwind styling

Prisma Data Modeling

SQLite schemas with autogenerated IDs and timestamps

Validated APIs

REST endpoints with Zod validation and clear error responses

Type-Safe UI

React components for list, create, and detail flows with TypeScript types

Iterative Fixes

TypeScript checks, Next.js builds, and auto-fix loops until green

CLI Control

Step-through, traces, and background process management for long runs

Quick Start

Prerequisite: Install Node.js v20.19.x
  • Download from nodejs.org (Windows Installer for v20.19.x LTS)
  • Verify installation: node --version (should show v20.19.x)
  • Node.js is required to build and run the web application that the GAIA Code Agent generates.
1

Clone the repository

git clone https://github.com/amd/gaia.git
cd gaia
2

Install development dependencies

curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv .venv --python 3.12
source .venv/bin/activate
uv pip install -e ".[dev]"
3

Start Lemonade server (local LLM)

lemonade-server serve --ctx-size 32768
4

Generate an app

gaia code "Build me a movie tracking app in nextjs where I can track the movie title, genre, date watched, and a score out of 10" --path movie-web-app
5

Run the generated app

cd movie-web-app
npm run dev
The app serves at http://localhost:3000

Basic Examples

gaia code "Build me a workout tracking app in nextjs where I can track workout, duration, date, and goal"

Next.js Full-Stack App Generation

The Code Agent outputs a complete Next.js project with Prisma, Zod, and Tailwind baked in.
your-app/
├── prisma/
│   └── schema.prisma          # SQLite models with IDs and timestamps
├── src/
│   ├── app/
│   │   ├── api/
│   │   │   └── [resource]/
│   │   │       ├── route.ts        # GET, POST
│   │   │       └── [id]/route.ts   # GET, PUT, DELETE
│   │   ├── [resource]/
│   │   │   ├── page.tsx        # List view
│   │   │   ├── new/page.tsx    # Create form
│   │   │   └── [id]/page.tsx   # Detail view
│   │   ├── layout.tsx          # Root layout
│   │   ├── page.tsx            # Landing page with navigation
│   │   └── globals.css         # Tailwind styles
│   └── lib/
│       └── prisma.ts           # Prisma client bootstrap
├── package.json
├── tsconfig.json
├── tailwind.config.ts
└── next.config.js
Stack defaults:
  • Next.js with the App Router
  • TypeScript + strict typing
  • Prisma ORM with SQLite
  • REST API routes validated with Zod
  • Tailwind CSS styling for layouts, forms, and states

Debug and Trace Options

Debug Logging

gaia code "Create a todo tracking app in nextjs" --debug
See internal decision logs

JSON Trace

gaia code "Create a todo tracking app in nextjs" --trace
Save detailed execution trace

Full Debug

gaia code "Create a todo tracking app in nextjs" --debug --trace
Maximum debugging information

JSON Output Structure

The --trace flag saves a complete trace with detailed information:
trace_output.json
{
  "status": "success",
  "result": "Final answer from agent",
  "system_prompt": "Complete system prompt used",
  "conversation": [
    {"role": "user", "content": "User's query"},
    {"role": "assistant", "content": {"thought": "...", "tool": "...", "tool_args": {...}}},
    {"role": "system", "content": {...}}
  ],
  "steps_taken": 28,
  "duration": 123.45,
  "total_input_tokens": 15000,
  "total_output_tokens": 8000,
  "output_file": "/absolute/path/to/output.json"
}

API & VSCode Integration

The Code Agent is available through the GAIA API Server as the gaia-code model, providing an OpenAI-compatible REST API for IDEs and automation.

Quick Start

1

Start Lemonade server

lemonade-server serve --ctx-size 32768
2

Install API dependencies

uv pip install -e ".[api]"
3

Start GAIA API server

uv run gaia api start
4

Call the model

curl -X POST http://localhost:8080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gaia-code",
    "messages": [{"role": "user", "content": "Build me a movie tracking app in nextjs"}]
  }'

API Highlights

  • OpenAI Compatible: Works with OpenAI clients and compatible tooling
  • Streaming Support: Real-time updates while generating
  • Multi-Turn: Maintain context across requests

Workflow Capabilities

1

Analyze Requirements

Interpret the prompt and determine the minimum viable schema
2

Generate Prisma Schema

Create models with IDs, timestamps, and inferred field types
3

Build API Routes

Scaffold REST endpoints with Zod validation for CRUD operations
4

Create React Pages

Generate list, creation, and detail pages wired to the APIs
5

Apply Styling

Add Tailwind-powered layouts, forms, and state handling
6

Validate & Build

Run TypeScript checks and Next.js build; collect any errors
7

Auto-Fix Loop

Apply targeted fixes and re-run validation/build until clean

Available Tools

  • run_cli_command - Execute npm/yarn commands and capture output
  • cleanup_all_processes / stop_process / list_processes - Manage background runs
  • manage_data_model - Create or update Prisma models
  • manage_api_endpoint - Generate REST routes with Zod validation
  • validate_crud_structure - Ensure CRUD files exist for each resource
  • manage_react_component - Generate list, form, detail React pages
  • setup_app_styling - Apply Tailwind design system and globals
  • update_landing_page - Wire navigation and landing content
  • validate_typescript - Run TypeScript compiler checks
  • test_crud_api - Smoke-test CRUD endpoints
  • validate_styles - Check CSS and design consistency
  • fix_code - LLM-driven targeted file fix for validation/build errors (used in remediation checklists)
  • setup_prisma - Initialize Prisma and database config
  • setup_nextjs_testing - Configure Vitest where needed

External Information Lookup

The agent can optionally use web search (Perplexity) when PERPLEXITY_API_KEY is set in .env to unblock documentation or best-practice questions.

Troubleshooting

❌ Error: Lemonade server is not running or not accessible.
Start the server with:
lemonade-server serve --ctx-size 32768
  • Ensure dependencies are installed: npm install
  • Regenerate Prisma client: npx prisma generate
  • Push schema: npx prisma db push
  • Re-run the agent with --debug --trace to inspect fixes
  • Occasionally the agent can loop on a minor issue; try rerunning the command
  • If it persists, update the prompt to call out the failing component or file
  • Check prisma/schema.prisma for typos
  • Delete node_modules and reinstall
  • Verify DATABASE_URL (if using a custom provider)
  • Stop existing dev servers or run npm run dev -- --port 3001

VS Code Debugging (Developers)

Use the existing launch configurations to step through the agent when it generates Next.js projects.
  1. Code Agent Debug - Next.js App - Full project generation workflow
  2. Code Agent Debug - REST API - Focus on API route generation
  3. Code Agent Debug - Interactive - Step through with --step-through
  4. Code Agent Debug - With Breakpoint ⭐ - Stops before execution for setting breakpoints
Useful breakpoint locations:
  • src/gaia/agents/code/agent.py - Agent initialization and orchestration
  • src/gaia/agents/code/tools/typescript_tools.py - TypeScript/Next.js tooling
  • src/gaia/agents/code/tools/checklist_orchestration.py - Full-stack checklist workflow
  • src/gaia/agents/base/agent.py - Base agent loop

Best Practices

Be Specific

Include required fields and relationships in the prompt to shape the Prisma schema

Run Setup Commands

After generation, just cd <path> and run npm run dev (the agent installs dependencies for you)

Review Before Shipping

Inspect API validation, UI flows, and database types before deploying

Iterate with Data

Start with the MVP output, then rerun the agent with refined prompts to add features

Next Steps