code-style

This style guide is based on the official iOS style guide and incorporates DuckDuckGo-specific patterns and requirements.

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

Made for: Cursor.

Per session 5,762 This file is loaded in full into every session.
When invoked 5,762 The same file — it is already loaded in full.
Security scan B 1 finding. Scan, not verified.
Origin unknown 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.05762 $0.05762
Opus 5 $0.02881 $0.02881
Sonnet 5 $0.01152 $0.01152
Haiku 4.5 $0.00576 $0.00576

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

Security

Grade B, and why

code-style scanned grade B with 1 finding 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 today.

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.

Strips warnings and disclaimersmediumAnti-refusal

Omitting safety caveats hides risk from the user and is a common jailbreak preamble.

**Strive to make your code compile without warnings.** This rule informs many style decisions such as using `#selector` types instead of string literals.
.cursor/rules/code-style.mdc · 971 lines

How it starts

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

Swift Code Style Guide

This style guide is based on the official iOS style guide and incorporates DuckDuckGo-specific patterns and requirements.

Correctness

Strive to make your code compile without warnings. This rule informs many style decisions such as using #selector types instead of string literals.

SwiftLint

We use SwiftLint for enforcing Swift style and conventions. See the SwiftLint configuration for specific rules.

Key SwiftLint settings:

  • Line length: 150 characters (not the default 100)
  • Force cast/try: warnings (not errors for pragmatic development)
  • Identifier naming: flexible for single-letter variables in closures

Naming Conventions

Follow the Swift API Design Guidelines with these key principles:

Core Principles

  • Clarity at the call site over brevity
  • Use camelCase (not snake_case)
  • UpperCamelCase for types and protocols
  • lowerCamelCase for everything else
  • Include all needed words while omitting needless words
  • Use names based on roles, not types

Type Names

// ✅ CORRECT: Descriptive, UpperCamelCase
class UserAuthenticationManager { }
struct BookmarkItem { }
enum NavigationState { }
protocol DataSourceProtocol { }

// ❌ INCORRECT: Too generic
class Manager { }
struct Data { }

Variable and Function Names

// ✅ CORRECT: Descriptive lowerCamelCase
let maximumRetryCount = 3
var isLoading = false
func fetchUserData() { }

// Boolean properties should read like assertions
var isEnabled: Bool
var hasCompleted: Bool
var canDelete: Bool

// ❌ INCORRECT: Abbreviations and unclear names
let usrMgr = UserManager()
func calcTotal() { }

Protocol Naming

// ✅ CORRECT: Capability protocols end in -able, -ible, -ing
protocol Loadable { }
protocol Refreshable { }
protocol UserAuthenticating { }

// ✅ CORRECT: Type protocols are nouns
protocol DataSource { }
protocol Delegate { }

Read the full file on GitHub · 971 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. today First seen · 971 lines · 5,762 tokens per session scan B bf0c7790b7a3

Subscribe to this mod's changes

code-style is a cursor rule published in the GitHub repository duckduckgo/apple-browsers (252 stars, last pushed today), licensed Apache-2.0. It adds 5,762 tokens to every session, about $0.0288 per session on Opus 5. A static security scan graded it B with 1 finding (strips warnings and disclaimers). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-01.