swift-networking

swift-networking is a skill for Claude Code, Codex from jeremieb/swift-unit-test-instructions. It costs 82 tokens per session (2,098 once invoked), scanned A, original, MIT.

A structure for making asynchronous internet requests in Swift with URLSession, Apple’s built-in networking API. It separates request code behind protocols so the rest of the app can be tested with substitutes.

In plain words
What is it for?
Use it to add an API layer, make HTTP or REST requests, decode responses, handle common network errors, and test code with mock clients.
Why use it?
It provides a consistent place for URLs, responses, decoding, authentication errors, and connection failures. Mock support makes tests possible without contacting a real server.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: positional $N argument.

Good fit Use it to add an API layer, make HTTP or REST requests, decode responses, handle common network errors, and test code with mock clients.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/jeremieb/swift-unit-test-instructions/swift-networking
Install

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.

Any agent
npx skills add jeremieb/swift-unit-test-instructions --skill swift-networking
Clone the repo
git clone --depth 1 https://github.com/jeremieb/swift-unit-test-instructions

Made for: Claude Code, Codex.

Wrote 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.

agentmods badge for swift-networking

README.md
[![agentmods](https://agentmods.dev/badge/skills/jeremieb/swift-unit-test-instructions/swift-networking/github.svg)](https://agentmods.dev/skills/jeremieb/swift-unit-test-instructions/swift-networking)
Your own site
<a href="https://agentmods.dev/skills/jeremieb/swift-unit-test-instructions/swift-networking"><img src="https://agentmods.dev/badge/skills/jeremieb/swift-unit-test-instructions/swift-networking/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for swift-networking

Your own site · 80×15
<a href="https://agentmods.dev/skills/jeremieb/swift-unit-test-instructions/swift-networking"><img src="https://agentmods.dev/badge/skills/jeremieb/swift-unit-test-instructions/swift-networking.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 82 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,098 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5.1 $0.00082 $0.02098
Opus 5 $0.00041 $0.01049
Sonnet 5 $0.00016 $0.00420
Haiku 4.5 $0.00008 $0.00210

Measured 9d ago against content hash faf45aaf7194, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

swift-networking scanned grade A with 1 finding 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 9d 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.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

try await apiClient.fetch(Endpoint(path: "/users"))
skills/swift-networking/SKILL.md · 289 lines

How it starts

The opening of the file, as written. The whole thing — 289 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Swift Networking Layer

Instructions

Step 1: Clarify Requirements

Ask if not already provided:

  • Base URL (can be a placeholder constant)
  • Authentication method: Bearer token, API key in header, OAuth, none
  • Endpoints to implement upfront (or start with the pattern only)
  • Response format: JSON (assumed), XML, or other
  • Error handling needs: retry logic, token refresh, offline support

Step 2: Generate the Core Layer

Generate in Services/Networking/:

HTTPClientProtocol — the testability key:

// Services/Networking/HTTPClientProtocol.swift
import Foundation

protocol HTTPClientProtocol {
    func data(for request: URLRequest) async throws -> (Data, URLResponse)
}

// URLSession conforms for free — no wrapper needed
extension URLSession: HTTPClientProtocol {}

APIError:

// Services/Networking/APIError.swift
import Foundation

enum APIError: LocalizedError {
    case invalidURL
    case invalidResponse(statusCode: Int)
    case decodingError(Error)
    case unauthorized
    case noInternetConnection
    case unknown(Error)

    var errorDescription: String? {
        switch self {
        case .invalidURL: return "Invalid URL."
        case .invalidResponse(let code): return "Server error (\(code))."
        case .decodingError: return "Failed to parse server response."
        case .unauthorized: return "You are not authorized. Please log in again."
        case .noInternetConnection: return "No internet connection."
        case .unknown(let error): return error.localizedDescription
        }
    }
}

Endpoint — type-safe request building:

// Services/Networking/Endpoint.swift
import Foundation

struct Endpoint {
    let path: String
    let method: HTTPMethod
    let queryItems: [URLQueryItem]?
    let body: Encodable?
    let headers: [String: String]

    init(
        path: String,
        method: HTTPMethod = .get,
        queryItems: [URLQueryItem]? = nil,
        body: Encodable? = nil,
        headers: [String: String] = [:]
    ) {
        self.path = path
        self.method = method
        self.queryItems = queryItems
        self.body = body
        self.headers = headers
    }

    func urlRequest(baseURL: URL, authToken: String? = nil) throws -> URLRequest {
        var components = URLComponents(url: baseURL.appendingPathComponent(path), resolvingAgainstBaseURL: true)
        components?.queryItems = queryItems

        guard let url = components?.url else { throw APIError.invalidURL }

        var request = URLRequest(url: url)
        request.httpMethod = method.rawValue
        request.setValue("application/json", forHTTPHeaderField: "Content-Type")

        if let token = authToken {
            request.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization")
        }

        headers.forEach { request.setValue($1, forHTTPHeaderField: $0) }

        if let body = body {
            request.httpBody = try JSONEncoder().encode(body)
        }

        return request
    }
}

enum HTTPMethod: String {
    case get = "GET"
    case post = "POST"
    case put = "PUT"
    case patch = "PATCH"
    case delete = "DELETE"
}

Read the full file on GitHub · 289 lines

Changes

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.

  1. 9d ago First seen · 289 lines · 82 tokens per session scan A faf45aaf7194

Subscribe to this mod's changes

swift-networking is a skill published in the GitHub repository jeremieb/swift-unit-test-instructions (5 stars, last pushed 6mo ago), licensed MIT. It adds 82 tokens to every session and 2,098 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

flutter-implement-json-serialization

Create model classes with fromJson and toJson methods using dart:convert. Use when manually mapping JSON keys to class properties for simple data structures.

aiskillstore/marketplace · 41 tokens

fastapi-pro

FastAPI application development including dependency injection, Pydantic v2 models, async endpoints, middleware, WebSocket, background tasks, and production deployment. Trigger when users build REST APIs with FastAPI, need help with Pydantic models/validation, dependency injection patterns, or FastAPI performance…

FutureJJ/claude-skills · 64 tokens

xcode-makefiles

Install strict Xcode Makefile tooling for iOS/macOS projects, including build/run/test scripts with AGENTNAME-based per-agent isolation under build/. Use when a project needs reproducible local CLI builds without full app scaffolding.

robertguss/claude-code-toolkit · 52 tokens

vapor-backend

Use this skill when building Vapor Swift backend applications — async HTTP server, Fluent ORM, WebSocket support, middleware pipeline. This skill enforces: structured concurrency with async/await, proper route grouping, Fluent migration patterns, environment-based configuration. Do NOT use for: iOS apps, macOS desktop…

j4flmao/agent-skills · 75 tokens

kotlin-dev

Use when implementing any feature or bugfix in a Kotlin/Spring Boot service, covers layer conventions, idioms, testing, and observability.

pranav8494/team-of-agents · 32 tokens

python-fastapi-patterns

FastAPI web framework patterns. Triggers on: fastapi, api endpoint, dependency injection, pydantic model, openapi, swagger, starlette, async api, rest api, uvicorn.

aiskillstore/marketplace · 47 tokens