Token导航 LogoToken导航TokenDH.com
研究检索操作浏览器github未标认证来源可访问clear审计通过

data-seeding-fixtures-builder数据播种装置构建器

Agent Skill

用于辅助数据整理、表格处理、CSV/Excel 分析、指标计算和图表准备。它适合让 Agent 清洗字段、汇总数据、发现异常、生成统计口径或把分析结果转成可读说明。使用时需要确认数据来源、字段含义和时间范围,避免把样本数据当全量事实;涉及敏感数据、导出文件或批量写回时,应先确认权限和脱敏边界。

总安装

2,196

周安装

88

GitHub Stars

33

下载量

711
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:data-seeding-fixtures-builder(数据播种装置构建器)
来源仓库:https://github.com/patricio0312rev/skills
仓库路径:skills/data-seeding-fixtures-builder
安装命令:
npx skills add https://github.com/patricio0312rev/skills --skill data-seeding-fixtures-builder
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/patricio0312rev/skills --skill data-seeding-fixtures-builder

简介

生成真实感强的确定性测试数据,用于开发环境与生产预演场景。

  • 基于 Prisma ORM 与 Faker.js 构建可扩展的播种策略模板。
  • 支持用户、订单、产品等多实体关联数据的一键式生成。
  • 提供数据清理与批量插入优化,确保大规模播种效率。
  • 安装需集成 @faker-js/faker 与 Prisma 客户端依赖。

SKILL.md

Data Seeding & Fixtures Builder

Generate realistic, deterministic seed data for development and testing.

Seed Data Strategy

// prisma/seed.ts
import { PrismaClient } from "@prisma/client";
import { faker } from "@faker-js/faker";

const prisma = new PrismaClient();

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

  // Clear existing data
  await prisma.order.deleteMany();
  await prisma.user.deleteMany();

  // Seed users
  const users = await seedUsers(10);
  console.log(`✅ Created ${users.length} users`);

  // Seed orders
  const orders = await seedOrders(users, 50);
  console.log(`✅ Created ${orders.length} orders`);

  console.log("✅ Seeding complete!");
}

main()
  .catch((e) => {
    console.error(e);
    process.exit(1);
  })
  .finally(async () => {
    await prisma.$disconnect();
  });

Factory Functions

// factories/user.factory.ts
import { faker } from "@faker-js/faker";
import { PrismaClient, User } from "@prisma/client";

const prisma = new PrismaClient();

export interface UserFactoryOptions {
  email?: string;
  name?: string;
  role?: "USER" | "ADMIN";
}

export class UserFactory {
  static async create(options: UserFactoryOptions = {}): Promise<User> {
    return prisma.user.create({
      data: {
        email: options.email || faker.internet.email(),
        name: options.name || faker.person.fullName(),
        role: options.role || "USER",
        createdAt: faker.date.past(),
      },
    });
  }

  static async createMany(
    count: number,
    options: UserFactoryOptions = {}
  ): Promise<User[]> {
    return Promise.all(
      Array.from({ length: count }, () => this.create(options))
    );
  }

  static async createAdmin(): Promise<User> {
    return this.create({ role: "ADMIN" });
  }
}

// Usage:
// const user = await UserFactory.create();
// const admin = await UserFactory.createAdmin();
// const users = await UserFactory.createMany(10);

Realistic Fixtures

// fixtures/products.ts
import { Product } from "@prisma/client";

export const PRODUCT_FIXTURES: Omit<
  Product,
  "id" | "createdAt" | "updatedAt"
>[] = [
  {
    name: 'MacBook Pro 16"',
    description: "Powerful laptop for developers",
    price: 2499.99,
    stock: 50,
    category: "Electronics",
  },
  {
    name: "iPhone 15 Pro",
    description: "Latest flagship smartphone",
    price: 999.99,
    stock: 100,
    category: "Electronics",
  },
  {
    name: "AirPods Pro",
    description: "Wireless earbuds with noise cancellation",
    price: 249.99,
    stock: 200,
    category: "Electronics",
  },
];

// Seed products
async function seedProducts() {
  return Promise.all(
    PRODUCT_FIXTURES.map((product) => prisma.product.create({ data: product }))
  );
}

Deterministic Seeding

// Use fixed seed for reproducibility
import { faker } from "@faker-js/faker";

// Set seed for deterministic data
faker.seed(12345);

// Same data every time
const user1 = {
  email: faker.internet.email(), // Always same email
  name: faker.person.fullName(), // Always same name
};

// Reset for different test
faker.seed(67890);

Relationship Building

// factories/order.factory.ts
export class OrderFactory {
  static async create(userId: number): Promise<Order> {
    const products = await prisma.product.findMany({ take: 3 });

    const order = await prisma.order.create({
      data: {
        userId,
        status: faker.helpers.arrayElement(["pending", "paid", "shipped"]),
        total: faker.number.float({ min: 10, max: 1000, precision: 0.01 }),
      },
    });

    // Create order items
    await Promise.all(
      products.map((product) =>
        prisma.orderItem.create({
          data: {
            orderId: order.id,
            productId: product.id,
            quantity: faker.number.int({ min: 1, max: 5 }),
            price: product.price,
          },
        })
      )
    );

    return order;
  }

