# Swift test scaffold

> Swift test scaffold is an open-source agent skill for developer tools. Guides an agent to write Swift Testing tests for ViewModels and services. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf, Goose
- **Website:** https://github.com/pstuart/pstuart/tree/main/plugins/swift-modern-dev/skills/swift-test-scaffold
- **Repository:** https://github.com/pstuart/pstuart
- **GitHub stars:** 20
- **License:** MIT
- **Skill name:** swift-test-scaffold
- **Collection:** https://github.com/pstuart/pstuart
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-04

## About

This skill steers an AI coding agent toward Swift Testing (import Testing, @Test and #expect) rather than XCTest when adding tests to a Swift project. It sets a structure for test folders split into ViewModels, Services, Models and Mocks, and includes a sample suite with a mock service injected through a protocol, covering both success and failure paths.

Its main constraint is restraint: creating new test files, test targets or test-only helpers requires explicit user approval. Otherwise the agent is told to run existing tests or direct runtime checks first, skip trivial getters and SwiftUI layout, and only add tests for business rules or state changes where they would actually catch a regression.

The agent runs checks with swift test or Xcode's test runner. The skill assumes a Swift codebase with a protocol-based service layer that can be mocked.

## When your agent uses it

> Use when adding Swift tests, creating test targets, scaffolding ViewModel or service tests, or choosing Swift Testing over XCTest.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/pstuart/pstuart/tree/HEAD/plugins/swift-modern-dev/skills/swift-test-scaffold)
- [License: MIT](https://github.com/pstuart/pstuart/tree/HEAD/plugins/swift-modern-dev/skills/swift-test-scaffold)

## Features

- **Swift Testing defaults:** Directs new tests to use import Testing with descriptive @Test names instead of XCTest cases.
- **Protocol-based mocking:** Shows how to isolate ViewModels from services with a mock conforming to a service protocol, avoiding live network calls.
- **Success and failure coverage:** Provides a pattern for testing both the success path and the error path of logic.
- **Test folder layout:** Suggests a test target structure separating ViewModels, Services, Models and Mocks.
- **Authorization gate:** Requires explicit user approval before creating new test files, targets or test helpers.
- **Test necessity decision tree:** Helps decide when a test is worth writing, skipping type-enforced rules and pure UI layout.

## Good for

- Add unit tests for a SwiftUI ViewModel that loads data from a service
- Write a Swift Testing suite covering error handling in a networking service
- Decide whether a Swift business rule needs a new test
- Create a mock service conforming to a protocol for tests
- Move an existing XCTest suite toward Swift Testing syntax

## Install

### Claude Code

This skill ships in the `swift-modern-dev` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add pstuart/pstuart
/plugin install swift-modern-dev@pstuart
```

Or copy only this skill to `~/.claude/skills/swift-test-scaffold`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/pstuart/pstuart.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/swift-test-scaffold &&
cp -R "$tmp/plugins/swift-modern-dev/skills/swift-test-scaffold" ~/.claude/skills/swift-test-scaffold &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/swift-test-scaffold` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/swift-test-scaffold` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/pstuart/pstuart.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/swift-test-scaffold &&
cp -R "$tmp/plugins/swift-modern-dev/skills/swift-test-scaffold" ~/.agents/skills/swift-test-scaffold &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/swift-test-scaffold` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/swift-test-scaffold` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/pstuart/pstuart.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/swift-test-scaffold &&
cp -R "$tmp/plugins/swift-modern-dev/skills/swift-test-scaffold" ~/.cursor/skills/swift-test-scaffold &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/swift-test-scaffold` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/pstuart/pstuart.git --path plugins/swift-modern-dev/skills/swift-test-scaffold
```

Or copy the folder to `~/.gemini/skills/swift-test-scaffold` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/swift-test-scaffold`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/pstuart/pstuart.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/swift-test-scaffold &&
cp -R "$tmp/plugins/swift-modern-dev/skills/swift-test-scaffold" ~/.copilot/skills/swift-test-scaffold &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/swift-test-scaffold` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/pstuart/pstuart.git
```

Then copy `pstuart/plugins/swift-modern-dev/skills/swift-test-scaffold` into your agent's skills folder as `swift-test-scaffold`. Agents that support SKILL.md read one folder per skill.

## FAQ

### Does Swift test scaffold create test files automatically?

No. New test files, test targets and test-only helpers require explicit user authorization. A request to implement or fix code alone does not allow creating them.

### Which testing framework does Swift test scaffold use?

It directs new tests to use Swift Testing (import Testing) and says not to write new XCTest cases.

### What commands does Swift test scaffold suggest for running tests?

It suggests swift test or running tests from Xcode.

### Which AI clients does Swift test scaffold work with?

The skill is published as a Claude Code plugin in the pstuart marketplace.

### How do I install Swift test scaffold in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/swift-test-scaffold to use it in all your projects, or to .claude/skills/swift-test-scaffold in one project. Or install the swift-modern-dev plugin, which includes it: /plugin marketplace add pstuart/pstuart, then /plugin install swift-modern-dev@pstuart.

### Does Swift test scaffold run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Swift test scaffold?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

### What are the best alternatives to Swift test scaffold?

The closest alternatives to Swift test scaffold are Axiom testing, Swift modern architecture, Swift app scaffold, Xcuitest skill and Build swiftui interface.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Axiom testing](https://ai-powered.com/skills/axiom-testing-charleswiltgen-2): Axiom testing is an open-source agent skill for developer tools.
- [Swift modern architecture](https://ai-powered.com/skills/swift-modern-architecture): Swift modern architecture is an open-source agent skill for developer tools.
- [Swift app scaffold](https://ai-powered.com/skills/swift-app-scaffold): Swift app scaffold is an open-source agent skill for developer tools.
- [Xcuitest skill](https://ai-powered.com/skills/xcuitest-skill): Xcuitest skill is an open-source agent skill for developer tools.
- [Build swiftui interface](https://ai-powered.com/skills/build-swiftui-interface): Build swiftui interface is an open-source agent skill for developer tools.
- [Test mac app](https://ai-powered.com/skills/test-mac-app): Test mac app is an open-source agent skill for developer tools.
- [TDD](https://ai-powered.com/skills/tdd-tonyghiani): TDD is an open-source agent skill for developer tools.
- [Unittest skill](https://ai-powered.com/skills/unittest-skill): Unittest skill is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/swift-test-scaffold
