@kood/claude-code 0.3.6 → 0.3.8

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 (120) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +1 -1
  3. package/templates/.claude/agents/code-reviewer.md +124 -124
  4. package/templates/.claude/agents/dependency-manager.md +85 -85
  5. package/templates/.claude/agents/deployment-validator.md +56 -56
  6. package/templates/.claude/agents/git-operator.md +64 -64
  7. package/templates/.claude/agents/implementation-executor.md +95 -95
  8. package/templates/.claude/agents/ko-to-en-translator.md +74 -0
  9. package/templates/.claude/agents/lint-fixer.md +78 -78
  10. package/templates/.claude/agents/refactor-advisor.md +122 -122
  11. package/templates/.claude/commands/agent-creator.md +185 -185
  12. package/templates/.claude/commands/bug-fix.md +193 -193
  13. package/templates/.claude/commands/command-creator.md +54 -54
  14. package/templates/.claude/commands/docs-creator.md +57 -57
  15. package/templates/.claude/commands/docs-refactor.md +26 -26
  16. package/templates/.claude/commands/execute.md +12 -12
  17. package/templates/.claude/commands/git-all.md +32 -32
  18. package/templates/.claude/commands/git-session.md +42 -42
  19. package/templates/.claude/commands/git.md +34 -34
  20. package/templates/.claude/commands/lint-fix.md +138 -138
  21. package/templates/.claude/commands/lint-init.md +61 -61
  22. package/templates/.claude/commands/plan.md +260 -260
  23. package/templates/.claude/commands/prd.md +24 -24
  24. package/templates/.claude/commands/pre-deploy.md +109 -109
  25. package/templates/.claude/commands/refactor.md +147 -147
  26. package/templates/.claude/commands/version-update.md +17 -17
  27. package/templates/hono/CLAUDE.md +27 -27
  28. package/templates/hono/docs/architecture.md +24 -24
  29. package/templates/hono/docs/deployment/cloudflare.md +18 -18
  30. package/templates/hono/docs/deployment/docker.md +13 -13
  31. package/templates/hono/docs/deployment/index.md +19 -19
  32. package/templates/hono/docs/deployment/railway.md +32 -32
  33. package/templates/hono/docs/deployment/vercel.md +29 -29
  34. package/templates/hono/docs/guides/conventions.md +57 -57
  35. package/templates/hono/docs/guides/env-setup.md +47 -47
  36. package/templates/hono/docs/guides/getting-started.md +27 -27
  37. package/templates/hono/docs/library/hono/error-handling.md +11 -11
  38. package/templates/hono/docs/library/hono/index.md +4 -4
  39. package/templates/hono/docs/library/hono/middleware.md +18 -18
  40. package/templates/hono/docs/library/hono/rpc.md +7 -7
  41. package/templates/hono/docs/library/hono/validation.md +6 -6
  42. package/templates/hono/docs/library/prisma/cloudflare-d1.md +29 -29
  43. package/templates/hono/docs/library/prisma/config.md +16 -16
  44. package/templates/hono/docs/library/prisma/index.md +32 -32
  45. package/templates/hono/docs/library/t3-env/index.md +22 -22
  46. package/templates/hono/docs/library/zod/index.md +31 -31
  47. package/templates/nextjs/CLAUDE.md +228 -0
  48. package/templates/nextjs/docs/design.md +558 -0
  49. package/templates/nextjs/docs/guides/conventions.md +343 -0
  50. package/templates/nextjs/docs/guides/getting-started.md +367 -0
  51. package/templates/nextjs/docs/guides/routes.md +342 -0
  52. package/templates/nextjs/docs/library/better-auth/index.md +541 -0
  53. package/templates/nextjs/docs/library/nextjs/app-router.md +269 -0
  54. package/templates/nextjs/docs/library/nextjs/caching.md +351 -0
  55. package/templates/nextjs/docs/library/nextjs/index.md +291 -0
  56. package/templates/nextjs/docs/library/nextjs/middleware.md +391 -0
  57. package/templates/nextjs/docs/library/nextjs/route-handlers.md +382 -0
  58. package/templates/nextjs/docs/library/nextjs/server-actions.md +366 -0
  59. package/templates/nextjs/docs/library/prisma/cloudflare-d1.md +76 -0
  60. package/templates/nextjs/docs/library/prisma/config.md +77 -0
  61. package/templates/nextjs/docs/library/prisma/crud.md +90 -0
  62. package/templates/nextjs/docs/library/prisma/index.md +73 -0
  63. package/templates/nextjs/docs/library/prisma/relations.md +69 -0
  64. package/templates/nextjs/docs/library/prisma/schema.md +98 -0
  65. package/templates/nextjs/docs/library/prisma/setup.md +49 -0
  66. package/templates/nextjs/docs/library/prisma/transactions.md +50 -0
  67. package/templates/nextjs/docs/library/tanstack-query/index.md +66 -0
  68. package/templates/nextjs/docs/library/tanstack-query/invalidation.md +54 -0
  69. package/templates/nextjs/docs/library/tanstack-query/optimistic-updates.md +77 -0
  70. package/templates/nextjs/docs/library/tanstack-query/use-mutation.md +63 -0
  71. package/templates/nextjs/docs/library/tanstack-query/use-query.md +70 -0
  72. package/templates/nextjs/docs/library/zod/complex-types.md +61 -0
  73. package/templates/nextjs/docs/library/zod/index.md +56 -0
  74. package/templates/nextjs/docs/library/zod/transforms.md +51 -0
  75. package/templates/nextjs/docs/library/zod/validation.md +70 -0
  76. package/templates/npx/CLAUDE.md +37 -37
  77. package/templates/npx/docs/library/commander/index.md +12 -12
  78. package/templates/npx/docs/library/fs-extra/index.md +9 -9
  79. package/templates/npx/docs/library/prompts/index.md +3 -3
  80. package/templates/npx/docs/references/patterns.md +12 -12
  81. package/templates/tanstack-start/CLAUDE.md +53 -49
  82. package/templates/tanstack-start/docs/architecture.md +128 -128
  83. package/templates/tanstack-start/docs/design.md +169 -169
  84. package/templates/tanstack-start/docs/guides/conventions.md +43 -43
  85. package/templates/tanstack-start/docs/guides/env-setup.md +35 -35
  86. package/templates/tanstack-start/docs/guides/getting-started.md +19 -19
  87. package/templates/tanstack-start/docs/guides/hooks.md +63 -35
  88. package/templates/tanstack-start/docs/guides/routes.md +61 -42
  89. package/templates/tanstack-start/docs/guides/services.md +45 -45
  90. package/templates/tanstack-start/docs/library/better-auth/index.md +68 -68
  91. package/templates/tanstack-start/docs/library/prisma/cloudflare-d1.md +19 -19
  92. package/templates/tanstack-start/docs/library/prisma/config.md +16 -16
  93. package/templates/tanstack-start/docs/library/prisma/crud.md +17 -17
  94. package/templates/tanstack-start/docs/library/prisma/index.md +17 -17
  95. package/templates/tanstack-start/docs/library/prisma/relations.md +16 -16
  96. package/templates/tanstack-start/docs/library/prisma/schema.md +23 -23
  97. package/templates/tanstack-start/docs/library/prisma/setup.md +6 -6
  98. package/templates/tanstack-start/docs/library/prisma/transactions.md +10 -10
  99. package/templates/tanstack-start/docs/library/t3-env/index.md +21 -160
  100. package/templates/tanstack-start/docs/library/tanstack-query/index.md +6 -6
  101. package/templates/tanstack-start/docs/library/tanstack-query/invalidation.md +19 -19
  102. package/templates/tanstack-start/docs/library/tanstack-query/optimistic-updates.md +4 -4
  103. package/templates/tanstack-start/docs/library/tanstack-query/use-mutation.md +14 -14
  104. package/templates/tanstack-start/docs/library/tanstack-query/use-query.md +21 -21
  105. package/templates/tanstack-start/docs/library/tanstack-router/error-handling.md +9 -9
  106. package/templates/tanstack-start/docs/library/tanstack-router/hooks.md +11 -11
  107. package/templates/tanstack-start/docs/library/tanstack-router/index.md +18 -18
  108. package/templates/tanstack-start/docs/library/tanstack-router/navigation.md +17 -17
  109. package/templates/tanstack-start/docs/library/tanstack-router/route-context.md +5 -5
  110. package/templates/tanstack-start/docs/library/tanstack-router/search-params.md +10 -10
  111. package/templates/tanstack-start/docs/library/tanstack-start/auth-patterns.md +8 -8
  112. package/templates/tanstack-start/docs/library/tanstack-start/index.md +15 -15
  113. package/templates/tanstack-start/docs/library/tanstack-start/middleware.md +9 -9
  114. package/templates/tanstack-start/docs/library/tanstack-start/routing.md +6 -6
  115. package/templates/tanstack-start/docs/library/tanstack-start/server-functions.md +18 -18
  116. package/templates/tanstack-start/docs/library/tanstack-start/setup.md +4 -4
  117. package/templates/tanstack-start/docs/library/zod/complex-types.md +11 -11
  118. package/templates/tanstack-start/docs/library/zod/index.md +8 -8
  119. package/templates/tanstack-start/docs/library/zod/transforms.md +11 -11
  120. package/templates/tanstack-start/docs/library/zod/validation.md +9 -9
