CLAUDE.md for a SwiftUI app
A CLAUDE.md for a SwiftUI app on macOS: the stack, the xcodebuild commands, the view-and-model conventions, and the Xcode files an agent should leave alone. Copy it into your repo root, fill in the bracketed parts, and commit it so every Claude Code session reads it first.
When to use this
Use it on a SwiftUI app targeting macOS. The conventions push the agent toward small views and a separate model, which is where SwiftUI code gets hard to read if you let it drift. Fill in the project name and the scheme, and adjust the macOS target to yours.
The template CLAUDE.md
# [Project] — agent guide
## Stack
Swift 6, SwiftUI, targeting macOS 14 and later. Built with Xcode.
## Commands
- Build: `xcodebuild -scheme [Scheme] build`
- Test: `xcodebuild -scheme [Scheme] test`
- Format: `swift format --in-place --recursive Sources`
## Conventions
- SwiftUI views stay small. Move logic into an observable model.
- One view per file. Keep view bodies readable, not clever.
- Use value types by default. Reach for a class when identity matters.
- Keep side effects out of view bodies; run them in the model.
## How to work here
- Build and run the tests before you call a task done.
- Make the smallest change that solves the task.
## Do not
- Do not edit the Xcode project file by hand unless the task is about it.
- Do not commit DerivedData or user-specific Xcode state.
- Do not block the main actor with slow work; move it off the main thread.
Why each section is there
- Stack sets the Swift version, the UI framework and the macOS target.
- Commands give the real xcodebuild lines, so the agent builds and tests the right scheme.
- Conventions keep views small and side effects in the model.
- Do not protects the project file and keeps slow work off the main actor.
Build one from a form with the CLAUDE.md generator. For how an agent works from the file, see working with agents.
FAQ
Does this cover AppKit apps?
It is written for SwiftUI. For an AppKit app, change the conventions to match your view layer and keep the commands and the do-not list.
How do I find my scheme name?
Run xcodebuild -list in the project folder. Put the scheme you build into the bracketed parts of the commands.