swift-testing
Skill19 starsChanged 3 months agoMITView on GitHub
Writes, reviews, and improves Swift Testing code using modern APIs and best practices. Use when reading, writing, or reviewing projects that use Swift Testing, including @Test, #expect, #require, async tests, XCTest migration, traits, confirmations, exit tests, and Swift 6.2+ testing features.
8 other projects use a version of this.
Adopted by
Most recently taken up by
- Fe2-O3/swift-field-guidetheir own version, first seen Sep 9, 2026
- ozgurakkaya90/claude-skillstheir own version, first seen Aug 2, 2026
- dpearson2699/swift-ios-skillstheir own version, first seen Jul 13, 2026
- Viniciuscarvalho/swift-code-reviewer-skilltheir own version, first seen Apr 26, 2026
- Prisma-Labs-Dev/apple-skillstheir own version, first seen Apr 14, 2026
- jeremieb/swift-unit-test-instructionstheir own version, first seen Feb 27, 2026
Other versions8 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 8
- dpearson2699/swift-ios-skills★ 1.2ksame name
- Prisma-Labs-Dev/apple-skills★ 337same name
- bocato/swift-testing-agent-skill★ 80same name
- Viniciuscarvalho/swift-code-reviewer-skill★ 37same name
- pluginagentmarketplace/custom-plugin-swift★ 9same name
- jeremieb/swift-unit-test-instructions★ 4same name
- Fe2-O3/swift-field-guide★ 0same name
- ozgurakkaya90/claude-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository16 other files it gives its agents.
- AGENTS.mdAGENTS.md
- code-reviewSkill
- gemini-files-apiSkill
- harness-engineeringSkill
- hint-overlay-visual-verificationSkill
- ios-xcodegenSkill
- lifecycle-and-side-effects-correctnessSkill
- local-model-servingSkill
- mechanism-auditSkill
- meeting-transcriptionSkill
- public-source-release-auditSkill
- silent-pushes-setupSkill
- spec-creation-updatingSkill
- swiftui-view-refactorSkill
- xcode-buildSkill
- xcode-cloudSkill
The file
We split this skill into the rules it gives an agent
12 rules. 0 are common, 7 are distinctive, and 5 are very specific to this project.
0
Common
Most of the 7 edited versions we read keep these.
7
Distinctive
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 6
Write and review Swift Testing code for correctness, modern API usage, and adherence to project conventions.
- Very specific: line 10
Ensure tests follow core Swift Testing conventions using references/core-rules.md.
- Very specific: line 12
Check async tests, confirmations, time limits, actor isolation, and networking mocks using references/async-tests.md.
- Very specific: line 13
Ensure new features like raw identifiers, test scopes, exit tests, and attachments are used correctly using references/new-features.md.
- Very specific: line 14
If migrating from XCTest, follow the conversion guidance in references/migrating-from-xctest.md.
- Distinctive: line 15
Check oracle strength: the test must prove the intended behavior, not merely exercise a path or accept broad normalized output.
- Distinctive: line 17
If doing partial work, load only the relevant reference files.
- Distinctive: line 25
Use a consistent project structure, with folder layout determined by app features.
- Distinctive: line 26
Treat weak or vacuous assertions as correctness issues, even when the test uses the right Swift Testing APIs.
- Distinctive: line 35
If the user asks for a review, organize findings by file.
- Distinctive: line 43
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 …
- Very specific: line 82
Fundamentals (high): Test suite on line 5 should be a struct, not a class inheriting from XCTestCase.
“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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.
Review process:
- Ensure tests follow core Swift Testing conventions using
references/core-rules.md. - Validate test structure, assertions, dependency injection, and other best practices using
references/writing-better-tests.md. - Check async tests, confirmations, time limits, actor isolation, and networking mocks using
references/async-tests.md. - Ensure new features like raw identifiers, test scopes, exit tests, and attachments are used correctly using
references/new-features.md. - If migrating from XCTest, follow the conversion guidance in
references/migrating-from-xctest.md. - Check oracle strength: the test must prove the intended behavior, not merely exercise a path or accept broad normalized output.
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.
- Treat weak or vacuous assertions as correctness issues, even when the test uses the right Swift Testing APIs.
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:
- State the file and relevant line(s).
- Name the rule being violated.
- 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.
// Before
class UserTests: XCTestCase {
// After
struct UserTests {Line 12: Use #expect instead of XCTAssertEqual.
// Before
XCTAssertEqual(user.name, "Taylor")
// After
#expect(user.name == "Taylor")Line 30: Use #require for preconditions, not #expect.
// Before
#expect(users.isEmpty == false)
let first = users.first!
// After
let first = try #require(users.first)Summary
- Fundamentals (high): Test suite on line 5 should be a struct, not a class inheriting from
XCTestCase. - Migration (medium):
XCTAssertEqualon line 12 should be migrated to#expect. - Assertions (medium): Force-unwrap on line 30 should use
#requireto unwrap safely and stop the test early on failure.
End of example.
Oracle strength checklist
Apply this before considering a new or changed test meaningful:
- The test has at least one assertion that would fail for the known or plausible regression.
- Boundary pairs cover both sides of the rule, not only the accepted case.
- Negative proofs reject forbidden values, duplicate records, stale identifiers, cancelled work, or invalid transitions.
- Collections assert ordering when order matters, and multiset/set equality when order must not matter.
- Snapshots are exact where output is contractual; normalization is explicit and does not erase the bug class.
- Identity handling covers stale IDs, regenerated IDs, canonical IDs, and crosswalk behavior when applicable.
- Paired edits assert both sides of a relationship, such as source and projection, model and persisted envelope, or request and emitted event.
- Path-to-suite or path-to-verifier mapping proves the changed source is actually covered by the test command.
- Helper verification methods preserve caller source location so failures point to the test that owns the oracle.
References
references/core-rules.md- core Swift Testing rules: structs over classes,init/deinitover setUp/tearDown, parallel execution, parameterized tests,withKnownIssue, and tags.references/writing-better-tests.md- test hygiene, structuring tests, hidden dependencies,#expectvs#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.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

