test-data-factory

test-data-factory is a skill for Claude Code from rshankras/claude-code-apple-skills. It costs 34 tokens per session (2,301 once invoked), scanned A, original, MIT.

A set of helpers that creates sample model data for tests, using builder-style or static factory methods. Test fixtures are prepared values used to set up a test.

In plain words
What is it for?
Use it to generate model fixtures, create realistic sample data, and simplify tests that repeatedly construct the same objects.
Why use it?
It reduces repeated setup code and lets each test override only the fields relevant to that test.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: names the AskUserQuestion tool.

Part of the apple-skills plugin — 182 skills shipped together , and of apple-skills

Good fit Use it to generate model fixtures, create realistic sample data, and simplify tests that repeatedly construct the same objects.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/rshankras/claude-code-apple-skills/test-data-factory
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add rshankras/claude-code-apple-skills --skill test-data-factory
Clone the repo
git clone --depth 1 https://github.com/rshankras/claude-code-apple-skills

Made for: Claude Code.

Or install apple-skills, the plugin that ships this one along with the rest of its 182 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for test-data-factory

README.md
[![agentmods](https://agentmods.dev/badge/skills/rshankras/claude-code-apple-skills/test-data-factory/github.svg)](https://agentmods.dev/skills/rshankras/claude-code-apple-skills/test-data-factory)
Your own site
<a href="https://agentmods.dev/skills/rshankras/claude-code-apple-skills/test-data-factory"><img src="https://agentmods.dev/badge/skills/rshankras/claude-code-apple-skills/test-data-factory/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for test-data-factory

Your own site · 80×15
<a href="https://agentmods.dev/skills/rshankras/claude-code-apple-skills/test-data-factory"><img src="https://agentmods.dev/badge/skills/rshankras/claude-code-apple-skills/test-data-factory.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 34 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,301 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00034 $0.02301
Opus 5.5 $0.00014 $0.00920
Sonnet 5.5 $0.00007 $0.00460
Haiku 4.5 $0.00003 $0.00230

Measured 2d ago against content hash 503d04f8a708, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

test-data-factory scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/testing/test-data-factory/SKILL.md · 353 lines

How it starts

The opening of the file, as written. The whole thing — 353 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Test Data Factory

Generate factory helpers that make creating test data effortless. Eliminates boilerplate in test setup so writing tests has zero friction.

When This Skill Activates

Use this skill when the user:

  • Has repetitive test setup code
  • Asks for "test fixtures" or "test factories" or "sample data"
  • Wants to reduce boilerplate in tests
  • Says "my tests have too much setup"
  • Is building a test suite and needs realistic sample data
  • Mentions "builder pattern" for tests

Why Test Factories

// ❌ Without factory — every test repeats this
let item = Item(
    id: UUID(),
    title: "Test Item",
    description: "A test description",
    category: .general,
    createdAt: Date(),
    updatedAt: Date(),
    isFavorite: false,
    tags: [],
    author: User(id: UUID(), name: "Test User", email: "[email protected]")
)

// ✅ With factory — one line, override only what matters
let item = Item.fixture()
let favoriteItem = Item.fixture(isFavorite: true)
let taggedItem = Item.fixture(tags: ["swift", "testing"])

Process

Phase 1: Discover Models

Glob: **/*.swift (in source targets)
Grep: "struct.*:.*Identifiable|class.*:.*Identifiable|@Model"
Grep: "struct.*:.*Codable|struct.*:.*Sendable"

Identify models that appear in test files:

Grep: "let.*=.*Model(" in test targets (manual construction)

Phase 2: Choose Factory Pattern

Ask via AskUserQuestion:

  1. Factory style?

    • Static factory methods (simpler, recommended)
    • Builder pattern (more flexible, for complex models)
    • Both
  2. Where to add?

    • Test target extension (recommended — keeps production code clean)
    • Shared test helper file

Phase 3: Generate Factories

Pattern 1: Static Factory Extension
// Tests/Factories/Item+Factory.swift

import Foundation
@testable import YourApp

extension Item {
    /// Creates a test fixture with sensible defaults.
    /// Override only the properties relevant to your test.
    static func fixture(
        id: UUID = UUID(),
        title: String = "Test Item",
        description: String = "A test description",
        category: Category = .general,
        createdAt: Date = Date(timeIntervalSince1970: 1_700_000_000),
        updatedAt: Date = Date(timeIntervalSince1970: 1_700_000_000),
        isFavorite: Bool = false,
        tags: [String] = [],
        author: User = .fixture()
    ) -> Item {
        Item(
            id: id,
            title: title,
            description: description,
            category: category,
            createdAt: createdAt,
            updatedAt: updatedAt,
            isFavorite: isFavorite,
            tags: tags,
            author: author
        )
    }

    /// Named fixtures for common test scenarios
    static var sample: Item { .fixture() }
    static var favorite: Item { .fixture(isFavorite: true) }
    static var empty: Item { .fixture(title: "", description: "") }

    /// Collection fixtures
    static var sampleList: [Item] {
        [
            .fixture(id: UUID(), title: "First Item", category: .work),
            .fixture(id: UUID(), title: "Second Item", category: .personal),
            .fixture(id: UUID(), title: "Third Item", category: .general)
        ]
    }
}

extension User {
    static func fixture(
        id: UUID = UUID(),
        name: String = "Test User",
        email: String = "[email protected]"
    ) -> User {
        User(id: id, name: name, email: email)
    }

    static var sample: User { .fixture() }
}

Read the full file on GitHub · 353 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 353 lines · 34 tokens per session scan A 503d04f8a708

Subscribe to this mod's changes

test-data-factory is a skill published in the GitHub repository rshankras/claude-code-apple-skills (867 stars, last pushed today), licensed MIT. It adds 34 tokens to every session and 2,301 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-11-05.

Related

test-data-factory compared with skills from other repositories

test-data-factory next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
test-data-factoryrshankras/claude-code-apple-skillsSkill867todayMITA34Claude Code
tdd-workflowaffaan-m/ECCSkill299ktodayMITA43Claude Code, Codex
cpp-testingaffaan-m/ECCSkill299ktodayMITA34Claude Code, Kiro
swift-protocol-di-testingaffaan-m/ECCSkill299ktodayMITA32Claude Code, Kiro
temporal-python-testingwshobson/agentsSkill42k2d agoMITA45Claude Code
image-crop-rotateinstavm/coderunnerSkill9013d agoApache-2.0A50Claude Code, Codex
test-generatorvstorm-co/pydantic-deepagentsSkill1.1k8d agoMITA12Claude Code, Codex