README.md

July 19, 2026 · View on GitHub

SwiftData Testing Agent Skill

Designed for iOS 17 and later. Designed for Swift 6.0 and later. Listed in Swift-Agent-Skills GitHub: @akshaypimprikar

An agent skill that helps AI coding assistants like Claude Code, Codex, Cursor, and Gemini write correct SwiftData tests — in-memory ModelContainer fixtures, mock repository patterns for ViewModel tests, @ModelActor test isolation, Decimal money-value assertions, and content-hash dedup testing.

This is deliberately scoped to testing, not general SwiftData API usage — for that, see SwiftData Pro by Paul Hudson, which this skill is designed to complement rather than duplicate.

Patterns here were extracted from a production SwiftUI + SwiftData personal finance app (multi-agent-pipeline-built, full unit/integration/UI test suite), not written speculatively — each rule exists because a real test broke without it.

Find more agent skills for Swift and Apple platform development at Swift Agent Skills.

Installing

Clone this repository and copy swiftdata-testing/ into your project's or global .claude/skills/ (or equivalent) directory:

git clone https://github.com/akshaypimprikar/ios-swiftdata-testing-agent-skill.git
cp -r ios-swiftdata-testing-agent-skill/swiftdata-testing ~/.claude/skills/

If you're using Xcode, watch the YouTube video on How to Install and Use Agent Skills in Xcode for a walkthrough of the general workflow.

Using SwiftData Testing

Trigger it by describing the task — e.g. "write a repository test for TransactionRepository" or "review this ViewModel test for SwiftData layering violations." The skill loads only the reference file relevant to what you're testing:

  • references/model-container-fixtures.md — in-memory ModelContainer setup for repository/integration tests
  • references/mock-repositories.md — mock repository pattern for ViewModel unit tests (no SwiftData at all)
  • references/model-actor-testing.md — testing @ModelActor code without crossing actor boundaries incorrectly
  • references/decimal-money-values.mdDecimal assertion patterns for money-typed properties
  • references/import-hash-dedup.md — testing content-hash dedup for CSV/API import pipelines

Contributing

Found a SwiftData testing gotcha this skill doesn't cover? Open an issue or PR — real, hard-won failure modes are welcome; speculative "best practices" are not the goal here.

License

MIT — see LICENSE.