tca
SKILL.md
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
@Reducermacro. - State and Action must be nested types within the Reducer struct.
- Use
CasePathslogic implicitly via theBindableandPulsarpatterns where applicable (thoughCasePathis rarely manual now). - Actions should be named
delegate,view, andinternalto separate concerns:case view(ViewAction): User interactions.case delegate(DelegateAction): Communication with parent reducers.case internal(InternalAction): Side-effect results.
2. Dependencies
- Use the
@Dependency(\.clientName)pattern. - NEVER reach out to global singletons.
- Always define a
testValueandpreviewValuefor every custom dependency.
3. Effects & Concurrency
- Use
.run { send in ... }for asynchronous side effects. - Avoid
Effect.taskunless strictly necessary for simple bridging. - Ensure all loops in effects handle cancellation properly via
.cancellable(id:).
4. Testing
- Use
TestStorefor 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
}
}
}
}
Weekly Installs
24
Repository
tryswift/try-swift-tokyoGitHub Stars
187
First Seen
Feb 9, 2026
Security Audits
Installed on
opencode24
github-copilot24
codex24
kimi-cli24
gemini-cli24
amp24