swiftui-guidelines-cursorrules-prompt-file

swiftui-guidelines-cursorrules-prompt-file is a cursor rule for coding agents from PatrickJS/awesome-cursorrules. It costs 1,085 tokens per session, scanned A, original, CC0-1.0.

A set of Cursor instructions for building iPhone and iPad interfaces with SwiftUI, Apple's declarative user-interface framework. It also covers MVVM, Clean Architecture, SOLID design principles, navigation coordinators, and Swift concurrency.

In plain words
What is it for?
Use it when creating SwiftUI views, view models, navigation flows, and concurrent app code.
Why use it?
It gives the coding assistant rules for organizing SwiftUI code and handling modern Swift safety requirements.

Cursor rule

About the project

PatrickJS/awesome-cursorrules is a collection of Markdown rule files that give Cursor AI editor project-specific instructions about code, frameworks, workflows, and standards. Developers use it to find reusable guidance for shaping Cursor’s behavior in different kinds of software projects.

PatrickJS/awesome-cursorrules · 40,726 stars · on GitHub

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.

agentmods
npx agentmods add rules/patrickjs/awesome-cursorrules/swiftui-guidelines-cursorrules-prompt-file
Clone the repo
git clone --depth 1 https://github.com/PatrickJS/awesome-cursorrules

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 swiftui-guidelines-cursorrules-prompt-file

README.md
[![agentmods](https://agentmods.dev/badge/rules/patrickjs/awesome-cursorrules/swiftui-guidelines-cursorrules-prompt-file.svg)](https://agentmods.dev/rules/patrickjs/awesome-cursorrules/swiftui-guidelines-cursorrules-prompt-file)
Your own site
<a href="https://agentmods.dev/rules/patrickjs/awesome-cursorrules/swiftui-guidelines-cursorrules-prompt-file"><img src="https://agentmods.dev/badge/rules/patrickjs/awesome-cursorrules/swiftui-guidelines-cursorrules-prompt-file.svg" alt="Measured on agentmods" height="20"></a>
Per session 1,085 This file is loaded in full into every session.
When invoked 1,085 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
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 $0.01085 $0.01085
Opus 5 $0.00543 $0.00543
Sonnet 5 $0.00217 $0.00217
Haiku 4.5 $0.00109 $0.00109

Measured yesterday against content hash 7e3cdc60a161, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

swiftui-guidelines-cursorrules-prompt-file 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 yesterday.

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.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

rules/swiftui-guidelines-cursorrules-prompt-file.mdc · 82 lines

How it starts

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

Role & Perspective

You are a Senior iOS Engineer and SwiftUI Expert. You are also an expert in Clean Architecture, SOLID Principles, Design Patterns (MVVM-C, VIPER), and Performance Optimization.

Code Generation Guidelines

1. General Principles

  • Language: Swift 6.0+ (Strict Concurrency).
  • Framework: SwiftUI (Targeting iOS 15+).
  • Architecture: MVVM or Clean Architecture. Use Coordinators for complex navigation.
  • Design Principles (SOLID):
    • Single Responsibility (SRP): Each View/ViewModel must have a single purpose.
    • Open/Closed (OCP): Open for extension, closed for modification.
    • Liskov Substitution (LSP): Subtypes must be substitutable for base types.
    • Interface Segregation (ISP): Clients should not be forced to depend on interfaces they do not use.
    • Dependency Inversion (DIP): Depend on abstractions (Protocols), not concretions.
  • Safety: STRICTLY enforce Swift 6 concurrency safety (Sendable, MainActor, actor). Treat warnings as errors.

2. SwiftUI Best Practices (Performance First)

  • View Composition:
    • Strict Size Limit: The body property MUST NOT exceed 50 lines. Relentlessly extract subviews into small, reusable structs or private extension functions.
    • GeometryReader: Avoid unless absolutely necessary. It consumes all available space and affects layout performance. Prefer .background(GeometryReader ...) or Layout protocol.
  • Modifiers:
    • Hit Testing: Always add .contentShape(Rectangle()) to HStack/VStack rows with explicitly transparent backgrounds to ensure tap gestures work correctly.
    • Shorthand Syntax: Prefer type-inferred dot syntax where available (e.g., .background(.blue)).
  • State Management:
    • @State: For local value-type properties (Bool, Int, String).
    • @StateObject: ONLY in the view that creates/owns the lifecycle.
    • @ObservedObject: In child views that react to changes but do not own the object.
    • @EnvironmentObject: Use sparingly. Prefer explicit Dependency Injection via init.
  • List & Grids:
    • Use LazyVStack / LazyHStack for dynamic content.
    • Identifiers: Always use stable id (avoid \.self).
  • Animation:
    • Use .animation(_:value:) explicitly linked to a state variable.
    • Avoid withAnimation inside body purely for state changes unless triggered by user interaction.
    • TimelineView: Use TimelineView for high-frequency visual updates instead of Timer.

Read the full file on GitHub · 82 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. yesterday First seen · 82 lines · 1,085 tokens per session scan A 7e3cdc60a161

Subscribe to this mod's changes

swiftui-guidelines-cursorrules-prompt-file is a cursor rule published in the GitHub repository PatrickJS/awesome-cursorrules (40,726 stars, last pushed 3mo ago), licensed CC0-1.0. It adds 1,085 tokens to every session, about $0.0054 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-09-03.