用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/Arete-Consortium/ai-skills --skill seed命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
| name | seed |
| description | Test Data Generation |
| lifecycle | experimental |
Generate realistic test data and fixtures.
/seed User 100 # Generate 100 User records
/seed --schema models.py # Generate from model definitions
/seed --format json # Output format (json, sql, csv)
/seed --realistic # Use realistic fake data
# Input: models.py
class User:
id: int
username: str
email: str
created_at: datetime
is_active: bool
class Order:
id: int
user_id: int # FK to User
total: Decimal
status: str
created_at: datetime
# fixtures/users.py
from datetime import datetime
from faker import Faker
fake = Faker()
def generate_users(count: int = 10) -> list[dict]:
"""Generate fake user data."""
users = []
for i in range(count):
users.append({
"id": i + 1,
"username": fake.user_name(),
"email": fake.email(),
"created_at": fake.date_time_between(
start_date="-1y", end_date="now"
).isoformat(),
"is_active": fake.boolean(chance_of_getting_true=90),
})
return users
def generate_orders(users: list[dict], count: int = 50) -> list[dict]:
"""Generate fake orders linked to users."""
orders = []
statuses = ["pending", "completed", "cancelled", "refunded"]
for i in range(count):
user = fake.random_element(users)
orders.append({
"id": i + 1,
"user_id": user["id"],
: (fake.pydecimal(
left_digits=, right_digits=, positive=
)),
: fake.random_element(statuses),
: fake.date_time_between(
start_date=user[], end_date=
).isoformat(),
})
orders
USERS = generate_users()
ORDERS = generate_orders(USERS, )
{
"users": [
{
"id": 1,
"username": "john_doe",
"email": "john@example.com",
"created_at": "2024-01-15T10:30:00",
"is_active": true
}
],
"orders": [
{
"id": 1,
"user_id": 1,
"total": 99.99,
"status": "completed",
"created_at": "2024-01-20T14:00:00"
}
]
}
INSERT INTO users (id, username, email, created_at, is_active) VALUES
(1, 'john_doe', 'john@example.com', '2024-01-15 10:30:00', true),
(2, 'jane_smith', 'jane@example.com', '2024-01-16 11:00:00', true);
INSERT INTO orders (id, user_id, total, status, created_at) VALUES
(1, 1, 99.99, 'completed', '2024-01-20 14:00:00'),
(2, 1, 49.50, 'pending', '2024-01-21 09:30:00');
id,username,email,created_at,is_active
1,john_doe,john@example.com,2024-01-15T10:30:00,true
2,jane_smith,jane@example.com,2024-01-16T11:00:00,true
# conftest.py
import pytest
from fixtures.users import USERS, ORDERS
@pytest.fixture
def sample_users():
"""Provide sample user data."""
return USERS[:10]
@pytest.fixture
def sample_user():
"""Provide a single sample user."""
return USERS[0]
@pytest.fixture
def sample_orders(sample_users):
"""Provide orders for sample users."""
user_ids = {u["id"] for u in sample_users}
return [o for o in ORDERS if o["user_id"] in user_ids]
@pytest.fixture
def db_with_data(db_session, sample_users, sample_orders):
"""Database populated with sample data."""
for user in sample_users:
db_session.add(User(**user))
for order in sample_orders:
db_session.add(Order(**order))
db_session.commit()
return db_session
| Field Type | Faker Method |
|---|---|
| Name | fake.name() |
fake.email() | |
| Username | fake.user_name() |
| Password | fake.password() |
| Phone | fake.phone_number() |
| Address | fake.address() |
| City | fake.city() |
| Country | fake.country() |
| Date | fake.date_between() |
| DateTime | fake.date_time_between() |
| Text | fake.text() |
| Paragraph | fake.paragraph() |
| UUID | fake.uuid4() |
| URL | fake.url() |
| IPv4 | fake.ipv4() |
| Price | fake.pydecimal() |
| Boolean | fake.boolean() |
def generate_product():
return {
"id": fake.uuid4(),
"name": fake.catch_phrase(),
"description": fake.paragraph(),
"price": float(fake.pydecimal(left_digits=2, right_digits=2)),
"sku": fake.bothify("???-####"),
"category": fake.random_element(["Electronics", "Clothing", "Books"]),
"in_stock": fake.boolean(chance_of_getting_true=80),
}
def generate_pilot():
return {
"id": fake.random_int(90000000, 99999999),
"name": f"{fake.first_name()} {fake.last_name()}",
"corporation": fake.company(),
"security_status": round(fake.pyfloat(min_value=-10, max_value=5), 2),
"ship_type": fake.random_element(["Rifter", "Caracal", "Dominix"]),
}
When /seed is invoked: