Official agent skill

Snapshot Tests

by microsoft in microsoft/SwiftStreamingMarkdown

Record and validate swift-snapshot-testing snapshots in the SwiftStreamingMarkdown package: regenerate reference PNGs, run snapshot tests, and diff failed snapshots.

OfficialMITAuto-check passedMobile

Install Snapshot Tests

skills CLI
$ npx skills add microsoft/SwiftStreamingMarkdown --skill snapshot-tests -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install microsoft/SwiftStreamingMarkdown snapshot-tests --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/microsoft/SwiftStreamingMarkdown.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/snapshot-tests .claude/skills/snapshot-tests && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
snapshot-tests
GitHub stars
377
Token cost
~2.2k tokens
SKILL.md length
945 words
Files
1
Skills in repo
2
Repo updated
First seen
Licence
MIT

At a glance

Record and validate swift-snapshot-testing snapshots in the SwiftStreamingMarkdown package: regenerate reference PNGs, run snapshot tests, and diff failed snapshots.

  • Works in 6 steps: Uncomment the recording flag → Verify the toggle → Run the tests using the build command… → …
  • Tasks that involve iOS development
  • SKILL.md covers When to use this skill, Repo context, Build command and Mode 1: record snapshots, plus 2 more sections
  • Calls gh, xcodebuild and git

What it does

Snapshot Tests is an agent skill from microsoft/SwiftStreamingMarkdown, published by the product's own GitHub organization. Record and validate swift-snapshot-testing snapshots in the SwiftStreamingMarkdown package: regenerate reference PNGs, run snapshot tests, and diff failed snapshots.

Its SKILL.md is about 2.2k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Mobile, covering iOS development. It works with iOS, macOS, SwiftUI and Swift. The repository describes itself as: A performant markdown library for iOS & macOS that supports streaming. The licence is MIT.

When your agent uses it

  • Tasks that involve iOS development

Example prompts

  • “/snapshot-tests”

Workflow steps

6 steps, taken from the first numbered list in SKILL.md.

  1. Uncomment the recording flag
  2. Verify the toggle
  3. Run the tests using the build command above. Every snapshot test
  4. Restore the comment — always, even if step 3 errored out
  5. Re-verify
  6. Report to the user

What it can do on your machine

Read from SKILL.md and the folder at commit 95bb755. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • gh
    • xcodebuild
    • git
    • xcrun

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use gh and git, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Snapshot Tests loads about 2.2k tokens when it runs. Until then it costs about 45 tokens; SKILL.md has 945 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~45
When it runs · the whole SKILL.md, loaded when a task matches
~2.2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from microsoft/SwiftStreamingMarkdown at commit 95bb755, republished under its MIT licence (© microsoft). 945 words, ~2,212 tokens.

