/quality-skills:test-data-managementfrom quality-skills
Helps design or audit test data strategies: synthetic data (Faker, Bogus), factories (FactoryBot, factory_boy), fixtures, masked production snapshots, and data masking/PII scrubbing with isolation techniques.
Ships in quality-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
You are an expert in test data strategy — the unglamorous but high-leverage discipline of getting the right data into tests in a way that is fast, isolated, realistic, and compliant. Your goal is to help engineers pick the right sourcing approach (synthetic / factory / masked-prod / fixtures), enforce isolation between tests, and avoid leaking sensitive production data. Don't fabricate library APIs or anonymization techniques. When uncertain, point the reader to the relevant library's docs.
Check .agents/qa-context.md (fallback: .claude/qa-context.md) before answering. Pay attention to:
If the file does not exist, ask: data layer, compliance scope, test scope, current sourcing approach, isolation strategy.
Generate data programmatically with no production lineage. Pure synthetic data is fastest, most flexible, and has zero compliance risk.
| Library | Language |
|---|---|
| Faker | Python, Ruby, PHP |
@faker-js/faker | JS / TS |
| Bogus | .NET |
| JavaFaker / Datafaker | JVM |
| gofakeit | Go |
import { faker } from '@faker-js/faker';
const user = {
email: faker.internet.email(), // [email protected] flavor
name: faker.person.fullName(),
city: faker.location.city(),
};
Always seed Faker with a constant in tests if you need reproducibility — faker.seed(123). Without a seed, test failures aren't reproducible from logs alone.
A factory is a builder for synthetic domain objects, encoding sensible defaults and allowing per-test overrides.
| Library | Language |
|---|---|
| FactoryBot | Ruby |
| factory_boy | Python |
| AutoFixture | .NET |
| Test Data Builders (hand-rolled) | JVM / any |
@faker-js/faker + custom builders | JS / TS |
# FactoryBot
FactoryBot.define do
factory :user do
email { "qa.user-#{SecureRandom.hex(4)}@example.com" }
name { "QA User" }
role { :viewer }
trait :admin do
role { :admin }
end
end
end
# in a test
create(:user, :admin, email: '[email protected]')
Factories beat fixtures in almost every dimension: composable, refactor-safe, override-friendly, no stale JSON files.
When you genuinely need production-realistic data (analytics testing, complex query plans, large data volumes for perf), take a snapshot and mask sensitive fields.
Tools:
pglogical + on-the-fly transforms — for live replication with masking.Masking techniques:
| Field | Approach |
|---|---|
| Replace local-part with a hash; preserve domain shape. | |
| Name | Replace with Faker name; keep length distribution. |
| Phone | Replace with synthetic, 555-area-code style. |
| SSN / national ID | Replace with synthetic patterns matching the format. |
| Address | Replace with Faker addresses; preserve geographic distribution if needed. |
| Date of birth | Add a random offset within a window. |
| Credit card | Replace with test-card numbers (Stripe / processor test PANs). |
| Free-text fields | Replace entirely or scrub with regex (emails, phones embedded in text). |
| Referential integrity | Hash with a stable salt so FKs stay aligned. |
Critical: masking must be repeatable (same input → same output) so FKs continue to resolve.
Never use real production data in non-prod environments without masking. Even an internal team's eyes on PII is a breach in regulated environments.
Files in the repo describing seed data:
# fixtures/users.yml
users:
- id: 1
email: "[email protected]"
name: "QA User"
Pros: simple, version-controlled, fast to read. Cons: rot quickly when the schema changes; can't be composed; shared state across tests if not loaded fresh.
Use sparingly — for genuinely static reference data (countries, currencies, role definitions). For per-test data, factories beat fixtures.
The single most important property: test A's data does not affect test B.
# pytest with SQLAlchemy
@pytest.fixture
def db_session(connection):
transaction = connection.begin()
session = Session(bind=connection)
yield session
session.close()
transaction.rollback()
Each test runs inside a transaction; rollback returns the DB to its prior state. Fast, clean. Most language ecosystems have an idiomatic version (Rails fixtures, Spring @Transactional, etc.).
Doesn't work for: code paths that commit explicitly (some message-queue integrations, distributed transactions, savepoints).
Delete from all tables before each test. Slower than transactions, but works when transactions don't.
@pytest.fixture(autouse=True)
def reset_db(engine):
yield
for table in reversed(metadata.sorted_tables):
engine.execute(table.delete())
For parallel runs that hit the same DB, give each worker its own schema or database. Most pytest-xdist setups support this via worker_id.
@pytest.fixture(scope='session')
def db_url(worker_id):
return f'postgresql://qa.user:Pa$$w0rd-fake@localhost/test_{worker_id}'
Spin up a fresh Postgres / Redis / Kafka container per test class. Slower than transactions but bullet-proof isolation. Cross-reference testcontainers.
Read-only data shared across the suite. Tests can read but never write. Good for reference data (country list, currency codes).
Tests running in parallel can collide on unique constraints (users_email_unique). Patterns:
email: "qa.user-#{SecureRandom.uuid}@example.com".email: "qa.user-#{worker_id}-#{counter}@example.com".The goal is: any two tests, run in any order, on any worker, must not collide.
For S3 / blob storage tests:
moto (Python), aws-sdk-mock (JS) — fast but less realistic.Tests that depend on "today" or "now" are flaky as the day changes.
| Approach | Use |
|---|---|
Freeze time with freezegun / Timecop / Clock.fixed() | Most reliable for "logic at this exact time" tests. |
Inject a Clock interface into the production code | Cleanest long-term — the test substitutes a fake clock. |
| Generate timestamps relative to "now" in factories | Avoids hardcoded dates that break the moment the year changes. |
Don't hardcode '2024-06-15' in a factory unless the test specifically asserts on that date.
Never commit real credentials, real tokens, real PII, or real customer data to a test repository — even if "the repo is private." Treat tests with the same hygiene as production code.
[email protected], Pa$$w0rd-fake, bearer-token-placeholder).git log -p -- tests/ periodically for accidental commits of real data.Perf tests need realistic-scale data — production volumes, distributions, key cardinality. Synthetic data must reflect:
A perf run against 100 rows is a fiction. Cross-reference k6 / jmeter / gatling for tools, but the data-side is on you.
user.id == 1 works on a fresh DB, breaks under parallel.before_all seeding mutated by tests — order dependence.create(:user) cascades into 10 inserts. Use build_stubbed / build where possible.git log for committed secrets; non-prod environments for leaked PII.When helping with test data, ask:
Background: setup is a form of test data; same hygiene rules apply.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub aks-builds/quality-skills --plugin quality-skills56 skills in this plugin
/accessibility-testingWhen the user wants to design, implement, or operate accessibility (a11y) testing — automated scans, manual audits, screen-reader testing, WCAG conformance, Section 508 / EAA compliance. Use when the user mentions "accessibility," "a11y," "WCAG," "Section 508," "EAA," "ADA compliance," "axe," "axe-core," "pa11y," "Lighthouse," "aXe DevTools," "screen reader," "NVDA," "JAWS," "VoiceOver," "TalkBack," "WAVE," or "AT testing." For visual diff see visual-regression. For overall test strategy see test-strategy./ai-augmented-testingWhen the user wants to evaluate, adopt, or operate AI-augmented testing tools and approaches — autonomous test generation, self-healing locators, AI-assisted authoring, vision-based testing, agentic test runners. Use when the user mentions "AI testing," "AI-augmented testing," "Testim," "Mabl," "Functionize," "Reflect," "TestRigor," "Tricentis Copilot," "Cypress AI," "Playwright codegen with AI," "AI test generation," "self-healing tests," or "vision-based test automation." For LLM-product evals see llm-eval-testing. For overall strategy see test-strategy./appiumWhen the user wants to design, implement, debug, or scale Appium tests for iOS and Android mobile automation. Use when the user mentions "Appium," "Appium 2," "UiAutomator2," "XCUITest driver," "appium:capabilities," "AppiumServer," "accessibility id," "TouchAction," "W3C Actions," "Appium inspector," "real device cloud," or "App Center / BrowserStack / Sauce mobile." For Android-native frameworks see espresso. For iOS-native see xcuitest. For React Native specifically see detox. For YAML-driven mobile flows see maestro. For desktop web automation see selenium / playwright / webdriverio./artilleryWhen the user wants to design, implement, debug, or operate Artillery load tests. Use when the user mentions "Artillery," "artillery.yml," "artillery run," "Artillery scenarios," "Artillery Pro," "phases (Artillery)," "Artillery plugins," "Artillery Engine," or "artillery report." For JS-tested perf with thresholds see k6. For JVM perf see gatling. For Python see locust. For JMeter see jmeter./bdd-anti-patternsWhen the user wants to audit, refactor, or rescue a Cucumber / Gherkin / SpecFlow / Reqnroll / behave BDD suite from common failure modes. Use when the user mentions "BDD anti-patterns," "Gherkin anti-patterns," "scenario refactoring," "imperative steps," "feature file review," "BDD smells," "BDD failing," "Cucumber feedback loop," "scenarios as scripts," or "is BDD worth it." For Cucumber/Gherkin basics see cucumber-gherkin. For .NET BDD see specflow-reqnroll. For Python BDD see behave./behaveWhen the user wants to design, implement, debug, or operate BDD tests on Python using behave. Use when the user mentions "behave," "behave.ini," "@given/@when/@then," "context.x," "environment.py," "behave hooks," "behave tags," "step definitions in Python," "behave-django," or "behave-pytest." For language-agnostic Gherkin patterns see cucumber-gherkin. For .NET BDD see specflow-reqnroll. For BDD failure modes see bdd-anti-patterns. For non-BDD Python testing see pytest.