swift-macros

Automate Swift macro development and testing across SwiftSyntax-based workflows.

4|1|Updated Apr 2, 2026
One-click install
npx skills add https://github.com/AutisticAF/claude-code-apple-dev-plugin --skill swift-macros
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swift-macros
Source: https://github.com/AutisticAF/claude-code-apple-dev-plugin/tree/main/skills/swift-macros
Command: npx skills add https://github.com/AutisticAF/claude-code-apple-dev-plugin --skill swift-macros

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Swift macros help developers reduce boilerplate and improve maintainability by generating code at compile time using SwiftSyntax, making generated code visible, debuggable, and easier to reason about.

Core Features & Use Cases

  • Freestanding and attached macros to generate new declarations or transform existing code.
  • Macro roles and a decision tree to guide when to use freestanding vs attached macros and extension macros.
  • Testing and debugging workflows, including examples for assertMacroExpansion, diagnostics, and macro expansion exploration.
  • Macro package setup and integration with a Swift package (Package.swift and compiler plugin setup).
  • API availability and patterns for common macro usage and evolution (SwiftSyntaxMacros, SwiftCompilerPlugin).

Quick Start

Install the macro package and begin using freestanding or attached macros in your Swift project.

Frequently Asked Questions about swift-macros

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I debug Swift macros during compile-time code generation?

Debug Swift macros by using macro expansion exploration workflows and assertMacroExpansion to inspect generated SwiftSyntax declarations and diagnostics during compile-time code generation.

When should I use freestanding vs attached macros in Swift?

Use freestanding macros to generate new declarations and attached macros to transform existing code, guided by a macro roles decision tree to determine the appropriate SwiftSyntax-based approach.

How do I test Swift macro expansion using SwiftSyntax?

Test Swift macro expansion by using assertMacroExpansion to validate diagnostics and verify generated code structures within SwiftSyntaxMacros and SwiftCompilerPlugin workflows.

What is the best way to set up a Swift macro package with a compiler plugin?

Set up a Swift macro package by configuring Package.swift and integrating the compiler plugin to enable SwiftSyntax-based macro development and code generation workflows.

Can I use extension macros to add conformances with SwiftSyntaxMacros?

Yes, you can use extension macros to transform existing code by adding conformances, utilizing the SwiftSyntaxMacros API to generate code at compile time.