AGENT SKILL

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

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:

  1. Read references/architecture.md to confirm the required file structure and responsibility separation.
  2. Read references/models.md and generate Data/Model/Domain/Domain.swift.
  3. Read references/target-type.md and generate Data/Module/Domain/Remote/TargetType/DomainTargetType.swift.
  4. Read references/remote.md and generate DomainRemoteDataSource.swift and DomainDefaultRemoteDataSource.swift.
  5. Read references/repository.md and generate DomainRepository.swift and DomainDefaultRepository.swift.
  6. Validate naming consistency across all layers using references/naming.md.
  7. If the user also requests a ViewModel, read references/viewmodel.md and generate DomainViewModel.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:

  1. Load references/architecture.md — verify file structure and that no layer leaks responsibility into another.
  2. Load references/models.md — check namespace pattern, CodingKeys, conformances, and model naming.
  3. Load references/target-type.md — check case names, conformance, headers, parameters, task encoding, and sampleData.
  4. Load references/remote.md — confirm no RequestState wrapping and no do/catch in the remote layer.
  5. Load references/repository.md — confirm RequestState wrapping, both catch blocks, and no UI logic.
  6. Load references/naming.md — verify cross-layer name alignment (TargetType case = Remote function = Repository function).
  7. 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 Domain with 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:

  1. State the file and relevant line(s).
  2. Name the rule being violated (e.g., "Repository must not contain UI logic").
  3. 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

  1. Architecture (high): RemoteDataSource is wrapping results in RequestState — move error handling to Repository.
  2. Naming (medium): TargetType case fetchItems must be renamed to getItems to 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

ictech-projects
ictech-projects/ios-claude-skills

unit-testing

Writes or reviews iOS unit tests for data layer (Repository) and ViewModel code, following ICT's XCTest + Combine testing patterns.

★ 0
ictech-projects
ictech-projects/ios-claude-skills

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.

★ 0
ictech-projects
ictech-projects/ios-claude-skills

swiftui-reviewer

Comprehensively reviews SwiftUI code for best practices on modern APIs, maintainability, and performance. Use when reading, writing, or reviewing SwiftUI projects.

★ 0
ictech-projects
ictech-projects/ios-claude-skills

swiftui-reviewer

Comprehensively reviews SwiftUI code for best practices on modern APIs, maintainability, and performance. Use when reading, writing, or reviewing SwiftUI projects.

★ 0
ictech-projects
ictech-projects/ios-claude-skills

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.

★ 0
ictech-projects
ictech-projects/ios-claude-skills

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.

★ 0