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.
git clone --depth 1 https://github.com/duckduckgo/apple-browsersWrote 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.
[](https://agentmods.dev/rules/duckduckgo/apple-browsers/macos-singletons-removal)<a href="https://agentmods.dev/rules/duckduckgo/apple-browsers/macos-singletons-removal"><img src="https://agentmods.dev/badge/rules/duckduckgo/apple-browsers/macos-singletons-removal.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00000 | $0.03462 |
| Opus 5 | $0.00000 | $0.01731 |
| Sonnet 5 | $0.00000 | $0.00692 |
| Haiku 4.5 | $0.00000 | $0.00346 |
Grade A, and why
macos-singletons-removal 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 6d 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.
How it starts
The opening of the file, as written. The whole thing — 217 lines — stays where its author put it; the contents beside it link to each section on GitHub.
macOS Singleton Removal Rules
Purpose
Define a concrete pattern for removing .shared singletons in the macOS app by replacing them with app-owned instances and dependency injection. The AIChatPreferences and AboutPreferences refactors in AppDelegate are canonical examples.
Rules
-
Do not introduce new singletons
- Never add new
static let sharedor similar global singletons. - New dependencies must be passed in via initializers or factory methods, not fetched from global state.
- Never add new
-
Move ownership to the composition root (AppDelegate)
- Add a stored property on the macOS composition root (currently
AppDelegate) for the dependency, for example:let aiChatPreferences: AIChatPreferences
- Construct the instance during app setup using real dependencies:
- Inject storage (e.g.
DefaultAIChatPreferencesStorage) - Inject configuration objects (e.g.
AIChatMenuVisibilityConfigurable) - Inject window managers via protocols (e.g.
WindowControllersManagerProtocol) - Inject feature flaggers and other services as needed
- Inject storage (e.g.
- Prefer protocol-typed properties in
AppDelegatewhen the dependency has a clear protocol (to keep testing and substitution easy).
- Add a stored property on the macOS composition root (currently
-
Thread the dependency through initializers
- For view controllers and models that need the former singleton, add initializer parameters and store them as non-optional properties. Example:
init(..., aiChatPreferences: AIChatPreferences = NSApp.delegateTyped.aiChatPreferences, ...)
- Avoid using
NSApp.delegateTypedorApplication.appDelegateand prefer to pass the dependency down from a parent object.- If a parent object doesn't contain the dependency, it should be updated to have it passed down from its own parent object, observing the exceptions mentioned below.
- It is explicitly allowed to use
NSApp.delegateTyped:- In the
Tabinitializer (following the existing pattern for other dependencies) - In default parameter values for the
MainViewControllerinitializer (this is the entry point for the dependency chain) - In default parameter values for the
TabCollectionViewModelinitializer (following the existing pattern for other dependencies) - In default parameter values for the
TabViewModelinitializer (temporary exception, will be refactored later) - Exception: For
@MainActorinitializers, use optional parameters withnildefaults and assign fromNSApp.delegateTypedin the initializer body.
- In the
- Important: Main actor isolation: If an initializer is marked
@MainActorand you need to default a parameter fromNSApp.delegateTyped, use an optional parameter withnildefault instead of accessingNSApp.delegateTypedin the default value. Then assign the value inside the initializer body:- ❌
init(savedZoomLevelsCoordinating: SavedZoomLevelsCoordinating = NSApp.delegateTyped.accessibilityPreferences)(causes main actor isolation warning) - ✅
init(savedZoomLevelsCoordinating: SavedZoomLevelsCoordinating? = nil)withself.savedZoomLevelsCoordinating = savedZoomLevelsCoordinating ?? NSApp.delegateTyped.accessibilityPreferencesin the body
- ❌
- When creating child objects from a parent that already has the dependency, pass the property down rather than re-reading from
NSApp.delegateTyped. - For preferences models that need to reach SwiftUI views, thread through the entire chain:
MainViewController(with default parameter) →BrowserTabViewController→PreferencesViewController→PreferencesSidebarModel→PreferencesRootView- Follow the existing pattern used by other preferences (e.g.,
searchPreferences,tabsPreferences,aiChatPreferences) - When adding to
PreferencesSidebarModel, add the property alongside existing preferences and update both the maininitand convenienceinit
- For dependencies that need to reach UserScripts initialization (e.g.,
DuckPlayerPreferences), thread through the content blocking infrastructure:AppDelegate→AppContentBlocking→UserContentUpdating→ScriptSourceProvider(viaScriptSourceProvidingprotocol) →UserScripts- Add the dependency to
ScriptSourceProvidingprotocol as a property - Add it to
ScriptSourceProviderstruct (property and initializer parameter) - Add it to
UserContentUpdatinginitializer and pass toScriptSourceProviderinmakeValueclosure - Add it to
AppContentBlockinginitializers (both convenience and main) and pass toUserContentUpdating - Pass it from
AppDelegatetoAppContentBlockinginitialization - In
UserScripts, access viasourceProvider.duckPlayerPreferencesinstead of using a default parameter - This follows the same pattern as
WebTrackingProtectionPreferencesandCookiePopupProtectionPreferences
- For view controllers and models that need the former singleton, add initializer parameters and store them as non-optional properties. Example:
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.
- 6d ago First seen · 217 lines · 0 tokens per session scan A 6eb0a6a97838
macos-singletons-removal is a cursor rule published in the GitHub repository duckduckgo/apple-browsers (251 stars, last pushed today), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 3,462 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.
Other cursor rules, from other repositories
react-native-debugger-mcp
A tool connection for reading logs from a React Native app, a framework for building mobile apps with JavaScript.
create-ios-release
As an AI assistant helping with iOS app releases, I should guide through the following process for successfully deploying iOS applications to the App Store.
flutter-forge
NeuraForge AI — flutter-forge.
203-healthkit-integration-detailed
Detailed rules for integrating Apple HealthKit and WorkoutKit. HealthKit stores health and fitness data on Apple devices, while WorkoutKit supports workout-related features.
010-healthkit-workoutkit
010: HealthKit and WorkoutKit integration patterns for iOS health apps.
main-refactoring-rules
ios cursor rules.