generate-factory

Generate test data factories from TypeScript interfaces, Prisma schemas, JSON schemas, database migrations, or OpenAPI specs.

175|26|Updated Aug 14, 2025
One-click install
npx skills add https://github.com/jmagly/ai-writing-guide --skill generate-factory
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: generate-factory
Source: https://github.com/jmagly/ai-writing-guide/tree/main/.factory/skills/generate-factory
Command: npx skills add https://github.com/jmagly/ai-writing-guide --skill generate-factory

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Auto-generates test data factories from schemas, reducing boilerplate and speeding up tests.

Core Features & Use Cases

  • Schema-aware generation: Factories from TypeScript, JSON Schema, or DB schemas.
  • Traits & relationships: Support for common variations and related entities.
  • Output: Factory files and example usage.

Quick Start

Generate a User factory from a TypeScript interface with a few overrides.

Frequently Asked Questions about generate-factory

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I auto-generate test data factories from TypeScript interfaces or Prisma schemas?

Auto-generate test data factories by feeding TypeScript interfaces, Prisma schemas, JSON schemas, or database migrations to the Skill. It analyzes the structure, maps fields to Faker.js generators, and produces factory code with build, buildList, and trait methods, eliminating manual fixture boilerplate.

Can I create factories with realistic yet deterministic test data?

Yes. The Skill generates deterministic test data using Faker.js patterns, producing realistic values for primitives and named fields while remaining reproducible for consistent test runs and reliable CI/CD execution.

Does the generated factory code support relationships between entities?

Yes. Generated factories support related entities and relationships through traits and buildWithTrait methods, allowing you to create interconnected test fixtures—such as users with posts—without writing relationship setup manually.

What input formats can I convert into test data factories?

The Skill accepts TypeScript interfaces, Prisma schemas, JSON schemas, database migrations, and OpenAPI specs as input. It analyzes any of these formats and generates matching factory code with the same structure and field mappings.

How does factory generation reduce test setup boilerplate?

Instead of writing factory methods by hand, the Skill analyzes your schema once and generates complete factory code with sensible Faker defaults for all fields. When schemas evolve, regenerate factories to stay in sync, eliminating manual updates.

Can I customize generated factories with overrides?

Yes. The generated factories support overrides, letting you specify custom values for particular fields while retaining Faker-generated defaults for the rest, giving you flexibility without rewriting the entire factory.