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.
npx agentmods add rules/duckduckgo/apple-browsers/import-hygienegit 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/import-hygiene)<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>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 | $0.00525 | $0.00525 |
| Opus 5 | $0.00262 | $0.00262 |
| Sonnet 5 | $0.00105 | $0.00105 |
| Haiku 4.5 | $0.00052 | $0.00052 |
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.
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)
-
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
-
Keep platform/framework imports minimal and local:
- Prefer
import AppKitfor macOS UI code - Prefer
import UIKitfor iOS UI code - Do not add
import SwiftUIto AppKit/UIKit view controllers unless they embed SwiftUI.
- Prefer
-
Scope SwiftUI to previews:
- Only import
SwiftUIinside#if DEBUGblocks for#Previewdeclarations - Example: See swiftui-preview-import.swift
- Only import
-
Keep Shared Modules stable:
- Do not remove
import Commonor other project modules unless a dedicated cleanup task - If a module is required elsewhere in the file, do not move or duplicate it
- Do not remove
-
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
- If a file shows missing-types errors after your edits (e.g.,
-
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
-
CORRECT (AppKit-only controller): See appkit-only-controller.swift
-
CORRECT (preview-only SwiftUI): See preview-only-swiftui.swift
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.
- 3d ago First seen · 51 lines · 525 tokens per session scan A 415d2b0361ad
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.
Other cursor rules, from other repositories
ignore-sourcekit-warnings
Ignore spurious SourceKit warnings.
create-tests-swift
This guide outlines Swift testing principles and practices, focusing on creating effective unit tests for Swift code.
with-swift
As an AI assistant working on Swift code, I should follow these guidelines to ensure high-quality, maintainable, and efficient Swift code.
on-load-rule
This guide outlines the critical development principles for this Swift project.
swiftui
Rules for IcySky, a SwiftUI project for a bluesky client.
202-swift-standards-detailed
Swift 6.2 + iOS 18-26 编码规范 - 详细参考.