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.
In this repository37 other files it gives its agents.
- AGENTS.mdAGENTS.md
- ios-accessibility-auditSkill
- ios-api-contract-migrationSkill
- ios-app-intents-siriSkill
- ios-bug-triageSkill
- ios-build-configurationSkill
- ios-cloudkit-syncSkill
- ios-combine-patternsSkill
- ios-commit-and-prSkill
- ios-commitSkill
- ios-concurrency-auditSkill
- ios-coreml-apple-intelligenceSkill
- ios-deep-linkingSkill
- ios-dependency-assessmentSkill
- ios-design-fixSkill
- ios-feature-moduleSkill
- ios-knowledge-baseSkill
- ios-latest-os-adoptionSkill
- ios-localizationSkill
- ios-offline-writeSkill
- ios-performance-tuningSkill
- ios-port-from-androidSkill
- ios-port-to-androidSkill
- ios-precommitSkill
- ios-privacy-complianceSkill
- ios-push-and-background-tasksSkill
- ios-refactorSkill
- ios-release-prepSkill
- ios-sdk-upgradeSkill
- ios-secure-reviewSkill
- ios-storekit-subscriptionsSkill
- ios-swift6-concurrency-migrationSkill
- ios-swiftdataSkill
- ios-swift-testing-migrationSkill
- ios-swiftui-screenSkill
- ios-unit-testsSkill
- ios-widgetkit-live-activitiesSkill
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
- Very specific: line 18
Never call client.send from a view model or a view.
- Very specific: line 55
Handle new error semantics: If the endpoint returns a status with meaning the app must act on, check APIError already distinguishes it, …
≈ “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.
Files
Add an API call
Where the pieces go
| Piece | Location |
| The call as data | Features/<X>/Data/<X>Endpoints.swift |
| Request/response models | Beside the endpoint, private if only used there |
| The method callers use | <X>Repository protocol + Live<X>Repository |
| Cache key, if cached | <X>CacheKeys |
| Tests | AppTemplateTests/Features/<X>RepositoryTests.swift |
Never call client.send from a view model or a view. The repository is the only
caller.
Steps
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: falseonly for genuinely public calls.- Body factories throw (encoding); the repository method is
throwsanyway.
- Model the response. Plain
Decodablewith camelCase properties —JSONDecoder.apiconvertssnake_casekeys automatically, soCodingKeysis usually unnecessary. Only enum raw values need to match the wire exactly.- Collections use
Page<Item>. - 204 / empty bodies use the non-generic
send(_:), orEmptyResponse. - Optional server fields are
Optionalin the model. Do not paper over a missing field with a default unless the contract says it may be absent.
- Collections use
- Add the repository method. Protocol first, then the implementation:
store to cache and invalidate the list where relevant, and catch
error.isConnectivityFailureif the operation is offline-capable. - Handle new error semantics. If the endpoint returns a status with meaning
the app must act on, check
APIErroralready distinguishes it, then make sureAppError.from(_:)phrases it for a person. Do not add error copy in a view. - Test it with
StubAPIClientkeyed"METHOD /path", or withStubHTTPSessionand a realLiveAPIClientwhen the test is about transport behaviour (status mapping, retry, refresh).
Verification
- Decoding tested against a realistic payload, including
snake_casekeys 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.logDescriptionomits them; keep it that way). - No credentials or tokens in the endpoint, headers or test fixtures.
- The call is reachable only through the repository.
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
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.

