swift-persistence

swift-persistence is a skill for Claude Code, Codex from jeremieb/swift-unit-test-instructions. It costs 74 tokens per session (1,199 once invoked), scanned A, original, MIT.

A setup guide for saving app data with SwiftData or Core Data, Apple technologies for storing information on an iPhone or iPad. It organizes the storage code around MVVM, a pattern that separates screens from application logic.

In plain words
What is it for?
Use it to add stored entities, repositories, create/read/update/delete operations, relationships, and an in-memory setup for tests or previews.
Why use it?
It provides a consistent place for data models and storage operations, while keeping the code easier to test.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to add stored entities, repositories, create/read/update/delete operations, relationships, and an in-memory setup for tests or previews.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/jeremieb/swift-unit-test-instructions/swift-persistence
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 jeremieb/swift-unit-test-instructions --skill swift-persistence
Clone the repo
git clone --depth 1 https://github.com/jeremieb/swift-unit-test-instructions

Made for: Claude Code, Codex.

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 swift-persistence

README.md
[![agentmods](https://agentmods.dev/badge/skills/jeremieb/swift-unit-test-instructions/swift-persistence/github.svg)](https://agentmods.dev/skills/jeremieb/swift-unit-test-instructions/swift-persistence)
Your own site
<a href="https://agentmods.dev/skills/jeremieb/swift-unit-test-instructions/swift-persistence"><img src="https://agentmods.dev/badge/skills/jeremieb/swift-unit-test-instructions/swift-persistence/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 swift-persistence

Your own site · 80×15
<a href="https://agentmods.dev/skills/jeremieb/swift-unit-test-instructions/swift-persistence"><img src="https://agentmods.dev/badge/skills/jeremieb/swift-unit-test-instructions/swift-persistence.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 74 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,199 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.00074 $0.01199
Opus 5 $0.00037 $0.00600
Sonnet 5 $0.00015 $0.00240
Haiku 4.5 $0.00007 $0.00120

Measured 9d ago against content hash 48737f2b1062, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

swift-persistence 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 9d 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/swift-persistence/SKILL.md · 145 lines

How it starts

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

Swift Persistence

Instructions

Step 1: Choose the framework

Ask if not already specified:

SwiftData or CoreData?

SwiftData CoreData
Min iOS iOS 17+ iOS 8+
Syntax @Model macro, Swift-native NSManagedObject, Objective-C roots
Recommended for New projects on iOS 17+ Legacy projects, complex migration needs

Then load the matching reference:

  • SwiftData → references/swiftdata.md
  • CoreData → references/coredata.md

Step 2: Define the models

Ask: what entities are needed? For each entity:

  • Name (singular, UpperCamelCase: Task, UserProfile, Transaction)
  • Properties and their types
  • Relationships to other entities (one-to-one, one-to-many, many-to-many)
  • Any computed properties needed

Step 3: Generate the model layer

Models go in Core/Models/ — they are plain data types, framework-agnostic where possible.

Persistence infrastructure goes in Services/Storage/:

  • PersistenceController.swift — container setup, in-memory preview/test variant
  • [Entity]Repository.swift — CRUD operations for each entity
  • [Entity]RepositoryProtocol.swift — protocol for testability

Rule: ViewModels inject a repository protocol. They never touch ModelContext or NSManagedObjectContext directly.

Services/Storage/
├── PersistenceController.swift
├── TaskRepository.swift
└── TaskRepositoryProtocol.swift

Step 4: Generate the repository protocol

Always define a protocol first so ViewModels can be tested with a mock:

// Services/Storage/TaskRepositoryProtocol.swift
protocol TaskRepositoryProtocol {
    func fetchAll() throws -> [Task]
    func save(_ task: Task) throws
    func delete(_ task: Task) throws
}

Step 5: Wire into the ViewModel

ViewModels receive the repository via init:

@MainActor
@Observable
final class TaskListViewModel {
    private(set) var tasks: [Task] = []
    private let repository: TaskRepositoryProtocol

    init(repository: TaskRepositoryProtocol = TaskRepository()) {
        self.repository = repository
    }

    func loadTasks() {
        tasks = (try? repository.fetchAll()) ?? []
    }
}

Read the full file on GitHub · 145 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 9d ago First seen · 145 lines · 74 tokens per session scan A 48737f2b1062

Subscribe to this mod's changes

swift-persistence is a skill published in the GitHub repository jeremieb/swift-unit-test-instructions (5 stars, last pushed 6mo ago), licensed MIT. It adds 74 tokens to every session and 1,199 once invoked, about $0.0004 per session on Opus 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-08-31.

Related

Other skills, from other repositories

db-whisperer

Diagnoses and improves application-layer databases: Postgres, MySQL, SQLite, and MongoDB. Covers EXPLAIN ANALYZE, slow query detection, index strategy, N+1 detection, schema migrations with up/down scripts, connection pooling, replication setup, and vacuum/analyze operations. Use this skill when the user says "this…

mturac/hermes-supercode-skills · 131 tokens

pipeline-architect

Designs and implements data pipelines: ETL/ELT, streaming, batch processing, schema migrations, and data warehouse architecture. Covers Kafka, Airflow, dbt, Spark, ClickHouse, BigQuery, Snowflake, Redis Streams, and more. Use this skill when the user asks about data pipelines, ETL jobs, data transformation, streaming…

mturac/hermes-supercode-skills · 148 tokens

django-master

Django web development including ORM mastery, Django REST Framework, signals, custom managers/querysets, migrations, and admin customization. Trigger when users work with Django projects, need ORM optimization, DRF serializers/viewsets, Django admin customization, or migration strategies.

FutureJJ/claude-skills · 54 tokens

sql-optimizer

SQL query optimization including EXPLAIN analysis, index strategies, window functions, CTEs, query rewriting, and performance tuning. Trigger when users have slow queries, need help reading EXPLAIN output, want index recommendations, or need to write complex analytical queries with window functions or CTEs.

FutureJJ/claude-skills · 64 tokens

postgres-expert

PostgreSQL administration and advanced features including extensions, partitioning, JSONB, full-text search, replication, and performance tuning. Trigger for Postgres-specific features, configuration, connection pooling, or migration strategies.

FutureJJ/claude-skills · 46 tokens

database-design

Database schema design including normalization, denormalization, migration strategies, and schema evolution. Trigger for database modeling, migration planning, or schema optimization.

FutureJJ/claude-skills · 32 tokens