data-layer
Creates or reviews the iOS Data layer for a given domain, following the ICT architecture (Model → TargetType → RemoteDataSource → Repository). Use when adding a new API domain, reviewing existing data layer code, or generating a ViewModel.
- License 许可
- MIT
- 最近更新
- 2026-08-21
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- data-layer
- license
- MIT
- metadata
- { "author": "ICT", "version": "1.0" }
- description
- Creates or reviews the iOS Data layer for a given domain, following the ICT architecture (Model → TargetType → RemoteDataSource → Repository). Use when adding a new API domain, reviewing existing data layer code, or generating a ViewModel.
02 资源文件 8
- 参考文档.claude-plugin/plugin.json462 B
- 参考文档references/architecture.md2.0 KB
- 参考文档references/models.md1.5 KB
- 参考文档references/naming.md2.3 KB
- 参考文档references/remote.md1.7 KB
- 参考文档references/repository.md2.7 KB
- 参考文档references/target-type.md1.9 KB
- 参考文档references/viewmodel.md3.3 KB
03 SKILL.md 正文
ICT iOS Team — This skill generates and reviews Data layer code following ICT's mandatory architecture. All output must adhere exactly to the patterns defined in the references. Do not deviate.
You are a Senior iOS Engineer on the ICT team. Your job is to either create a new Data layer for a given domain, or review existing Data layer code for compliance with ICT's architecture.
Determine the mode from the user's request:
- Create mode — user wants to generate a new domain's Data layer files
- Review mode — user wants to check existing Data layer code for violations
Create Mode
When generating a new domain, follow this process:
- Read
references/architecture.mdto confirm the required file structure and responsibility separation. - Read
references/models.mdand generateData/Model/Domain/Domain.swift. - Read
references/target-type.mdand generateData/Module/Domain/Remote/TargetType/DomainTargetType.swift. - Read
references/remote.mdand generateDomainRemoteDataSource.swiftandDomainDefaultRemoteDataSource.swift. - Read
references/repository.mdand generateDomainRepository.swiftandDomainDefaultRepository.swift. - Validate naming consistency across all layers using
references/naming.md. - If the user also requests a ViewModel, read
references/viewmodel.mdand generateDomainViewModel.swift.
Output each file with its full path relative to the project root. Generate one file at a time in the order above.
Review Mode
When reviewing existing Data layer code, follow this process:
- Load
references/architecture.md— verify file structure and that no layer leaks responsibility into another. - Load
references/models.md— check namespace pattern, CodingKeys, conformances, and model naming. - Load
references/target-type.md— check case names, conformance, headers, parameters, task encoding, and sampleData. - Load
references/remote.md— confirm noRequestStatewrapping and nodo/catchin the remote layer. - Load
references/repository.md— confirmRequestStatewrapping, bothcatchblocks, and no UI logic. - Load
references/naming.md— verify cross-layer name alignment (TargetType case = Remote function = Repository function). - If a ViewModel is in scope, load
references/viewmodel.md— check@MainActor,ObservableObject, test patterns.
If doing a targeted review of a specific layer, load only the relevant reference files.
Core Instructions
- Replace
Domainwith the actual domain name (singular, PascalCase) in all generated file names, type names, and function names. - Never mix responsibilities across layers — the Remote layer must not catch errors, the Repository must not contain UI logic.
- Do not introduce third-party frameworks beyond Moya (
MoyaProvider) and Combine. - Each type belongs in its own Swift file — do not combine multiple structs, protocols, or enums in one file.
- All naming across TargetType cases, Remote functions, Repository functions, and Request models must align exactly — see
references/naming.md.
Output Format — Create Mode
Output each generated file as a Swift code block with its file path as the heading:
Data/Model/Domain/Domain.swift
// generated code
After all files, show a summary table:
| File | Status |
|---|---|
Data/Model/Domain/Domain.swift |
✅ Created |
Data/Module/Domain/DomainRepository.swift |
✅ Created |
| ... | ... |
Output Format — Review Mode
Organize findings by file. For each issue:
- State the file and relevant line(s).
- Name the rule being violated (e.g., "Repository must not contain UI logic").
- Show a brief before/after code fix.
Skip files with no issues. End with a prioritized summary of the most impactful changes to make first.
Example:
DomainDefaultRemoteDataSource.swift
Line 18: RemoteDataSource must not wrap results in RequestState — that belongs in the Repository.
// Before
return .loaded(try await provider.request(...))
// After
return try await provider.request(
.getItems(request),
model: GeneralResponse<[Domain.Response.Item]>.self
)
Summary
- Architecture (high): RemoteDataSource is wrapping results in
RequestState— move error handling to Repository. - Naming (medium): TargetType case
fetchItemsmust be renamed togetItemsto match Remote and Repository functions.
References
references/architecture.md- layered structure, required file layout, responsibility separation.references/models.md- namespace enum pattern, request/response rules, CodingKeys.references/target-type.md- enum cases, conformance, headers, parameters, task encoding, sampleData.references/remote.md- RemoteDataSource protocol and default implementation rules.references/repository.md- Repository protocol and default implementation, error mapping.references/naming.md- cross-layer naming consistency rules.references/viewmodel.md- MVVM async/await, @MainActor, unit testing pattern.
04 同仓库更多 Skills
unit-testing
Writes or reviews iOS unit tests for data layer (Repository) and ViewModel code, following ICT's XCTest + Combine testing patterns.
unit-testing
Writes or reviews iOS unit tests for data layer (Repository) and ViewModel code, supporting both XCTest and Swift Testing frameworks. Use when adding new unit tests, reviewing existing tests for compliance, or expanding test coverage for a domain.
swiftui-reviewer
Comprehensively reviews SwiftUI code for best practices on modern APIs, maintainability, and performance. Use when reading, writing, or reviewing SwiftUI projects.
swiftui-reviewer
Comprehensively reviews SwiftUI code for best practices on modern APIs, maintainability, and performance. Use when reading, writing, or reviewing SwiftUI projects.
security-review
Comprehensive iOS security assessment for the ICT iOS team. Reviews authentication, data storage, network security, secrets management, and more against OWASP MASVS and Apple security guidelines. Use when auditing or reviewing iOS app security.
security-review
Comprehensive iOS security assessment for the ICT iOS team. Reviews authentication, data storage, network security, secrets management, and more against OWASP MASVS and Apple security guidelines. Use when auditing or reviewing iOS app security.