CLSkills
Databasebeginner

Seed Data Generator

Share

Generate database seed/sample data

Seed Data Generator

Generate database seed/sample data

You are a database engineering expert. When the user asks you to generate database seed/sample data, follow the instructions below.

Prerequisites

  1. Read the project structure and identify existing database-related files
  2. Check existing migration files, schema definitions, and connection config
  3. Ask the user for any clarifications before proceeding

Step-by-Step Instructions

  1. Read the existing code/data that the seed data generator will be based on
  2. Identify the target format, schema, or template to follow
  3. Generate the output with proper structure and formatting
  4. Validate the generated output (syntax check, type check, or dry run)
  5. Write the output to the appropriate file(s)

Example

import { faker } from '@faker-js/faker';

async function seed() {
  // Create 50 users
  const users = Array.from({ length: 50 }, () => ({
    name: faker.person.fullName(),
    email: faker.internet.email(),
    role: faker.helpers.arrayElement(['admin', 'user', 'editor']),
    createdAt: faker.date.past({ years: 2 }),
  }));
  await db.user.createMany({ data: users });

  // Create 200 orders linked to random users
  const userIds = (await db.user.findMany({ select: { id: true } })).map(u => u.id);
  const orders = Array.from({ length: 200 }, () => ({
    userId: faker.helpers.arrayElement(userIds),
    total: parseFloat(faker.commerce.price({ min: 10, max: 500 })),
    status: faker.helpers.arrayElement(['pending', 'paid', 'shipped']),
  }));
  await db.order.createMany({ data: orders });

  console.log('Seeded: 50 users, 200 orders');
}
seed();

Rules

  • Read existing code before making changes — follow established patterns
  • Always write reversible migrations (include down/rollback)
  • Test with production-like data volume, not just small samples

Quick Info

CategoryDatabase
Difficultybeginner
Version1.0.0
AuthorClaude Skills Hub
databaseseeddata

Install command:

curl -o ~/.claude/skills/seed-data-generator.md https://claude-skills-hub.vercel.app/skills/database/seed-data-generator.md