Claude-swift-engineering automates planning, implementation, documentation, and testing of Swift/TCA code. Benefits Swift developers by accelerating development workflows and ensuring code quality. Integrates with Xcode and GitHub for streamlined collaboration.
git clone https://github.com/johnrogers/claude-swift-engineering.gitClaude-swift-engineering automates planning, implementation, documentation, and testing of Swift/TCA code. Benefits Swift developers by accelerating development workflows and ensuring code quality. Integrates with Xcode and GitHub for streamlined collaboration.
[{"step":"Define your feature requirements","action":"Replace [FEATURE_DESCRIPTION] in the prompt with your specific feature (e.g., 'a shopping cart with discount code application and checkout flow'). Specify any architectural guidelines like 'must use dependency injection' or 'prefer Combine over async/await'.","tip":"Be as specific as possible about the feature's behavior and edge cases to get more accurate implementations."},{"step":"Set up your environment","action":"Ensure you have Xcode 14+ and the Swift TCA library installed (via Swift Package Manager). Clone your project repository to a clean branch.","tip":"Use `swift package resolve` to ensure all dependencies are downloaded before running the generated code."},{"step":"Generate the code","action":"Paste the prompt into your AI assistant and execute it. Review the generated files (State, Actions, Reducer, View, Tests) and place them in your project's appropriate directories.","tip":"For large features, break it into smaller prompts focusing on one component at a time (e.g., first the state/actions, then the reducer, then the view)."},{"step":"Integrate with your project","action":"Update your project's `Package.swift` to include the TCA dependencies if not already present. Modify the generated environment to use your actual services (e.g., replace mock API clients with real implementations).","tip":"Use Xcode's 'Add Package Dependency' feature to easily add TCA and other dependencies from GitHub."},{"step":"Run and test","action":"Build your project in Xcode (Cmd+B). Run the generated unit tests (Cmd+U) and fix any compilation errors. Manually test the feature in the simulator or device.","tip":"Use the TCA debugger in Xcode to inspect state changes during testing. Enable 'Show Debug Prints' in TCA settings for additional logging."}]
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/johnrogers/claude-swift-engineeringCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Act as an expert Swift/TCA engineer. Plan, implement, document, and generate tests for a new feature in my SwiftUI app using the TCA (The Composable Architecture) pattern. The feature should be [FEATURE_DESCRIPTION]. Use modern Swift concurrency (async/await) and ensure the code follows best practices for [SPECIFIC_GUIDELINES, e.g., SOLID principles, MVVM separation, or performance optimizations]. Provide a complete implementation with: 1) State, Action, and Reducer definitions, 2) SwiftUI views with proper bindings, 3) Unit tests for critical logic, and 4) Documentation in Markdown format. Include a GitHub Actions workflow file to automate testing on pull requests.
### Feature Implementation: User Profile Management
**Context:** We're building a social media app where users can edit their profile. The feature includes: updating display name, bio, and avatar, with validation and persistence. The TCA implementation will handle state changes, side effects (API calls), and view interactions.
---
#### 1. State Definition
```swift
struct ProfileState: Equatable {
var displayName: String = ""
var bio: String = ""
var avatarData: Data? = nil
var isLoading = false
var saveError: String? = nil
var validationError: String? = nil
}
```
#### 2. Actions
```swift
enum ProfileAction: Equatable {
case displayNameChanged(String)
case bioChanged(String)
case avatarSelected(Data)
case saveButtonTapped
case saveResponse(Result<Profile, Error>)
case cancelButtonTapped
}
```
#### 3. Reducer
```swift
let profileReducer = Reducer<ProfileState, ProfileAction, ProfileEnvironment> { state, action, environment in
switch action {
case let .displayNameChanged(newName):
state.displayName = newName
state.validationError = nil
return .none
case let .bioChanged(newBio):
state.bio = newBio
return .none
case let .avatarSelected(data):
state.avatarData = data
return .none
case .saveButtonTapped:
state.isLoading = true
state.saveError = nil
guard !state.displayName.isEmpty else {
state.validationError = "Display name cannot be empty"
state.isLoading = false
return .none
}
let profile = Profile(
displayName: state.displayName,
bio: state.bio,
avatarData: state.avatarData
)
return environment.profileService
.saveProfile(profile)
.receive(on: environment.mainQueue)
.catchToEffect(ProfileAction.saveResponse)
case let .saveResponse(.success(profile)):
state.isLoading = false
state.displayName = profile.displayName
state.bio = profile.bio
state.avatarData = profile.avatarData
return .none
case let .saveResponse(.failure(error)):
state.isLoading = false
state.saveError = error.localizedDescription
return .none
case .cancelButtonTapped:
state.validationError = nil
return .none
}
}
```
#### 4. Environment
```swift
struct ProfileEnvironment {
var profileService: ProfileService
var mainQueue: AnySchedulerOf<DispatchQueue>
}
```
#### 5. SwiftUI View
```swift
struct ProfileView: View {
let store: Store<ProfileState, ProfileAction>
var body: some View {
WithViewStore(store) { viewStore in
Form {
Section(header: Text("Profile Information")) {
TextField("Display Name", text: viewStore.binding(
get: \.displayName,
send: ProfileAction.displayNameChanged
))
TextEditor(text: viewStore.binding(
get: \.bio,
send: ProfileAction.bioChanged
))
.frame(height: 100)
if let error = viewStore.validationError {
Text(error)
.foregroundColor(.red)
}
}
Section {
Button("Save Profile") {
viewStore.send(.saveButtonTapped)
}
.disabled(viewStore.isLoading)
if viewStore.isLoading {
ProgressView()
}
}
}
.navigationTitle("Edit Profile")
.onAppear { viewStore.send(.onAppear) }
}
}
}
```
#### 6. Unit Tests
```swift
func testProfileReducer_SaveSuccess() {
let scheduler = DispatchQueue.test
let environment = ProfileEnvironment(
profileService: .mock(saveResult: .success(.mock)),
mainQueue: scheduler.eraseToAnyScheduler()
)
let store = TestStore(
initialState: ProfileState(displayName: "Test User"),
reducer: profileReducer,
environment: environment
)
store.send(.saveButtonTapped) {
$0.isLoading = true
}
scheduler.advance()
store.receive(.saveResponse(.success(.mock))) {
$0.isLoading = false
$0.displayName = "Test User"
}
}
```
#### 7. Documentation
```markdown
## Profile Feature
### Overview
Manages user profile updates with validation and persistence.
### State
- `displayName`: Current display name
- `bio`: User biography
- `avatarData`: Selected avatar image data
- `isLoading`: Loading state for API calls
- `saveError`: Error message if save fails
- `validationError`: Validation errors for form fields
### Actions
- `displayNameChanged`: Updates display name
- `bioChanged`: Updates biography
- `avatarSelected`: Handles avatar image selection
- `saveButtonTapped`: Initiates save operation
- `saveResponse`: Handles API response
- `cancelButtonTapped`: Resets form state
### Environment
- `profileService`: Handles API calls
- `mainQueue`: Scheduler for UI updates
```
#### 8. GitHub Actions Workflow
```yaml
name: Profile Tests
on: [push, pull_request]
jobs:
test:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Run tests
run: swift test --filter ProfileFeatureTests
```AI assistant built for thoughtful, nuanced conversation
Cloud ETL platform for non-technical data integration
Enterprise workflow automation and service management platform
Get more done every day with Microsoft Teams – powered by AI
Customer feedback management made simple
Design, document, and generate code for APIs with interactive tools for developers.
Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan