/swift-modern-dev:swift-test-scaffoldfrom swift-modern-dev
Scaffolds Swift tests using Swift Testing framework with protocol-based mocking, suite/test structure, and decision guidance for when to test.
Ships in swift-modern-dev. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
New test files, test targets requiring new files, and test-only helpers/fixtures require explicit user authorization. A request to implement, fix, test, or verify does not by itself authorize their creation. Prefer existing tests and direct runtime checks; ask only when a specific new test has concrete benefit. Run checks appropriate to the change and repeat only after relevant changes, failures, or unresolved concerns.
Generate Swift Testing structure that verifies intent, not only surface behavior.
| ALWAYS | NEVER |
|---|---|
import Testing for new tests | New XCTest cases |
Descriptive @Test("...") names | Tests that cannot fail when logic changes |
| Mock at protocol/service boundary | Hit live network in unit tests |
| Cover success + failure paths for logic | Test trivial getters / SwiftUI layout trees |
Tests/YourAppTests/
├── ViewModels/
├── Services/
├── Models/
└── Mocks/
import Testing
@testable import YourApp
@Suite("FeatureViewModel")
struct FeatureViewModelTests {
private func makeSUT(service: MockFeatureService = .init()) -> FeatureViewModel {
FeatureViewModel(service: service)
}
@Test("load populates items on success")
func loadSuccess() async {
let service = MockFeatureService()
service.itemsToReturn = [Item(name: "A")]
let sut = makeSUT(service: service)
await sut.loadItems()
#expect(sut.items.count == 1)
}
@Test("load records error on failure")
func loadFailure() async {
let service = MockFeatureService()
service.errorToThrow = TestError.boom
let sut = makeSUT(service: service)
await sut.loadItems()
#expect(sut.error != nil)
}
}
final class MockFeatureService: FeatureServiceProtocol, @unchecked Sendable {
var itemsToReturn: [Item] = []
var errorToThrow: Error?
func fetchItems() async throws -> [Item] {
if let errorToThrow { throw errorToThrow }
return itemsToReturn
}
}
swift test
# or Xcode Test
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
7 skills in this plugin
/ios-accessibilityUse when implementing or auditing VoiceOver, Dynamic Type, accessibility labels, focus, contrast, or Hit-testing for SwiftUI iOS/macOS apps./memory-leak-diagnosisUse when investigating memory growth, retain cycles, leaks in Instruments, Task cancellation issues, or ARC problems in Swift 6 apps./swift-anti-pattern-guardUse when reviewing Swift code for outdated patterns, modernizing a project, running architecture health checks, or grepping for ObservableObject, DispatchQueue.main, NavigationView, or Core Data.npx claudepluginhub pstuart/pstuart --plugin swift-modern-devOther plugins' skills for the same job