README.md

April 16, 2026 ยท View on GitHub

Swift FormatStyle Agent Skill

iOS 15+ Swift 5.7+ MIT License Agent Skills Compatible

An agent skill that helps AI coding agents like Claude Code, Codex, Cursor, and Gemini write modern Swift formatting code using FormatStyle and .formatted() APIs instead of legacy Formatter subclasses and C-style String(format:).

It uses the Agent Skills format, so it works smoothly with Claude Code, Codex, Gemini, Cursor, and more.

What It Covers

  • Number, Percent, Currency - precision, rounding, sign, notation, scale, grouping, locale
  • Date/Time - compositing, presets, ISO 8601, relative, anchored relative, verbatim, HTTP
  • Date Ranges - interval and components styles
  • Duration - time patterns (HH:MM:SS) and units (human-readable)
  • Measurement - locale-aware unit conversion for length, mass, temperature, speed, etc.
  • List - array-to-text with "and"/"or" joining
  • Person Name - locale-aware name ordering
  • Byte Count - file/memory size display
  • URL - component-level formatting and parsing
  • Custom FormatStyle - creating your own
  • Anti-patterns - catches String(format:), DateFormatter, NumberFormatter, and other legacy code

Installing

You can install this skill into Claude Code, Codex, Gemini, Cursor, and more by using npx:

npx skills add https://github.com/n0an/Swift-FormatStyle-Agent-Skill --skill swift-format-style

If you get the error npx: command not found, it means you don't currently have Node installed. You need to run this command to install Node through Homebrew:

brew install node

And if that fails it usually means you need to install Homebrew first.

When using npx, you can select exactly which agents you want to use during the installation. You can also select whether the skill should be installed just for one project, or whether it should be made available for all your projects.

Alternative install methods

Claude Code:

/plugin install n0an/Swift-FormatStyle-Agent-Skill

Gemini:

gemini extensions install https://github.com/n0an/Swift-FormatStyle-Agent-Skill.git --consent

Alternatively, you can clone this whole repository and install it however you want.

Using Swift Format Style

The skill is called Swift Format Style, and can be triggered in various ways. For example, in Claude Code you would use this:

/swift-format-style

And in Codex you would use this:

$swift-format-style

In both cases you can provide specific instructions if you want only a partial review. For example, /swift-format-style Replace all String(format:) calls with FormatStyle on Claude, or $swift-format-style Fix the date formatting in this file in Codex.

You can also trigger the skill using natural language:

Use the Swift Format Style skill to review the formatting code in this project.

Why Use an Agent Skill for FormatStyle?

LLMs frequently generate legacy Swift formatting code - String(format: "%.2f", value), DateFormatter, manual duration calculations with String(format: "%02d:%02d", minutes, seconds) - because the majority of their training data predates iOS 15's FormatStyle APIs.

This skill:

  • Catches anti-patterns that LLMs default to, like C-style number formatting and legacy Formatter subclasses
  • Provides comprehensive examples for every FormatStyle variant with expected output
  • Covers newer APIs like Duration styles (iOS 16+), anchored relative dates (Xcode 16+), and URL formatting
  • Enforces SwiftUI best practices like Text(_:format:) over string interpolation

Contributing

Contributions are welcome - whether adding new checks, improving existing examples, or fixing typos.

  • Keep Markdown concise. There is a token cost to using skills, so respect the token budgets of users.
  • Do not repeat things LLMs already know. Focus on edge cases, surprises, and common mistakes.
  • All work must be licensed under the MIT license.

License

Available under the MIT License, which permits commercial use, modification, distribution, and private use.