attributed-string

attributed-string is a skill for Claude Code from rshankras/claude-code-apple-skills. It costs 37 tokens per session (2,547 once invoked), scanned A, original, MIT.

A guide to AttributedString, Swift’s built-in type for text whose parts can have different formatting or behavior. It covers rich text, alignment, writing direction, line spacing, selection, editing, and SwiftUI integration.

In plain words
What is it for?
Use it to create or edit styled text, control paragraph layout, support text selection and editing, or display AttributedString values in SwiftUI TextEditor and other views.
Why use it?
It reduces mistakes when changing only selected parts of formatted text or connecting rich text to an editor. It also explains less familiar concepts such as a range set for multiple non-adjacent selections.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Part of the apple-skills plugin — 147 skills shipped together , and of apple-skills

Good fit Use it to create or edit styled text, control paragraph layout, support text selection and editing, or display AttributedString values in SwiftUI TextEditor and other views.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/rshankras/claude-code-apple-skills/attributed-string
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add rshankras/claude-code-apple-skills --skill attributed-string
Clone the repo
git clone --depth 1 https://github.com/rshankras/claude-code-apple-skills

Made for: Claude Code.

Or install apple-skills, the plugin that ships this one along with the rest of its 147 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for attributed-string

README.md
[![agentmods](https://agentmods.dev/badge/skills/rshankras/claude-code-apple-skills/attributed-string/github.svg)](https://agentmods.dev/skills/rshankras/claude-code-apple-skills/attributed-string)
Your own site
<a href="https://agentmods.dev/skills/rshankras/claude-code-apple-skills/attributed-string"><img src="https://agentmods.dev/badge/skills/rshankras/claude-code-apple-skills/attributed-string/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for attributed-string

Your own site · 80×15
<a href="https://agentmods.dev/skills/rshankras/claude-code-apple-skills/attributed-string"><img src="https://agentmods.dev/badge/skills/rshankras/claude-code-apple-skills/attributed-string.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 37 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,547 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 1 finding, up to medium

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • medium Excessive Agency · line 82
    Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.
    Fix: Add human-in-the-loop confirmation for destructive, irreversible, or high-impact operations. Never auto-execute commands that modify files, send data, or alter system state.
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00037 $0.02547
Opus 5.5 $0.00015 $0.01019
Sonnet 5.5 $0.00007 $0.00509
Haiku 4.5 $0.00004 $0.00255

Measured 1mo ago against content hash 82c403a3ae62, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

attributed-string scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/foundation/attributed-string/SKILL.md · 314 lines

How it starts

The opening of the file, as written. The whole thing — 314 lines — stays where its author put it; the contents beside it link to each section on GitHub.

AttributedString Patterns

Correct API shapes and patterns for Foundation's AttributedString. Covers creating styled text, applying attributes to ranges, text alignment, writing direction, line height control, text selection and editing, discontiguous substrings, and SwiftUI integration.

When This Skill Activates

Use this skill when the user:

  • Asks about AttributedString creation or manipulation
  • Wants to style text with fonts, colors, underlines, or other attributes
  • Mentions text alignment, writing direction, or line height
  • Asks about text selection or text editing with AttributedString
  • Wants to work with DiscontiguousAttributedSubstring or RangeSet
  • Mentions TextEditor with AttributedString in SwiftUI
  • Asks about rich text formatting in Swift
  • Wants to replace or modify text within an AttributedString
  • Mentions paragraphStyle, textSelectionAffinity, or AttributedTextSelection

Decision Tree

What do you need with AttributedString?
|
+-- Create or style text
|   |
|   +-- Simple inline attributes (font, color)
|   |   --> Creating and Styling section
|   |
|   +-- Paragraph-level formatting (alignment, line height)
|       --> Text Alignment and Formatting section
|
+-- Control text layout
|   |
|   +-- Writing direction (LTR / RTL)
|   |   --> Writing Direction and Line Height section
|   |
|   +-- Line spacing / height
|       --> Writing Direction and Line Height section
|
+-- Edit or select text programmatically
|   |
|   +-- Replace selection with characters or AttributedString
|   |   --> Text Selection and Editing section
|   |
|   +-- Work with multiple non-contiguous ranges
|       --> DiscontiguousAttributedSubstring section
|
+-- Display in SwiftUI
    --> SwiftUI Integration section

API Availability

API Minimum Version Notes
AttributedString iOS 15 / macOS 12 Swift-native replacement for NSAttributedString
AttributedString.paragraphStyle iOS 15 / macOS 12 Uses NSMutableParagraphStyle
AttributedString.writingDirection iOS 26 / macOS 26 New in 2025
AttributedString.LineHeight iOS 26 / macOS 26 .exact(points:), .multiple(factor:), .loose
AttributedString.alignment iOS 26 / macOS 26 .left, .center, .right
AttributedTextSelection iOS 26 / macOS 26 Programmatic text selection
replaceSelection(_:withCharacters:) iOS 26 / macOS 26 Replace selection with plain characters
replaceSelection(_:with:) iOS 26 / macOS 26 Replace selection with AttributedString
DiscontiguousAttributedSubstring iOS 26 / macOS 26 Non-contiguous range selections
AttributedString.utf8 iOS 26 / macOS 26 UTF-8 code unit view
TextEditor(text:selection:) with AttributedString iOS 26 / macOS 26 SwiftUI rich text editing
.textSelectionAffinity(_:) iOS 26 / macOS 26 Control cursor affinity at line boundaries

Read the full file on GitHub · 314 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 314 lines · 37 tokens per session scan A 82c403a3ae62

Subscribe to this mod's changes

attributed-string is a skill published in the GitHub repository rshankras/claude-code-apple-skills (816 stars, last pushed 2mo ago), licensed MIT. It adds 37 tokens to every session and 2,547 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

android-development

Android development with Kotlin, Jetpack Compose, and modern Android architecture. Use when building Android apps, implementing Material Design, or following Android best practices.

travisjneuman/.claude · 33 tokens

ios-development

Comprehensive guide for building native Apple platform applications.

travisjneuman/.claude · 43 tokens

macos-native

Native macOS development with AppKit, Catalyst, and macOS-specific APIs. Use when building Mac-native apps, menu bar apps, system extensions, or macOS-specific features.

travisjneuman/.claude · 40 tokens

kotlin-multiplatform

KMP/CMP shared business logic, Compose Multiplatform, expect/actual, Ktor, SQLDelight, and platform-specific implementations. Use when building cross-platform Kotlin applications for Android, iOS, desktop, or web.

travisjneuman/.claude · 54 tokens

agent-kotlin-expert

Specialist subagent: Kotlin Multiplatform, Compose Multiplatform, coroutines, Ktor, and JVM ecosystem specialist. Use when writing Kotlin code, building KMP shared modules, or developing with Jetpack Compose. Trigger phrases: Kotlin, KMP, Compose Multiplatform, coroutines, Ktor, Gradle, JVM, Flow, suspend, sealed…

travisjneuman/.claude · 85 tokens

swift-expert

Expert-level Swift development for iOS, macOS with SwiftUI, Combine, and modern Swift 5.9+. Use when the user mentions iOS, macOS, SwiftUI, Combine, async await, or Apple platforms, or when the task involves Modern Swift Features, Basics and Optionals, Functions and Closures, or Structs and Classes.

personamanagmentlayer/pcl · 76 tokens