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/brunogama/ios-cursor-rules/create-tests-swiftgit clone --depth 1 https://github.com/brunogama/ios-cursor-rulesWrote 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/brunogama/ios-cursor-rules/create-tests-swift)<a href="https://agentmods.dev/rules/brunogama/ios-cursor-rules/create-tests-swift"><img src="https://agentmods.dev/badge/rules/brunogama/ios-cursor-rules/create-tests-swift.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.02570 | $0.02570 |
| Opus 5 | $0.01285 | $0.01285 |
| Sonnet 5 | $0.00514 | $0.00514 |
| Haiku 4.5 | $0.00257 | $0.00257 |
Grade A, and why
create-tests-swift 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 — 403 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Swift Testing Guide
This guide outlines Swift testing principles and practices, focusing on creating effective unit tests for Swift code.
actions:
-
type: suggest message: |
Swift Testing Guidelines
In this project, every public function must have unit tests. We follow these guidelines:
Test Structure
Naming Convention
- Test class name:
[ClassUnderTest]Tests - Test method name:
test_[FunctionUnderTest]_[Scenario]_[ExpectedResult]
Example:
class UserAuthenticationTests: XCTestCase { func test_authenticate_withValidCredentials_shouldReturnToken() { ... } func test_authenticate_withInvalidPassword_shouldThrowAuthError() { ... } }Arrangement
Every test should follow the Arrange-Act-Assert (AAA) pattern:
func test_addItem_withValidProduct_shouldAddToCart() { // Arrange let cart = ShoppingCart(id: CartID()) let product = Product(id: ProductID(), name: "Test Product", price: Money(amount: 10, currency: .usd)) // Act try! cart.addItem(product: product, quantity: 1) // Assert XCTAssertEqual(cart.items.count, 1) XCTAssertEqual(cart.total()?.amount, 10) }Types of Tests
1. Unit Tests
- Tests a single unit of code in isolation
- Uses mocks/stubs for dependencies
- Fast and reliable
- Located in target's matching test target (e.g., DomainTests for Domain code)
func test_placeOrder_withValidItems_shouldCreateOrderSuccessfully() { // Arrange let mockOrderRepository = MockOrderRepository() let mockProductRepository = MockProductRepository() let orderService = OrderService( orderRepository: mockOrderRepository, productRepository: mockProductRepository ) let items = [OrderItem(productID: ProductID(), quantity: 1, price: Money(amount: 10, currency: .usd))] // Act let result = orderService.placeOrder(items: items, customerID: CustomerID()) // Assert XCTAssertTrue(result.isSuccess) XCTAssertEqual(mockOrderRepository.savedOrders.count, 1) }2. Integration Tests
- Tests interaction between multiple components
- Typically involves real implementations rather than mocks
- Located in separate test targets
func test_orderFlow_endToEnd_shouldProcessOrderSuccessfully() { // Tests the full order flow from cart to confirmation // Uses real implementations for most components }Mocking Guidelines
- Create mocks for protocols, not for concrete classes
- Use protocol-based dependencies to make testing easier
- Name mocks clearly with the
Mockprefix
protocol OrderRepository { func save(_ order: Order) throws func findByID(_ id: OrderID) -> Order? } class MockOrderRepository: OrderRepository { var savedOrders: [Order] = [] var ordersToReturn: [OrderID: Order] = [:] func save(_ order: Order) throws { savedOrders.append(order) } func findByID(_ id: OrderID) -> Order? { return ordersToReturn[id] } }Testing Value Objects
Test both valid and invalid initialization:
func test_emailInitialization_withValidEmail_shouldSucceed() { // Arrange & Act let email = Email(value: "[email protected]") // Assert XCTAssertNotNil(email) XCTAssertEqual(email?.value, "[email protected]") } func test_emailInitialization_withInvalidEmail_shouldReturnNil() { // Arrange & Act let email = Email(value: "invalid-email") // Assert XCTAssertNil(email) } - Test class name:
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 · 403 lines · 2,570 tokens per session scan A d3f32ab03cd7
create-tests-swift is a cursor rule published in the GitHub repository brunogama/ios-cursor-rules (74 stars, last pushed 1y ago), licensed MIT. It adds 2,570 tokens to every session, about $0.0128 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-08-30.
Other cursor rules, from other repositories
swiftui
Rules for IcySky, a SwiftUI project for a bluesky client.
202-swift-standards-detailed
Swift 6.2 + iOS 18-26 编码规范 - 详细参考.
cursorrules
This project aims to create a simple command line executable and Swift package to make creating MCPs (Model Control Protocol) for Mac very easy. The project will eventually support.
126-swift-advanced
126: Advanced Swift patterns including error handling, SwiftUI design system, SwiftData, concurrency, security, and documentation.
121-swift-core
121: Core Swift development principles and modern iOS best practices.
pytest-tests
Below is an example test, you'll notice the following.