swift-testing

swift-testing is a skill for Claude Code from johnrogers/claude-swift-engineering. It costs 13 tokens per session (1,096 once invoked), scanned A, original, MIT.

A modern framework for writing tests in Swift, using annotations such as `@Test` and checks such as `#expect` instead of XCTest.

In plain words
What is it for?
Use it to write and migrate unit tests for Swift code, including tests that fetch data asynchronously.
Why use it?
It gives Swift tests a newer structure with built-in support for asynchronous code and parallel test runs.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the swift-engineering plugin — 17 skills, 3 commands, 11 agents shipped together

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 skills/johnrogers/claude-swift-engineering/swift-testing
Any agent
npx skills add johnrogers/claude-swift-engineering --skill swift-testing
Clone the repo
git clone --depth 1 https://github.com/johnrogers/claude-swift-engineering

Made for: Claude Code.

Or install swift-engineering, the plugin that ships this one along with the rest of its 17 skills, 3 commands, 11 agents.

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 swift-testing

README.md
[![agentmods](https://agentmods.dev/badge/skills/johnrogers/claude-swift-engineering/swift-testing.svg)](https://agentmods.dev/skills/johnrogers/claude-swift-engineering/swift-testing)
Your own site
<a href="https://agentmods.dev/skills/johnrogers/claude-swift-engineering/swift-testing"><img src="https://agentmods.dev/badge/skills/johnrogers/claude-swift-engineering/swift-testing.svg" alt="Measured on agentmods" height="20"></a>
Per session 13 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,096 The whole file, excluding the scripts and references it only reads on demand.
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.1 $0.00013 $0.01096
Opus 5 $0.00006 $0.00548
Sonnet 5 $0.00003 $0.00219
Haiku 4.5 $0.00001 $0.00110

Measured 6d ago against content hash 2e86cff8c819, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

swift-testing 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.

plugins/swift-engineering/skills/swift-testing/SKILL.md · 143 lines

How it starts

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

Swift Testing Framework

Modern testing with Swift Testing framework. No XCTest.

Overview

Swift Testing replaces XCTest with a modern macro-based approach that's more concise, has better async support, and runs tests in parallel by default. The core principle: if you learned XCTest, unlearn it—Swift Testing works differently.

References

Core Concepts

Assertions

Macro Use Case
#expect(expression) Soft check — continues on failure. Use for most assertions.
#require(expression) Hard check — stops test on failure. Use for preconditions only.

Optional Unwrapping

let user = try #require(await fetchUser(id: "123"))
#expect(user.id == "123")

Test Structure

import Testing
@testable import YourModule

@Suite
struct FeatureTests {
    let sut: FeatureType
    
    init() throws {
        sut = FeatureType()
    }
    
    @Test("Description of behavior")
    func testBehavior() {
        #expect(sut.someProperty == expected)
    }
}

Assertion Conversions

XCTest Swift Testing
XCTAssert(expr) #expect(expr)
XCTAssertEqual(a, b) #expect(a == b)
XCTAssertNil(a) #expect(a == nil)
XCTAssertNotNil(a) #expect(a != nil)
try XCTUnwrap(a) try #require(a)
XCTAssertThrowsError #expect(throws: ErrorType.self) { }
XCTAssertNoThrow #expect(throws: Never.self) { }

Error Testing

#expect(throws: (any Error).self) { try riskyOperation() }
#expect(throws: NetworkError.self) { try fetch() }
#expect(throws: NetworkError.timeout) { try fetch() }
#expect(throws: Never.self) { try safeOperation() }

Parameterized Tests

@Test("Validates inputs", arguments: zip(
    ["a", "b", "c"],
    [1, 2, 3]
))
func testInputs(input: String, expected: Int) {
    #expect(process(input) == expected)
}

Read the full file on GitHub · 143 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. 6d ago First seen · 143 lines · 13 tokens per session scan A 2e86cff8c819

Subscribe to this mod's changes

swift-testing is a skill published in the GitHub repository johnrogers/claude-swift-engineering (228 stars, last pushed 7mo ago), licensed MIT. It adds 13 tokens to every session and 1,096 once invoked, about $0.0001 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.

Related

Other skills, from other repositories