@kood/claude-code 0.2.4 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/dist/index.js +13 -8
  2. package/package.json +1 -1
  3. package/templates/.claude/agents/code-reviewer.md +371 -19
  4. package/templates/.claude/agents/dependency-manager.md +197 -0
  5. package/templates/.claude/agents/deployment-validator.md +136 -0
  6. package/templates/.claude/agents/git-operator.md +147 -0
  7. package/templates/.claude/agents/implementation-executor.md +202 -0
  8. package/templates/.claude/agents/lint-fixer.md +155 -0
  9. package/templates/.claude/agents/refactor-advisor.md +339 -29
  10. package/templates/.claude/commands/agent-creator.md +355 -0
  11. package/templates/.claude/commands/docs-creator.md +404 -163
  12. package/templates/.claude/commands/docs-refactor.md +400 -113
  13. package/templates/.claude/commands/execute.md +357 -185
  14. package/templates/.claude/commands/git-all.md +16 -70
  15. package/templates/.claude/commands/git-session.md +36 -68
  16. package/templates/.claude/commands/git.md +20 -69
  17. package/templates/.claude/commands/lint-fix.md +164 -107
  18. package/templates/.claude/commands/lint-init.md +142 -168
  19. package/templates/.claude/commands/plan.md +300 -84
  20. package/templates/.claude/commands/prd.md +613 -0
  21. package/templates/.claude/commands/pre-deploy.md +242 -0
  22. package/templates/.claude/commands/subagent-creator.md +118 -0
  23. package/templates/.claude/commands/version-update.md +45 -57
  24. package/templates/hono/CLAUDE.md +99 -54
  25. package/templates/hono/docs/guides/conventions.md +352 -0
  26. package/templates/hono/docs/guides/env-setup.md +347 -0
  27. package/templates/hono/docs/guides/getting-started.md +239 -0
  28. package/templates/hono/docs/library/hono/error-handling.md +20 -29
  29. package/templates/hono/docs/library/hono/index.md +25 -52
  30. package/templates/hono/docs/library/hono/middleware.md +16 -75
  31. package/templates/hono/docs/library/hono/rpc.md +7 -35
  32. package/templates/hono/docs/library/hono/validation.md +25 -45
  33. package/templates/hono/docs/library/t3-env/index.md +374 -0
  34. package/templates/npx/CLAUDE.md +165 -65
  35. package/templates/npx/docs/library/commander/index.md +10 -73
  36. package/templates/npx/docs/library/fs-extra/index.md +21 -113
  37. package/templates/npx/docs/library/prompts/index.md +30 -176
  38. package/templates/npx/docs/references/patterns.md +75 -48
  39. package/templates/tanstack-start/CLAUDE.md +101 -77
  40. package/templates/tanstack-start/docs/architecture.md +427 -0
  41. package/templates/tanstack-start/docs/design.md +558 -0
  42. package/templates/tanstack-start/docs/guides/conventions.md +132 -32
  43. package/templates/tanstack-start/docs/guides/env-setup.md +127 -62
  44. package/templates/tanstack-start/docs/guides/getting-started.md +81 -20
  45. package/templates/tanstack-start/docs/guides/hooks.md +241 -36
  46. package/templates/tanstack-start/docs/guides/routes.md +213 -61
  47. package/templates/tanstack-start/docs/guides/services.md +260 -24
  48. package/templates/tanstack-start/docs/library/better-auth/index.md +469 -16
  49. package/templates/tanstack-start/docs/library/t3-env/index.md +307 -0
  50. package/templates/tanstack-start/docs/library/tanstack-query/index.md +12 -21
  51. package/templates/tanstack-start/docs/library/tanstack-query/invalidation.md +22 -35
  52. package/templates/tanstack-start/docs/library/tanstack-query/optimistic-updates.md +7 -24
  53. package/templates/tanstack-start/docs/library/tanstack-query/use-mutation.md +26 -39
  54. package/templates/tanstack-start/docs/library/tanstack-query/use-query.md +23 -26
  55. package/templates/tanstack-start/docs/library/tanstack-router/error-handling.md +32 -147
  56. package/templates/tanstack-start/docs/library/tanstack-router/hooks.md +25 -167
  57. package/templates/tanstack-start/docs/library/tanstack-router/index.md +39 -74
  58. package/templates/tanstack-start/docs/library/tanstack-router/navigation.md +46 -116
  59. package/templates/tanstack-start/docs/library/tanstack-router/route-context.md +35 -154
  60. package/templates/tanstack-start/docs/library/tanstack-router/search-params.md +32 -171
  61. package/templates/tanstack-start/docs/library/tanstack-start/auth-patterns.md +7 -15
  62. package/templates/tanstack-start/docs/library/tanstack-start/routing.md +16 -23
  63. package/templates/tanstack-start/docs/library/zod/complex-types.md +12 -31
  64. package/templates/tanstack-start/docs/library/zod/index.md +18 -35
  65. package/templates/tanstack-start/docs/library/zod/transforms.md +11 -25
  66. package/templates/tanstack-start/docs/library/zod/validation.md +12 -34
  67. package/templates/.claude/agents/debug-detective.md +0 -37
  68. package/templates/.claude/agents/test-writer.md +0 -41
  69. package/templates/.claude/commands/feedback.md +0 -199
  70. package/templates/.claude/commands/ts-fix.md +0 -176
  71. package/templates/.claude/skills/command-creator/LICENSE.txt +0 -202
  72. package/templates/.claude/skills/command-creator/SKILL.md +0 -245
  73. package/templates/.claude/skills/command-creator/scripts/init_command.py +0 -244
  74. package/templates/.claude/skills/command-creator/scripts/package_command.py +0 -125
  75. package/templates/.claude/skills/command-creator/scripts/quick_validate.py +0 -143
  76. package/templates/.claude/skills/frontend-design/SKILL.md +0 -310
  77. package/templates/.claude/skills/frontend-design/references/animation-patterns.md +0 -446
  78. package/templates/.claude/skills/frontend-design/references/colors-2026.md +0 -244
  79. package/templates/.claude/skills/frontend-design/references/typography-2026.md +0 -302
  80. package/templates/.claude/skills/gemini-review/SKILL.md +0 -118
  81. package/templates/.claude/skills/gemini-review/references/checklists.md +0 -129
  82. package/templates/.claude/skills/gemini-review/references/prompt-templates.md +0 -274
  83. package/templates/.claude/skills/skill-creator/LICENSE.txt +0 -202
  84. package/templates/.claude/skills/skill-creator/SKILL.md +0 -184
  85. package/templates/.claude/skills/skill-creator/scripts/init_skill.py +0 -303
  86. package/templates/.claude/skills/skill-creator/scripts/package_skill.py +0 -110
  87. package/templates/.claude/skills/skill-creator/scripts/quick_validate.py +0 -65
  88. package/templates/hono/docs/library/ai-sdk/index.md +0 -190
  89. package/templates/hono/docs/library/ai-sdk/openrouter.md +0 -111
  90. package/templates/hono/docs/library/ai-sdk/providers.md +0 -102
  91. package/templates/hono/docs/library/ai-sdk/streaming.md +0 -146
  92. package/templates/hono/docs/library/ai-sdk/structured-output.md +0 -161
  93. package/templates/hono/docs/library/ai-sdk/tools.md +0 -144
  94. package/templates/hono/docs/library/drizzle/cloudflare-d1.md +0 -247
  95. package/templates/hono/docs/library/drizzle/config.md +0 -167
  96. package/templates/hono/docs/library/drizzle/index.md +0 -259
  97. package/templates/hono/docs/library/hono/env-setup.md +0 -169
  98. package/templates/hono/docs/library/pino/index.md +0 -146
  99. package/templates/tanstack-start/docs/architecture/architecture.md +0 -243
  100. package/templates/tanstack-start/docs/deployment/cloudflare.md +0 -132
  101. package/templates/tanstack-start/docs/deployment/index.md +0 -163
  102. package/templates/tanstack-start/docs/deployment/nitro.md +0 -110
  103. package/templates/tanstack-start/docs/deployment/railway.md +0 -147
  104. package/templates/tanstack-start/docs/deployment/vercel.md +0 -135
  105. package/templates/tanstack-start/docs/design/components.md +0 -175
  106. package/templates/tanstack-start/docs/design/index.md +0 -151
  107. package/templates/tanstack-start/docs/design/safe-area.md +0 -118
  108. package/templates/tanstack-start/docs/design/tailwind-setup.md +0 -156
  109. package/templates/tanstack-start/docs/library/ai-sdk/hooks.md +0 -472
  110. package/templates/tanstack-start/docs/library/ai-sdk/index.md +0 -264
  111. package/templates/tanstack-start/docs/library/ai-sdk/openrouter.md +0 -371
  112. package/templates/tanstack-start/docs/library/ai-sdk/providers.md +0 -403
  113. package/templates/tanstack-start/docs/library/ai-sdk/streaming.md +0 -320
  114. package/templates/tanstack-start/docs/library/ai-sdk/structured-output.md +0 -454
  115. package/templates/tanstack-start/docs/library/ai-sdk/tools.md +0 -473
  116. package/templates/tanstack-start/docs/library/better-auth/2fa.md +0 -48
  117. package/templates/tanstack-start/docs/library/better-auth/advanced.md +0 -55
  118. package/templates/tanstack-start/docs/library/better-auth/plugins.md +0 -34
  119. package/templates/tanstack-start/docs/library/better-auth/session.md +0 -47
  120. package/templates/tanstack-start/docs/library/better-auth/setup.md +0 -41
  121. package/templates/tanstack-start/docs/library/drizzle/cloudflare-d1.md +0 -147
  122. package/templates/tanstack-start/docs/library/drizzle/config.md +0 -118
  123. package/templates/tanstack-start/docs/library/drizzle/crud.md +0 -205
  124. package/templates/tanstack-start/docs/library/drizzle/index.md +0 -79
  125. package/templates/tanstack-start/docs/library/drizzle/relations.md +0 -202
  126. package/templates/tanstack-start/docs/library/drizzle/schema.md +0 -154
  127. package/templates/tanstack-start/docs/library/drizzle/setup.md +0 -96
  128. package/templates/tanstack-start/docs/library/drizzle/transactions.md +0 -127
  129. package/templates/tanstack-start/docs/library/pino/index.md +0 -320
  130. /package/templates/hono/docs/{architecture/architecture.md → architecture.md} +0 -0
