ワンクリックで
ballog-entity-template
Ballog entity 슬라이스 생성 템플릿. ky API 그룹, query-key-factory 등록, query/mutation 훅 네이밍과 invalidation 규칙. /feat-new 가 참조.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Ballog entity 슬라이스 생성 템플릿. ky API 그룹, query-key-factory 등록, query/mutation 훅 네이밍과 invalidation 규칙. /feat-new 가 참조.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Ballog(apps/web) FSD 레이어 규칙. 의존 방향, public API, import 순서, 네이밍. 파일 생성/리뷰 시 경계 위반 검증에 사용.
Ballog MSW handler/data 생성 템플릿과 handlers.ts 레지스트리 삽입 규칙. /feat-new 가 참조.
Ballog 커밋 및 PR 메시지 컨벤션. 이모지 prefix(✨Feat/💄Style/✏️Fix)와 fix:/feat: 간결 스타일 혼용 규칙, 한국어 PR 본문 작성 틀. /review-pr 이 참조.
/feat-new 가 읽는 Ballog API 명세 MD의 YAML 스키마 정의. endpoints/types/msw/figma 필드와 작성 규칙. spec 파일 작성이나 파싱할 때 참조.
Ballog 프로젝트의 Tailwind + cn() 사용 규칙. 조건부 클래스 가독성, twMerge 충돌 회피, 반복 유틸 추출 기준. className을 작성하거나 리뷰할 때 참조.
| name | ballog-entity-template |
| description | Ballog entity 슬라이스 생성 템플릿. ky API 그룹, query-key-factory 등록, query/mutation 훅 네이밍과 invalidation 규칙. /feat-new 가 참조. |
기준 파일: apps/web/src/entities/auth/*
apps/web/src/entities/<kebab>/
├── api/
│ ├── <camel>.api.ts
│ ├── <camel>.queries.ts
│ └── index.ts ← 서브 barrel
├── model/
│ ├── <camel>.type.ts
│ └── index.ts ← 서브 barrel
├── hooks/
│ ├── use<Pascal><Endpoint>Query.ts
│ ├── use<Pascal><Endpoint>Mutation.ts
│ └── index.ts ← 서브 barrel
├── ui/ (UI 있을 때만)
│ └── index.ts ← 서브 barrel
└── index.ts ← 루트 barrel
barrel 규칙 (프로젝트 관례):
index.ts 로 내부 파일을 export * 로 공개index.ts 는 서브디렉토리 barrel만 export (개별 파일 참조 X)entities/auth/index.ts 는 ./ui, ./api 만 export. 외부에서 model/ 타입을 직접 쓰려면 deep path 사용 (예: @/entities/auth/model/auth.type)model/<camel>.type.tsimport type {
ApiResponse,
ApiResponseWithNoSuccess,
} from '@/types/api/common'
export interface Emotion {
id: number
type: 'HAPPY' | 'SAD'
createdAt: string
}
export type EmotionResponseDTO = ApiResponseWithNoSuccess<Emotion[]>
export interface CreateEmotionRequestDTO {
type: Emotion['type']
matchRecordId: number
}
api/<camel>.api.ts — ky 기반 method 그룹import { api } from '@/shared/lib/ky'
import type {
CreateEmotionRequestDTO,
EmotionResponseDTO,
} from '../model/emotion.type'
export const emotionGet = {
getEmotionRecord: async (
matchRecordId: number,
): Promise<EmotionResponseDTO> => {
return api.get(`emotion/${matchRecordId}`).json<EmotionResponseDTO>()
},
}
export const emotionPost = {
createEmotion: async (
data: CreateEmotionRequestDTO,
): Promise<EmotionResponseDTO> => {
return api.post('emotion', { json: data }).json<EmotionResponseDTO>()
},
}
핵심:
api (ky instance)는 prefix에 /api/v1 포함 → path 선행 슬래시 제거<camel>Get / <camel>Post / <camel>Patch / <camel>Deleteapi/<camel>.queries.tsimport { createQueryKeys } from '@lukemorales/query-key-factory'
import { emotionGet } from './emotion.api'
export const emotionQueries = createQueryKeys('emotion', {
getEmotionRecord: (matchRecordId: number) => ({
queryKey: [matchRecordId],
queryFn: () => emotionGet.getEmotionRecord(matchRecordId),
}),
})
<camel>Queries'<camel>' (문자열 리터럴)hooks/use<Pascal><Endpoint>Query.tsimport { useQuery } from '@tanstack/react-query'
import { emotionQueries } from '../api/emotion.queries'
export const useGetEmotionRecordQuery = (matchRecordId: number) => {
return useQuery({
...emotionQueries.getEmotionRecord(matchRecordId),
enabled: matchRecordId > 0,
})
}
enabled 기본 규칙: path param이 falsy면 비활성화hooks/use<Pascal><Endpoint>Mutation.tsimport { useMutation, useQueryClient } from '@tanstack/react-query'
import { emotionPost } from '../api/emotion.api'
import { emotionQueries } from '../api/emotion.queries'
export const useCreateEmotionMutation = () => {
const queryClient = useQueryClient()
return useMutation({
mutationFn: emotionPost.createEmotion,
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: emotionQueries.getEmotionRecord._def,
})
},
})
}
invalidates: [a, b] → invalidateQueries 두 번 또는 _def 배열 loopapi/index.tsexport * from './emotion.api'
export * from './emotion.queries'
model/index.tsexport * from './emotion.type'
hooks/index.tsexport * from './useGetEmotionRecordQuery'
export * from './useCreateEmotionMutation'
ui/index.ts (UI 생성 시)export * from './EmotionCard'
// ...각 컴포넌트
index.tsexport * from './api'
export * from './hooks'
// ui 있으면 추가:
// export * from './ui'
규칙:
model 은 관례상 루트 barrel에 넣지 않음 (실제 auth/index.ts 패턴). 타입이 필요한 외부 코드는 @/entities/<kebab>/model/<camel>.type 로 deep importmocks/는 인프라 레이어라 model deep import 허용 (ballog-fsd-conventions 의 예외 조항)react, @tanstack/react-query, ...)@/shared/..., @/types/...)./, ../)각 블록 사이 빈 줄 1칸.
api/index.ts, hooks/index.ts 등) → 참조 깨짐invalidateQueries 없음 → spec invalidates 확인