Skip to main content
Component: WebToolsMixin Module: gaia_agent_code.tools.web_dev_tools Import: from gaia_agent_code.tools.web_dev_tools import WebToolsMixin

Overview

WebToolsMixin provides comprehensive web development tools for building full-stack applications with Next.js, Prisma, and React. It offers framework-agnostic patterns with schema-aware code generation, modern design systems, and complete CRUD scaffolding. Key Features:
  • Prisma data model management
  • Next.js API endpoint generation
  • React component generation (server & client)
  • Schema-aware payload generation
  • Modern dark-theme design system
  • Complete CRUD scaffolding
  • Testing infrastructure setup
  • Configuration management

Core Tool Specifications

1. manage_data_model

Manage database models with Prisma ORM. Parameters:
  • project_dir (str, required): Project directory
  • model_name (str, required): Model name (PascalCase, e.g., โ€œUserโ€)
  • fields (Dict[str, str], required): Field name to type mapping
  • relationships (List[Dict], optional): Model relationships
Field Types:
Returns:
Auto-Operations:
  1. Validates schema doesnโ€™t have forbidden output field
  2. Adds model to schema.prisma
  3. Runs npx prisma format
  4. Runs npx prisma generate
  5. Verifies Prisma client generation
  6. Runs npx prisma db push
Reserved Fields (auto-generated):
  • id: Int @id @default(autoincrement())
  • createdAt: DateTime @default(now())
  • updatedAt: DateTime @updatedAt

2. manage_api_endpoint

Manage API endpoints with actual Prisma operations. Parameters:
  • project_dir (str, required): Project directory
  • resource_name (str, required): Resource name (e.g., โ€œtodoโ€)
  • operations (List[str], optional): HTTP methods (default: [โ€œGETโ€, โ€œPOSTโ€])
  • fields (Dict[str, str], optional): Field definitions (auto-read from schema)
  • enable_pagination (bool, optional): Add pagination (default: False)
Returns:
Generated Files:
  • Collection route: src/app/api/{resource_plural}/route.ts
  • Item route: src/app/api/{resource_plural}/[id]/route.ts (for PATCH/DELETE)
Auto-Generated Features:
  • NextResponse imports
  • Prisma client singleton import
  • Zod validation schemas (for POST/PATCH)
  • Try-catch error handling
  • Appropriate status codes (200, 201, 400, 500)

3. manage_react_component

Manage React components with functional implementations. Parameters:
  • project_dir (str, required): Project directory
  • component_name (str, required): Component name
  • component_type (str, optional): โ€œserverโ€ | โ€œclientโ€
  • resource_name (str, optional): Associated resource
  • fields (Dict[str, str], optional): Field definitions (auto-read from schema)
  • variant (str, optional): Component variant
Variants:
  • "list": Server component showing all items
  • "form": Client component for create/edit
  • "new": Client page using form component
  • "detail": Client page for view/edit/delete
  • "actions": Client component for edit/delete buttons
Returns:
Auto-Generated Tests:
  • Form component: src/components/__tests__/{Resource}Form.test.tsx
  • Actions component: src/components/__tests__/{Resource}Actions.test.tsx

Design System Tools

4. setup_app_styling

Set up app-wide styling with modern dark theme. Parameters:
  • project_dir (str, required): Project directory
  • app_title (str, optional): App title (default: โ€œMy Appโ€)
  • app_description (str, optional): App description
Returns:
Generated Files:
  • src/app/layout.tsx: Root layout with dark theme
  • src/app/globals.css: Global styles with design system
Design System Classes:
  • .glass-card: Glass morphism card effect
  • .btn-primary: Primary gradient button
  • .btn-secondary: Secondary button
  • .btn-danger: Danger/delete button
  • .input-field: Styled form input
  • .checkbox-modern: Modern checkbox
  • .page-title: Gradient title text
  • .link-back: Back navigation link
  • Custom scrollbar styling

5. update_landing_page

Update landing page with resource links. Parameters:
  • project_dir (str, required): Project directory
  • resource_name (str, required): Resource name
  • description (str, optional): Link description
Returns:

High-Level Scaffolding

6. generate_crud_scaffold

Generate complete CRUD scaffold with all files. Parameters:
  • project_dir (str, required): Project directory
  • resource_name (str, required): Resource name
  • fields (Dict[str, str], required): Field definitions
Returns:
Generated Structure:

7. validate_crud_completeness

Validate complete CRUD structure exists. Parameters:
  • project_dir (str, required): Project directory
  • resource_name (str, required): Resource name
Returns:

Testing & Validation Tools

8. setup_nextjs_testing

Set up Vitest testing infrastructure. Parameters:
  • project_dir (str, required): Project directory
  • resource_name (str, optional): Resource for Prisma mocks
Returns:
Installed Dependencies:
  • vitest
  • @vitejs/plugin-react
  • jsdom
  • @testing-library/react
  • @testing-library/jest-dom
  • @testing-library/user-event
Generated Files:
  • vitest.config.ts: Vitest configuration
  • tests/setup.ts: Test setup with mocks

9. generate_style_tests

Generate CSS and styling validation tests. Parameters:
  • project_dir (str, required): Project directory
  • resource_name (str, optional): Resource name
Returns:
Generated Tests:
  • tests/styles.test.ts: CSS integrity tests
  • tests/styling/routes.test.ts: App router structure tests

Configuration Tools

10. manage_web_config

Manage configuration files. Parameters:
  • project_dir (str, required): Project directory
  • config_type (str, required): โ€œenvโ€ | โ€œnextjsโ€ | โ€œtailwindโ€
  • updates (Dict[str, Any], required): Configuration updates
Returns:

11. manage_prisma_client

Regenerate the Prisma client and keep the projectโ€™s Prisma bindings in sync after manage_data_model calls. Invoked by the code agent after schema edits so subsequent CRUD operations see the new types. Parameters:
  • project_dir (str, required): Project directory containing the Prisma schema
Returns:

Helper Functions

read_prisma_model

Read model definition from Prisma schema (Phase 1 Fix - Issue #885). Parameters:
  • project_dir (str): Project directory
  • model_name (str): Model name
Returns:
Usage:

Usage Examples

Example 1: Build Complete CRUD App

Example 2: Incremental Component Development

Example 3: Schema-Aware Development


Dependencies


Testing Requirements

File: tests/agents/code/test_web_tools.py

WebToolsMixin Technical Specification