@@ -1,169 +0,0 @@
1
- # Hono - 환경 변수 설정
2
-
3
- > 타입 안전한 환경 변수 관리
4
-
5
- ---
6
-
7
- ## 파일 구조
8
-
9
- ```
10
- 프로젝트/
11
- ├── .env # 기본 (공통)
12
- ├── .env.development # 개발 환경
13
- ├── .env.production # 프로덕션
14
- ├── .env.local # 로컬 (gitignore)
15
- ├── .env.example # 템플릿 (커밋용)
16
- └── src/env.ts # 검증 및 타입
17
- ```
18
-
19
- ---
20
-
21
- ## 설치
22
-
23
- ```bash
24
- npm install dotenv zod
25
- npm install -D @types/node
26
- ```
27
-
28
- ---
29
-
30
- ## Zod로 환경 변수 검증
31
-
32
- ### src/env.ts
33
-
34
- ```typescript
35
- import { z } from 'zod'
36
-
37
- const envSchema = z.object({
38
- NODE_ENV: z.enum(['development', 'production', 'test']).default('development'),
39
- PORT: z.coerce.number().default(3000),
40
- DATABASE_URL: z.string().url(),
41
- JWT_SECRET: z.string().min(16),
42
- JWT_EXPIRES_IN: z.string().default('7d'),
43
- OPENAI_API_KEY: z.string().optional(),
44
- LOG_LEVEL: z.enum(['debug', 'info', 'warn', 'error']).default('info'),
45
- CORS_ORIGIN: z.string().default('*'),
46
- })
47
-
48
- export type Env = z.infer<typeof envSchema>
49
-
50
- const parseEnv = (): Env => {
51
- const result = envSchema.safeParse(process.env)
52
- if (!result.success) {
53
- console.error('환경 변수 검증 실패:', result.error.format())
54
- process.exit(1)
55
- }
56
- return result.data
57
- }
58
-
59
- export const env = parseEnv()
60
- ```
61
-
62
- ---
63
-
64
- ## dotenv 로드
65
-
66
- ### src/index.ts
67
-
68
- ```typescript
69
- import 'dotenv/config' // 최상단!
70
- import { serve } from '@hono/node-server'
71
- import { app } from './app'
72
- import { env } from './env'
73
-
74
- serve({ fetch: app.fetch, port: env.PORT }, (info) => {
75
- console.log(`Server: http://localhost:${info.port}`)
76
- })
77
- ```
78
-
79
- ---
80
-
81
- ## Hono Bindings
82
-
83
- ### src/types/hono.ts
84
-
85
- ```typescript
86
- import type { Env } from '../env'
87
-
88
- export type Bindings = Env
89
-
90
- export type Variables = {
91
- requestId: string
92
- userId?: string
93
- }
94
-
95
- export type HonoEnv = {
96
- Bindings: Bindings
97
- Variables: Variables
98
- }
99
- ```
100
-
101
- ### src/app.ts
102
-
103
- ```typescript
104
- import { Hono } from 'hono'
105
- import type { HonoEnv } from './types/hono'
106
- import { env } from './env'
107
-
108
- export const app = new Hono<HonoEnv>()
109
-
110
- // Node.js에서 env 바인딩
111
- app.use('*', async (c, next) => {
112
- Object.assign(c.env, env)
113
- await next()
114
- })
115
-
116
- app.get('/', (c) => c.json({ env: c.env.NODE_ENV }))
117
- ```
118
-
119
- ---
120
-
121
- ## Cloudflare Workers
122
-
123
- ### wrangler.toml
124
-
125
- ```toml
126
- name = "my-hono-app"
127
- main = "src/index.ts"
128
- compatibility_date = "2024-01-01"
129
-
130
- [vars]
131
- NODE_ENV = "production"
132
- LOG_LEVEL = "info"
133
- ```
134
-
135
- ### .dev.vars (시크릿, gitignore)
136
-
137
- ```env
138
- DATABASE_URL=postgresql://localhost:5432/myapp_dev
139
- JWT_SECRET=dev-secret-key
140
- ```
141
-
142
- ### 시크릿 설정
143
-
144
- ```bash
145
- wrangler secret put DATABASE_URL
146
- wrangler secret put JWT_SECRET
147
- ```
148
-
149
- ---
150
-
151
- ## .gitignore
152
-
153
- ```gitignore
154
- .env
155
- .env.local
156
- .env.*.local
157
- .dev.vars
158
-
159
- !.env.example
160
- !.env.development
161
- !.env.production
162
- ```
163
-
164
- ---
165
-
166
- ## 관련 문서
167
-
168
- - [Hono 개요](./index.md)
169
- - [Cloudflare 배포](../../deployment/cloudflare.md)
@@ -1,146 +0,0 @@
1
- # Pino - Structured Logging
2
-
3
- > 초고속 JSON 로거
4
-
5
- ---
6
-
7
- ## 설치
8
-
9
- ```bash
10
- npm install pino pino-pretty
11
- ```
12
-
13
- ---
14
-
15
- ## 기본 설정
16
-
17
- ### lib/logger.ts
18
-
19
- ```typescript
20
- import pino from 'pino'
21
-
22
- const isDev = process.env.NODE_ENV === 'development'
23
-
24
- export const logger = pino({
25
- level: isDev ? 'debug' : 'info',
26
- transport: isDev
27
- ? {
28
- target: 'pino-pretty',
29
- options: {
30
- colorize: true,
31
- translateTime: 'SYS:yyyy-mm-dd HH:MM:ss',
32
- ignore: 'pid,hostname',
33
- },
34
- }
35
- : undefined,
36
- })
37
- ```
38
-
39
- ---
40
-
41
- ## 로그 레벨
42
-
43
- ```typescript
44
- logger.debug({ data }, 'Debug message') // 10
45
- logger.info({ userId }, 'User logged in') // 30
46
- logger.warn({ attempt }, 'Rate limit') // 40
47
- logger.error({ err }, 'Failed') // 50
48
- logger.fatal({ err }, 'Crash') // 60
49
- ```
50
-
51
- ---
52
-
53
- ## Hono 통합
54
-
55
- ### 미들웨어
56
-
57
- ```typescript
58
- import { createMiddleware } from 'hono/factory'
59
- import { logger } from '@/lib/logger'
60
-
61
- type Env = { Variables: { log: pino.Logger } }
62
-
63
- export const loggerMiddleware = createMiddleware<Env>(async (c, next) => {
64
- const requestId = c.req.header('x-request-id') ?? crypto.randomUUID()
65
- const log = logger.child({ requestId })
66
-
67
- c.set('log', log)
68
-
69
- const start = Date.now()
70
- await next()
71
-
72
- log.info({
73
- method: c.req.method,
74
- path: c.req.path,
75
- status: c.res.status,
76
- duration: Date.now() - start,
77
- }, 'Request completed')
78
- })
79
- ```
80
-
81
- ### 사용
82
-
83
- ```typescript
84
- app.use(loggerMiddleware)
85
-
86
- app.post('/users', async (c) => {
87
- const log = c.get('log')
88
- const data = c.req.valid('json')
89
-
90
- log.info({ email: data.email }, 'Creating user')
91
-
92
- const user = await prisma.user.create({ data })
93
- log.info({ userId: user.id }, 'User created')
94
-
95
- return c.json({ user }, 201)
96
- })
97
- ```
98
-
99
- ---
100
-
101
- ## Child Logger
102
-
103
- ```typescript
104
- const log = logger.child({
105
- requestId: 'abc-123',
106
- userId: 'user-456',
107
- })
108
-
109
- log.info('Message with context')
110
- // {"requestId":"abc-123","userId":"user-456","msg":"Message with context"}
111
- ```
112
-
113
- ---
114
-
115
- ## 에러 로깅
116
-
117
- ```typescript
118
- app.onError((err, c) => {
119
- const log = c.get('log')
120
-
121
- log.error({
122
- err: {
123
- message: err.message,
124
- stack: err.stack,
125
- name: err.name,
126
- },
127
- path: c.req.path,
128
- }, 'Request failed')
129
-
130
- return c.json({ error: 'Internal Server Error' }, 500)
131
- })
132
- ```
133
-
134
- ---
135
-
136
- ## 프로덕션 출력
137
-
138
- ```json
139
- {"level":30,"time":1705312245000,"requestId":"abc-123","msg":"Request completed","method":"POST","path":"/users","status":201,"duration":45}
140
- ```
141
-
142
- ---
143
-
144
- ## 관련 문서
145
-
146
- - [Hono 미들웨어](../hono/middleware.md)
@@ -1,243 +0,0 @@
1
- # Architecture
2
-
3
- TanStack Start 애플리케이션 아키텍처 가이드.
4
-
5
- ## 목차
6
-
7
- - [System Overview](#system-overview)
8
- - [Layer Architecture](#layer-architecture)
9
- - [Routes Layer](#1-routes-layer)
10
- - [Services Layer](#2-services-layer)
11
- - [Server Functions Layer](#3-server-functions-layer)
12
- - [Database Layer](#4-database-layer)
13
- - [Data Flow](#data-flow)
14
- - [Technology Stack](#technology-stack)
15
-
16
- ---
17
-
18
- ## System Overview
19
-
20
- ```
21
- ┌─────────────────────────────────────────────────────────────────┐
22
- │ Client (Browser) │
23
- │ ┌────────────────┐ ┌────────────────┐ ┌───────────────┐ │
24
- │ │ React Router │───▶│ TanStack Query │───▶│ React UI │ │
25
- │ │ (Navigation) │◀───│ (Caching) │◀───│ (Components) │ │
26
- │ └────────────────┘ └───────┬────────┘ └───────────────┘ │
27
- └────────────────────────────────┼─────────────────────────────────┘
28
-
29
- ┌─────────────────────────────────────────────────────────────────┐
30
- │ TanStack Start Server │
31
- │ ┌────────────────────────────────────────────────────────────┐ │
32
- │ │ Server Functions │ │
33
- │ │ routes/-functions/ → 페이지 전용 | functions/ → 글로벌 │ │
34
- │ └────────────────────────────┬───────────────────────────────┘ │
35
- │ ┌────────────────────────────▼───────────────────────────────┐ │
36
- │ │ Services Layer │ │
37
- │ │ Zod Validation | Business Logic | Data Transformation │ │
38
- │ └────────────────────────────┬───────────────────────────────┘ │
39
- └───────────────────────────────┼──────────────────────────────────┘
40
-
41
- ┌─────────────────────────────────────────────────────────────────┐
42
- │ Database Layer │
43
- │ ┌────────────────┐ ┌────────────────┐ ┌───────────────┐ │
44
- │ │ Prisma Client │───▶│ PostgreSQL │ │ Redis │ │
45
- │ └────────────────┘ └────────────────┘ └───────────────┘ │
46
- └─────────────────────────────────────────────────────────────────┘
47
- ```
48
-
49
- ## Layer Architecture
50
-
51
- ### 1. Routes Layer
52
-
53
- ```
54
- routes/<route-name>/
55
- ├── (main)/ # route group (목록 페이지)
56
- │ ├── index.tsx # 페이지 컴포넌트
57
- │ ├── -components/ # 페이지 전용 컴포넌트
58
- │ ├── -sections/ # UI 섹션 분리 (200줄+ 페이지)
59
- │ ├── -tabs/ # 탭 콘텐츠 분리
60
- │ ├── -hooks/ # 페이지 전용 훅
61
- │ └── -utils/ # 상수, 헬퍼
62
- ├── new/ # 생성 페이지 (route group 외부)
63
- │ └── index.tsx
64
- ├── route.tsx # route 설정 (loader, beforeLoad)
65
- └── -functions/ # 페이지 전용 서버 함수
66
- ```
67
-
68
- #### Route Group 패턴 `(main)`
69
-
70
- 목록 페이지는 반드시 `(main)` route group으로 감싸야 한다:
71
-
72
- ```
73
- routes/dashboard/companies/
74
- ├── (main)/ # /dashboard/companies (목록)
75
- │ ├── index.tsx
76
- │ └── -components/
77
- └── new/ # /dashboard/companies/new (생성)
78
- └── index.tsx
79
- ```
80
-
81
- **규칙:**
82
- - 목록 페이지 → `(main)/` 내부
83
- - 생성/편집 페이지 → `(main)/` 외부
84
- - URL에 `(main)`은 포함되지 않음
85
-
86
- #### 페이지 크기 기준
87
-
88
- | 줄 수 | 권장 조치 |
89
- |-------|----------|
90
- | ~100줄 | 단일 파일 OK |
91
- | 100-200줄 | -components 분리 검토 |
92
- | 200줄+ | -sections 분리 필수 |
93
- | 탭 UI | -tabs 분리 권장 |
94
-
95
- #### `-sections/` 패턴 (200줄+ 페이지)
96
-
97
- 큰 페이지는 논리적 섹션으로 분리:
98
-
99
- ```tsx
100
- // routes/settings/(main)/index.tsx
101
- import { GeneralSection } from './-sections/general-section'
102
- import { SecuritySection } from './-sections/security-section'
103
- import { NotificationSection } from './-sections/notification-section'
104
-
105
- function SettingsPage() {
106
- return (
107
- <div className="space-y-8">
108
- <GeneralSection />
109
- <SecuritySection />
110
- <NotificationSection />
111
- </div>
112
- )
113
- }
114
- ```
115
-
116
- ```
117
- routes/settings/(main)/
118
- ├── index.tsx
119
- └── -sections/
120
- ├── general-section.tsx
121
- ├── security-section.tsx
122
- └── notification-section.tsx
123
- ```
124
-
125
- #### `-tabs/` 패턴 (탭 UI)
126
-
127
- 탭 기반 페이지는 각 탭을 별도 파일로 분리:
128
-
129
- ```tsx
130
- // routes/project-settings/(main)/index.tsx
131
- import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'
132
- import { GeneralTab } from './-tabs/general-tab'
133
- import { MembersTab } from './-tabs/members-tab'
134
- import { DangerTab } from './-tabs/danger-tab'
135
-
136
- function ProjectSettingsPage() {
137
- return (
138
- <Tabs defaultValue="general">
139
- <TabsList>
140
- <TabsTrigger value="general">일반</TabsTrigger>
141
- <TabsTrigger value="members">멤버</TabsTrigger>
142
- <TabsTrigger value="danger">위험</TabsTrigger>
143
- </TabsList>
144
- <TabsContent value="general"><GeneralTab /></TabsContent>
145
- <TabsContent value="members"><MembersTab /></TabsContent>
146
- <TabsContent value="danger"><DangerTab /></TabsContent>
147
- </Tabs>
148
- )
149
- }
150
- ```
151
-
152
- ```
153
- routes/project-settings/(main)/
154
- ├── index.tsx
155
- └── -tabs/
156
- ├── general-tab.tsx
157
- ├── members-tab.tsx
158
- └── danger-tab.tsx
159
- ```
160
-
161
- ### 2. Services Layer
162
-
163
- ```
164
- services/<domain>/
165
- ├── index.ts # 진입점 (re-export)
166
- ├── schemas.ts # Zod 스키마
167
- ├── queries.ts # GET 요청
168
- └── mutations.ts # POST 요청
169
- ```
170
-
171
- ### 3. Server Functions Layer
172
-
173
- ```
174
- functions/ # 글로벌 서버 함수
175
- ├── index.ts
176
- ├── <function-name>.ts # 파일당 하나의 함수
177
- └── middlewares/
178
- └── <middleware-name>.ts
179
-
180
- routes/<route>/-functions/ # 페이지 전용
181
- └── <function-name>.ts
182
- ```
183
-
184
- **규칙**: 파일당 하나의 함수, 글로벌 vs 로컬 분리
185
-
186
- ### 4. Database Layer
187
-
188
- ```typescript
189
- // database/prisma.ts
190
- import { PrismaClient } from '../../generated/prisma'
191
-
192
- const globalForPrisma = globalThis as unknown as {
193
- prisma: PrismaClient | undefined
194
- }
195
-
196
- export const prisma =
197
- globalForPrisma.prisma ?? new PrismaClient()
198
-
199
- if (process.env.NODE_ENV !== 'production') {
200
- globalForPrisma.prisma = prisma
201
- }
202
- ```
203
-
204
- ## Data Flow
205
-
206
- ### Query Flow (읽기)
207
-
208
- ```
209
- Page Hook → useQuery → Server Function (GET) → Prisma → Database
210
-
211
- TanStack Query (Cache)
212
- ```
213
-
214
- ### Mutation Flow (쓰기)
215
-
216
- ```
217
- Form Submit → useMutation → Server Function (POST)
218
-
219
- Zod Validation
220
-
221
- Prisma Mutation → Database
222
-
223
- Cache Invalidate
224
- ```
225
-
226
- ## Technology Stack
227
-
228
- | Layer | Technology | Version |
229
- |-------|------------|---------|
230
- | Framework | TanStack Start | latest |
231
- | Router | TanStack Router | latest |
232
- | Data | TanStack Query | latest |
233
- | ORM | Prisma | 7.x |
234
- | Validation | Zod | 4.x |
235
- | Database | PostgreSQL | - |
236
- | UI | React 18+ | - |
237
-
238
- ## 관련 문서
239
-
240
- - [conventions.md](../guides/conventions.md) - 코드 컨벤션
241
- - [routes.md](../guides/routes.md) - 라우트 구조
242
- - [hooks.md](../guides/hooks.md) - Custom Hook 패턴
243
- - [services.md](../guides/services.md) - Service Layer
@@ -1,132 +0,0 @@
1
- # Cloudflare 배포
2
-
3
- ## Quick Reference (Workers 직접 통합)
4
-
5
- ```typescript
6
- // vite.config.ts
7
- import { cloudflare } from '@cloudflare/vite-plugin'
8
- import { tanstackStart } from '@tanstack/react-start/plugin/vite'
9
-
10
- export default defineConfig({
11
- plugins: [
12
- cloudflare({ viteEnvironment: { name: 'ssr' } }),
13
- tanstackStart(),
14
- viteReact(),
15
- ],
16
- })
17
- ```
18
-
19
- ```jsonc
20
- // wrangler.jsonc
21
- {
22
- "name": "my-app",
23
- "compatibility_date": "2024-09-19",
24
- "compatibility_flags": ["nodejs_compat"],
25
- "main": "@tanstack/react-start/server-entry"
26
- }
27
- ```
28
-
29
- ```bash
30
- yarn add -D @cloudflare/vite-plugin wrangler
31
- yarn build && wrangler deploy
32
- ```
33
-
34
- ---
35
-
36
- ## 배포 옵션
37
-
38
- | 옵션 | 방식 | 권장 |
39
- |------|------|------|
40
- | Workers | 직접 통합 | ✅ |
41
- | Pages | Nitro `cloudflare_pages` | - |
42
-
43
- ---
44
-
45
- ## Pages (Nitro)
46
-
47
- ```typescript
48
- // nitro.config.ts
49
- export default defineNitroConfig({
50
- preset: 'cloudflare_pages',
51
- compatibilityDate: '2024-09-19',
52
- cloudflare: { deployConfig: true, nodeCompat: true },
53
- })
54
- ```
55
-
56
- ```bash
57
- yarn build
58
- wrangler pages deploy .output/public
59
- ```
60
-
61
- ---
62
-
63
- ## Wrangler 설정
64
-
65
- ```jsonc
66
- // wrangler.jsonc (Workers)
67
- {
68
- "name": "my-app",
69
- "compatibility_date": "2024-09-19",
70
- "compatibility_flags": ["nodejs_compat"],
71
- "main": "@tanstack/react-start/server-entry",
72
- "vars": { "MY_VAR": "value" },
73
- "kv_namespaces": [{ "binding": "MY_KV", "id": "kv-id" }],
74
- "d1_databases": [{ "binding": "DB", "database_name": "my-db", "database_id": "db-id" }]
75
- }
76
- ```
77
-
78
- ---
79
-
80
- ## KV / D1 사용
81
-
82
- ```typescript
83
- // server/api/example.ts
84
- export default defineHandler(async (event) => {
85
- const env = event.context.cloudflare.env
86
- const value = await env.MY_KV.get('key')
87
- await env.MY_KV.put('key', 'value')
88
- const results = await env.DB.prepare('SELECT * FROM users').all()
89
- return { value, results }
90
- })
91
- ```
92
-
93
- ---
94
-
95
- ## 환경변수
96
-
97
- ```bash
98
- # .dev.vars (로컬)
99
- DATABASE_URL=your-local-url
100
-
101
- # 프로덕션 시크릿
102
- wrangler secret put API_SECRET
103
- ```
104
-
105
- ---
106
-
107
- ## CI/CD
108
-
109
- ```yaml
110
- # .github/workflows/cloudflare.yml
111
- - uses: cloudflare/wrangler-action@v3
112
- with:
113
- apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
114
- command: deploy
115
- ```
116
-
117
- ---
118
-
119
- ## 트러블슈팅
120
-
121
- ```typescript
122
- // nitro.config.ts - Node.js 호환성
123
- cloudflare: { nodeCompat: true }
124
-
125
- // 번들 최적화
126
- externals: ['@prisma/client']
127
- minify: true
128
- ```
129
-
130
- ```bash
131
- wrangler tail # 실시간 로그
132
- ```