Skip to content
SwiftSkills

iOS app architecture with AI agents: pick a pattern, modularize, then audit

Have the agent choose an architecture per feature instead of defaulting to MVVM, move shared code into local Swift packages the way Apple's Xcode docs describe, and then audit module boundaries against the real dependency graph. Use one pattern skill, one graph or audit tool, and build after every package move.

Last updated:

This page is about getting a coding agent to structure an iOS app: pick a pattern, split code into Swift packages and keep module boundaries honest. Naming and API shape are in the Swift API design guide; compile-time tuning in the build time guide.

What Apple says about modularizing an app

Apple's Organizing your code with local packages says to "organize its code in a modular way to keep it maintainable by creating Swift packages and using them as local packages." The steps an agent can follow:

  1. Pick candidates first. Apple's examples are "networking logic, source files that contain utilities, and so on."

  2. Create the package in the project. File > New > Package (Swift Package before Xcode 15); for a library, choose Multiplatform and the Library template. Don't create a new Git repository if the app is already under version control.

  3. Move code and update the manifest. You might need to vend the code as a library product and declare the package's targets.

  4. Link it. Add the package's library product under "Frameworks, Libraries, and Embedded Content" in the app target's General pane.

  5. Later, share it. As you create more apps, Apple suggests moving local packages to their own Git repositories and adding them as package dependencies.

Rules for AGENTS.md

markdown

## Architecture
- Do not introduce a new architecture pattern without asking. Follow the existing one per feature.
- One package move per step; build and run tests after each move.
- Features never import sibling features; shared code goes in a lower-level package.
- Never invent module names: read Package.swift and the project before proposing a graph.

Step 1: install one pattern skill

Ask the agent to install Swift Architecture Skill (npx skills add https://github.com/efremidze/swift-architecture-skill --skill swift-architecture-skill). It routes to MVP, MVVM, MVI, TCA, Clean Architecture, VIPER, Coordinator or Reactive and keeps each playbook scoped. Prefer clean architecture with a composition root? Use iOS Architecture Expert instead, not both.

Step 2: map the real module graph

Before changing anything, have the agent run Module Map to extract the graph from Package.swift, the project file and imports. Ask for a list of upward and sibling imports; this is your baseline.

Step 3: move code into packages, one at a time

Start where Apple does: networking and utilities. For SwiftUI apps built as feature slices, SwiftUI Architect describes feature packages, a small shared layer and an app target that owns composition and navigation.

Step 4: audit boundaries

After the moves, run Modular iOS Audit: it checks the codebase against eight principles and writes an evidence-backed HTML report. Treat sibling-feature imports and UI frameworks in business modules as blockers.

Tools compared (5)

ToolBest forAgents (README)Install (README)LicenseStarsLast push
Swift Architecture Skill (efremidze)Routes each feature to MVP, MVVM, MVI, TCA, Clean, VIPER, Coordinator or Reactive with scoped playbooksAgent Skills tools; Claude Code pluginnpx skills add https://github.com/efremidze/swift-architecture-skill --skill swift-architecture-skillMIT8128 Sep 2026 ⚠
iOS Architecture Expert (SwiftyJourney)Clean, testable modular apps: protocol-oriented design, composition rootClaude Codenpx skills add SwiftyJourney/ios-architecture-expert-skillMIT22 Nov 2026
Module Map (n0an)Real Swift module graph from Package.swift, project file and imports, as HTMLClaude Code, Cursor, Codex, Gemininpx skills add n0an/module-map --skill module-mapMIT39 Sep 2026 ⚠
Modular iOS Audit (SzymonMrozek)Audit against eight modularity principles with an interactive HTML reportClaude Code, Codexnpx skills add SzymonMrozek/modular-ios-auditMIT329 Oct 2026
SwiftUI Architect (the-braveknight)Feature slices as Swift packages, shared layer, app target owns navigationClaude Codenpx skills add https://github.com/the-braveknight/swiftui-architect-skill --skill swiftui-architectMIT030 Oct 2026

⚠ = no push for more than 4 weeks.

Which one to pick:

  • Choosing a pattern: Swift Architecture Skill.

  • Seeing what you actually have: Module Map.

  • Auditing boundaries: Modular iOS Audit.

  • New SwiftUI app with feature packages: SwiftUI Architect.

A prompt that keeps the agent honest

Setting up the agent itself: Claude Code for iOS development, Codex for iOS development. Build speed: iOS build time.

Do not edit files yet. Read Package.swift, the Xcode project and imports, and list the current modules and every sibling or upward import with file and line. Propose at most one local Swift package to extract first (networking or utilities), with its library product and targets. After I approve, move it, add the product to the app target, build and run tests, and stop.

FAQ

Which architecture should an AI agent use for my iOS app?
Let the agent pick per feature, not per habit. LLMs tend to default to MVVM; a routing skill such as Swift Architecture Skill selects among MVP, MVVM, MVI, TCA, Clean Architecture, VIPER, Coordinator and Reactive based on UI stack, state complexity and existing conventions, then keeps guidance scoped to that pattern.
How do I modularize an iOS app with Claude Code or Codex?
Follow Apple's local-package workflow: identify candidate code such as networking or utilities, create a local Swift package with File > New > Package, move the code, vend it as a library product, and add that product to the app target. Have the agent do one package per step and build after each move.
Can an AI agent audit my module boundaries?
Yes, if the tool reads the real code. Modular iOS Audit checks a codebase against eight principles and reports evidence-backed findings in an HTML report, and Module Map extracts the actual module graph from Package.swift, project files and imports instead of an LLM-invented diagram.
Should every feature be its own Swift package?
Not by default. Apple suggests starting with code that is a good candidate for modularization, such as networking logic and utilities. Feature-slice packages pay off in larger apps with several teams; for a small app, a few shared packages and one app target are usually enough.
Which iOS architecture skill should I install?
Swift Architecture Skill is the most-starred live option for choosing a pattern. Add Module Map to see the real dependency graph. After the next catalog merge, Modular iOS Audit covers boundary audits and SwiftUI Architect covers feature-package SwiftUI apps. Install one pattern skill, not several.