Source Code:
src/gaia/agents/code/agent.py · src/gaia/agents/code/tools/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.
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
2
Install development dependencies
3
Start Lemonade server (local LLM)
4
Generate an app
5
Run the generated app
Basic Examples
- Workout Tracker
- Restaurant Reviews
- AI Tool Leaderboard
- Simple Todos
- Interactive Mode
Next.js Full-Stack App Generation
The Code Agent outputs a complete Next.js project with Prisma, Zod, and Tailwind baked in.- 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
JSON Trace
Full Debug
JSON Output Structure
The--trace flag saves a complete trace with detailed information:
trace_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
2
Install API dependencies
3
Start GAIA API server
4
Call the model
- Linux/macOS
- PowerShell
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
Project Bootstrap & Processes
Project Bootstrap & Processes
run_cli_command- Execute npm/yarn commands and capture outputcleanup_all_processes/stop_process/list_processes- Manage background runs
Data Modeling & APIs
Data Modeling & APIs
manage_data_model- Create or update Prisma modelsmanage_api_endpoint- Generate REST routes with Zod validationvalidate_crud_structure- Ensure CRUD files exist for each resource
UI & Styling
UI & Styling
manage_react_component- Generate list, form, detail React pagessetup_app_styling- Apply Tailwind design system and globalsupdate_landing_page- Wire navigation and landing content
Validation & Quality
Validation & Quality
validate_typescript- Run TypeScript compiler checkstest_crud_api- Smoke-test CRUD endpointsvalidate_styles- Check CSS and design consistency
Debugging & Error Fixes
Debugging & Error Fixes
fix_code- LLM-driven targeted file fix for validation/build errors (used in remediation checklists)
Tooling Setup
Tooling Setup
setup_prisma- Initialize Prisma and database configsetup_nextjs_testing- Configure Vitest where needed
External Information Lookup
The agent can optionally use web search (Perplexity) whenPERPLEXITY_API_KEY is set in .env to unblock documentation or best-practice questions.
Troubleshooting
LLM server not running
LLM server not running
TypeScript or build errors keep returning
TypeScript or build errors keep returning
- Ensure dependencies are installed:
npm install - Regenerate Prisma client:
npx prisma generate - Push schema:
npx prisma db push - Re-run the agent with
--debug --traceto inspect fixes
Agent gets stuck on a simple bug
Agent gets stuck on a simple bug
- 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
Prisma client issues
Prisma client issues
- Check
prisma/schema.prismafor typos - Delete
node_modulesand reinstall - Verify
DATABASE_URL(if using a custom provider)
Port already in use
Port already in use
- 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.Available Debug Configurations
Available Debug Configurations
- Code Agent Debug - Next.js App - Full project generation workflow
- Code Agent Debug - REST API - Focus on API route generation
- Code Agent Debug - Interactive - Step through with
--step-through - Code Agent Debug - With Breakpoint ⭐ - Stops before execution for setting breakpoints
src/gaia/agents/code/agent.py- Agent initialization and orchestrationsrc/gaia/agents/code/tools/typescript_tools.py- TypeScript/Next.js toolingsrc/gaia/agents/code/tools/checklist_orchestration.py- Full-stack checklist workflowsrc/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
VSCode Integration
API Server
Integrate via OpenAI-compatible API
Playbook
Deep dive into how the Code Agent builds Next.js apps
Features Overview
Explore all GAIA capabilities