Skip to content
Back to skills

Swift Testing Pro

ASecurity

Writes, reviews, and improves Swift Testing code using modern APIs and best practices, with a basalt section on fixtures, real-model gating and the no-sleep rule. Use when reading, writing, or reviewing tests in this repo or any project that uses Swift Testing.

  • 8 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 15, 2026
ai-agentsswiftshellawstestingapidocumentation

Works with

  • api
  • mcp

Security analysis

A100/100

Pro scans all 9 files and shows the line behind each finding

Scanned November 15, 2026

npx -y skills add goodmai/basalt --skill swift-testing-pro --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Swift Testing Pro?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Swift Testing Pro
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/goodmai-swift-testing-pro/badge)](https://www.skillsdirectory.com/skills/goodmai-swift-testing-pro)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: swift-testing-pro
description: Writes, reviews, and improves Swift Testing code using modern APIs and best practices, with a basalt section on fixtures, real-model gating and the no-sleep rule. Use when reading, writing, or reviewing tests in this repo or any project that uses Swift Testing.
license: MIT
metadata:
  author: Paul Hudson
  version: "1.0"
  modified: "basalt section and related-skills table added 2026-11-11; the references are upstream text"
---

Write and review Swift Testing code for correctness, modern API usage, and adherence to project conventions. Report only genuine problems - do not nitpick or invent issues.

## In basalt

This skill is general Swift Testing guidance. Where it and the repo disagree, the repo wins (`CLAUDE.md` section 4, CONTRIBUTING):

- **Swift Testing only.** There are no UI tests and no new `XCTestCase`; skip `references/migrating-from-xctest.md` unless you are deleting an old one. Do not add Swift Numerics: compare floats with an explicit tolerance, as the existing suites do.
- **Fixtures come from `TinyModel.make(_:)`** (`Tests/BasaltTests/Fixtures/TinyModels.swift`). A new architecture gets a `TinyModel.Family` case, not a builder local to one suite. No Llama fixtures.
- **No mocked engine below `BasaltServer`** (#228). `MockInferenceEngine` is for REST and controller tests.
- **Real-model tests are gated by environment**: `.enabled(if:)` on `BASALT_E2E…` variables, run one model at a time under the GPU lock (`basalt-model-runs`). They never run in the default `swift test --parallel`.
- **No `Task.sleep`**, no timing windows. Suites that share the GPU or global state are `.serialized`.
- **Zero comments** in test code too. Put the intent in the `@Test("…")` and `@Suite("…")` names, which this repo writes as full sentences.
- **Coverage:** CI requires 60% of changed lines (`scripts/check_changed_coverage.swift`). An uncovered range in new logic is a missing test.
- **Target Swift 6.4.** "Requires Swift 6.2" in the references is satisfied.

Review process:

1. Ensure tests follow core Swift Testing conventions using `references/core-rules.md`.
1. Validate test structure, assertions, dependency injection, and other best practices using `references/writing-better-tests.md`.
1. Check async tests, confirmations, time limits, actor isolation, and networking mocks using `references/async-tests.md`.
1. Ensure new features like raw identifiers, test scopes, exit tests, and attachments are used correctly using `references/new-features.md`.
1. If migrating from XCTest, follow the conversion guidance in `references/migrating-from-xctest.md`.

If doing partial work, load only the relevant reference files.


## Core Instructions

- Target Swift 6.2 or later, using modern Swift concurrency.
- As a Swift Testing developer, the user wants all new unit and integration tests to be written using Swift Testing, and they may ask for help migrating existing XCTest code to Swift Testing.
- Swift Testing does *not* support UI tests – XCTest must be used there.
- Use a consistent project structure, with folder layout determined by app features.

Swift Testing evolves with each Swift release, so expect three to four releases each year, each introducing new features. This means existing training data you have will naturally be outdated or missing key features.

This skill specifically draws upon the very latest Swift and Swift Testing code, which means it will suggest things you are not aware of. Treat the user’s installed toolchain as authoritative, but there's a fairly high chance Apple's *documentation* about the APIs will be stale, so treat them carefully.


## Output Format

If the user asks for a review, organize findings by file. For each issue:

1. State the file and relevant line(s).
2. Name the rule being violated.
3. Show a brief before/after code fix.

Skip files with no issues. End with a prioritized summary of the most impactful changes to make first.

If the user asks you to write or improve tests, follow the same rules above but make the changes directly instead of returning a findings report.

Example output:

### UserTests.swift

**Line 5: Use struct, not class, for test suites.**

```swift
// Before
class UserTests: XCTestCase {

// After
struct UserTests {
```

**Line 12: Use `#expect` instead of `XCTAssertEqual`.**

```swift
// Before
XCTAssertEqual(user.name, "Taylor")

// After
#expect(user.name == "Taylor")
```

**Line 30: Use `#require` for preconditions, not `#expect`.**

```swift
// Before
#expect(users.isEmpty == false)
let first = users.first!

// After
let first = try #require(users.first)
```

### Summary

1. **Fundamentals (high):** Test suite on line 5 should be a struct, not a class inheriting from `XCTestCase`.
2. **Migration (medium):** `XCTAssertEqual` on line 12 should be migrated to `#expect`.
3. **Assertions (medium):** Force-unwrap on line 30 should use `#require` to unwrap safely and stop the test early on failure.

End of example.


## References

- `references/core-rules.md` - core Swift Testing rules: structs over classes, `init`/`deinit` over setUp/tearDown, parallel execution, parameterized tests, `withKnownIssue`, and tags.
- `references/writing-better-tests.md` - test hygiene, structuring tests, hidden dependencies, `#expect` vs `#require`, `Issue.record()`, `#expect(throws:)`, and verification methods.
- `references/async-tests.md` - serialized tests, `confirmation()`, time limits, actor isolation, testing pre-concurrency code, and mocking networking.
- `references/new-features.md` - raw identifiers, range-based confirmations, test scoping traits, exit tests, attachments, `ConditionTrait.evaluate()`, and the updated `#expect(throws:)` return value.
- `references/migrating-from-xctest.md` - XCTest-to-Swift Testing conversion steps, assertion mappings, and floating-point tolerance via Swift Numerics.

## Related skills

All skills live in `.claude/skills/<name>/SKILL.md` (mirrored at `.agents/skills/`). Start from `swiftcoder` when unsure.

| Skill | Use it for |
|---|---|
| `swiftcoder` | the role and entry point: which skill to load, in what order, and the gates |
| `ponytail` | scope and the smallest complete change |
| `ponytail-review` | review of a change for correctness, safety, load, tests and need |
| `swift-64-architecture` | targets, boundaries, isolation domains, value core and actor shell |
| `swift-64-optimization-coding` | writing Swift 6.4 code: ownership, typed throws, size limits, Metal kernels |
| `swift-64-pr-review` | the 5-gate review of a Swift diff |
| `swift-concurrency-pro` | async/await, actors, tasks, streams and cancellation in depth |
| `swift-race-review` | races and deadlocks the compiler cannot see; MLX and Metal threading |
| `xcode-mcp` | checking an API against Apple's documentation; Xcode workspace tools |
| `basalt-model-runs` | runs that load model weights: benchmarks, ppl, memory, parity, GPU lock |
| `model-xray` | looking inside a running model and calling basalt's own MCP server |

Files in this skill

  • SKILL.md6.9 KB
  • agents/openai.yaml360 B
  • assets/swift-testing-pro-icon.png3 KB
  • assets/swift-testing-pro-icon.svg1.5 KB
  • references/async-tests.md8.4 KB
  • references/core-rules.md3.9 KB
  • references/migrating-from-xctest.md2 KB
  • references/new-features.md10 KB
  • references/writing-better-tests.md10.8 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.