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.
npx agentmods add skills/dagba/ios-mcp/swift-codable-jsonnpx skills add dagba/ios-mcp --skill swift-codable-jsongit clone --depth 1 https://github.com/dagba/ios-mcpWrote 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.
[](https://agentmods.dev/skills/dagba/ios-mcp/swift-codable-json)<a href="https://agentmods.dev/skills/dagba/ios-mcp/swift-codable-json"><img src="https://agentmods.dev/badge/skills/dagba/ios-mcp/swift-codable-json.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00043 | $0.03531 |
| Opus 5 | $0.00022 | $0.01766 |
| Sonnet 5 | $0.00009 | $0.00706 |
| Haiku 4.5 | $0.00004 | $0.00353 |
Grade A, and why
swift-codable-json 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 4d 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.
How it starts
The opening of the file, as written. The whole thing — 523 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Swift Codable for JSON Parsing
Overview
Codable provides type-safe JSON parsing but strict typing means any mismatch crashes decoding. One date strategy per decoder, CodingKeys for every naming mismatch, custom decoders for nested structures.
Core principle: Design for API reality (not ideal JSON), fail gracefully with error handling, use optionals for unreliable data.
Basic Patterns
Pattern 1: Simple Mapping
// JSON: {"id": 123, "name": "Alice", "email": "[email protected]"}
struct User: Codable {
let id: Int
let name: String
let email: String
}
// Usage:
let data = jsonString.data(using: .utf8)!
let user = try JSONDecoder().decode(User.self, from: data)
Auto-synthesis works when:
- Property names match JSON keys exactly
- All types match (String → String, Int → Int)
- All required properties present in JSON
Pattern 2: CodingKeys for Name Mapping
Problem: API uses snake_case, Swift uses camelCase.
// JSON: {"user_id": 123, "first_name": "Alice", "created_at": "2026-01-15"}
struct User: Codable {
let userID: Int
let firstName: String
let createdAt: String
enum CodingKeys: String, CodingKey {
case userID = "user_id"
case firstName = "first_name"
case createdAt = "created_at"
}
}
Rule: Every property must appear in CodingKeys, even if name matches.
// ❌ WRONG: Compiler error (missing properties in CodingKeys)
enum CodingKeys: String, CodingKey {
case userID = "user_id" // Missing firstName and createdAt
}
// ✅ CORRECT: All properties listed
enum CodingKeys: String, CodingKey {
case userID = "user_id"
case firstName = "first_name"
case createdAt = "created_at"
}
Date Handling
Problem: Multiple Date Formats in Same Response
CRITICAL: JSONDecoder supports ONE date strategy at a time.
// JSON with mixed formats:
{
"created": "2026-01-15T10:30:00Z", // ISO8601
"published": "15/01/2026", // Custom format
"timestamp": 1705316400 // Unix timestamp
}
// ❌ WRONG: Can't set multiple strategies
let decoder = JSONDecoder()
decoder.dateDecodingStrategy = .iso8601 // Only applies to ONE field
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.
- 4d ago First seen · 523 lines · 43 tokens per session scan A d6af7f2f94ec
swift-codable-json is a skill published in the GitHub repository dagba/ios-mcp (3 stars, last pushed 7mo ago), licensed MIT. It adds 43 tokens to every session and 3,531 once invoked, about $0.0002 per session on Opus 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-31.
Other skills, from other repositories
kotlin-specialist
Provides idiomatic Kotlin implementation patterns including coroutine concurrency, Flow stream handling, multiplatform architecture, Compose UI construction, Ktor server setup, and type-safe DSL design. Use when building Kotlin applications requiring coroutines, multiplatform development, or Android with Compose.…
macos-swiftpm
Build, run, and test SwiftPM macOS packages and executables. Use when the repo is package-first or has no Xcode project.
kotlin-tooling-java-to-kotlin
Use when converting Java source files to idiomatic Kotlin, when user mentions "java to kotlin", "j2k", "convert java", "migrate java to kotlin", or when working with .java files that need to become .kt files. Handles framework-aware conversion for Spring, Lombok, Hibernate, Jackson, Micronaut, Quarkus, Dagger/Hilt…
signals-migration-6-to-7
Detailed guidelines, patterns, and rules for migrating codebases from signals.dart version 6.x to version 7.x.
kotlin-concurrency-expert
Kotlin Coroutines review and remediation for Android. Use when asked to review concurrency usage, fix coroutine-related bugs, improve thread safety, or resolve lifecycle issues in Kotlin/Android code.
android-viewmodel
Best practices for implementing Android ViewModels using Kotlin 2.3+ Explicit Backing Fields, StateFlow for UI state, and SharedFlow for one-off events.