Give your simulator superpowers

RocketSim: An Essential Developer Tool
as recommended by Apple

Subscribe to my YouTube Channel

SwiftUI Agent Skill: Build better views with AI

A SwiftUI Agent Skill that helps you build better views or refactor existing ones. It’s the reality we’re in today, and I honestly can’t live without it anymore myself. Several skills helped me improve the code quality produced by agents, and I’m happy to introduce you to a new open-source skill for SwiftUI.

Before reading this article, I highly recommend reading Agent Skills explained: Replacing AGENTS.md with reusable AI knowledge. It’s the foundation of what you need to know about this feature. Additionally, you can read a brief background on this new skill in How I Stopped Resisting AI and Started Teaching It, written by Omar Elsayed, with whom I built this skill.

Adding SwiftUI Expertise to your Agents

If you’ve been building with agents, I’m sure you’ve been updating your AGENTS.md file with all kinds of fixes for SwiftUI. One of the most common additions I’ve seen is this one:

Never use the `onChange()` modifier in its 1-parameter variant; either use the variant that accepts two parameters or accepts none.

If you know, you know, but it’s annoying when agents make the same mistake over and over again. I’ve been updating my agents file too, but I’m now prompting this instead:

A SwiftUI Agent Skill that helps building better views using AI.
A SwiftUI Agent Skill that helps building better views using AI.

The SwiftUI Agent skill is available on GitHub at AvdLee/SwiftUI-Agent-Skill. It contains a detailed SKILL.md file and several specific references:

swiftui-expert-skill/
  SKILL.md
  references/
    image-optimization.md - AsyncImage usage, downsampling, caching
    layout-best-practices.md - Layout patterns and GeometryReader alternatives
    liquid-glass.md - iOS 26+ glass effects and fallback patterns
    list-patterns.md - ForEach identity and list performance
    modern-apis.md - Deprecated API replacements
    performance-patterns.md - Hot-path optimizations and update control
    scroll-patterns.md - ScrollViewReader and programmatic scrolling
    sheet-navigation-patterns.md - Sheets and type-safe navigation
    state-management.md - Property wrapper selection and data flow
    text-formatting.md - Modern Text formatting and string utilities
    view-structure.md - View extraction and composition patterns

(I recommend checking the repo for an up to date overview)

What’s interesting is that this leads to a detailed response while planning together with this skill. For the above prompt, the results showed various improvements. Here’s an example of view structure that could be improved:

  • Nested scrollingBuildInsightsPageView wraps BuildInsightsView in a ScrollView, but BuildInsightsView already contains its own ScrollView, which can cause awkward scrolling/gesture behavior and layout work.

But it’s also great at analyzing performance patterns:

  • Selection/view-model synchronization is duplicated and easy to get into redundant updates: there are multiple onAppear/onChange handlers that all set currentSelectedApp and/or viewModel.

It totally depends on what you are building and how good your views already are. However, if you’ve been developing with agents for a while now, you’ve probably created views that can be improved already.

FREE 5-day email course: The Swift Concurrency Playbook by Antoine van der Lee

FREE 5-Day Email Course: The Swift Concurrency Playbook

A FREE 5-day email course revealing the 5 biggest mistakes iOS developers make with with async/await that lead to App Store rejections And migration projects taking months instead of days (even if you've been writing Swift for years)

Reducing tech debt using the SwiftUI Agent Skill

At the same time, your future views built with agents can be better from the start. Agents are smart enough to reference the skill when needed, so chances are high that your initial versions of SwiftUI Views will already be improved using this Agent Skill. It’s important to note that agents aren’t always able to find skills yet, but it’s only a matter of time before they do.

We’re open to contributions!

If you have been developing intensively with agents already, you might have created your own set of agent instructions. We’ve already merged several pull requests from developers like yourself, and we would love to receive more. Feel free to open a PR, and make sure to read our detailed contribution guidelines. Not because we’re strict, but because it will teach you how to built and test agent skills along the way!

Conclusion

The SwiftUI Agent Skill already impacts the code I create with agents and I’m sure it will make your code better as well. The skill is in active development, continously evolving, but I can’t imagine writing code without it anymore. Even views I’ve written completely myself get improved, which is just a golden path to reducing tech debt.

If you want to improve your AI development knowledge, even more, check out the AI Development Category page. Feel free to contact me or tweet me on Twitter if you have any additional tips or feedback.

Thanks!

 
Antoine van der Lee

Written by

Antoine van der Lee

iOS Developer since 2010, former Staff iOS Engineer at WeTransfer and currently full-time Indie Developer & Founder at SwiftLee. Writing a new blog post every week related to Swift, iOS and Xcode. Regular speaker and workshop host.

Are you ready to

Turn your side projects into independence?

Learn my proven steps to transform your passion into profit.