agentleFS
moasqmoasq/ios-dev-agent/.agents/skills/storage/SKILL.md

storage

Skill4 starsChanged 6 months agoMITView on GitHub

Use when implementing data storage. Covers in-memory with sample data, @AppStorage, SwiftData persistence patterns.

5 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 5 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this guide when implementing or modifying data persistence.

    line 8
  2. Very specific:

    Use @Model, @Query, .modelContainer ONLY if user says "save", "persist", "database", or "SwiftData":

    line 62

“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Storage Patterns

Use this guide when implementing or modifying data persistence.

Default: In-Memory with Sample Data

Unless explicitly requested, use in-memory data with rich dummy data:

Data TypeStorageAPI
App data (items, records)In-memory (DEFAULT)Plain struct, @Observable arrays
Simple flags/settingsUserDefaults@AppStorage
Transient UI stateIn-memory@State

In-Memory Models (Default)

struct Note: Identifiable {
    let id: UUID
    var title: String
    var content: String

    init(title: String, content: String = "") {
        self.id = UUID()
        self.title = title
        self.content = content
    }

    static let sampleData: [Note] = [
        Note(title: "Meeting Notes", content: "Discuss Q2 roadmap"),
        Note(title: "Recipe", content: "Eggs, pecorino, guanciale"),
    ]
}

In-Memory ViewModel (Default)

@Observable @MainActor
class NotesViewModel {
    var notes: [Note] = Note.sampleData

    func addNote(title: String) {
        notes.insert(Note(title: title), at: 0)
    }

    func deleteNote(_ note: Note) {
        notes.removeAll { $0.id == note.id }
    }
}

@AppStorage

@AppStorage("sortOrder") private var sortOrder = "date"
@AppStorage("showCompleted") private var showCompleted = true

SwiftData (ONLY when user explicitly requests persistence)

Use @Model, @Query, .modelContainer ONLY if user says "save", "persist", "database", or "SwiftData":

import SwiftData

@Model
class Note {
    var title: String
    var content: String
    var createdAt: Date

    init(title: String, content: String = "") {
        self.title = title
        self.content = content
        self.createdAt = Date()
    }
}

App entry with container:

@main
struct MyApp: App {
    var body: some Scene {
        WindowGroup { ContentView() }
        .modelContainer(for: Note.self)
    }
}

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.