| ํญ๋ชฉ | ๋ด์ฉ |
|---|---|
| Invoke | /feature:data |
| Aliases | /data:create, /layer:data |
| Tools | Read, Edit, Write, Glob, Grep |
| Model | sonnet |
| Skills | feature |
/feature:data โ ์ฑ์ "๋ฐ์ดํฐ ์ฐฝ๊ณ " ๋ด๋น ์ผ๊พผ#
ํ๋ง๋๋ก#
์ฑ์ด ํ๋ฉด์ ๋ณด์ฌ์ค ์ ๋ณด๋ฅผ ์๋ฒ์์ ๊ฐ์ ธ์ค๊ณ , ์ ๊น ๋ณด๊ด(์บ์)ํ๊ณ , ๊ธฐ๊ธฐ ์์ ์ ์ฅํ๋ "๋ฐ์ดํฐ ์ฐฝ๊ณ ๋ด๋น์"๋ฅผ ์๋์ผ๋ก ๋ง๋ค์ด ์ฃผ๋ ๋๊ตฌ์ ๋๋ค. ๋ง์น ๋งค์ฅ ๋คํธ์ ์ฐฝ๊ณ ์ง์์ฒ๋ผ โ ๋ณธ์ฌ(์๋ฒ)์์ ๋ฌผ๊ฑด์ ๋ฐ์์ค๊ณ , ์์ฃผ ์ฐ๋ ๊ฑด ๊ฐ๊น์ด ์์๋๊ณ (์บ์), ํ์ํ๋ฉด ๋งค์ฅ ๋ด ๋ณด๊ดํจ(๋ก์ปฌ DB)์ ๋ฃ์ด ๋ก๋๋ค.
๋๊ฐยท์ธ์ ์ฐ๋์#
- Flutter ์ฑ์ ์ ๊ธฐ๋ฅ์ ๋ง๋๋ ๊ฐ๋ฐ์๊ฐ, ๊ทธ ๊ธฐ๋ฅ์ "๋ฐ์ดํฐ ์ฒ๋ฆฌ ๋ถ๋ถ"์ ๋ง๋ค ๋ ์ฌ์ฉํฉ๋๋ค.
-
/feature:data๋ช ๋ น์ ์ง์ ์คํํ๊ฑฐ๋, ์ ์ฒด ๊ธฐ๋ฅ์ ํ ๋ฒ์ ๋ง๋๋/feature:create์์ ์ 4๋ฒ์งธ ๋จ๊ณ์์ ์๋์ผ๋ก ํธ์ถ๋ฉ๋๋ค.
๋ฌด์์ ํด์ฃผ๋์#
๋ฐ์ดํฐ๋ฅผ ๋ค๋ฃจ๋ ๋ฐ ํ์ํ ํ์ผ๋ค์ ์ ํด์ง ๊ตฌ์กฐ๋ก ํ๊บผ๋ฒ์ ๋ง๋ค์ด ์ค๋๋ค. ๋ง๋ค์ด์ง๋ ๊ฒ๋ค:
- Repository (
{feature}_repository.dart) โ ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์ค๊ณ ์ ์ฅํ๋ ํต์ฌ ์ฐฝ๊ตฌ - API Mixin (
{feature}_api_mixin.dart) โ ์๋ฒ์ ํต์ ํ๋ ๋ถ๋ถ - Cache (
{entity}_cache_repository.dart) โ ์์ฃผ ์ฐ๋ ๋ฐ์ดํฐ๋ฅผ ์ ๊น ๋ณด๊ดํ๋ ๊ณณ -
Local DB (
{entity}_table.dart,{entity}_dao.dart,{feature}_database.dart) โ ๊ธฐ๊ธฐ ์์ ๋ฐ์ดํฐ๋ฅผ ์ ์ฅํ๋ ๋ถ๋ถ
์บ์ ๋ฐฉ์์ ๋ ๊ฐ์ง ์ค์์ ๊ณ ๋ฆ ๋๋ค: SWR(์์ฃผ ๋ฐ๋๊ฑฐ๋ ์ค์๊ฐ ๋ฐ์ดํฐ์ ์ ํฉ) ๋๋ Cache-First(๊ฑฐ์ ์ ๋ฐ๋๋ ๋ฐ์ดํฐ์ ์ ํฉ).
์ด๋ป๊ฒ ์ฐ๋์#
# ๊ธฐ๋ณธ ์ฌ์ฉ โ ๊ธฐ๋ฅ ์ด๋ฆ๊ณผ ํต์ฌ ๋ฐ์ดํฐ(์ํฐํฐ) ์ด๋ฆ์ ์ง์
/feature:data feature_name=post entity_name=Post
feature_name(ํ์) โ ๊ธฐ๋ฅ ๋ชจ๋ ์ด๋ฆ (snake_case, ์:post)entity_name(ํ์) โ ํต์ฌ ๋ฐ์ดํฐ ์ด๋ฆ (PascalCase, ์:Post)-
location(์ ํ) โ ์ด๋์ ๋ง๋ค์ง:application(๊ธฐ๋ณธ),common,console caching(์ ํ) โ ์บ์ ๋ฐฉ์:swr(๊ธฐ๋ณธ),cache-first,none
์์์ ๋ฌด์จ ์ผ์ด ๋ฒ์ด์ง๋์#
- ์๋ฒ์์ ๋ฐ์ดํฐ๋ฅผ ๋ฐ์์ค๋ ์ฐฝ๊ตฌ(Repository)์ ํต์ ๋ถ๋ถ(API Mixin)์ ๋ง๋ญ๋๋ค.
- ์๋ฒ ๋ฐ์ดํฐ์ ์ฑ ๋ด๋ถ ๋ฐ์ดํฐ ํ์์ ์๋ก ๋ณํํ๋ ์ฐ๊ฒฐ ์์ ์ ๋ฃ์ต๋๋ค.
- ์ ํํ ์บ์ ๋ฐฉ์(SWR / Cache-First)์ ๋ง๊ฒ ๋ฐ์ดํฐ๋ฅผ ์ ๊น ๋ณด๊ดํ๋ ๋ถ๋ถ์ ๊ตฌ์ฑํฉ๋๋ค.
- ๊ธฐ๊ธฐ ์์ ๋ฐ์ดํฐ๋ฅผ ์ ์ฅํ๋ ํ(Table)์ ์ ์ฅ ๋ด๋น(DAO)์ ๋ง๋ญ๋๋ค.
- ๋ง์ง๋ง์ผ๋ก, ๊ฒฐ๊ณผ๊ฐ ํญ์ ์ผ์ ํ ํ์์ผ๋ก ๋์ค๋์ง ๋ฑ ์ฒดํฌ๋ฆฌ์คํธ๋ฅผ ์ ๊ฒํฉ๋๋ค.
โ๏ธ ์์ธ ์ต์ ยท์คํ ๋ช ์ธ (๊ฐ๋ฐ์ / AI ์์ด์ ํธ์ฉ)
Role#
Consistently generates Repository implementation, API Mixin (namespace import), Cache strategy, and Local DB.
Activation Conditions#
/feature:dataActivated when command is invoked- Invoked from
/feature:createorchestration Step 4
Parameters#
| Parameter | Required | Description |
|---|---|---|
feature_name | โ | Feature module name (snake_case) |
entity_name | โ | Entity name (PascalCase) |
location | โ | application, common, console (default: application) |
caching | โ | swr, cache-first, none (default: swr) |
Generated Files#
feature/{location}/{feature_name}/lib/src/data/
โโโ repository/
โ โโโ {feature}_repository.dart
โ โโโ mixins/
โ โ โโโ {feature}_api_mixin.dart
โ โโโ repository.dart
โโโ cache/
โ โโโ {entity}_cache_repository.dart
โโโ local/
โโโ tables/
โ โโโ {entity}_table.dart
โโโ dao/
โ โโโ {entity}_dao.dart
โโโ {feature}_database.dartCore Patterns Summary#
Repository Implementation#
๐ Details: Repository Pattern
@LazySingleton(as: IFeatureRepository)Annotation- Mixin separation pattern recommended (network logic reuse)
API Mixin (Namespace required!)#
import 'package:serverpod_service/serverpod_service.dart' as serverpod;
mixin FeatureApiMixin implements IFeatureRepository {
serverpod.ServerpodClient get client; // โ
๋ค์์คํ์ด์ค๋ก ์ถฉ๋ ๋ฐฉ์ง
}
Caching Strategy Selection#
๐ Details: Caching Pattern
| Pattern | Selection Criteria |
|---|---|
| SWR | Frequent updates, Real-time |
| Cache-First | Minimize network, Static data |
Critical Import Pattern#
// Repository: dependencies๋ง ์ฌ์ฉ
import 'package:dependencies/dependencies.dart';
// Mixin: ๋ค์์คํ์ด์ค ํ์!
import 'package:serverpod_service/serverpod_service.dart' as serverpod;
// Domain Entity (๋ค์์คํ์ด์ค ์์)
PostCategory category = PostCategory.qna;
// API DTO (๋ค์์คํ์ด์ค๋ก ์ถฉ๋ ๋ฐฉ์ง)
serverpod.PostCategory apiCategory = serverpod.PostCategory.qna;
Checklist#
- Repository:
@LazySingleton(as: Interface)Annotation - API Mixin:
as serverpodNamespace import - ์๋ฐฉํฅ DTO ๋ณํ:
_mapFromDto,_categoryToDto - Caching strategy: SWR or Cache-First
- Drift: Table + DAO Generation
- Return Type:
Either<Failure, T>consistency