$npx skillfedfor your agent

memory

Learn Swift 6.2's low-level memory types designed for performance-critical code: InlineArray for fixed-size inline storage without heap allocation, and Span for safe, zero-cost access to contiguous memory. These compiler-checked alternatives replace common uses of UnsafeBufferPointer and hand-tuned tuple storage, helping you eliminate allocations in hot paths while maintaining memory safety.

memory skill teaches Swift 6.2 InlineArray and Span types to eliminate heap allocations in performance-critical code.

AI-generated summary based on this skill's SKILL.md

565 47 MITupdated by rshankras

Decision gist · record as of 2026-07-24

memory skill teaches Swift 6.2 InlineArray and Span types to eliminate heap allocations in performance-critical code. Learn Swift 6.2's low-level memory types designed for performance-critical code: InlineArray for fixed-size inline storage without heap allocation, and Span for safe, zero-cost access to contiguous memory. These compiler-checked alternatives replace common uses of UnsafeBufferPointer and hand-tuned tuple storage, helping you eliminate allocations in hot paths while maintaining memory safety.

manual: git clone https://github.com/rshankras/claude-code-apple-skills → cp -r claude-code-apple-skills/skills/swift/memory ~/.claude/skills/memory
skills/swift/memory/SKILL.md · version 825b64ae

Use it when

  • memory's InlineArray is a fixed-size collection that stores elements directly inline—no heap allocation, no copy-on-write.
  • memory's Span types (Span, MutableSpan, RawSpan, UTF8Span) are compiler-checked safe alternatives to UnsafeBufferPointer.

Verify before relying

Read SKILL.md below before installing (2 files). Open directory: indexed for reading, not audited.

Same gist for agents: .md · .json

Install

rshankras/claude-code-apple-skills/memory · repository language: Swift

Open directory. Skills are indexed for reading, not audited. Review a skill's body before installing it.

Frequently asked questions

AI-generated answers based on this skill's SKILL.md and metadata

How to use Span for memory access in Swift 6.2?

Swift's Span type provides safe, zero-cost access to contiguous memory without the overhead of Array's copy-on-write semantics. memory uses Span as a non-escapable view over existing storage—pass it to functions that need read-only access to a buffer without copying. For mutable access, use MutableSpan. Both are compiler-checked alternatives to UnsafeBufferPointer, eliminating bounds-checking overhead while preserving memory safety in performance-critical code.

What is InlineArray and when should I use it?

memory's InlineArray is a fixed-size collection that stores elements directly inline—no heap allocation, no copy-on-write. Use InlineArray when you need a small, compile-time-sized collection in hot paths: signal processing, embedded Swift, or any scenario where eliminating allocations matters. InlineArray guarantees zero-copy semantics and provides compile-time size validation, making it ideal for replacing hand-tuned tuple storage or small Array instances.

How does memory help replace UnsafeBufferPointer with Span?

memory's Span types (Span, MutableSpan, RawSpan, UTF8Span) are compiler-checked safe alternatives to UnsafeBufferPointer. They enforce non-escapable lifetimes at compile time, preventing use-after-free bugs. Migrate by replacing UnsafeBufferPointer views with the appropriate Span variant: Span for typed read-only, MutableSpan for typed mutable, RawSpan for untyped binary data, UTF8Span for Unicode text. No runtime overhead—same performance, better safety.

Can memory eliminate heap allocations in Swift hot paths?

Yes. memory combines InlineArray for fixed-size inline storage with Span for zero-copy views over existing buffers. Together they eliminate the heap allocations and copy-on-write overhead that small Array instances incur. In performance-critical loops, replace Array with InlineArray (when size is known) and pass buffers as Span instead of copying. This keeps data on the stack and reduces GC pressure in embedded and real-time contexts.

What are RawSpan and UTF8Span used for?

memory's RawSpan provides safe, untyped access to binary data—ideal for parsing protocols, file formats, or network packets without unsafe casts. UTF8Span specializes in Unicode text processing, offering safe iteration and validation over UTF-8 bytes. Both are non-escapable views that prevent lifetime violations while maintaining zero-copy performance, making them essential for signal processing, embedded systems, and any binary I/O where safety and speed matter equally.

Does memory support value generics and compile-time size guarantees?

Yes. memory's InlineArray uses value generics (let count: Int) to encode fixed sizes at compile time, enabling the compiler to validate bounds and eliminate runtime checks. This compile-time guarantee means InlineArray storage is allocated inline with no heap indirection. The result: type-safe, zero-allocation fixed-size collections that the optimizer can fully specialize, delivering performance equivalent to hand-written C while maintaining Swift's memory safety.

SKILL.md

Rendered from the published skill. Quoted content, verbatim.

InlineArray and Span

Guidance for Swift 6.2's low-level memory types: InlineArray for fixed-size inline storage without heap allocation, and Span for safe, zero-cost access to contiguous memory. These replace common uses of UnsafeBufferPointer and hand-tuned tuple storage with compiler-checked alternatives.

When This Skill Activates

Use this skill when the user: - Asks about InlineArray, fixed-size arrays, or stack-allocated collections - Mentions Span, MutableSpan, RawSpan, or UTF8Span - Wants to eliminate heap allocations in hot paths - Is replacing UnsafeBufferPointer or UnsafePointer with safe alternatives - Asks about value generics or let count: Int generic parameters - Needs zero-copy access to collection storage - Mentions inline storage, contiguous memory, or memory layout - Is

(truncated - see the full file via the links below)

File tree — 2 files
skills/swift/memory/SKILL.md
skills/swift/memory/swift-performance.md

Let your AI agent find skills like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 56,283 agent skills by what they can do, searchable in plain language.

wish › “Optimize performance-critical code by replacing heap allocations with InlineArray and Span”

Give your agent the search over MCP, or paste the wish link into any chat. No install? Search from any chat →

Related skills

swift-development
by rshankras · rshankras/claude-code-apple-skills

Swift Development provides language-level guidance for writing correct, performant Swift across iOS, macOS, and other Apple platforms. It covers concurrency architecture with async/await and actors, Swift 6 strict concurrency migration, memory optimization through InlineArray and Span, and code complexity standards via SwiftLint thresholds. Use it to review code for data races, actor isolation, and modern idioms.

MITupdated Jul 2026
★ 565repo stars
axiom-apple-docs
by CharlesWiltgen · CharlesWiltgen/Axiom

axiom-apple-docs routes you to Apple's bundled documentation for framework APIs, design patterns, and compiler errors. It covers 20 authoritative guides spanning Liquid Glass, SwiftData, StoreKit, Foundation Models, and concurrency, plus 46 Swift compiler diagnostics with explanations. Use it alongside Axiom skills to ground opinionated guidance in Apple's official specifications.

MITupdated Jul 2026
★ 1,095repo stars
swift-concurrency-6-2
by xu-xiang · xu-xiang/everything-claude-code-zh

This skill guides you through Swift 6.2's concurrency paradigm, where code runs single-threaded by default and background work requires explicit @concurrent annotation. Learn how async functions now stay on the caller's actor, eliminating implicit thread offloading that caused data races in earlier versions. Master isolated protocol conformances for MainActor types and adopt MainActor inference to reduce boilerplate in app targets.

MITdocs in Chineseupdated Mar 2026
★ 1,767repo stars
swift-concurrency-updates
by rshankras · rshankras/claude-code-apple-skills

This skill guides you through Swift 6.2's "Approachable Concurrency" features that simplify strict concurrency adoption. Discover how default MainActor inference eliminates manual annotations, how async functions now stay on their calling actor, and how to use @concurrent for explicit background execution. Perfect for migrating from Swift 6.0/6.1 or resolving data-race errors with the latest toolchain.

MITupdated Jul 2026
★ 565repo stars
Swift Ios Migration
by xtone · xtone/ai_development_tools

This skill guides developers through converting legacy iOS applications from Objective-C to Swift, covering the technical and architectural decisions needed for a successful transition. Learn strategies for managing dependencies, refactoring code patterns, and maintaining app stability during the migration process.

no license declared → metadata onlyupdated Jun 2026
★ 3repo stars
Swift Language
by dpearson2699 · dpearson2699/swift-ios-skills

Swift Language covers contemporary syntax and idioms for core Swift development, excluding concurrency and SwiftUI. Learn if/switch expressions, typed throws, result builders, property wrappers, opaque versus existential types, guard patterns, the Never type, regex builders, Codable techniques, modern collection methods, FormatStyle basics, and string interpolation. Routes specialized topics like deep decoding, formatting, API naming, concurrency, and SwiftUI state to dedicated skills.

no license declared → metadata onlyupdated Jul 2026
★ 932repo stars

More skills swift-concurrency-6-2 (MIT) · concurrency-patterns (MIT)

Tags
low-level-memorystack-storagezero-allocationsafe-pointersperformance-criticalembedded-systemsbinary-datalifetime-safetycontiguous-buffersvalue-semantics