agentleFS
Vladimir-BrVladimir-Br/swiftui-project-template/.cursor/rules/10-architecture.mdc

swiftui-project-template / rules

Cursor rule0 starsChanged 6 months agoMITView on GitHub

Architecture decisions for this specific project

We split this 10-architecture.mdc into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use constructor injection for services.

    line 31
  2. Very specific:

    Do NOT introduce a <Domain>ServiceProtocol by default.

    line 41

≈ “Common” is an estimate: at least 1 in 5 of the 6,350 Cursor rule 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
10-architecture.mdc
---
description: Architecture decisions for this specific project
globs: **/*View.swift,**/*ViewModel.swift,**/*Service.swift,**/*Repository.swift
alwaysApply: false
---

# Architecture (per-project decisions)

> TODO: fill in BEFORE starting the project. Delete sections that don't apply.

## Pattern of choice
<!-- choose ONE -->
- [ ] **MV (Model-View)** — `@Observable` model used directly in views. No ViewModel layer.
- [ ] **IVO (Input-View-Output)** — `@Observable` ViewModel with `enum Input` + `trigger(_:)`.

## Folder layout
```
Sources/
  App/                  # App entry + DI composition root
  Features/
    <FeatureName>/
      Views/            # SwiftUI views
      ViewModels/       # @Observable view models (if IVO/MVVM)
      Models/           # Domain models / SwiftData @Model entities
  Services/             # actors: network, persistence, analytics
  DesignSystem/         # Colors, Typography, reusable Views
  Resources/            # Assets, Localizable.xcstrings
```

## Dependency injection
- Use **constructor injection** for services. No singletons unless justified.
- Pass dependencies down through view initializers or `@Environment`.

## Naming
- Views: `<Feature>View`, subviews: `<Feature><Part>View`.
- ViewModels: `<Feature>ViewModel`.
- Services: `<Domain>Service` (typically an `actor`).
- Errors: nested `enum Error: LocalizedError` inside the owning type.

## Protocols — only when there is a real need
Do NOT introduce a `<Domain>ServiceProtocol` by default. Add a protocol only when there is a concrete reason:
- a mock implementation is needed for unit tests,
- a preview-only fake is needed for SwiftUI previews,
- there are (or will soon be) multiple real implementations,
- the service is exposed across module boundaries that require abstraction.

Otherwise — keep the concrete type. Less code, easier to read, easier to refactor later.

Download now (ZIP)

  • Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.

    Of the Cursor rule files we read, the 3,978 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository3 other files it gives its agents.

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.