faker
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "faker" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-eabfd74cfd21ab25615a51cf8e8c6f5aea356bdb7fd8d31d2d710893c4df6be6. Verify the upstream source and version against https://github.com/TerminalSkills/skills before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Faker: A tool for generating realistic fake data for testing, database seeding, or prototyping. Use when users mention “faker,” fake data, test data generation, seed data, mock data, random names, or realistic test data. For API mocking, refer to mockoon or wiremock.
Introduction source: third_party · TerminalSkills · 1.0.0 Reference
SkillPi interpretation
- Tasks
- When the user wants to generate realistic fake data for testing, seeding databases, or prototyping. Also use when the user mentions "faker," "fake data," "test data generation," "seed data," "mock data," "random names," or "realistic test data." For API mocking, see mockoon or wiremock.
- Software, accounts and paid services
- ```bash
- Testing
- Not tested
Browse files
Frontmatter
name: faker
description: When the user wants to generate realistic fake data for testing, seeding databases, or prototyping. Also use when the user mentions "faker," "fake data," "test data generation," "seed data," "mock data," "random names," or "realistic test data." For API mocking, see mockoon or wiremock.
metadata:
author: terminal-skills
version: "1.0.0"
category: development
tags:
- test-data
- data-generation
- seeding
- prototypingFaker
Overview
You are an expert in Faker.js (@faker-js/faker), the library for generating realistic fake data. You help users generate names, emails, addresses, dates, commerce data, and more across multiple locales. You understand seeding for reproducible data, creating custom generators, generating bulk datasets, and using Faker in tests, database seeders, and Storybook stories.
Instructions
Initial Assessment
- Purpose — Testing, database seeding, prototyping, or demos?
- Language — JavaScript/TypeScript, Python, Ruby, PHP, or other?
- Data shape — What entities need fake data? (users, products, orders)
- Locale — Which language/region? (en, de, fr, ja, etc.)
Setup
# setup-faker.sh — Install Faker.js.
npm install --save-dev @faker-js/faker
Basic Usage
// generate-data.ts — Basic Faker.js usage for common data types.
// Generates names, emails, addresses, and more.
import { faker } from '@faker-js/faker';
const user = {
id: faker.string.uuid(),
firstName: faker.person.firstName(),
lastName: faker.person.lastName(),
email: faker.internet.email(),
avatar: faker.image.avatar(),
phone: faker.phone.number(),
address: {
street: faker.location.streetAddress(),
city: faker.location.city(),
state: faker.location.state(),
zip: faker.location.zipCode(),
country: faker.location.country(),
},
company: faker.company.name(),
jobTitle: faker.person.jobTitle(),
bio: faker.lorem.paragraph(),
createdAt: faker.date.past(),
};
console.log(user);
Generating Collections
// generate-users.ts — Generate an array of fake users with consistent shape.
// Useful for seeding databases or populating test fixtures.
import { faker } from '@faker-js/faker';
interface User {
id: string;
name: string;
email: string;
role: 'admin' | 'user' | 'moderator';
isActive: boolean;
createdAt: Date;
}
function createRandomUser(): User {
return {
id: faker.string.uuid(),
name: faker.person.fullName(),
email: faker.internet.email().toLowerCase(),
role: faker.helpers.arrayElement(['admin', 'user', 'moderator']),
isActive: faker.datatype.boolean({ probability: 0.8 }),
createdAt: faker.date.between({ from: '2023-01-01', to: new Date() }),
};
}
const users = faker.helpers.multiple(createRandomUser, { count: 100 });
console.log(`Generated ${users.length} users`);
Reproducible Data with Seeds
// seeded-data.ts — Use seeds for reproducible fake data across test runs.
// Same seed always produces the same data.
import { faker } from '@faker-js/faker';
faker.seed(42);
const user1 = faker.person.fullName();
const email1 = faker.internet.email();
// Reset seed for a different but equally reproducible set
faker.seed(123);
const user2 = faker.person.fullName();
Multiple Locales
// localized-data.ts — Generate fake data in different languages and locales.
// Each locale produces culturally appropriate names, addresses, etc.
import { faker, fakerDE, fakerFR, fakerJA } from '@faker-js/faker';
const germanUser = {
name: fakerDE.person.fullName(),
address: fakerDE.location.streetAddress(),
phone: fakerDE.phone.number(),
};
const frenchUser = {
name: fakerFR.person.fullName(),
city: fakerFR.location.city(),
};
const japaneseUser = {
name: fakerJA.person.fullName(),
city: fakerJA.location.city(),
};
Database Seeder
// seeds/seed-database.ts — Database seeder using Faker for realistic test data.
// Creates users, products, and orders with proper relationships.
import { faker } from '@faker-js/faker';
import { db } from '../src/db';
async function seed() {
faker.seed(42);
const userIds: string[] = [];
for (let i = 0; i < 50; i++) {
const [user] = await db('users').insert({
name: faker.person.fullName(),
email: faker.internet.email().toLowerCase(),
avatar_url: faker.image.avatar(),
created_at: faker.date.past({ years: 2 }),
}).returning('id');
userIds.push(user.id);
}
const productIds: string[] = [];
for (let i = 0; i < 200; i++) {
const [product] = await db('products').insert({
name: faker.commerce.productName(),
description: faker.commerce.productDescription(),
price: parseFloat(faker.commerce.price({ min: 5, max: 500 })),
category: faker.commerce.department(),
image_url: faker.image.urlPicsumPhotos(),
in_stock: faker.datatype.boolean({ probability: 0.85 }),
}).returning('id');
productIds.push(product.id);
}
for (let i = 0; i < 500; i++) {
const userId = faker.helpers.arrayElement(userIds);
const itemCount = faker.number.int({ min: 1, max: 5 });
const [order] = await db('orders').insert({
user_id: userId,
status: faker.helpers.arrayElement(['pending', 'confirmed', 'shipped', 'delivered']),
total: 0,
created_at: faker.date.recent({ days: 90 }),
}).returning('id');
let total = 0;
for (let j = 0; j < itemCount; j++) {
const productId = faker.helpers.arrayElement(productIds);
const quantity = faker.number.int({ min: 1, max: 3 });
const price = parseFloat(faker.commerce.price({ min: 5, max: 100 }));
total += price * quantity;
await db('order_items').insert({
order_id: order.id,
product_id: productId,
quantity,
price,
});
}
await db('orders').where({ id: order.id }).update({ total });
}
console.log('Seeded: 50 users, 200 products, 500 orders');
}
seed().then(() => process.exit(0));
Using in Tests
// tests/user-service.test.ts — Using Faker inside unit tests for random but realistic data.
// Each test gets unique data; seed for reproducibility when debugging.
import { faker } from '@faker-js/faker';
import { UserService } from '../src/services/userService';
describe('UserService', () => {
const service = new UserService();
it('should validate email format', () => {
const validEmail = faker.internet.email();
expect(service.isValidEmail(validEmail)).toBe(true);
const invalidEmail = faker.person.firstName();
expect(service.isValidEmail(invalidEmail)).toBe(false);
});
it('should create user with all fields', async () => {
const input = {
name: faker.person.fullName(),
email: faker.internet.email(),
age: faker.number.int({ min: 18, max: 99 }),
};
const user = await service.create(input);
expect(user.name).toBe(input.name);
expect(user.email).toBe(input.email);
expect(user.id).toBeDefined();
});
});
Custom Helpers
// helpers/fake-helpers.ts — Custom Faker helpers for domain-specific data.
// Generates application-specific entities like subscriptions and invoices.
import { faker } from '@faker-js/faker';
export function fakeSubscription() {
const plans = ['free', 'pro', 'enterprise'] as const;
const plan = faker.helpers.arrayElement(plans);
return {
id: faker.string.uuid(),
plan,
price: plan === 'free' ? 0 : plan === 'pro' ? 19.99 : 99.99,
startDate: faker.date.past(),
renewalDate: faker.date.future(),
isActive: faker.datatype.boolean({ probability: 0.9 }),
};
}
export function fakeInvoice() {
return {
id: `INV-${faker.string.alphanumeric(8).toUpperCase()}`,
amount: parseFloat(faker.finance.amount({ min: 10, max: 5000 })),
currency: faker.finance.currencyCode(),
status: faker.helpers.arrayElement(['draft', 'sent', 'paid', 'overdue']),
dueDate: faker.date.soon({ days: 30 }),
lineItems: faker.helpers.multiple(
() => ({
description: faker.commerce.productName(),
quantity: faker.number.int({ min: 1, max: 10 }),
unitPrice: parseFloat(faker.commerce.price()),
}),
{ count: { min: 1, max: 5 } }
),
};
}Current listing version
1.0.0
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供 Faker.js 假数据生成能力,适用于测试、数据库填充、原型设计等高频开发场景
- 覆盖多种数据类型(姓名、邮箱、地址、商业数据等)和高级用法(种子、多语言、批量生成)
Highlights
- 触发词覆盖全面且精准(faker、假数据、测试数据生成、种子数据等),边界清晰
Areas to improve
-
description写错位置 Reported severity: Minor
顶层 frontmatter 中 description 字段为空,实际描述内容位于 skill_body 内部
Recommendation: 建议将 description 内容移至顶层 frontmatter 的 description 字段中,以符合规范
Highlights
- 结构完整,包含清晰的 Overview、Instructions 和多个端到端示例
- frontmatter 完整,涵盖作者、版本、分类和标签
Highlights
- 所有代码示例均基于 @faker-js/faker,来源明确,参数使用正确
- 涵盖种子控制、布尔概率、数组选择等异常处理机制,确保数据生成稳定可靠
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
-
Install or fetch external dependencies
Use official sources and pin versions. Check install scripts in an isolated environment. This document check does not cover code downloaded later.
Mentioned in main document · lines 34
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
```bash
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.