  static async createForUser(user: User, count: number): Promise<Order[]> {
    return Promise.all(
      Array.from({ length: count }, () => this.create(user.id))
    );
  }
}

Environment-Specific Seeds

// seeds/development.ts
export async function seedDevelopment() {
  // Development: Few records, easy to debug
  const users = await UserFactory.createMany(5);
  const products = await ProductFactory.createMany(10);

  for (const user of users) {
    await OrderFactory.createForUser(user, 2);
  }
}

// seeds/staging.ts
export async function seedStaging() {
  // Staging: Moderate data, realistic scenarios
  const users = await UserFactory.createMany(50);
  const products = await ProductFactory.createMany(100);

  for (const user of users) {
    await OrderFactory.createForUser(
      user,
      faker.number.int({ min: 1, max: 10 })
    );
  }
}

// seeds/testing.ts
export async function seedTesting() {
  // Testing: Minimal, predictable data
  faker.seed(12345); // Deterministic

  const user = await UserFactory.create({
    email: "test@example.com",
    name: "Test User",
  });

  const product = await ProductFactory.create({
    name: "Test Product",
    price: 99.99,
  });

  return { user, product };
}

// Main seed file
async function main() {
  const env = process.env.NODE_ENV;

  if (env === "development") {
    await seedDevelopment();
  } else if (env === "staging") {
    await seedStaging();
  } else if (env === "test") {
    await seedTesting();
  }
}

Database Reset Script

// scripts/reset-db.ts
import { PrismaClient } from "@prisma/client";

const prisma = new PrismaClient();

async function resetDatabase() {
  console.log("🗑️  Resetting database...");

  // Disable foreign key checks (PostgreSQL)
  await prisma.$executeRaw`SET session_replication_role = 'replica';`;

  // Get all tables
  const tables = await prisma.$queryRaw<{ tablename: string }[]>`
    SELECT tablename FROM pg_tables WHERE schemaname = 'public';
  `;

  // Truncate all tables
  for (const { tablename } of tables) {
    if (tablename !== "_prisma_migrations") {
      await prisma.$executeRawUnsafe(`TRUNCATE TABLE "${tablename}" CASCADE;`);
      console.log(`  Truncated ${tablename}`);
    }
  }

  // Re-enable foreign key checks
  await prisma.$executeRaw`SET session_replication_role = 'origin';`;

  console.log("✅ Database reset complete");
}

resetDatabase()
  .catch((e) => {
    console.error(e);
    process.exit(1);
  })
  .finally(() => prisma.$disconnect());

Test Fixtures for E2E Tests

// tests/fixtures/e2e.fixture.ts
import { test as base } from "@playwright/test";
import { UserFactory, ProductFactory } from "../factories";

type Fixtures = {
  authenticatedUser: User;
  products: Product[];
};

export const test = base.extend<Fixtures>({
  authenticatedUser: async ({ page }, use) => {
    // Create user
    const user = await UserFactory.create();

    // Login
    await page.goto("/login");
    await page.fill('[name="email"]', user.email);
    await page.fill('[name="password"]', "password123");
    await page.click('button[type="submit"]');

    await use(user);

    // Cleanup
    await prisma.user.delete({ where: { id: user.id } });
  },

  products: async ({}, use) => {
    const products = await ProductFactory.createMany(5);
    await use(products);

    // Cleanup
    await prisma.product.deleteMany({
      where: { id: { in: products.map((p) => p.id) } },
    });
  },
});

// Usage:
test("should add product to cart", async ({ authenticatedUser, products }) => {
  // Test with pre-seeded data
});

Package.json Scripts

{
  "scripts": {
    "db:seed": "tsx prisma/seed.ts",
    "db:seed:dev": "NODE_ENV=development tsx prisma/seed.ts",
    "db:seed:staging": "NODE_ENV=staging tsx prisma/seed.ts",
    "db:reset": "tsx scripts/reset-db.ts && npm run db:seed",
    "db:reset:test": "tsx scripts/reset-db.ts && NODE_ENV=test tsx prisma/seed.ts"
  }
}

Best Practices

  1. Use factories: Reusable data generation
  2. Deterministic in tests: Fixed seed values
  3. Realistic fixtures: Production-like data
  4. Environment-specific: Different needs per environment
  5. Cleanup after tests: Avoid pollution
  6. Relationship integrity: Proper foreign keys
  7. Performance: Batch inserts for large datasets

Output Checklist

  • Seed script created
  • Factory functions for each model
  • Realistic fixtures defined
  • Deterministic seeding (tests)
  • Relationship building logic
  • Environment-specific seeds
  • Database reset script
  • E2E test fixtures

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

28.05%
按下载量换算199

Gemini CLI

23.24%
按下载量换算165

Antigravity

18.6%
按下载量换算132

windsurf

12.85%
按下载量换算91

github-copilot

8.63%
按下载量换算61

Codex

4.08%
按下载量换算29

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills