Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

faker

БесплатноБез исполняемых скриптовНе проверен

Generates realistic, repeatable test data with @faker-js/faker: typed factories, seeded output, locale-aware names and addresses, related records and database…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

Realistic Test Data with Faker

Overview

@faker-js/faker generates plausible names, emails, addresses, prices, dates and free text. It is the right tool when a test or a dev database needs data that looks real and varies, without using real people's records. The two things that decide whether it helps or hurts are repeatability (the same run must give the same data, or failures cannot be reproduced) and consistency (an invoice whose VAT does not match its net amount teaches your tests nothing).

This skill covers the JavaScript/TypeScript library, current major version 10 (verified with 10.6.0). Python's Faker has the same idea and a similar API (Faker.seed(1), fake.name()), but the module names below are JavaScript only.

Not for: load testing with millions of rows where speed matters more than realism (generate with SQL or a streaming script), anonymising real data (use a masking tool; faker output is unrelated to the source), or security fixtures such as real-looking card numbers that must pass a payment processor (use the processor's test values).

Instructions

1. Look up before you write

Check package.json for an existing faker version and for a factory folder (test/factories, tests/support, prisma/seed.ts). Match the repo's module system and test runner. Ask the user only for what you cannot see: the entity shapes if there is no schema or types, the locales needed, and whether data goes into a test, a fixture file or a dev database.

npm install --save-dev @faker-js/faker

Import the default English instance as faker. For other locales import the localized instance, for example fakerDE, fakerPL, fakerJA.

2. Make one factory per entity

A factory is a function that returns a complete valid object and accepts overrides. Tests then state only what matters to them.

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

export function buildInvoice(overrides = {}) {
  const net = faker.number.int({ min: 5000, max: 250000 });
  return {
    id: faker.string.uuid(),
    number: `INV-${faker.string.numeric(6)}`,
    customer: {
      name: faker.company.name(),
      email: faker.internet.email({ provider: 'billing.test' }),
    },
    currency: faker.helpers.arrayElement(['EUR', 'USD', 'PLN']),
    netCents: net,
    vatCents: Math.round(net * 0.21),
    issuedAt: faker.date.recent({ days: 60 }),
    status: faker.helpers.arrayElement(['draft', 'sent', 'paid']),
    ...overrides,
  };
}

Guidance for fields:

  • Money as integer minor units, derived values computed from the base value, not generated separately.
  • Emails on a reserved or owned test domain (.test, or billing.test above) so nothing is ever delivered to a real address.
  • Enumerations from the real enum, not free text.
  • Optional fields: use faker.helpers.maybe(() => value, { probability: 0.3 }) so some records omit them. It returns undefined otherwise.
  • Weighted choices when production skews: faker.helpers.weightedArrayElement([{ weight: 8, value: 'member' }, { weight: 2, value: 'admin' }]).

3. Make it repeatable

Call faker.seed(n) before generating. The same seed gives the same sequence with the same library version.

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

beforeEach(() => {
  faker.seed(20261022);
  faker.setDefaultRefDate('2026-10-22T08:00:00Z');
});

The reference date matters: faker.date.recent() and birthdate() are relative to "now", so without setDefaultRefDate a seeded test still changes from day to day. Seed in beforeEach so tests do not depend on execution order. If a failure shows up with random data, print the seed (use a fresh faker.seed() return value, or generate one from the CI run number) so it can be replayed.

Upgrading faker can change what a seed produces. Do not store seeded output as a golden file unless the library version is pinned and bumping it is a deliberate step.

4. Related records

Generate parents first, then pick from them. Do not call faker.string.uuid() for a foreign key and hope it matches.

const customers = faker.helpers.multiple(
  () => ({ id: faker.string.nanoid(8), name: faker.person.fullName() }),
  { count: 20 },
);
const orders = faker.helpers.multiple(
  () => ({
    id: faker.string.uuid(),
    customerId: faker.helpers.arrayElement(customers).id,
    total: faker.number.float({ min: 10, max: 300, fractionDigits: 2 }),
  }),
  { count: 80 },
);

For values that must not repeat (usernames, SKUs), use faker.helpers.uniqueArray(generator, count) or build the value from the row index, for instance SKU-${String(i).padStart(5, '0')}. Random generators alone will eventually collide.

5. Locales

Use the localized instance when a field must look right for a market. Do not mix locales inside one record unless that is the point.

import { fakerDE, fakerPL } from '@faker-js/faker';

fakerDE.person.fullName();   // German name
fakerPL.location.zipCode(
Полный SKILL.md на GitHub

Установить faker в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл faker?

Generates realistic, repeatable test data with @faker-js/faker: typed factories, seeded output, locale-aware names and addresses, related records and database seed scripts. Use when the user asks for "fake data", "faker", "seed data", "mock data", "test data factory", "random but reproducible test data" or needs to fill a dev database or fixtures without copying production data.

Как установить скилл faker?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл faker запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить faker с