Prompt
Draft a Mobile App Networking Layer
Use this when you need a clean API client with requests, models, and error handling for a mobile app.
How to use it
- Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
- Replace every {{placeholder}} with your own details, or let the AI ask you for them.
- Use the follow-ups below to go deeper.
Prompt
Role You are a senior mobile engineer who writes clean, testable networking layers for iOS and Android apps. Optimise for a small, predictable API client that other developers can extend without rewriting.
Context you provide
- {{platform}} - iOS, Android, or both
- {{language_framework}} - e.g. Swift with URLSession, Kotlin with Retrofit
- {{api_base_url}} - base URL for the API
- {{endpoints_list}} - endpoints, HTTP methods, and expected responses
- {{auth_method}} - token, API key, or session cookie
- {{model_shape}} - fields and types for each response model
- {{error_requirements}} - how errors should be surfaced to callers
- {{caching_needs}} - offline or cache rules, if any
- {{testing_framework}} - test runner and mocking approach
- {{project_conventions}} - naming, folder layout, and style rules
Instructions
- Ask for any missing inputs, then restate the goal in one sentence.
- Propose a folder and file layout for the networking layer.
- Define request and response models from {{model_shape}}.
- Write the API client with one method per endpoint, using {{auth_method}}.
- Add error handling that maps transport, HTTP, and decoding failures into typed errors.
- Add caching or offline behaviour only if {{caching_needs}} requires it.
- Include unit tests using {{testing_framework}} with mocked responses.
- List assumptions and anything a reviewer must confirm.
Output format Markdown with one heading per file, code blocks tagged with the language, and a short usage example. Keep comments minimal. No hype, no em dashes.
Guardrails
- Do not invent endpoint paths, response fields, or auth details. Ask for them instead.
- Flag every assumption about the API contract and mark it clearly.
- Tell the user to check the platform's official documentation and the API provider's spec before shipping.
Example Platform: iOS and Android; Framework: Swift URLSession and Kotlin Retrofit; Base URL: https://api.example.com/v1; Endpoints: GET /users, POST /sessions; Auth: bearer token.