/networking-layer
Generates a protocol-based networking layer with async/await, error handling, and swappable implementations. Use when user wants to add API client, networking, or HTTP layer.
$ npx -y skills add rshankras/claude-code-apple-skills --skill networking-layer --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/networking-layer
Context preview
The summary Claude sees to decide when to auto-load this skill.
Generates a protocol-based networking layer with async/await, error handling, and swappable implementations. Use when user wants to add API client, networking, or HTTP layer.
SKILL.md
networking-layer.SKILL.mdname: networking-layer
description: Generates a protocol-based networking layer with async/await, error handling, and swappable implementations. Use when user wants to add API client, networking, or HTTP layer.
allowed-tools: [Read, Write, Edit, Glob, Grep, Bash, AskUserQuestion]
last_verified: 2026-07-16
review_by: 2027-06-22
os_version: iOS 27 / macOS 27
Networking Layer Generator
Generate a modern, protocol-based networking layer using Swift's async/await concurrency, with proper error handling and easy testability.
When This Skill Activates
Use this skill when the user:
- Asks to "add networking" or "create API client"
- Mentions "HTTP layer" or "REST API"
- Wants to "fetch data from API"
- Asks about "URLSession wrapper" or "network requests"
Pre-Generation Checks
1. Project Context Detection
- [ ] Check Swift version (async/await requires Swift 5.5+)
- [ ] Check deployment target (async/await requires iOS 15+ / macOS 12+)
- [ ] Search for existing networking implementations
- [ ] Identify source file locations
2. Conflict Detection
Search for existing networking:
Glob: **/*API*.swift, **/*Network*.swift, **/*Client*.swift
Grep: "URLSession" or "HTTPURLResponse"
If found, ask user:
- Replace existing implementation?
- Extend with new endpoints?
Configuration Questions
Ask user via AskUserQuestion:
1. **Authentication type?**
- Bearer token
- API key (header or query param)
- None
- Custom
2. **Base URL configuration?**
- Single environment
- Multiple environments (dev/staging/prod)
3. **Additional features?**
- Retry logic with exponential backoff
- Request/response logging
- Caching
Generation Process
Step 1: Create Core Files
Generate these files: 1. `APIClient.swift` - Protocol and implementation 2. `APIEndpoint.swift` - Endpoint definition protocol 3. `NetworkError.swift` - Typed errors 4. `APIConfiguration.swift` - Base URL and auth config
Step 2: Optional Files
Based on configuration:
- `RetryPolicy.swift` - If retry logic selected
- `NetworkLogger.swift` - If logging selected
Step 3: Determine File Location
Check project structure:
- If `Sources/` exists → `Sources/Networking/`
- If `App/` exists → `App/Networking/`
- Otherwise → `Networking/`
Swift 6.2 Concurrency Notes
Reference: Apple's Swift Concurrency Updates
@concurrent for Background Work
Use `@concurrent` to offload heavy processing:
@concurrent
static func parseResponse<T: Decodable>(_ data: Data) async throws -> T {
try JSONDecoder().decode(T.self, from: data)
}MainActor for UI Updates
Keep UI-related code on MainActor:
@Observable
@MainActor
final class NetworkViewModel {
var items: [Item] = []
func fetch() async {
items = try await apiClient.fetch(ItemsEndpoint())
}
}Output Format
After generation, provide:
Files Created
Sources/Networking/
├── APIClient.swift # Protocol + URLSession implementation
├── APIEndpoint.swift # Endpoint protocol
├── NetworkError.swift # Error types
├── APIConfiguration.swift # Config (base URL, auth)
└── Endpoints/ # Example endpoints
└── ExampleEndpoint.swiftIntegration Steps
**Define an Endpoint:**
struct UsersEndpoint: APIEndpoint {
typealias Response = [User]
var path: String { "/users" }
var method: HTTPMethod { .get }
}**Make a Request:**
let client = URLSessionAPIClient(configuration: .production)
let users = try await client.request(UsersEndpoint())
**With SwiftUI:**
struct UsersView: View {
@State private var users: [User] = []
@Environment(\.apiClient) private var apiClient
var body: some View {
List(users) { user in
Text(user.name)
}
.task {
users = try await apiClient.request(UsersEndpoint())
}
}
}Testing
Use `MockAPIClient` for tests:
let mockClient = MockAPIClient()
mockClient.mockResponse(for: UsersEndpoint.self, response: [User.mock])
let viewModel = UsersViewModel(apiClient: mockClient)
await viewModel.fetch()
XCTAssertEqual(viewModel.users.count, 1)
References
- **networking-patterns.md** - Architecture patterns and best practices
- **templates/** - All template files
- Apple Docs: Swift Concurrency Updates (Swift 6.2)
Read more
name: networking-layer description: Generates a protocol-based networking layer with async/await, error handling, and swappable implementations. Use when user wants to add API client, networking, or HTTP layer. allowed-tools: [Read, Write, Edit, Glob, Grep, Bash, AskUserQuestion] last_verified: 2026-07-16 review_by: 2027-06-22 os_version: iOS 27 / macOS 27
Networking Layer Generator
Generate a modern, protocol-based networking layer using Swift's async/await concurrency, with proper error handling and easy testability.
When This Skill Activates
Use this skill when the user:
- Asks to "add networking" or "create API client"
- Mentions "HTTP layer" or "REST API"
- Wants to "fetch data from API"
- Asks about "URLSession wrapper" or "network requests"
Pre-Generation Checks
1. Project Context Detection
- [ ] Check Swift version (async/await requires Swift 5.5+)
- [ ] Check deployment target (async/await requires iOS 15+ / macOS 12+)
- [ ] Search for existing networking implementations
- [ ] Identify source file locations
2. Conflict Detection
Search for existing networking:
Glob: **/*API*.swift, **/*Network*.swift, **/*Client*.swift Grep: "URLSession" or "HTTPURLResponse"
If found, ask user:
- Replace existing implementation?
- Extend with new endpoints?
Configuration Questions
Ask user via AskUserQuestion:
1. **Authentication type?**
- Bearer token
- API key (header or query param)
- None
- Custom
2. **Base URL configuration?**
- Single environment
- Multiple environments (dev/staging/prod)
3. **Additional features?**
- Retry logic with exponential backoff
- Request/response logging
- Caching
Generation Process
Step 1: Create Core Files
Generate these files: 1. `APIClient.swift` - Protocol and implementation 2. `APIEndpoint.swift` - Endpoint definition protocol 3. `NetworkError.swift` - Typed errors 4. `APIConfiguration.swift` - Base URL and auth config
Step 2: Optional Files
Based on configuration:
- `RetryPolicy.swift` - If retry logic selected
- `NetworkLogger.swift` - If logging selected
Step 3: Determine File Location
Check project structure:
- If `Sources/` exists → `Sources/Networking/`
- If `App/` exists → `App/Networking/`
- Otherwise → `Networking/`
Swift 6.2 Concurrency Notes
Reference: Apple's Swift Concurrency Updates
@concurrent for Background Work
Use `@concurrent` to offload heavy processing:
@concurrent
static func parseResponse<T: Decodable>(_ data: Data) async throws -> T {
try JSONDecoder().decode(T.self, from: data)
}MainActor for UI Updates
Keep UI-related code on MainActor:
@Observable
@MainActor
final class NetworkViewModel {
var items: [Item] = []
func fetch() async {
items = try await apiClient.fetch(ItemsEndpoint())
}
}Output Format
After generation, provide:
Files Created
Sources/Networking/
├── APIClient.swift # Protocol + URLSession implementation
├── APIEndpoint.swift # Endpoint protocol
├── NetworkError.swift # Error types
├── APIConfiguration.swift # Config (base URL, auth)
└── Endpoints/ # Example endpoints
└── ExampleEndpoint.swiftIntegration Steps
**Define an Endpoint:**
struct UsersEndpoint: APIEndpoint {
typealias Response = [User]
var path: String { "/users" }
var method: HTTPMethod { .get }
}**Make a Request:**
let client = URLSessionAPIClient(configuration: .production) let users = try await client.request(UsersEndpoint())
**With SwiftUI:**
struct UsersView: View {
@State private var users: [User] = []
@Environment(\.apiClient) private var apiClient
var body: some View {
List(users) { user in
Text(user.name)
}
.task {
users = try await apiClient.request(UsersEndpoint())
}
}
}Testing
Use `MockAPIClient` for tests:
let mockClient = MockAPIClient() mockClient.mockResponse(for: UsersEndpoint.self, response: [User.mock]) let viewModel = UsersViewModel(apiClient: mockClient) await viewModel.fetch() XCTAssertEqual(viewModel.users.count, 1)
References
- **networking-patterns.md** - Architecture patterns and best practices
- **templates/** - All template files
- Apple Docs: Swift Concurrency Updates (Swift 6.2)
A collection of Claude Code skills for iOS, macOS, watchOS, visionOS, and Apple platform development. These skills help you plan and build apps, maintain code quality, ensure HIG compliance, and guide you from idea to App Store.
Repo: rshankras/claude-code-apple-skills
Other skills on rshankras-apple-skills.
- /app-store
App Store optimization and marketing skills for descriptions, screenshots, keywords, review responses, and comprehensive promotional strategy. Use when user needs help with App Store presence, ASO, marketing, or customer communication.
Open skill - /ad-attribution
Privacy-preserving ad measurement with AdAttributionKit (SKAdNetwork's successor) — install and re-engagement attribution, conversion-value strategy under crowd anonymity, and end-to-end postback testing. Use when running paid acquisition beyond Apple Ads, measuring
Open skill - /app-description-writer
Generate compelling App Store descriptions that convert browsers into users. Use when writing initial descriptions, improving existing copy, or drafting promotional text and What's New for a major update.
Open skill - /apple-search-ads
Apple Search Ads campaign strategy for indie developers — paid acquisition, keyword bidding, budget planning, and ROAS optimization. Use when user asks about running ads, paid user acquisition, or Apple Search Ads campaigns.
Open skill - /iap-finalizer
Take a one-time in-app purchase from MISSING_METADATA to READY_TO_SUBMIT in App Store Connect — set its price schedule and localized display name/description (and optional review screenshot) via the ASC REST API. Use at Phase 6 (Pre-Release), after the IAP is built in-app (Phase
Open skill - /keyword-optimizer
Optimize app title, subtitle, and keywords for maximum App Store discoverability. Use when launching a new app, improving search rankings, entering new markets/languages, or safely optimizing ASO for an app with existing traffic.
Open skill

