skills/generators/networking-layer/SKILL.md
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 skillsauth add rshankras/claude-code-apple-skills networking-layerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Generate a modern, protocol-based networking layer using Swift's async/await concurrency, with proper error handling and easy testability.
Use this skill when the user:
Search for existing networking:
Glob: **/*API*.swift, **/*Network*.swift, **/*Client*.swift
Grep: "URLSession" or "HTTPURLResponse"
If found, ask user:
Ask user via AskUserQuestion:
Authentication type?
Base URL configuration?
Additional features?
Generate these files:
APIClient.swift - Protocol and implementationAPIEndpoint.swift - Endpoint definition protocolNetworkError.swift - Typed errorsAPIConfiguration.swift - Base URL and auth configBased on configuration:
RetryPolicy.swift - If retry logic selectedNetworkLogger.swift - If logging selectedCheck project structure:
Sources/ exists → Sources/Networking/App/ exists → App/Networking/Networking/Reference: Apple's Swift Concurrency Updates
Use @concurrent to offload heavy processing:
@concurrent
static func parseResponse<T: Decodable>(_ data: Data) async throws -> T {
try JSONDecoder().decode(T.self, from: data)
}
Keep UI-related code on MainActor:
@Observable
@MainActor
final class NetworkViewModel {
var items: [Item] = []
func fetch() async {
items = try await apiClient.fetch(ItemsEndpoint())
}
}
After generation, provide:
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.swift
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())
}
}
}
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)
development
Build, install, and launch an iOS app on a physical iPhone or iPad entirely from the command line (no Xcode GUI), using xcodebuild + devicectl. Use when the user wants to run, test, or screenshot their app on a real device without opening Xcode.
development
Comprehensive iOS development guidance including Swift best practices, SwiftUI patterns, UI/UX review against HIG, and app planning. Use for iOS code review, best practices, accessibility audits, or planning new iOS apps.
development
Build, install, launch, and screenshot an iOS app in the Simulator to verify a change visually. Use when the user wants to run the app, see a change live, screenshot the running app, or confirm a UI fix actually works (not just that it compiles).
development
Audits skills in this repo for consistency, API drift, and structural gaps. Produces a prioritized report grouped by severity (Critical/High/Medium/Low). Use when asked to "audit skills", "check the skill repo for drift", or when planning bulk skill cleanup. Read-only — does not apply fixes.