import-hygiene

import-hygiene is a cursor rule for Cursor from duckduckgo/apple-browsers. It costs 525 tokens per session, scanned A, original, Apache-2.0.

A set of Swift import rules for keeping framework imports minimal and limiting SwiftUI imports to preview code.

In plain words
What is it for?
Use it when editing Swift and SwiftUI files, especially AppKit or UIKit code with previews.
Why use it?
It prevents unnecessary import changes that can cause build or lint errors and unrelated diffs.

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/import-hygiene
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 import-hygiene

README.md
[![agentmods](https://agentmods.dev/badge/rules/duckduckgo/apple-browsers/import-hygiene.svg)](https://agentmods.dev/rules/duckduckgo/apple-browsers/import-hygiene)
Your own site
<a href="https://agentmods.dev/rules/duckduckgo/apple-browsers/import-hygiene"><img src="https://agentmods.dev/badge/rules/duckduckgo/apple-browsers/import-hygiene.svg" alt="Measured on agentmods" height="20"></a>
Per session 525 This file is loaded in full into every session.
When invoked 525 The same file — it is already loaded in full.
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.00525 $0.00525
Opus 5 $0.00262 $0.00262
Sonnet 5 $0.00105 $0.00105
Haiku 4.5 $0.00052 $0.00052

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

Security

Grade A, and why

import-hygiene 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 3d 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/import-hygiene.mdc · 51 lines

How it starts

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

Import Hygiene & Preview-Only Imports

Purpose

Prevent accidental or unrequested import churn that causes build/lint issues and diffs unrelated to the task. Ensure SwiftUI is only imported where required (e.g., #Preview blocks) and avoid touching existing imports unless strictly necessary.

Rules (Always Apply)

  1. Do not change imports unless:

    • A new symbol is introduced that the compiler cannot resolve without the import
    • An existing import is provably unused and removal is part of the explicit task scope
    • The change resolves a red compiler error you introduced in this edit
  2. Keep platform/framework imports minimal and local:

    • Prefer import AppKit for macOS UI code
    • Prefer import UIKit for iOS UI code
    • Do not add import SwiftUI to AppKit/UIKit view controllers unless they embed SwiftUI.
  3. Scope SwiftUI to previews:

  4. Keep Shared Modules stable:

    • Do not remove import Common or other project modules unless a dedicated cleanup task
    • If a module is required elsewhere in the file, do not move or duplicate it
  5. Lint & Build first, then adjust:

    • If a file shows missing-types errors after your edits (e.g., Cannot find type 'FireproofDomains'), prefer adding the specific missing import required for those existing symbols
    • Avoid speculative imports
  6. No import reordering for style-only reasons unless the repository enforces it via formatter

Rationale

  • Unnecessary import edits generate churn and can break platform- or target-specific build settings
  • Scoping SwiftUI to previews avoids accidental framework inclusion and linking in non-preview code paths

Examples

Read the full file on GitHub · 51 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. 3d ago First seen · 51 lines · 525 tokens per session scan A 415d2b0361ad

Subscribe to this mod's changes

import-hygiene is a cursor rule published in the GitHub repository duckduckgo/apple-browsers (251 stars, last pushed today), licensed Apache-2.0. It adds 525 tokens to every session, about $0.0026 per session on Opus 5. 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.