faker
БесплатноБез исполняемых скриптовНе проверенGenerates realistic, repeatable test data with @faker-js/faker: typed factories, seeded output, locale-aware names and addresses, related records and database…
от 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, orbilling.testabove) 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 returnsundefinedotherwise. - 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(
Установить faker в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
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), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic