# swift-library-design

Guides public API design for Swift libraries and frameworks: protocols, result builders, inlining, noncopyable types.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · ★ 62
- Author: wendylabsinc
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/wendylabsinc/claude-skills/tree/HEAD/swift-library-design/SKILL.md
- Updated: 2026-10-22
- HTML: https://affpapa.org/en/nevibecode/skills/swift-library-design

## What it does

The skill fires when a conversation turns to building a Swift library or framework, public API patterns, protocol-oriented architecture with associated types, result builders and DSLs, library performance, `@inlinable` and `@usableFromInline`, noncopyable types, progressive disclosure, or ResponseGenerator and builder patterns.

Two reference files carry the detail. `references/api-patterns.md` covers protocol design, result builders, the builder pattern, error handling and parameter extraction. `references/performance.md` deals with inlining, noncopyable types, data structures, lock-free patterns and state machines. The main file states four principles: protocols with associated types, compile-time safety, APIs that are efficient by default, and progressive disclosure.

Examples assume a modern Swift toolchain with generics and async/await. Code using `some RequestContext` and `@resultBuilder` will not compile on an older compiler, so check your version first. Installation is a single `npx skills` command.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add wendylabsinc/claude-skills --skill swift-library-design -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/swift-library-design/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/swift-library-design/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add wendylabsinc/claude-skills --skill swift-library-design -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/swift-library-design/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add wendylabsinc/claude-skills --skill swift-library-design -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/swift-library-design/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install wendylabsinc/claude-skills swift-library-design
```

2. **Manually: put the files in place**
- File: `.github/skills/swift-library-design/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add wendylabsinc/claude-skills --skill swift-library-design -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/wendylabsinc/claude-skills --path swift-library-design
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/swift-library-design/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add wendylabsinc/claude-skills --skill swift-library-design -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/wendylabsinc/claude-skills/tree/HEAD/swift-library-design/SKILL.md

## When to use it
- shape a library's public API so misuse fails at compile time
- build a result-builder DSL for composing middleware
- let a handler return several response types via a ResponseGenerator protocol
- mark hot paths `@inlinable` without breaking API compatibility
- define a protocol with associated types and type-safe composition

## Example prompts
- Design the public API for a Swift networking library
- Write a result builder DSL so middleware can be listed inline
- Tell me where `@inlinable` helps here and where it does not

## Similar
- [swift-api-design-guidelines](https://affpapa.org/en/nevibecode/skills/swift-api-design-guidelines.md) — skill · 2800 installs
- [swift-api-design-guidelines-skill](https://affpapa.org/en/nevibecode/skills/swift-api-design-guidelines-skill.md) — skill · 1200 installs
- [swift-language](https://affpapa.org/en/nevibecode/skills/swift-language.md) — skill · 4000 installs
- [swift-mcp-server-generator](https://affpapa.org/en/nevibecode/skills/swift-mcp-server-generator.md) — skill · 8800 installs
- [write-swift](https://affpapa.org/en/nevibecode/skills/write-swift.md) — skill · 119300 installs
- [Swift MCP Expert](https://affpapa.org/en/nevibecode/agents/swift-mcp-expert.md) — subagent · ★ 40451

From the same set: [wendylabsinc/claude-skills](https://affpapa.org/en/nevibecode/by/wendylabsinc/claude-skills.md) — 7 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
