agentleFS
ProjAnvilProjAnvil/MindForge/skills/en/swiftui-development/SKILL.md

swiftui-development

Skill3 starsChanged 23 days agoMITView on GitHub

Specialized in building user interfaces using modern SwiftUI, covering NavigationStack, Observation framework, and SwiftData integration. Use this skill when writing SwiftUI view files, designing app navigation, handling animations and transitions, or binding ViewModel data to the interface.

We split this skill into the rules it gives an agent

10 rules. About 0 are common, 7 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill to write declarative, reactive UI code.

    line 10
  2. Very specific:

    When writing .swift view files.

    line 23
  3. Distinctive:

    When designing the App's navigation structure.

    line 24
  4. Distinctive:

    When handling animations and transitions.

    line 25
  5. Distinctive:

    When binding ViewModel data to the interface.

    line 26
  6. Distinctive:

    Single Source of Truth: Always maintain a single source of truth for your data.

    line 93
  7. Very specific:

    Environment: Use .environment() to inject global dependencies or theme data.

    line 94
  8. Very specific:

    State vs Binding: Use @State when the view owns the data, and @Binding (@Bindable for Observables) when it modifies parent data.

    line 96
  9. Distinctive:

    Computed Properties: Use computed properties to derive UI state instead of manually syncing multiple state variables.

    line 97
  10. Distinctive:

    All UI updates must be performed on the main thread (SwiftUI generally handles this, but be careful with callbacks from background tasks).

    line 102

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “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

SwiftUI Development Skill

Instructions

Use this skill to write declarative, reactive UI code. Always adhere to the iOS Human Interface Guidelines (HIG).

What This Skill Does

  • UI Construction: Build interfaces using Views, Modifiers, and Layout containers.
  • State Management: Manage data flow using the Observation framework (@Observable, @State, @Environment).
  • Navigation: Handle routing using NavigationStack and navigationDestination.
  • Previews: Rapidly iterate on UI using the #Preview macro.
  • Persistence Integration: Seamlessly integrate SwiftData (@Query) into views.

When to Use This Skill

Trigger scenarios:

  • When writing .swift view files.
  • When designing the App's navigation structure.
  • When handling animations and transitions.
  • When binding ViewModel data to the interface.

Examples

Example 1: Observation-based ViewModel and View

@Observable
class CounterModel {
    var count = 0
    
    func increment() {
        count += 1
    }
}

struct CounterView: View {
    @State private var model = CounterModel()
    
    var body: some View {
        VStack {
            Text("Count: \(model.count)")
                .font(.largeTitle)
            Button("Add") {
                model.increment()
            }
        }
    }
}

#Preview {
    CounterView()
}

Example 2: Type-Safe Navigation with NavigationStack

enum Route: Hashable {
    case profile(id: String)
    case settings
}

struct ContentView: View {
    @State private var path = NavigationPath()
    
    var body: some View {
        NavigationStack(path: $path) {
            List {
                NavigationLink("Go to Profile", value: Route.profile(id: "123"))
                NavigationLink("Settings", value: Route.settings)
            }
            .navigationDestination(for: Route.self) { route in
                switch route {
                case .profile(let id):
                    ProfileView(userId: id)
                case .settings:
                    SettingsView()
                }
            }
        }
    }
}

Best Practices

  • Single Source of Truth: Always maintain a single source of truth for your data.
  • Environment: Use .environment() to inject global dependencies or theme data.
  • Avoid Massive Views: Break down complex views into smaller component views (struct SubView: View).
  • State vs Binding: Use @State when the view owns the data, and @Binding (@Bindable for Observables) when it modifies parent data.
  • Computed Properties: Use computed properties to derive UI state instead of manually syncing multiple state variables.

Notes

  • For iOS 17+, @Observable is preferred. For legacy support, fallback to ObservableObject may be needed, but strictly mark it.
  • All UI updates must be performed on the main thread (SwiftUI generally handles this, but be careful with callbacks from background tasks).

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.