Purpose
Add a complete feature module to an existing iOS project with View, ViewModel, and tests.
Arguments
- •
feature-name— Feature name in PascalCase (e.g.,Settings,UserProfile) - •
--with-detail— Include detail view for drill-down - •
--with-form— Include form/edit view - •
--no-tests— Skip test file generation
What gets created
Default
code
Features/<Feature>/ ├── <Feature>View.swift # Main view ├── <Feature>ViewModel.swift # ViewModel with state + intents └── <Feature>Row.swift # List row component (if list-based) Tests/UnitTests/ └── <Feature>ViewModelTests.swift # ViewModel tests
With --with-detail
code
Features/<Feature>/ ├── <Feature>View.swift ├── <Feature>ViewModel.swift ├── <Feature>DetailView.swift # Detail view └── <Feature>DetailViewModel.swift
With --with-form
code
Features/<Feature>/ ├── <Feature>View.swift ├── <Feature>ViewModel.swift ├── <Feature>FormView.swift # Create/edit form └── <Feature>FormViewModel.swift
Conventions
File naming
- •Views:
<Feature>View.swift - •ViewModels:
<Feature>ViewModel.swift - •Rows/cells:
<Feature>Row.swift - •Tests:
<Feature>ViewModelTests.swift
ViewModel pattern
- •
@MainActor final class - •
@Published private(set)for state - •Public methods for intents
- •Dependencies injected via init
- •Uses
PersistenceStoreprotocol (not SwiftData directly)
View pattern
- •
@StateObjectfor owned ViewModel - •
@EnvironmentObjectfor shared services - •No business logic in views
- •Accessibility labels on controls
Test pattern (Swift Testing)
- •
struct(notXCTestCaseclass) - •
init()for setup (notsetUp()) - •
@Test func methodName()(notest_prefix) - •
#expect(condition)for assertions - •
@Test(arguments:)for parameterized tests
Workflow
- •Create feature folder under
Features/ - •Create View with basic layout
- •Create ViewModel with state and intents
- •Wire up to DependencyContainer
- •Create tests for ViewModel
- •Run
./scripts/lint.shand tests to verify
Output
Summarize: files created, how to access the feature, test coverage.
Reference
For templates and patterns, see reference/ios-add-feature-reference.md