mcpbeat Sign in

Networking Layer Skill for Claude

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.

8k tokens
context cost
the whole folder, loaded on every use
7
files
instructions only
0
copies elsewhere
how many repositories repackaged it
585
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/rshankras/claude-code-apple-skills --skill networking-layer

The instruction itself

18 sections, as written by the author

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:

  • Authentication type?
  • Bearer token
  • API key (header or query param)
  • None
  • Custom
  • Base URL configuration?
  • Single environment
  • Multiple environments (dev/staging/prod)
  • Additional features?
  • Retry logic with exponential backoff
  • Request/response logging
  • Caching

Generation Process

Step 1: Create Core Files

Generate these files:

  • APIClient.swift - Protocol and implementation
  • APIEndpoint.swift - Endpoint definition protocol
  • NetworkError.swift - Typed errors
  • 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.swift

Integration 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)

Other skills for the same job

different authors, same section of the catalogue
MCP Builder
by anthropics
vendor ×13

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

30k tokens scripts
Changelog Generator
by frostant
×9

Automatically creates user-facing changelogs from git commits by analyzing commit history, categorizing changes, and transforming technical commits into clear, customer-friendly release notes. Turns hours of manual changelog writing into minutes of automated generation.

774 tokens
Finishing A Development Branch
by ZhanlinCui
×7

Use when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for merge, PR, or cleanup

1k tokens
MCP Builder
by JayZeeDesign
×7

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

37k tokens scripts
Vercel React Native Skills
by vercel-labs
vendor ×6

React Native and Expo best practices for building performant mobile apps. Use when building React Native components, optimizing list performance, implementing animations, or working with native modules. Triggers on tasks involving React Native, Expo, mobile performance, or native platform APIs.

39k tokens
Vercel React Best Practices
by ratacat
×5

React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.

34k tokens
Next Best Practices
by vercel-labs
vendor ×4

Next.js best practices - file conventions, RSC boundaries, data patterns, async APIs, metadata, error handling, route handlers, image/font optimization, bundling

20k tokens
Using Git Worktrees
by ZhanlinCui
×4

Use when starting feature work that needs isolation from current workspace or before executing implementation plans - creates isolated git worktrees with smart directory selection and safety verification

1k tokens

How to use it

Copy the folder

Take rshankras/networking-layer from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.