Home › Swift / SwiftUI › SwiftUI iOS app CLAUDE.md

SwiftUI iOS app CLAUDE.md

CLAUDE.md for SwiftUI apps on iOS 18+ with Swift 6 strict concurrency, @Observable, SwiftData, and Swift Testing.

Claude Code (CLAUDE.md)Swift / SwiftUI

How to use

Save this as CLAUDE.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

CLAUDE.mdDownload  
# CLAUDE.md: SwiftUI app (Swift 6)

## Build & test
- `xcodebuild -scheme App -destination 'platform=iOS Simulator,name=iPhone 16' build test`
- Format/lint with `swift format` / SwiftLint if configured.

## Conventions
- Swift 6 language mode with strict concurrency. Fix data-race errors properly (actors, `Sendable`, `@MainActor`); don't silence them with `@unchecked Sendable` or `nonisolated(unsafe)`.
- UI state with the Observation framework: `@Observable` classes, `@State` for owned models, `@Bindable` for bindings, `@Environment` for shared ones. No new `ObservableObject`/`@Published`.
- Views stay small; extract subviews instead of long `body`s. Previews with `#Preview` for every view.
- Navigation with `NavigationStack` and typed `navigationDestination(for:)`.
- Async work with `async/await` and `.task {}` modifiers (auto-cancelled). No completion handlers in new code; no `DispatchQueue.main.async` in SwiftUI code.
- Persistence with SwiftData (`@Model`, `@Query`) if the project uses it; otherwise follow the existing store.
- Networking through one `APIClient` using `URLSession` + `Codable`.
- Accessibility: labels on icon-only buttons, support Dynamic Type, no fixed font sizes.

## Tests
Swift Testing (`import Testing`, `@Test`, `#expect`) for new tests.

## Don't
Don't force unwrap (`!`) outside tests, or edit the `.pbxproj` by hand when a Swift package or file can be added via the project's tooling.

Related rules

AWS CDK (TypeScript) CLAUDE.md

CLAUDE.md for AWS CDK v2 apps in TypeScript: constructs, least-privilege grants, snapshot tests, and safe deploys.

Claude Code (CLAUDE.md)AWS CDK

Bun runtime CLAUDE.md

CLAUDE.md for TypeScript projects on Bun 1.2+: bun test, Bun.serve, built-in SQLite/Postgres, and bundling.

Claude Code (CLAUDE.md)Bun

Claude Agent SDK CLAUDE.md

CLAUDE.md for building agents with the Claude Agent SDK (Python/TypeScript): options, tools, permissions, and hooks.

Claude Code (CLAUDE.md)LLM apps & agents

Code reviewer subagent (Claude Code)

A Claude Code subagent definition that reviews the current diff for bugs, security, and tests, reporting by severity.

Claude Code (CLAUDE.md)Agent workflows

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.