Prompting coding agents for iOS work: tighter briefs, smaller diffs, better results
How to use coding agents for iOS development without drowning in technical debt. Focus on contextual briefs, bite-sized tasks, and a strict review loop.
Coding agents for iOS are not magic. They are high-speed junior developers with a photographic memory and no common sense.
If you treat them like a magical “do what I mean” button, you will get exactly what you deserve: a codebase that compiles today and becomes a nightmare to maintain tomorrow.
The trick to getting high-quality Swift code out of an agent is not “better prompts” in the vague, spiritual sense. It is better engineering constraints.
You want tighter briefs, smaller diffs, and a review loop that doesn’t blink.
1. Context is the actual prompt
The most common failure in AI-assisted iOS work is the “blind request.”
Asking an agent to “Add a search bar to this view” without giving it the navigation stack, the state model, and the local design system tokens is a recipe for hallucinations. The agent will invent a search pattern that looks plausible but violates your app’s actual contracts.
Before you ask for code, establish the context:
- State Ownership: Tell the agent where the data lives (e.g., “This view is driven by an
@Observablestore”). - Design Tokens: Provide the existing UI components (e.g., “Use our
PrimaryButtonandAppColors”). - Concurrency Rules: Specify the isolation (e.g., “The persistence layer is isolated to the
DatabaseActor”). - Dependencies: List the internal libraries (e.g., “We use
Pulsefor logging andFactoryfor DI”).
An agent with the right context produces code that fits. An agent without it produces code that has to be rewritten.
2. Think in bite-sized diffs
The second mistake is asking for a whole feature at once.
Large diffs from an agent are dangerous because they are harder to review. When an agent touches twenty files, it is easy to miss a subtle ownership bug or a missing cancellation path in file fourteen.
Break the task down into stages:
- Model & Protocol: Define the data shape and the service interface.
- Implementation: Write the actual service logic and tests.
- UI Integration: Hook it up to the SwiftUI view.
- Refinement: Add logging, analytics, and error handling.
If you can’t describe the task in three bullet points, it is too big for a single agent turn. Smaller diffs mean higher quality and faster reviews.
3. The “AGENTS.md” guardrail
If you find yourself repeating the same instructions to an agent, stop.
Create an AGENTS.md file in your repository root. This is the “house rules” document for your robot coworkers. It should include:
- Naming Conventions: How you name services, view models, and tests.
- Forbidden Patterns: (e.g., “No
Task.detachedwithout a written reason”). - Architecture Preferences: (e.g., “Prefer composition over inheritance”).
- Test Standards: (e.g., “Every service needs a
Mockand a suite of unit tests”).
When you start a session with an agent, point it at this file first. It sets the bar before a single line of code is written.
4. Don’t let the agent “refactor” without permission
Agents love to tidy up.
If you ask an agent to fix a bug, it might also decide to rename three variables and reorder five functions to match what it thinks is “best practice.” This creates noise in the PR.
Be explicit: “Fix the bug in NetworkService.swift. Do not change the formatting or structure of unrelated code.”
If you actually want a refactor, make it a separate task. Mixing logic changes with “clean up” from an agent is how you lose track of what actually changed.
5. iOS is more than just Swift syntax
Models are great at Swift. They are less great at the iOS platform.
They often forget about the app lifecycle, background task limits, Keychain access groups, and entitlement requirements. When you receive code from an agent that touches a platform boundary, ask the platform questions:
- Does this handle the user denying permission?
- Does it survive the app being killed and relaunched?
- What happens if the network drops halfway through?
- Is this using a deprecated API that only exists in the model’s training data?
The agent provides the typing speed. You provide the platform expertise.
6. The Review is the only thing that matters
If you accept an agent’s code without reading every line, you have abdicated your role as an engineer.
You are not a “prompt engineer.” You are a lead engineer with a very fast, very reckless junior developer.
If the code doesn’t have tests, reject it. If it uses an unstructured Task where a structured one belongs, reject it. If the naming is “good enough” instead of “correct,” reject it.
Better results don’t come from the first prompt. They come from the third correction.
The goal isn’t to write code faster. It’s to build a better app with less friction. Tighter briefs and smaller diffs are how you get there.