Download SKILL.mdSave it as .claude/skills/snapshot-tests/SKILL.md (or your agent's skills folder).
name
snapshot-tests
description
Record and validate swift-snapshot-testing snapshots in the SwiftStreamingMarkdown package: regenerate reference PNGs, run snapshot tests, and diff failed snapshots.

Snapshot Tests Skill

Workflow for recording and validating swift-snapshot-testing snapshots in the SwiftStreamingMarkdown package.

When to use this skill

Trigger when the user asks anything that resolves to one of:

  • Record — "record snapshots", "re-record the snapshots", "update snapshots", "regenerate references" → use Mode 1.
  • Validate — "validate snapshots", "run snapshot tests", "check snapshots for regressions", "diff the failed snapshots" → use Mode 2.

If the request is ambiguous (e.g. "fix the snapshot tests"), validate first (Mode 2) and only re-record after the user confirms the visual changes are intentional.

Repo context

ThingLocation
Base class for every snapshot testTests/MarkdownTextTests/SnapshotTestFoundation/SnapshotTestCase.swift
Recording toggle (committed commented out)line 18 of that file: // isRecording = true
Diff-tool configurationSnapshotTesting.diffTool = "diff-image" in setUp() (line 17)
Reference PNGsTests/MarkdownTextTests/__Snapshots__/<TestClass>/
Failed PNGs (written by the test run)DerivedData; their absolute paths show up in failure messages

Because diffTool is the string "diff-image", swift-snapshot-testing formats every failure message with a literal line shaped exactly like:

diff-image <reference-png-path> <failed-png-path>

That is the hook this skill keys off of.

Build command

bash
xcodebuild test \
  -scheme SwiftStreamingMarkdown \
  -destination "platform=iOS Simulator,OS=26.4.1,name=iPhone 17" \
  -skipMacroValidation 2>&1 | tee /tmp/snapshot-tests.log

Always tee to a log file — the Mode 2 grep below depends on it.

If the iPhone 17 / iOS 26.4.1 destination is unavailable on the developer's machine, list installed simulators with xcrun simctl list devices available | head -30 and substitute an equivalent iOS Simulator destination.

Mode 1: record snapshots

  1. Uncomment the recording flag:
    bash
    sed -i '' 's|// isRecording = true|isRecording = true|' \
      Tests/MarkdownTextTests/SnapshotTestFoundation/SnapshotTestCase.swift
  2. Verify the toggle:
    bash
    grep -n "isRecording" Tests/MarkdownTextTests/SnapshotTestFoundation/SnapshotTestCase.swift
    Expect a single hit with isRecording = true and no leading //.
  3. Run the tests using the build command above. Every snapshot test will fail — recording mode always emits a failure after it writes the new reference PNG. This is expected; do not treat it as an error.
  4. Restore the comment — always, even if step 3 errored out:
    bash
    sed -i '' 's|^\([[:space:]]*\)isRecording = true|\1// isRecording = true|' \
      Tests/MarkdownTextTests/SnapshotTestFoundation/SnapshotTestCase.swift
  5. Re-verify:
    bash
    grep -n "isRecording" Tests/MarkdownTextTests/SnapshotTestFoundation/SnapshotTestCase.swift
    Should once again show // isRecording = true.
  6. Report to the user:
    bash
    git status Tests/MarkdownTextTests/__Snapshots__/
    Summarise which reference PNGs were added or changed, and remind the user to eyeball the diff before committing — recording overwrites references blindly, including wrong renders.
Platform coverage: iOS records locally, macOS does not

A local xcodebuild ... -destination "platform=iOS Simulator,..." run only regenerates the iOS variants (iPhone16-*, iPadPro11-*, iPadPro11Landscape-*). The macOS variants (macOS-standard-light, macOS-standard-dark) are not produced by that run.

Do not record macOS references on a developer machine. The macOS variants use a strict perceptualPrecision: 1.0, so even a one-off subpixel/font-rendering difference between a local macOS version and the CI runner's macOS version fails validation. Locally-recorded macOS PNGs will almost always mismatch CI.

macOS references are recorded by the dedicated Record macOS Snapshots workflow (.github/workflows/record-macos-snapshots.yml), a workflow_dispatch job on runs-on: macos-26. It flips isRecording on, deletes the existing *macOS*.png references, re-records them with -destination "platform=macOS", and uploads the fresh PNGs as the macos-snapshots artifact. (The record step's continue-on-error: true means the run reports success even though xcodebuild test exits non-zero in record mode.)

Note the workflow re-records the entire macOS suite, so the artifact contains every *.macOS-standard-*.png — copy back only the files your change actually affects, so you don't churn unrelated references against a possibly-different runner rendering.

When the branch lives in microsoft/SwiftStreamingMarkdown
  1. Push your branch (with re-recorded iOS references) to origin.
  2. Run the workflow against it:
    bash
    gh workflow run "Record macOS Snapshots" --ref <branch>
    gh run watch "$(gh run list --workflow 'Record macOS Snapshots' \
      --branch <branch> --limit 1 --json databaseId -q '.[0].databaseId')" \
      --exit-status
  3. Download the artifact and copy only the affected PNGs into place:
    bash
    gh run download <run-id> -n macos-snapshots -D /tmp/macos-snaps
    cp /tmp/macos-snaps/<TestMethod>.macOS-standard-*.png \
      Tests/MarkdownTextTests/__Snapshots__/<TestClass>/
  4. Eyeball the PNGs, commit, and push.
Show full SKILL.md (440 more words)Show less
When the branch lives on a fork (cross-repo PR)

workflow_dispatch only lists branches that exist in microsoft/SwiftStreamingMarkdown; a fork PR's head branch is not selectable, and the base repo cannot dispatch a workflow against a fork branch. Mirror the branch onto origin first (requires write access to the base repo — e.g. a maintainer updating a contributor's PR):

  1. Check out the PR branch locally (gh pr checkout <pr-number>) and push a temporary mirror to origin:
    bash
    git push origin <local-branch>:pr-<n>-macos-record
  2. Run Record macOS Snapshots against pr-<n>-macos-record (same gh workflow run / gh run watch as above). The mirror carries the same code state, so the recorded PNGs match the PR's rendering.
  3. Download the macos-snapshots artifact and copy only the affected PNGs over the references in your local PR-branch working tree.
  4. Eyeball, commit, and git push to the fork PR branch (the local branch already tracks the fork via gh pr checkout).
  5. Delete the temporary mirror:
    bash
    git push origin --delete pr-<n>-macos-record

So the normal flow for a rendering change is: record iOS locally, push, then backfill the affected macOS references from the Record macOS Snapshots workflow artifact in a follow-up commit.

Mode 2: validate snapshots

  1. Run the test suite using the build command above (with the | tee /tmp/snapshot-tests.log).
  2. If the log ends with ** TEST SUCCEEDED **, report success and stop.
  3. Otherwise, extract every diff command from the log:
    bash
    grep -E "^diff-image " /tmp/snapshot-tests.log | sort -u
    Each line is diff-image <reference-png> <failed-png>. Reference paths sit under …/__Snapshots__/<TestClass>/<testMethod>.<variant>.png; failed paths sit under DerivedData.
  4. Identify failing tests — also grep the log for test method names so the report links each diff back to its source test:
    bash
    grep -E "Test Case .* failed" /tmp/snapshot-tests.log | sort -u
  5. Present each pair to the user:
    • Use the view tool to open both PNGs inline so the user sees them in the chat.
    • Print the literal diff-image … command verbatim so the user can reproduce the side-by-side comparison locally.
  6. After showing all diffs, ask whether to:
    • re-record (switch to Mode 1), or
    • investigate the rendering regression in source.

Safety rules

  • Never commit SnapshotTestCase.swift with isRecording = true uncommented. Make the post-Mode-1 grep mandatory; if the working tree contains the uncommented form, restore it before any commit.
  • xcodebuild test exits non-zero in recording mode. That is not a build failure; do not retry or escalate.
  • The diff-image line emitted by swift-snapshot-testing does not quote its paths. Paths in this repo never contain spaces, so a simple grep / shell tokenisation is safe; do not introduce paths with spaces in Tests/MarkdownTextTests/__Snapshots__/.
  • Reference PNGs are binary — never edit them by hand; always regenerate via Mode 1.

© microsoft, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/snapshot-tests of microsoft/SwiftStreamingMarkdown.

Open the folder on GitHubat commit 95bb755

Compare with similar skills

Snapshot Tests next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Snapshot Tests compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Snapshot Tests this skillmicrosoft/SwiftStreamingMarkdown377—~2.2kAutomated safety check: PassMIT
Bootstrap iOSRayFernando1337/rayfernando-skills130—~1.1kAutomated safety check: PassApache-2.0
Swift Developmentaiskillstore/marketplace430—~1.8kAutomated safety check: PassNone
Swiftui Expert SkillAvdLee/SwiftUI-Agent-Skill3.7k—~2.9kAutomated safety check: PassMIT
Swiftui Expert SkillEslzzyl/Pixiv-SwiftUI1115 repos~3.1kAutomated safety check: PassAGPL-3.0
Hig Project Contextraintree-technology/hig-doctor1425 repos~1.2kAutomated safety check: PassMIT

Similar skills

  • Bootstrap iOS

    RayFernando1337/rayfernando-skills

    Bootstrap agents for iOS, iPadOS, macOS, Swift, SwiftUI, SwiftData/Core Data, Swift Testing, Xcode build/test/debug, Simulator, App Intents, or XcodeBuildMCP work.

    130 GitHub stars~1.1k tokensUpdated 2 mo ago
    MobileAuto-check passed
  • Swift Development

    aiskillstore/marketplace

    Comprehensive Swift development for building, testing, and deploying iOS/macOS applications.

    430 GitHub stars~1.8k tokensUpdated today
    MobileAuto-check passed
  • Swiftui Expert Skill

    AvdLee/SwiftUI-Agent-Skill

    A skill your agent uses when writing, reviewing, or refactoring SwiftUI code for iOS or macOS, including state and @Observable data flow, view composition, resizable layouts, safe areas, display…

    3.7k GitHub stars~2.9k tokensUpdated yesterday
    MobileAuto-check passed
  • Swiftui Expert Skill

    Eslzzyl/Pixiv-SwiftUI

    A skill your agent uses when writing, reviewing, or refactoring SwiftUI code for iOS or macOS, including state management and @Observable data flow, view composition and invalidation/performance…

    111 GitHub starsUsed in 5 repos~3.1k tokens
    MobileAuto-check passed
  • Hig Project Context

    raintree-technology/hig-doctor

    Create or update a shared Apple design context document that other HIG skills use to tailor guidance.

    142 GitHub starsUsed in 5 repos~1.2k tokens
    MobileAuto-check passed
  • Hig Components Content

    raintree-technology/hig-doctor

    Apple Human Interface Guidelines for content display components.

    142 GitHub starsUsed in 5 repos~1.3k tokens
    MobileAuto-check passed

More from microsoft/SwiftStreamingMarkdown

  • PR Writer

    microsoft/SwiftStreamingMarkdown

    Official

    Prepare and publish SwiftStreamingMarkdown pull requests end-to-end: generate PR description, commit changes, create/push branch, and open a PR when needed.

    377 GitHub stars~2.9k tokensUpdated 12 days ago
    Auto-check passed

Categories

Questions about Snapshot Tests

What does Snapshot Tests do?

Record and validate swift-snapshot-testing snapshots in the SwiftStreamingMarkdown package: regenerate reference PNGs, run snapshot tests, and diff failed snapshots. Snapshot Tests is an agent skill from microsoft/SwiftStreamingMarkdown, published by the product's own GitHub organization. Record and validate swift-snapshot-testing snapshots in the SwiftStreamingMarkdown package: regenerate reference PNGs, run snapshot tests, and diff failed snapshots.

When should I use Snapshot Tests?

Snapshot Tests fits situations like: tasks that involve iOS development.

How do I install Snapshot Tests in Claude Code?

Run `npx skills add microsoft/SwiftStreamingMarkdown --skill snapshot-tests -a claude-code`. Or copy the skill folder (.agents/skills/snapshot-tests in microsoft/SwiftStreamingMarkdown) into .claude/skills/snapshot-tests in your project. Claude Code loads it when a task matches its description.

How do I install Snapshot Tests in Codex?

Run `npx skills add microsoft/SwiftStreamingMarkdown --skill snapshot-tests -a codex`. Or copy the skill folder (.agents/skills/snapshot-tests in microsoft/SwiftStreamingMarkdown) into .agents/skills/snapshot-tests in your project. Codex loads it when a task matches its description.

Can I use Snapshot Tests in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add microsoft/SwiftStreamingMarkdown --skill snapshot-tests -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/snapshot-tests, .gemini/skills/snapshot-tests, .github/skills/snapshot-tests and .opencode/skills/snapshot-tests in your project.

What does Snapshot Tests need to run?

Going by SKILL.md and its folder, Snapshot Tests needs the command-line tools its instructions call (gh, xcodebuild, git and xcrun).

Does Snapshot Tests access the network?

SKILL.md contains no URLs. Its commands use gh and git, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Snapshot Tests safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Snapshot Tests use?

Snapshot Tests is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Snapshot Tests use?

About 2.2k tokens (SKILL.md is roughly 8.8k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Snapshot Tests?

Skills that share tags, products or a category with Snapshot Tests: Bootstrap iOS (RayFernando1337/rayfernando-skills, 130 stars), Swift Development (aiskillstore/marketplace, 430 stars), Swiftui Expert Skill (AvdLee/SwiftUI-Agent-Skill, 3.7k stars) and Swiftui Expert Skill (Eslzzyl/Pixiv-SwiftUI, 111 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Snapshot Tests?

microsoft (a GitHub organization, an official publisher) maintains it in microsoft/SwiftStreamingMarkdown, which has 377 GitHub stars. The repository holds 2 skills in this directory. The repository was last updated on September 25, 2026.

Source: microsoft/SwiftStreamingMarkdown on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.