@@ -0,0 +1,382 @@
1
+ # Route Handlers
2
+
3
+ > REST API endpoints (`app/api/`)
4
+
5
+ ---
6
+
7
+ ## Basic Usage
8
+
9
+ ```typescript
10
+ // app/api/posts/route.ts
11
+ import { NextRequest, NextResponse } from "next/server"
12
+
13
+ export async function GET(request: NextRequest) {
14
+ const posts = await prisma.post.findMany()
15
+ return NextResponse.json(posts)
16
+ }
17
+
18
+ export async function POST(request: NextRequest) {
19
+ const body = await request.json()
20
+ const post = await prisma.post.create({ data: body })
21
+ return NextResponse.json(post, { status: 201 })
22
+ }
23
+ ```
24
+
25
+ ---
26
+
27
+ ## HTTP Methods
28
+
29
+ ```typescript
30
+ // app/api/posts/route.ts
31
+ export async function GET(request: NextRequest) {}
32
+ export async function POST(request: NextRequest) {}
33
+ export async function PUT(request: NextRequest) {}
34
+ export async function PATCH(request: NextRequest) {}
35
+ export async function DELETE(request: NextRequest) {}
36
+ export async function HEAD(request: NextRequest) {}
37
+ export async function OPTIONS(request: NextRequest) {}
38
+ ```
39
+
40
+ ---
41
+
42
+ ## Dynamic Routes
43
+
44
+ ```typescript
45
+ // app/api/posts/[id]/route.ts
46
+ export async function GET(
47
+ request: NextRequest,
48
+ { params }: { params: { id: string } }
49
+ ) {
50
+ const post = await prisma.post.findUnique({ where: { id: params.id } })
51
+
52
+ if (!post) {
53
+ return NextResponse.json({ error: "Not found" }, { status: 404 })
54
+ }
55
+
56
+ return NextResponse.json(post)
57
+ }
58
+
59
+ export async function DELETE(
60
+ request: NextRequest,
61
+ { params }: { params: { id: string } }
62
+ ) {
63
+ await prisma.post.delete({ where: { id: params.id } })
64
+ return NextResponse.json({ success: true })
65
+ }
66
+ ```
67
+
68
+ ---
69
+
70
+ ## Request Processing
71
+
72
+ ### Query Parameters
73
+
74
+ ```typescript
75
+ // GET /api/posts?page=1&limit=10
76
+ export async function GET(request: NextRequest) {
77
+ const searchParams = request.nextUrl.searchParams
78
+ const page = Number(searchParams.get("page") || 1)
79
+ const limit = Number(searchParams.get("limit") || 10)
80
+
81
+ const posts = await prisma.post.findMany({
82
+ skip: (page - 1) * limit,
83
+ take: limit,
84
+ })
85
+
86
+ return NextResponse.json(posts)
87
+ }
88
+ ```
89
+
90
+ ### JSON Body
91
+
92
+ ```typescript
93
+ export async function POST(request: NextRequest) {
94
+ const body = await request.json()
95
+
96
+ const post = await prisma.post.create({
97
+ data: {
98
+ title: body.title,
99
+ content: body.content,
100
+ },
101
+ })
102
+
103
+ return NextResponse.json(post, { status: 201 })
104
+ }
105
+ ```
106
+
107
+ ### FormData
108
+
109
+ ```typescript
110
+ export async function POST(request: NextRequest) {
111
+ const formData = await request.formData()
112
+ const title = formData.get("title") as string
113
+ const file = formData.get("file") as File
114
+
115
+ // File processing...
116
+
117
+ return NextResponse.json({ success: true })
118
+ }
119
+ ```
120
+
121
+ ### Headers
122
+
123
+ ```typescript
124
+ export async function GET(request: NextRequest) {
125
+ const token = request.headers.get("authorization")
126
+ const userAgent = request.headers.get("user-agent")
127
+
128
+ // Use headers...
129
+
130
+ return NextResponse.json({ data: "..." })
131
+ }
132
+ ```
133
+
134
+ ---
135
+
136
+ ## Response Processing
137
+
138
+ ### JSON Response
139
+
140
+ ```typescript
141
+ export async function GET() {
142
+ return NextResponse.json({ message: "Hello" }, { status: 200 })
143
+ }
144
+ ```
145
+
146
+ ### Response Headers
147
+
148
+ ```typescript
149
+ export async function GET() {
150
+ return NextResponse.json(
151
+ { data: "..." },
152
+ {
153
+ status: 200,
154
+ headers: {
155
+ "Content-Type": "application/json",
156
+ "Cache-Control": "max-age=3600",
157
+ },
158
+ }
159
+ )
160
+ }
161
+ ```
162
+
163
+ ### Redirect
164
+
165
+ ```typescript
166
+ import { redirect } from "next/navigation"
167
+
168
+ export async function GET() {
169
+ redirect("https://example.com")
170
+ }
171
+ ```
172
+
173
+ ### Cookies
174
+
175
+ ```typescript
176
+ import { cookies } from "next/headers"
177
+
178
+ export async function GET() {
179
+ const cookieStore = cookies()
180
+
181
+ // Read cookie
182
+ const token = cookieStore.get("token")
183
+
184
+ // Set cookie
185
+ cookieStore.set("token", "value", {
186
+ httpOnly: true,
187
+ secure: true,
188
+ maxAge: 60 * 60 * 24 * 7, // 7 days
189
+ })
190
+
191
+ return NextResponse.json({ success: true })
192
+ }
193
+ ```
194
+
195
+ ---
196
+
197
+ ## Zod Validation
198
+
199
+ ```typescript
200
+ import { z } from "zod"
201
+ import { NextRequest, NextResponse } from "next/server"
202
+
203
+ const createPostSchema = z.object({
204
+ title: z.string().min(1).max(100),
205
+ content: z.string().min(1),
206
+ })
207
+
208
+ export async function POST(request: NextRequest) {
209
+ try {
210
+ const body = await request.json()
211
+ const parsed = createPostSchema.parse(body)
212
+
213
+ const post = await prisma.post.create({ data: parsed })
214
+ return NextResponse.json(post, { status: 201 })
215
+ } catch (error) {
216
+ if (error instanceof z.ZodError) {
217
+ return NextResponse.json(
218
+ { errors: error.errors },
219
+ { status: 400 }
220
+ )
221
+ }
222
+ return NextResponse.json(
223
+ { error: "Internal Server Error" },
224
+ { status: 500 }
225
+ )
226
+ }
227
+ }
228
+ ```
229
+
230
+ ---
231
+
232
+ ## Authentication
233
+
234
+ ```typescript
235
+ import { auth } from "@/lib/auth"
236
+
237
+ export async function DELETE(
238
+ request: NextRequest,
239
+ { params }: { params: { id: string } }
240
+ ) {
241
+ const session = await auth()
242
+
243
+ if (!session?.user) {
244
+ return NextResponse.json({ error: "Unauthorized" }, { status: 401 })
245
+ }
246
+
247
+ await prisma.post.delete({
248
+ where: {
249
+ id: params.id,
250
+ userId: session.user.id,
251
+ },
252
+ })
253
+
254
+ return NextResponse.json({ success: true })
255
+ }
256
+ ```
257
+
258
+ ---
259
+
260
+ ## CORS
261
+
262
+ ```typescript
263
+ export async function GET(request: NextRequest) {
264
+ const data = await fetchData()
265
+
266
+ return NextResponse.json(data, {
267
+ headers: {
268
+ "Access-Control-Allow-Origin": "*",
269
+ "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
270
+ "Access-Control-Allow-Headers": "Content-Type, Authorization",
271
+ },
272
+ })
273
+ }
274
+
275
+ export async function OPTIONS() {
276
+ return new NextResponse(null, {
277
+ status: 204,
278
+ headers: {
279
+ "Access-Control-Allow-Origin": "*",
280
+ "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
281
+ "Access-Control-Allow-Headers": "Content-Type, Authorization",
282
+ },
283
+ })
284
+ }
285
+ ```
286
+
287
+ ---
288
+
289
+ ## Streaming
290
+
291
+ ```typescript
292
+ export async function GET() {
293
+ const encoder = new TextEncoder()
294
+
295
+ const stream = new ReadableStream({
296
+ async start(controller) {
297
+ for (let i = 0; i < 10; i++) {
298
+ await new Promise(resolve => setTimeout(resolve, 1000))
299
+ controller.enqueue(encoder.encode(`data: ${i}\n\n`))
300
+ }
301
+ controller.close()
302
+ },
303
+ })
304
+
305
+ return new Response(stream, {
306
+ headers: {
307
+ "Content-Type": "text/event-stream",
308
+ "Cache-Control": "no-cache",
309
+ "Connection": "keep-alive",
310
+ },
311
+ })
312
+ }
313
+ ```
314
+
315
+ ---
316
+
317
+ ## Error Handling
318
+
319
+ ```typescript
320
+ export async function GET(
321
+ request: NextRequest,
322
+ { params }: { params: { id: string } }
323
+ ) {
324
+ try {
325
+ const post = await prisma.post.findUnique({ where: { id: params.id } })
326
+
327
+ if (!post) {
328
+ return NextResponse.json({ error: "Not found" }, { status: 404 })
329
+ }
330
+
331
+ return NextResponse.json(post)
332
+ } catch (error) {
333
+ console.error("Error fetching post:", error)
334
+ return NextResponse.json(
335
+ { error: "Internal Server Error" },
336
+ { status: 500 }
337
+ )
338
+ }
339
+ }
340
+ ```
341
+
342
+ ---
343
+
344
+ ## Caching
345
+
346
+ ```typescript
347
+ // Static response (generated at build time)
348
+ export const dynamic = "force-static"
349
+
350
+ // Dynamic response (every request)
351
+ export const dynamic = "force-dynamic"
352
+
353
+ // Revalidate (regenerate every n seconds)
354
+ export const revalidate = 60 // 60 seconds
355
+
356
+ export async function GET() {
357
+ const posts = await prisma.post.findMany()
358
+ return NextResponse.json(posts)
359
+ }
360
+ ```
361
+
362
+ ---
363
+
364
+ ## Server Actions vs Route Handlers
365
+
366
+ | Criteria | Server Actions | Route Handlers |
367
+ |----------|----------------|----------------|
368
+ | **Purpose** | Form submissions, mutations | REST API, external integration |
369
+ | **Types** | ✅ Automatic type inference | ❌ Manual type definition |
370
+ | **Caching** | revalidatePath | export const revalidate |
371
+ | **Auth** | await auth() | await auth() |
372
+ | **Recommended** | Internal API | External API, webhooks |
373
+
374
+ **Recommendation:**
375
+ - Internal API → Server Actions
376
+ - External API, webhooks, third-party integration → Route Handlers
377
+
378
+ ---
379
+
380
+ ## References
381
+
382
+ - [Next.js Route Handlers](https://nextjs.org/docs/app/building-your-application/routing/route-handlers)