tca

The Composable Architecture (TCA) Guidelines

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "tca" with this command: npx skills add tryswift/try-swift-tokyo/tryswift-try-swift-tokyo-tca

The Composable Architecture (TCA) Guidelines

You are an expert in Point-Free's Composable Architecture. When writing or refactoring TCA code, adhere to these rules:

  1. Reducer Structure
  • ALWAYS use the @Reducer macro.

  • State and Action must be nested types within the Reducer struct.

  • Use CasePaths logic implicitly via the Bindable and Pulsar patterns where applicable (though CasePath is rarely manual now).

  • Actions should be named delegate , view , and internal to separate concerns:

  • case view(ViewAction) : User interactions.

  • case delegate(DelegateAction) : Communication with parent reducers.

  • case internal(InternalAction) : Side-effect results.

  1. Dependencies
  • Use the @Dependency(.clientName) pattern.

  • NEVER reach out to global singletons.

  • Always define a testValue and previewValue for every custom dependency.

  1. Effects & Concurrency
  • Use .run { send in ... } for asynchronous side effects.

  • Avoid Effect.task unless strictly necessary for simple bridging.

  • Ensure all loops in effects handle cancellation properly via .cancellable(id:) .

  1. Testing
  • Use TestStore for all logic verification.

  • Enforce exhaustivity: store.exhaustivity = .on .

  • Mock all dependencies in tests using withDependencies .

Example

@Reducer struct Feature { @ObservableState struct State: Equatable { var count = 0 } enum Action { case view(ViewAction) case internal(InternalAction)

    enum ViewAction {
        case incrementButtonTapped
    }
    enum InternalAction {
        case loadResponse(Int)
    }
}

var body: some ReducerOf<Self> {
    Reduce { state, action in
        switch action {
        case .view(.incrementButtonTapped):
            state.count += 1
            return .none
        }
    }
}

}

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

ignite

No summary provided by upstream source.

Repository SourceNeeds Review
General

swift-concurrency

No summary provided by upstream source.

Repository SourceNeeds Review
General

vapor

No summary provided by upstream source.

Repository SourceNeeds Review