agentleFS
SajidisrarSajidisrar/ios-claude-skills/skills/ios-api-endpoint/SKILL.md

ios-api-endpoint

Skill1 starsChanged 14 days agoMITView on GitHub

Add or change an API call in this iOS codebase — an Endpoint, its wire models, the repository method that calls it, and the tests. Use when asked to wire up a new backend call, integrate an API endpoint, change a request or response shape, add a query parameter or filter, handle a new error response, or when the backend contract has changed and the app must follow.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Never call client.send from a view model or a view.

    line 18
  2. Very specific:

    Handle new error semantics: If the endpoint returns a status with meaning the app must act on, check APIError already distinguishes it, …

    line 55

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Add an API call

Where the pieces go

PieceLocation
The call as dataFeatures/<X>/Data/<X>Endpoints.swift
Request/response modelsBeside the endpoint, private if only used there
The method callers use<X>Repository protocol + Live<X>Repository
Cache key, if cached<X>CacheKeys
TestsAppTemplateTests/Features/<X>RepositoryTests.swift

Never call client.send from a view model or a view. The repository is the only caller.

Steps

  1. Write the endpoint.

    static func list(page: PageRequest = .first, search: String? = nil) -> Endpoint {
        var query = page.queryItems
        if let search, search.trimmingCharacters(in: .whitespaces).isEmpty == false {
            query.append(URLQueryItem(name: "q", value: search))
        }
        return .get("widgets", query: query)
    }
    
    static func create(_ draft: WidgetDraft) throws -> Endpoint {
        try .post("widgets", body: draft)
    }
    • Path is relative with no leading slash.
    • requiresAuthentication: false only for genuinely public calls.
    • Body factories throw (encoding); the repository method is throws anyway.
  2. Model the response. Plain Decodable with camelCase properties — JSONDecoder.api converts snake_case keys automatically, so CodingKeys is usually unnecessary. Only enum raw values need to match the wire exactly.
    • Collections use Page<Item>.
    • 204 / empty bodies use the non-generic send(_:), or EmptyResponse.
    • Optional server fields are Optional in the model. Do not paper over a missing field with a default unless the contract says it may be absent.
  3. Add the repository method. Protocol first, then the implementation: store to cache and invalidate the list where relevant, and catch error.isConnectivityFailure if the operation is offline-capable.
  4. Handle new error semantics. If the endpoint returns a status with meaning the app must act on, check APIError already distinguishes it, then make sure AppError.from(_:) phrases it for a person. Do not add error copy in a view.
  5. Test it with StubAPIClient keyed "METHOD /path", or with StubHTTPSession and a real LiveAPIClient when the test is about transport behaviour (status mapping, retry, refresh).

Verification

  • Decoding tested against a realistic payload, including snake_case keys and an ISO 8601 date.
  • Failure path tested — at least the one status this endpoint can realistically return (404, 409, 422).
  • Query values are not logged (Endpoint.logDescription omits them; keep it that way).
  • No credentials or tokens in the endpoint, headers or test fixtures.
  • The call is reachable only through the repository.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.