ios-architecture

ios-architecture is a cursor rule for Cursor from duckduckgo/apple-browsers. It costs 0 tokens per session (2,280 once invoked), scanned A, original, Apache-2.0.

Architecture rules for an iOS browser app that require shared dependency providers and protocol-based services. A protocol defines the operations a service offers without tying code to one implementation.

In plain words
What is it for?
Use them when designing view models, services, app settings, or other features that need injected dependencies.
Why use it?
They make services easier to replace in tests and avoid direct reliance on global singleton objects.

Cursor rule for Cursor

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/duckduckgo/apple-browsers/ios-architecture
Clone the repo
git clone --depth 1 https://github.com/duckduckgo/apple-browsers

Made for: Cursor.

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 ios-architecture

README.md
[![agentmods](https://agentmods.dev/badge/rules/duckduckgo/apple-browsers/ios-architecture.svg)](https://agentmods.dev/rules/duckduckgo/apple-browsers/ios-architecture)
Your own site
<a href="https://agentmods.dev/rules/duckduckgo/apple-browsers/ios-architecture"><img src="https://agentmods.dev/badge/rules/duckduckgo/apple-browsers/ios-architecture.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 2,280 The whole file, excluding the scripts and references it only reads on demand.
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.00000 $0.02280
Opus 5 $0.00000 $0.01140
Sonnet 5 $0.00000 $0.00456
Haiku 4.5 $0.00000 $0.00228

Measured 4d ago against content hash 4e7c05f9c258, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

ios-architecture 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 4d ago.

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.

.cursor/rules/ios-architecture.mdc · 443 lines

How it starts

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

iOS DuckDuckGo Browser Architecture Rules

Dependency Injection and AppDependencies

Use AppDependencyProvider Pattern

ALWAYS use the centralized dependency provider for all service dependencies:

// ✅ CORRECT - Use the shared dependency provider
final class FeatureViewModel: ObservableObject {
    private let networkService: NetworkServiceProtocol
    
    init(dependencies: DependencyProvider = AppDependencyProvider.shared) {
        self.networkService = dependencies.networkService
    }
}

// ❌ INCORRECT - Direct singleton access
final class FeatureViewModel: ObservableObject {
    private let networkService = NetworkService.shared // Avoid singletons
}

Protocol-Based Dependencies

ALWAYS define protocols for dependencies to enable testing:

// ✅ CORRECT - Protocol abstraction
protocol FeatureServiceProtocol {
    func fetchData() async throws -> [Item]
}

final class FeatureService: FeatureServiceProtocol {
    // Implementation
}

// ❌ INCORRECT - Concrete dependency
final class ViewModel {
    private let service: FeatureService // Hard to test
}

AppSettings and Configuration

Use AppSettings Protocol

ALWAYS access settings through the AppSettings protocol:

// ✅ CORRECT - Protocol-based settings access
final class SettingsViewModel: ObservableObject {
    private let appSettings: AppSettings
    
    init(appSettings: AppSettings) {
        self.appSettings = appSettings
    }
    
    var isFeatureEnabled: Bool {
        get { appSettings.featureEnabled }
        set { appSettings.featureEnabled = newValue }
    }
}

// ❌ INCORRECT - Direct UserDefaults access
final class SettingsViewModel: ObservableObject {
    var isFeatureEnabled: Bool {
        get { UserDefaults.standard.bool(forKey: "feature_enabled") }
        set { UserDefaults.standard.set(newValue, forKey: "feature_enabled") }
    }
}

UserDefaults Property Wrapper

Use the established @UserDefaultsWrapper pattern for new settings:

// ✅ CORRECT - Property wrapper usage
extension AppUserDefaults {
    @UserDefaultsWrapper(key: .newFeatureEnabled, defaultValue: false)
    var newFeatureEnabled: Bool
}

// ❌ INCORRECT - Manual UserDefaults handling
extension AppUserDefaults {
    var newFeatureEnabled: Bool {
        get { userDefaults.bool(forKey: "new_feature_enabled") }
        set { userDefaults.set(newValue, forKey: "new_feature_enabled") }
    }
}

Read the full file on GitHub · 443 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. 4d ago First seen · 443 lines · 0 tokens per session scan A 4e7c05f9c258

Subscribe to this mod's changes

ios-architecture is a cursor rule published in the GitHub repository duckduckgo/apple-browsers (251 stars, last pushed yesterday), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 2,280 tokens. 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-01.