Skip to main content
Component: ValidationToolsMixin Module: gaia_agent_code.tools.validation_tools Import: from gaia_agent_code.tools.validation_tools import ValidationToolsMixin

Overview

ValidationToolsMixin provides comprehensive testing and validation tools for Next.js applications with Prisma. It includes CRUD API testing, TypeScript validation, file structure validation, and CSS integrity checks. Key Features:
  • Test CRUD API endpoints using curl
  • Validate TypeScript compilation
  • Validate CRUD application structure
  • Validate CSS files for common issues
  • Schema-aware test payload generation
  • Automatic dev server management
  • Tier 4 error messaging with rule citations

Tool Specifications

1. test_crud_api

Test CRUD API endpoints with automatic payload generation from schema. Parameters:
  • project_dir (str, required): Path to Next.js project
  • model_name (str, required): Model name (e.g., “Todo”, “Post”)
  • port (int, optional): Dev server port (default: 3000)
Returns:
Test Sequence:
  1. Ensure dev server is running (start if needed)
  2. Read Prisma schema to get field definitions
  3. Generate test payload from schema fields
  4. POST: Create test record (expect 201)
  5. GET_LIST: List all records (expect 200)
  6. GET_SINGLE: Get created record (expect 200)
  7. PATCH: Update record (expect 200)
  8. DELETE: Delete record (expect 200)
  9. Cleanup: Stop dev server if we started it

2. validate_typescript

Validate TypeScript code with tier 4 error messaging. Parameters:
  • project_dir (str, required): Path to Next.js project
Returns:
Detected Violations:
  • Missing type imports
  • Missing Prisma singleton
  • Prisma types not generated
  • Direct prisma import in client component
Example Error Response:

3. validate_crud_structure

Validate that all required CRUD files exist. Parameters:
  • project_dir (str, required): Path to Next.js project
  • resource_name (str, required): Resource name (e.g., “todo”)
Returns:
Checked Files:
  • List page: src/app/{resource_plural}/page.tsx
  • New page: src/app/{resource_plural}/new/page.tsx
  • Detail page: src/app/{resource_plural}/[id]/page.tsx
  • Form component: src/components/{Resource}Form.tsx
  • Actions component: src/components/{Resource}Actions.tsx
  • Collection API: src/app/api/{resource_plural}/route.ts
  • Item API: src/app/api/{resource_plural}/[id]/route.ts

4. validate_styles

Validate CSS files and design system consistency. Parameters:
  • project_dir (str, required): Path to Next.js project
  • resource_name (str, optional): Resource name for component checks
Returns:
Validates:
  1. CSS files contain valid CSS (not TypeScript) - CRITICAL
  2. globals.css has Tailwind directives
  3. layout.tsx imports globals.css
  4. Balanced braces in CSS files
TypeScript Detection Patterns:

Helper Functions

generate_test_payload

Generate test data from Prisma field definitions. Parameters:
  • fields (Dict[str, str]): Field names to types
Returns:
Type Mappings:

_get_create_command

Generate tool command to create missing CRUD file. Parameters:
  • description (str): File description
  • resource_name (str): Resource name
Returns:

Usage Examples

Example 1: Test CRUD API

Example 2: Validate TypeScript

Example 3: Validate CRUD Structure

Example 4: Validate Styles


Testing Requirements

File: tests/agents/code/test_validation_tools.py

Dependencies


Integration with Other Mixins

Requires CLIToolsMixin

  • _run_foreground_command: Execute curl commands
  • _run_background_command: Start dev server
  • _stop_process: Stop dev server

Requires WebToolsMixin

  • read_prisma_model: Read schema for field definitions

ValidationToolsMixin Technical Specification