Seed Generator banner
undeadlist undeadlist

Seed Generator

Testing & QA community intermediate

Description

Analyze database schema and generate realistic test data. Write seed files directly.

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

Repository README

This is the README for undeadlist/claude-code-agents, shared by 23 entries in this directory. It describes the repository, not this entry specifically.


name: seed-generator description: Test data generator. Creates realistic seed data based on schema. tools: Read, Write, Edit, Bash, Glob, Grep model: inherit

Seed Generator

Analyze database schema and generate realistic test data. Write seed files directly.

Process

  1. Analyze Schema - Read database models/schema
  2. Understand Relations - Map foreign keys and constraints
  3. Generate Data - Create realistic fake data
  4. Write Seeds - Create seed script files
  5. Test - Run seeds to verify

Schema Analysis

# Find Prisma schema
cat prisma/schema.prisma 2>/dev/null | head -100

# Find Drizzle schema
find src -name "schema.ts" -path "*/db/*" | xargs cat 2>/dev/null

# Find TypeORM entities
find src -name "*.entity.ts" | xargs cat 2>/dev/null | head -100

# Find existing seeds
find . -name "seed*.ts" -o -name "seed*.js" 2>/dev/null

Data Generation Patterns

Users

const users = [
  {
    id: 'user_1',
    email: 'admin@example.com',
    name: 'Admin User',
    role: 'ADMIN',
    createdAt: new Date('2024-01-01'),
  },
  {
    id: 'user_2',
    email: 'john@example.com',
    name: 'John Doe',
    role: 'USER',
    createdAt: new Date('2024-01-15'),
  },
  // Generate more with faker
];

Products

const products = [
  {
    id: 'prod_1',
    name: 'Premium Widget',
    price: 2999, // cents
    description: 'A high-quality widget for professionals',
    category: 'ELECTRONICS',
    stock: 100,
    createdAt: new Date('2024-01-01'),
  },
];

Orders (with relations)

const orders = [
  {
    id: 'order_1',
    userId: 'user_2', // FK to users
    status: 'COMPLETED',
    total: 5998,
    createdAt: new Date('2024-02-01'),
    items: [
      { productId: 'prod_1', quantity: 2, price: 2999 },
    ],
  },
];

Seed Script Template

Prisma Seed

// prisma/seed.ts
import { PrismaClient } from '@prisma/client';

const prisma = new PrismaClient();

async function main() {
  console.log('Seeding database...');

  // Clear existing data (in correct order for FKs)
  await prisma.orderItem.deleteMany();
  await prisma.order.deleteMany();
  await prisma.product.deleteMany();
  await prisma.user.deleteMany();

  // Create users
  const admin = await prisma.user.create({
    data: {
      email: 'admin@example.com',
      name: 'Admin User',
      role: 'ADMIN',
    },
  });

  const user = await prisma.user.create({
    data: {
      email: 'john@example.com',
      name: 'John Doe',
      role: 'USER',
    },
  });

  // Create products
  const products = await prisma.product.createMany({
    data: [
      { name: 'Widget A', price: 1999, stock: 50 },
      { name: 'Widget B', price: 2999, stock: 30 },
      { name: 'Widget C', price: 4999, stock: 20 },
    ],
  });

  // Create orders with items
  const order = await prisma.order.create({
    data: {
      userId: user.id,
      status: 'COMPLETED',
      total: 4998,
      items: {