# swift-codable

This skill guides an agent through Swift Codable models for JSON and property lists. Use it for API payloads, nested data, key mapping, and date handling.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 3600 installs · ★ 1237
- Author: dpearson2699
- License: LicenseRef-Unknown · policy=link-only · description only; the file stays with the author
- Source: https://github.com/dpearson2699/swift-ios-skills/tree/HEAD/skills/swift-codable/SKILL.md
- Updated: 2026-07-31
- HTML: https://affpapa.org/en/nevibecode/skills/swift-codable

## What it does

The skill covers Swift Codable work around JSONDecoder and JSONEncoder. It helps an agent shape API response models, map external names with CodingKeys, and write custom init(from:) or encode(to:) logic when compiler synthesis is insufficient. The material also addresses nested containers, flattened structures, mixed-type arrays, and strategies for dates, Data, and keys.

It connects these models with URLSession, SwiftData, and UserDefaults, then checks failures through DecodingError, codingPath, and the raw payload. The suggested workflow tests valid, missing, null, malformed, acronym-key, and date fixtures before checking round trips where both directions matter.

The skill targets Swift 6.3 and iOS 26+. Projects on another version pairing need their APIs checked against these examples.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add dpearson2699/swift-ios-skills --skill swift-codable -a claude-code
```

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

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add dpearson2699/swift-ios-skills --skill swift-codable -a codex
```

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

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add dpearson2699/swift-ios-skills --skill swift-codable -a cursor
```

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

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install dpearson2699/swift-ios-skills swift-codable
```

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

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add dpearson2699/swift-ios-skills --skill swift-codable -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/dpearson2699/swift-ios-skills --path skills/swift-codable
```

### Windsurf (Devin Desktop)

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

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add dpearson2699/swift-ios-skills --skill swift-codable -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/dpearson2699/swift-ios-skills/tree/HEAD/skills/swift-codable/SKILL.md

## When to use it
- decode API payloads into Swift models
- map external JSON names to Swift properties
- flatten nested response objects
- handle date and Data decoding rules
- trace Codable failures through codingPath

## Example prompts
- Create Swift Codable models for this API response and explain the decoder setup.
- Map `user_name` and `image_url` to Swift property names with CodingKeys.
- Decode the nested payload and turn its Unix timestamp into `Date`.

## Similar
- [vercel-react-native-skills](https://affpapa.org/en/nevibecode/skills/vercel-react-native-skills.md) — skill · 255200 installs
- [animate-expo](https://affpapa.org/en/nevibecode/skills/animate-expo.md) — skill · 137900 installs
- [mobile-native](https://affpapa.org/en/nevibecode/skills/mobile-native.md) — skill · 86600 installs
- [aso](https://affpapa.org/en/nevibecode/skills/aso.md) — skill · 75400 installs
- [swiftui-pro](https://affpapa.org/en/nevibecode/skills/swiftui-pro.md) — skill · 35200 installs
- [orca-emulator](https://affpapa.org/en/nevibecode/skills/orca-emulator.md) — skill · 5800 installs

From the same set: [dpearson2699/swift-ios-skills](https://affpapa.org/en/nevibecode/by/dpearson2699/swift-ios-skills.md) — 86 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
