Workflow: Create a Feature
End-to-end procedure for building a new feature with proper architecture, security, and tests.
Objective
Deliver a production-ready feature implemented in Clean Architecture + MVVM, secured, tested, and reviewed — from requirement to merge-ready PR.
Inputs
- Feature requirement / user story with acceptance criteria.
- Relevant API contract(s) or a note that they're TBD.
- Target module (or a decision to create one).
Outputs
- New/updated module with Domain, Data, Presentation layers.
- Unit tests (and UI test for critical journeys).
- Self-review against the checklists; a merge-ready change.
Step-by-Step Process
- Architect (iOS Architect) — define entities, use cases, repository protocols, module placement, and DI wiring. Produce a short architecture brief.
- Domain — implement entities + use cases (pure, framework-free) with unit tests first (TDD).
- Data (Networking/Backend Integrator) — implement DTOs, mappers, and the repository against the API contract.
- Presentation (SwiftUI Expert) — build the ViewModel (state enum) and View; handle loading/empty/error/content.
- Security (Security Expert) — review any sensitive data, tokens, or new network calls.
- Accessibility (Accessibility Expert) — labels, Dynamic Type, identifiers.
- Tests (Testing Expert) — fill coverage gaps; add a UI test if it's a critical journey.
- Review (Code Reviewer) — final gate against
checklists/code_review.md.
Validation Steps
- Project builds; all tests pass.
- Acceptance criteria demonstrably met.
- No layering violations (Domain framework-free; DTOs not leaked).
- Security and accessibility checklists pass.
Failure Scenarios
- API contract unclear/missing → stub the repository behind its protocol, mock data, flag to backend; proceed on the protocol.
- Architecture conflict → escalate to System Design Expert.
- Security finding (Critical/High) → block; remediate before continuing.
- Flaky/failing tests → run
investigate_bug.mdbefore merge.
AI Agent Instructions
- Follow the agent chain in order; emit a handoff block at each step.
- Write tests before/with implementation, not after.
- Do not skip the security and review steps even for "small" features.
- State assumptions explicitly; escalate rather than guess on ambiguity.
Acceptance Criteria
- [ ] Three layers implemented; dependency rule respected.
- [ ] Use cases + ViewModel unit-tested (success + error paths).
- [ ] Loading/empty/error/content states handled.
- [ ] Security + accessibility checklists pass.
- [ ] Code review verdict is Approve / Approve-with-nits.