@kood/claude-code 0.3.7 → 0.3.9
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.
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/templates/.claude/agents/code-reviewer.md +138 -123
- package/templates/.claude/agents/dependency-manager.md +99 -84
- package/templates/.claude/agents/deployment-validator.md +70 -55
- package/templates/.claude/agents/git-operator.md +78 -63
- package/templates/.claude/agents/implementation-executor.md +109 -94
- package/templates/.claude/agents/ko-to-en-translator.md +74 -0
- package/templates/.claude/agents/lint-fixer.md +93 -78
- package/templates/.claude/agents/refactor-advisor.md +136 -121
- package/templates/.claude/commands/agent-creator.md +199 -184
- package/templates/.claude/commands/bug-fix.md +207 -192
- package/templates/.claude/commands/command-creator.md +69 -53
- package/templates/.claude/commands/docs-creator.md +72 -56
- package/templates/.claude/commands/docs-refactor.md +41 -25
- package/templates/.claude/commands/execute.md +27 -11
- package/templates/.claude/commands/git-all.md +46 -31
- package/templates/.claude/commands/git-session.md +57 -41
- package/templates/.claude/commands/git.md +49 -33
- package/templates/.claude/commands/lint-fix.md +153 -137
- package/templates/.claude/commands/lint-init.md +76 -60
- package/templates/.claude/commands/plan.md +275 -259
- package/templates/.claude/commands/prd.md +39 -23
- package/templates/.claude/commands/pre-deploy.md +124 -108
- package/templates/.claude/commands/refactor.md +162 -146
- package/templates/.claude/commands/version-update.md +32 -16
- package/templates/hono/CLAUDE.md +28 -27
- package/templates/hono/docs/architecture.md +24 -24
- package/templates/hono/docs/deployment/cloudflare.md +18 -18
- package/templates/hono/docs/deployment/docker.md +13 -13
- package/templates/hono/docs/deployment/index.md +19 -19
- package/templates/hono/docs/deployment/railway.md +32 -32
- package/templates/hono/docs/deployment/vercel.md +29 -29
- package/templates/hono/docs/guides/conventions.md +57 -57
- package/templates/hono/docs/guides/env-setup.md +47 -47
- package/templates/hono/docs/guides/getting-started.md +27 -27
- package/templates/hono/docs/library/hono/error-handling.md +11 -11
- package/templates/hono/docs/library/hono/index.md +4 -4
- package/templates/hono/docs/library/hono/middleware.md +18 -18
- package/templates/hono/docs/library/hono/rpc.md +7 -7
- package/templates/hono/docs/library/hono/validation.md +6 -6
- package/templates/hono/docs/library/prisma/cloudflare-d1.md +29 -29
- package/templates/hono/docs/library/prisma/config.md +16 -16
- package/templates/hono/docs/library/prisma/index.md +32 -32
- package/templates/hono/docs/library/t3-env/index.md +22 -22
- package/templates/hono/docs/library/zod/index.md +31 -31
- package/templates/nextjs/CLAUDE.md +54 -51
- package/templates/nextjs/docs/architecture.md +812 -0
- package/templates/nextjs/docs/design.md +183 -183
- package/templates/nextjs/docs/guides/conventions.md +86 -86
- package/templates/nextjs/docs/guides/getting-started.md +28 -28
- package/templates/nextjs/docs/guides/routes.md +32 -32
- package/templates/nextjs/docs/library/better-auth/index.md +70 -70
- package/templates/nextjs/docs/library/nextjs/app-router.md +43 -43
- package/templates/nextjs/docs/library/nextjs/caching.md +73 -73
- package/templates/nextjs/docs/library/nextjs/index.md +51 -51
- package/templates/nextjs/docs/library/nextjs/middleware.md +41 -41
- package/templates/nextjs/docs/library/nextjs/route-handlers.md +31 -31
- package/templates/nextjs/docs/library/nextjs/server-actions.md +34 -34
- package/templates/nextjs/docs/library/prisma/cloudflare-d1.md +20 -20
- package/templates/nextjs/docs/library/prisma/config.md +18 -18
- package/templates/nextjs/docs/library/prisma/crud.md +17 -17
- package/templates/nextjs/docs/library/prisma/index.md +18 -18
- package/templates/nextjs/docs/library/prisma/relations.md +16 -16
- package/templates/nextjs/docs/library/prisma/schema.md +23 -23
- package/templates/nextjs/docs/library/prisma/setup.md +6 -6
- package/templates/nextjs/docs/library/prisma/transactions.md +10 -10
- package/templates/nextjs/docs/library/tanstack-query/index.md +6 -6
- package/templates/nextjs/docs/library/tanstack-query/invalidation.md +20 -20
- package/templates/nextjs/docs/library/tanstack-query/optimistic-updates.md +4 -4
- package/templates/nextjs/docs/library/tanstack-query/use-mutation.md +15 -15
- package/templates/nextjs/docs/library/tanstack-query/use-query.md +22 -22
- package/templates/nextjs/docs/library/zod/complex-types.md +11 -11
- package/templates/nextjs/docs/library/zod/index.md +8 -8
- package/templates/nextjs/docs/library/zod/transforms.md +11 -11
- package/templates/nextjs/docs/library/zod/validation.md +9 -9
- package/templates/npx/CLAUDE.md +38 -37
- package/templates/npx/docs/library/commander/index.md +12 -12
- package/templates/npx/docs/library/fs-extra/index.md +9 -9
- package/templates/npx/docs/library/prompts/index.md +3 -3
- package/templates/npx/docs/references/patterns.md +12 -12
- package/templates/tanstack-start/CLAUDE.md +54 -53
- package/templates/tanstack-start/docs/architecture.md +128 -128
- package/templates/tanstack-start/docs/design.md +169 -169
- package/templates/tanstack-start/docs/guides/conventions.md +43 -43
- package/templates/tanstack-start/docs/guides/env-setup.md +35 -35
- package/templates/tanstack-start/docs/guides/getting-started.md +19 -19
- package/templates/tanstack-start/docs/guides/hooks.md +45 -45
- package/templates/tanstack-start/docs/guides/routes.md +54 -54
- package/templates/tanstack-start/docs/guides/services.md +45 -45
- package/templates/tanstack-start/docs/library/better-auth/index.md +68 -68
- package/templates/tanstack-start/docs/library/prisma/cloudflare-d1.md +19 -19
- package/templates/tanstack-start/docs/library/prisma/config.md +16 -16
- package/templates/tanstack-start/docs/library/prisma/crud.md +17 -17
- package/templates/tanstack-start/docs/library/prisma/index.md +17 -17
- package/templates/tanstack-start/docs/library/prisma/relations.md +16 -16
- package/templates/tanstack-start/docs/library/prisma/schema.md +23 -23
- package/templates/tanstack-start/docs/library/prisma/setup.md +6 -6
- package/templates/tanstack-start/docs/library/prisma/transactions.md +10 -10
- package/templates/tanstack-start/docs/library/t3-env/index.md +21 -160
- package/templates/tanstack-start/docs/library/tanstack-query/index.md +6 -6
- package/templates/tanstack-start/docs/library/tanstack-query/invalidation.md +19 -19
- package/templates/tanstack-start/docs/library/tanstack-query/optimistic-updates.md +4 -4
- package/templates/tanstack-start/docs/library/tanstack-query/use-mutation.md +14 -14
- package/templates/tanstack-start/docs/library/tanstack-query/use-query.md +21 -21
- package/templates/tanstack-start/docs/library/tanstack-router/error-handling.md +9 -9
- package/templates/tanstack-start/docs/library/tanstack-router/hooks.md +11 -11
- package/templates/tanstack-start/docs/library/tanstack-router/index.md +18 -18
- package/templates/tanstack-start/docs/library/tanstack-router/navigation.md +17 -17
- package/templates/tanstack-start/docs/library/tanstack-router/route-context.md +5 -5
- package/templates/tanstack-start/docs/library/tanstack-router/search-params.md +10 -10
- package/templates/tanstack-start/docs/library/tanstack-start/auth-patterns.md +8 -8
- package/templates/tanstack-start/docs/library/tanstack-start/index.md +15 -15
- package/templates/tanstack-start/docs/library/tanstack-start/middleware.md +9 -9
- package/templates/tanstack-start/docs/library/tanstack-start/routing.md +6 -6
- package/templates/tanstack-start/docs/library/tanstack-start/server-functions.md +18 -18
- package/templates/tanstack-start/docs/library/tanstack-start/setup.md +4 -4
- package/templates/tanstack-start/docs/library/zod/complex-types.md +11 -11
- package/templates/tanstack-start/docs/library/zod/index.md +8 -8
- package/templates/tanstack-start/docs/library/zod/transforms.md +11 -11
- package/templates/tanstack-start/docs/library/zod/validation.md +9 -9
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Zod -
|
|
1
|
+
# Zod - Validation
|
|
2
2
|
|
|
3
3
|
<patterns>
|
|
4
4
|
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
// Refinement (v4: message → error)
|
|
7
7
|
const PasswordSchema = z.string()
|
|
8
8
|
.min(8)
|
|
9
|
-
.refine((val) => /[A-Z]/.test(val), { error: '
|
|
10
|
-
.refine((val) => /[0-9]/.test(val), { error: '
|
|
9
|
+
.refine((val) => /[A-Z]/.test(val), { error: 'Uppercase letter required' })
|
|
10
|
+
.refine((val) => /[0-9]/.test(val), { error: 'Number required' })
|
|
11
11
|
|
|
12
|
-
z.string().refine(val => val.includes("@")).min(5) // v4:
|
|
12
|
+
z.string().refine(val => val.includes("@")).min(5) // v4: chaining after refinement
|
|
13
13
|
|
|
14
14
|
// Async
|
|
15
15
|
const schema = z.string().refine(async (val) => val.length <= 8)
|
|
@@ -23,20 +23,20 @@ z.object({
|
|
|
23
23
|
if (data.password !== data.confirmPassword) {
|
|
24
24
|
ctx.addIssue({
|
|
25
25
|
code: z.ZodIssueCode.custom,
|
|
26
|
-
message: '
|
|
26
|
+
message: 'Passwords do not match',
|
|
27
27
|
path: ['confirmPassword'],
|
|
28
28
|
})
|
|
29
29
|
}
|
|
30
|
-
}) // v4: ctx.path
|
|
30
|
+
}) // v4: ctx.path is unavailable
|
|
31
31
|
|
|
32
|
-
//
|
|
32
|
+
// Custom
|
|
33
33
|
const px = z.custom<`${number}px`>((val) =>
|
|
34
34
|
typeof val === 'string' && /^\d+px$/.test(val)
|
|
35
35
|
)
|
|
36
36
|
px.parse('42px') // ✅
|
|
37
37
|
px.parse('42vw') // throws
|
|
38
38
|
|
|
39
|
-
//
|
|
39
|
+
// Error handling
|
|
40
40
|
const result = schema.safeParse(data)
|
|
41
41
|
if (!result.success) {
|
|
42
42
|
result.error.errors.forEach((err) => {
|
|
@@ -50,7 +50,7 @@ export const createUser = createServerFn({ method: 'POST' })
|
|
|
50
50
|
.inputValidator(zodValidator(createUserSchema))
|
|
51
51
|
.handler(async ({ data }) => prisma.user.create({ data }))
|
|
52
52
|
|
|
53
|
-
//
|
|
53
|
+
// Environment variables
|
|
54
54
|
const env = z.object({
|
|
55
55
|
NODE_ENV: z.enum(['development', 'production', 'test']),
|
|
56
56
|
DATABASE_URL: z.string().url(),
|
package/templates/npx/CLAUDE.md
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
# CLAUDE.md - NPX CLI
|
|
2
2
|
|
|
3
|
-
> Node.js CLI
|
|
3
|
+
> Node.js CLI tool development
|
|
4
4
|
|
|
5
5
|
<context>
|
|
6
6
|
|
|
7
|
-
**Purpose:** Node.js CLI
|
|
7
|
+
**Purpose:** Work instructions for Node.js CLI tool development
|
|
8
8
|
|
|
9
|
-
**Scope:**
|
|
9
|
+
**Scope:** Implement CLI packages deployable via npx
|
|
10
10
|
|
|
11
11
|
**Key Features:**
|
|
12
|
-
- Commander.js
|
|
13
|
-
-
|
|
14
|
-
-
|
|
12
|
+
- Commander.js command system
|
|
13
|
+
- Interactive prompts (prompts)
|
|
14
|
+
- File system operations (fs-extra)
|
|
15
15
|
- TypeScript + ESM
|
|
16
|
-
-
|
|
16
|
+
- Colored output (picocolors)
|
|
17
17
|
|
|
18
18
|
</context>
|
|
19
19
|
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
|
|
32
32
|
<forbidden>
|
|
33
33
|
|
|
34
|
-
|
|
|
35
|
-
|
|
36
|
-
| **Git
|
|
37
|
-
|
|
|
38
|
-
|
|
|
39
|
-
|
|
|
40
|
-
|
|
|
34
|
+
| Category | Prohibited Actions |
|
|
35
|
+
|----------|-------------------|
|
|
36
|
+
| **Git Commits** | AI markers (`Generated with Claude Code`, `🤖`, `Co-Authored-By:`), multi-line messages, emojis |
|
|
37
|
+
| **Console Output** | Direct `console.log` usage (use logger functions) |
|
|
38
|
+
| **File Operations** | Synchronous APIs (`fs.readFileSync`, etc.), hardcoded paths (use path.join) |
|
|
39
|
+
| **Error Handling** | Missing `process.exit()`, async operations without try-catch |
|
|
40
|
+
| **Code Search** | Bash grep/rg/find commands (use ast-grep or dedicated tools) |
|
|
41
41
|
|
|
42
42
|
</forbidden>
|
|
43
43
|
|
|
@@ -45,15 +45,16 @@
|
|
|
45
45
|
|
|
46
46
|
<required>
|
|
47
47
|
|
|
48
|
-
|
|
|
49
|
-
|
|
50
|
-
|
|
|
51
|
-
|
|
|
52
|
-
|
|
|
53
|
-
|
|
|
54
|
-
|
|
|
55
|
-
|
|
|
56
|
-
|
|
|
48
|
+
| Task | Required Actions |
|
|
49
|
+
|------|-----------------|
|
|
50
|
+
| **Before Starting** | Read relevant docs (Commander → commander, Files → fs-extra) |
|
|
51
|
+
| **Document Search** | Use serena mcp (document indexing/search, context length optimization) |
|
|
52
|
+
| **Console Output** | Use logger functions (info/success/error/warn) |
|
|
53
|
+
| **File Operations** | Async API (`fs-extra`), `path.join` for paths |
|
|
54
|
+
| **Error Handling** | try-catch + `process.exit(1)`, clear error messages to users |
|
|
55
|
+
| **Code Search** | Use ast-grep (search functions/classes/patterns) |
|
|
56
|
+
| **Code Writing** | UTF-8 encoding, Korean comments per code block, const function declarations |
|
|
57
|
+
| **Complex Tasks** | Sequential Thinking MCP (5+ step tasks) |
|
|
57
58
|
|
|
58
59
|
</required>
|
|
59
60
|
|
|
@@ -61,8 +62,8 @@
|
|
|
61
62
|
|
|
62
63
|
<tech_stack>
|
|
63
64
|
|
|
64
|
-
|
|
|
65
|
-
|
|
65
|
+
| Technology | Version |
|
|
66
|
+
|-----------|---------|
|
|
66
67
|
| Node.js | >= 18 (ESM) |
|
|
67
68
|
| TypeScript | 5.x (strict) |
|
|
68
69
|
| Commander | 12.x |
|
|
@@ -78,13 +79,13 @@
|
|
|
78
79
|
<structure>
|
|
79
80
|
```
|
|
80
81
|
src/
|
|
81
|
-
├── index.ts # CLI
|
|
82
|
-
├── commands/ #
|
|
82
|
+
├── index.ts # CLI entry point
|
|
83
|
+
├── commands/ # Command modules
|
|
83
84
|
├── utils/ # logger, copy
|
|
84
|
-
└── types/ #
|
|
85
|
+
└── types/ # Types
|
|
85
86
|
|
|
86
|
-
templates/ #
|
|
87
|
-
dist/ #
|
|
87
|
+
templates/ # Copied during build
|
|
88
|
+
dist/ # Build output
|
|
88
89
|
```
|
|
89
90
|
</structure>
|
|
90
91
|
|
|
@@ -92,9 +93,9 @@ dist/ # 빌드 결과물
|
|
|
92
93
|
|
|
93
94
|
<conventions>
|
|
94
95
|
|
|
95
|
-
|
|
96
|
-
**TypeScript:** const
|
|
97
|
-
**Import
|
|
96
|
+
**File naming:** kebab-case
|
|
97
|
+
**TypeScript:** const declarations, explicit return types, interface(objects)/type(unions), any→unknown
|
|
98
|
+
**Import order:** external → internal → type
|
|
98
99
|
|
|
99
100
|
</conventions>
|
|
100
101
|
|
|
@@ -103,7 +104,7 @@ dist/ # 빌드 결과물
|
|
|
103
104
|
<quick_patterns>
|
|
104
105
|
|
|
105
106
|
```typescript
|
|
106
|
-
// CLI
|
|
107
|
+
// CLI entry point (index.ts)
|
|
107
108
|
#!/usr/bin/env node
|
|
108
109
|
import { Command } from 'commander'
|
|
109
110
|
import { logger } from './utils/logger.js'
|
|
@@ -142,7 +143,7 @@ export const logger = {
|
|
|
142
143
|
```
|
|
143
144
|
|
|
144
145
|
```typescript
|
|
145
|
-
//
|
|
146
|
+
// File copying (utils/copy.ts)
|
|
146
147
|
import path from 'node:path'
|
|
147
148
|
import { copy, pathExists } from 'fs-extra'
|
|
148
149
|
|
|
@@ -162,7 +163,7 @@ export const copyTemplate = async (
|
|
|
162
163
|
```
|
|
163
164
|
|
|
164
165
|
```typescript
|
|
165
|
-
//
|
|
166
|
+
// Interactive prompts
|
|
166
167
|
import prompts from 'prompts'
|
|
167
168
|
|
|
168
169
|
const response = await prompts([
|
|
@@ -192,6 +193,6 @@ const response = await prompts([
|
|
|
192
193
|
```
|
|
193
194
|
docs/
|
|
194
195
|
├── library/ # commander, fs-extra, prompts
|
|
195
|
-
└── references/ # CLI
|
|
196
|
+
└── references/ # CLI patterns, best practices
|
|
196
197
|
```
|
|
197
198
|
</docs_structure>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# Commander.js
|
|
2
2
|
|
|
3
|
-
> Node.js CLI
|
|
3
|
+
> Node.js CLI framework
|
|
4
4
|
|
|
5
5
|
<patterns>
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Basic Setup
|
|
8
8
|
|
|
9
9
|
```typescript
|
|
10
10
|
import { Command } from 'commander';
|
|
@@ -22,7 +22,7 @@ program.parse();
|
|
|
22
22
|
## Options
|
|
23
23
|
|
|
24
24
|
```typescript
|
|
25
|
-
//
|
|
25
|
+
// Basic
|
|
26
26
|
program
|
|
27
27
|
.option('-t, --template <name>', 'template name')
|
|
28
28
|
.option('-f, --force', 'force overwrite')
|
|
@@ -31,19 +31,19 @@ program
|
|
|
31
31
|
console.log(options.force); // boolean | undefined
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
//
|
|
34
|
+
// Required
|
|
35
35
|
program
|
|
36
36
|
.requiredOption('-c, --config <path>', 'config file path')
|
|
37
37
|
.action((options) => {
|
|
38
|
-
// options.config
|
|
38
|
+
// options.config is always present
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
-
//
|
|
41
|
+
// Default values
|
|
42
42
|
program
|
|
43
43
|
.option('-p, --port <number>', 'port number', '3000')
|
|
44
44
|
.option('-e, --env <name>', 'environment', 'development')
|
|
45
45
|
|
|
46
|
-
//
|
|
46
|
+
// Multiple values
|
|
47
47
|
program
|
|
48
48
|
.option('-i, --include <path...>', 'include paths')
|
|
49
49
|
.action((options) => {
|
|
@@ -58,8 +58,8 @@ program
|
|
|
58
58
|
.argument('<source>', 'source file')
|
|
59
59
|
.argument('[destination]', 'destination file')
|
|
60
60
|
.action((source, destination, options) => {
|
|
61
|
-
console.log(source); //
|
|
62
|
-
console.log(destination); //
|
|
61
|
+
console.log(source); // required
|
|
62
|
+
console.log(destination); // optional
|
|
63
63
|
});
|
|
64
64
|
```
|
|
65
65
|
|
|
@@ -71,14 +71,14 @@ program
|
|
|
71
71
|
.description('Initialize project')
|
|
72
72
|
.option('-t, --template <name>', 'template')
|
|
73
73
|
.action((options) => {
|
|
74
|
-
// init
|
|
74
|
+
// Handle init
|
|
75
75
|
});
|
|
76
76
|
|
|
77
77
|
program
|
|
78
78
|
.command('build')
|
|
79
79
|
.description('Build project')
|
|
80
80
|
.action(() => {
|
|
81
|
-
// build
|
|
81
|
+
// Handle build
|
|
82
82
|
});
|
|
83
83
|
```
|
|
84
84
|
|
|
@@ -95,7 +95,7 @@ program
|
|
|
95
95
|
}
|
|
96
96
|
});
|
|
97
97
|
|
|
98
|
-
await program.parseAsync(); // await
|
|
98
|
+
await program.parseAsync(); // await required
|
|
99
99
|
```
|
|
100
100
|
|
|
101
101
|
</patterns>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# fs-extra
|
|
2
2
|
|
|
3
|
-
> Node.js
|
|
3
|
+
> Node.js file system utilities
|
|
4
4
|
|
|
5
5
|
<patterns>
|
|
6
6
|
|
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
import fs from 'fs-extra';
|
|
9
9
|
import path from 'path';
|
|
10
10
|
|
|
11
|
-
//
|
|
11
|
+
// Check existence
|
|
12
12
|
const exists = await fs.pathExists('/path/to/file');
|
|
13
13
|
|
|
14
|
-
//
|
|
14
|
+
// Create directory
|
|
15
15
|
await fs.ensureDir('/path/to/nested/dir');
|
|
16
16
|
await fs.mkdir('/path/to/dir');
|
|
17
17
|
|
|
18
|
-
//
|
|
18
|
+
// Copy
|
|
19
19
|
await fs.copy('/src/file.txt', '/dest/file.txt');
|
|
20
20
|
await fs.copy('/src/dir', '/dest/dir');
|
|
21
21
|
await fs.copy(src, dest, {
|
|
@@ -24,18 +24,18 @@ await fs.copy(src, dest, {
|
|
|
24
24
|
filter: (src) => !src.includes('node_modules'),
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
-
//
|
|
27
|
+
// Remove
|
|
28
28
|
await fs.remove('/path/to/dir');
|
|
29
29
|
|
|
30
|
-
//
|
|
30
|
+
// Read directory
|
|
31
31
|
const items = await fs.readdir('/path/to/dir');
|
|
32
32
|
|
|
33
|
-
//
|
|
33
|
+
// Check file type
|
|
34
34
|
const stat = await fs.stat(itemPath);
|
|
35
35
|
if (stat.isDirectory()) { /* ... */ }
|
|
36
36
|
if (stat.isFile()) { /* ... */ }
|
|
37
37
|
|
|
38
|
-
//
|
|
38
|
+
// Read/Write files
|
|
39
39
|
const content = await fs.readFile('/path/to/file', 'utf-8');
|
|
40
40
|
await fs.writeFile('/path/to/file', content, 'utf-8');
|
|
41
41
|
|
|
@@ -43,7 +43,7 @@ await fs.writeFile('/path/to/file', content, 'utf-8');
|
|
|
43
43
|
const data = await fs.readJson('/path/to/file.json');
|
|
44
44
|
await fs.writeJson('/path/to/file.json', data, { spaces: 2 });
|
|
45
45
|
|
|
46
|
-
//
|
|
46
|
+
// Recursive copy
|
|
47
47
|
const copyRecursive = async (src: string, dest: string) => {
|
|
48
48
|
const counter = { files: 0, directories: 0 };
|
|
49
49
|
|
|
@@ -66,7 +66,7 @@ const { secret } = await prompts({
|
|
|
66
66
|
message: 'Enter password:',
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
-
//
|
|
69
|
+
// Handle cancellation
|
|
70
70
|
const { template } = await prompts({ /* ... */ });
|
|
71
71
|
|
|
72
72
|
if (!template) {
|
|
@@ -74,14 +74,14 @@ if (!template) {
|
|
|
74
74
|
process.exit(0);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
//
|
|
77
|
+
// Multiple questions
|
|
78
78
|
const response = await prompts([
|
|
79
79
|
{ type: 'text', name: 'name', message: 'Project name?' },
|
|
80
80
|
{ type: 'select', name: 'template', message: 'Template?', choices: [...] },
|
|
81
81
|
{ type: 'confirm', name: 'git', message: 'Initialize git?' },
|
|
82
82
|
]);
|
|
83
83
|
|
|
84
|
-
//
|
|
84
|
+
// Conditional questions
|
|
85
85
|
const response = await prompts([
|
|
86
86
|
{ type: 'confirm', name: 'useTypescript', message: 'Use TypeScript?' },
|
|
87
87
|
{ type: (prev) => prev ? 'confirm' : null, name: 'strict', message: 'Enable strict mode?' },
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# NPX CLI Patterns
|
|
2
2
|
|
|
3
|
-
> CLI
|
|
3
|
+
> Integrated CLI implementation patterns
|
|
4
4
|
|
|
5
5
|
<patterns>
|
|
6
6
|
|
|
7
|
-
## CLI
|
|
7
|
+
## CLI Entry Point
|
|
8
8
|
|
|
9
9
|
```typescript
|
|
10
10
|
#!/usr/bin/env node
|
|
@@ -35,7 +35,7 @@ program
|
|
|
35
35
|
program.parse();
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
## Logger
|
|
38
|
+
## Logger Utility
|
|
39
39
|
|
|
40
40
|
```typescript
|
|
41
41
|
import pc from 'picocolors';
|
|
@@ -49,7 +49,7 @@ export const logger = {
|
|
|
49
49
|
};
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
##
|
|
52
|
+
## Interactive Template Selection
|
|
53
53
|
|
|
54
54
|
```typescript
|
|
55
55
|
import prompts from 'prompts';
|
|
@@ -61,7 +61,7 @@ export const selectAndCopyTemplate = async (
|
|
|
61
61
|
templatesDir: string,
|
|
62
62
|
targetDir: string,
|
|
63
63
|
): Promise<void> => {
|
|
64
|
-
// 1.
|
|
64
|
+
// 1. Select template
|
|
65
65
|
const { template } = await prompts({
|
|
66
66
|
type: 'select',
|
|
67
67
|
name: 'template',
|
|
@@ -77,7 +77,7 @@ export const selectAndCopyTemplate = async (
|
|
|
77
77
|
process.exit(0);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
// 2.
|
|
80
|
+
// 2. Confirm overwrite
|
|
81
81
|
const targetExists = await fs.pathExists(targetDir);
|
|
82
82
|
if (targetExists) {
|
|
83
83
|
const { overwrite } = await prompts({
|
|
@@ -93,14 +93,14 @@ export const selectAndCopyTemplate = async (
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
// 3.
|
|
96
|
+
// 3. Copy files
|
|
97
97
|
const src = path.join(templatesDir, template);
|
|
98
98
|
await fs.copy(src, targetDir, { overwrite: true });
|
|
99
99
|
logger.success(`Template copied to ${targetDir}`);
|
|
100
100
|
};
|
|
101
101
|
```
|
|
102
102
|
|
|
103
|
-
## ESM __dirname
|
|
103
|
+
## ESM __dirname Handling
|
|
104
104
|
|
|
105
105
|
```typescript
|
|
106
106
|
import { fileURLToPath } from 'url';
|
|
@@ -109,11 +109,11 @@ import path from 'path';
|
|
|
109
109
|
const __filename = fileURLToPath(import.meta.url);
|
|
110
110
|
const __dirname = path.dirname(__filename);
|
|
111
111
|
|
|
112
|
-
//
|
|
112
|
+
// Templates directory path
|
|
113
113
|
const templatesDir = path.resolve(__dirname, '../templates');
|
|
114
114
|
```
|
|
115
115
|
|
|
116
|
-
##
|
|
116
|
+
## Recursive Copy with Counter
|
|
117
117
|
|
|
118
118
|
```typescript
|
|
119
119
|
import fs from 'fs-extra';
|
|
@@ -147,7 +147,7 @@ export const copyRecursive = async (
|
|
|
147
147
|
};
|
|
148
148
|
```
|
|
149
149
|
|
|
150
|
-
## package.json
|
|
150
|
+
## package.json Configuration
|
|
151
151
|
|
|
152
152
|
```json
|
|
153
153
|
{
|
|
@@ -167,7 +167,7 @@ export const copyRecursive = async (
|
|
|
167
167
|
}
|
|
168
168
|
```
|
|
169
169
|
|
|
170
|
-
## tsup
|
|
170
|
+
## tsup Configuration
|
|
171
171
|
|
|
172
172
|
```typescript
|
|
173
173
|
import { defineConfig } from 'tsup';
|
|
@@ -4,17 +4,17 @@
|
|
|
4
4
|
|
|
5
5
|
<context>
|
|
6
6
|
|
|
7
|
-
**Purpose:**
|
|
7
|
+
**Purpose:** Work guidelines for TanStack Start framework development
|
|
8
8
|
|
|
9
|
-
**Scope:** Full-stack React
|
|
9
|
+
**Scope:** Full-stack React application implementation
|
|
10
10
|
|
|
11
11
|
**Key Features:**
|
|
12
12
|
- File-based routing (TanStack Router)
|
|
13
|
-
- Server Functions (
|
|
13
|
+
- Server Functions (type-safe API)
|
|
14
14
|
- SSR + Streaming
|
|
15
|
-
- TanStack Query
|
|
16
|
-
- Middleware
|
|
17
|
-
- Deployment
|
|
15
|
+
- TanStack Query integration
|
|
16
|
+
- Middleware system
|
|
17
|
+
- Deployment flexibility (Vercel, Cloudflare, Nitro)
|
|
18
18
|
|
|
19
19
|
</context>
|
|
20
20
|
|
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
|
|
37
37
|
<forbidden>
|
|
38
38
|
|
|
39
|
-
|
|
|
40
|
-
|
|
41
|
-
| **Git
|
|
42
|
-
| **Prisma** | `db push/migrate/generate
|
|
43
|
-
| **API
|
|
44
|
-
| **Server Fn** |
|
|
45
|
-
|
|
|
46
|
-
|
|
|
39
|
+
| Category | Forbidden Actions |
|
|
40
|
+
|----------|-------------------|
|
|
41
|
+
| **Git Commits** | AI markers (`Generated with Claude Code`, `🤖`, `Co-Authored-By:`), multi-line messages, emojis |
|
|
42
|
+
| **Prisma** | Auto-running `db push/migrate/generate`, unauthorized `schema.prisma` modifications |
|
|
43
|
+
| **API Routes** | Creating routes in `/api` path (use Server Functions instead) |
|
|
44
|
+
| **Server Fn** | Manual validation/auth inside handler, using `.validator()` (use `.inputValidator()` instead) |
|
|
45
|
+
| **Client** | Direct Server Function calls (use TanStack Query) |
|
|
46
|
+
| **Code Search** | Bash grep/rg/find commands (use ast-grep or dedicated tools) |
|
|
47
47
|
|
|
48
48
|
</forbidden>
|
|
49
49
|
|
|
@@ -51,17 +51,18 @@
|
|
|
51
51
|
|
|
52
52
|
<required>
|
|
53
53
|
|
|
54
|
-
|
|
|
55
|
-
|
|
56
|
-
|
|
|
57
|
-
|
|
|
58
|
-
|
|
|
59
|
-
|
|
|
60
|
-
| **
|
|
61
|
-
|
|
|
62
|
-
| **
|
|
63
|
-
|
|
|
64
|
-
| **
|
|
54
|
+
| Task | Required Actions |
|
|
55
|
+
|------|-----------------|
|
|
56
|
+
| **Before Starting** | Read related docs (UI → design, API → tanstack-start, DB → prisma, Auth → better-auth) |
|
|
57
|
+
| **Document Search** | Use serena mcp (document indexing/search, context length optimization) |
|
|
58
|
+
| **Code Search** | Use ast-grep (function/component/pattern search) |
|
|
59
|
+
| **Complex Tasks** | Sequential Thinking MCP (5+ step tasks) |
|
|
60
|
+
| **Large Changes** | gemini-review (3+ file changes, architecture decisions) |
|
|
61
|
+
| **Server Function** | POST/PUT/PATCH → `.inputValidator()` required, Auth needed → `.middleware()` required |
|
|
62
|
+
| **Client API** | Call Server Functions via TanStack Query (`useQuery`/`useMutation`) |
|
|
63
|
+
| **Custom Hook Order** | State → Global Hooks (useParams, useNavigate) → React Query → Handlers → Memo → Effect |
|
|
64
|
+
| **Code Writing** | UTF-8 encoding, Korean comments per code block, const function declarations |
|
|
65
|
+
| **Prisma** | Multi-File structure (`prisma/schema/`), Korean comments on all elements required |
|
|
65
66
|
|
|
66
67
|
</required>
|
|
67
68
|
|
|
@@ -69,14 +70,14 @@
|
|
|
69
70
|
|
|
70
71
|
<tech_stack>
|
|
71
72
|
|
|
72
|
-
|
|
|
73
|
-
|
|
74
|
-
| TanStack Start |
|
|
73
|
+
| Tech | Version | Notes |
|
|
74
|
+
|------|---------|-------|
|
|
75
|
+
| TanStack Start | Latest | - |
|
|
75
76
|
| TypeScript | 5.x | strict |
|
|
76
77
|
| Tailwind CSS | 4.x | @theme |
|
|
77
|
-
| Prisma | **7.x** | `prisma-client`, output
|
|
78
|
+
| Prisma | **7.x** | `prisma-client`, output required |
|
|
78
79
|
| Zod | **4.x** | `z.email()`, `z.url()` |
|
|
79
|
-
| Better Auth |
|
|
80
|
+
| Better Auth | Latest | - |
|
|
80
81
|
| TanStack Query | 5.x | - |
|
|
81
82
|
|
|
82
83
|
</tech_stack>
|
|
@@ -88,36 +89,36 @@
|
|
|
88
89
|
src/
|
|
89
90
|
├── routes/ # __root.tsx, index.tsx, $slug.tsx
|
|
90
91
|
│ └── [path]/
|
|
91
|
-
│ ├── -components/ #
|
|
92
|
-
│ ├── -hooks/ #
|
|
93
|
-
│ └── -functions/ #
|
|
94
|
-
├── functions/ #
|
|
92
|
+
│ ├── -components/ # Page-specific (required)
|
|
93
|
+
│ ├── -hooks/ # Page-specific Custom Hooks (required)
|
|
94
|
+
│ └── -functions/ # Page-specific Server Functions (required)
|
|
95
|
+
├── functions/ # Shared Server Functions
|
|
95
96
|
├── components/ui/
|
|
96
97
|
├── middleware/
|
|
97
98
|
├── database/prisma.ts
|
|
98
99
|
└── lib/
|
|
99
100
|
```
|
|
100
101
|
|
|
101
|
-
|
|
102
|
-
-
|
|
103
|
-
- Custom
|
|
104
|
-
-
|
|
102
|
+
**Required Rules:**
|
|
103
|
+
- Each page must have `-components/`, `-hooks/`, `-functions/` folders (regardless of line count)
|
|
104
|
+
- Custom Hooks **must always** be separated into `-hooks/` folder regardless of page size
|
|
105
|
+
- Shared functions → `@/functions/`, Route-specific → `routes/[path]/-functions/`
|
|
105
106
|
</structure>
|
|
106
107
|
|
|
107
108
|
---
|
|
108
109
|
|
|
109
110
|
<conventions>
|
|
110
111
|
|
|
111
|
-
|
|
112
|
-
TypeScript: const
|
|
113
|
-
Import
|
|
112
|
+
Filenames: kebab-case, Routes: `__root.tsx`, `$param.tsx`
|
|
113
|
+
TypeScript: const declarations, explicit return types, interface (objects)/type (unions), any→unknown
|
|
114
|
+
Import order: external → @/ → relative → type
|
|
114
115
|
|
|
115
116
|
Prisma Multi-File:
|
|
116
117
|
```
|
|
117
118
|
prisma/schema/
|
|
118
119
|
├── +base.prisma # datasource, generator
|
|
119
|
-
├── +enum.prisma #
|
|
120
|
-
└── [model].prisma #
|
|
120
|
+
├── +enum.prisma # enums
|
|
121
|
+
└── [model].prisma # per model (Korean comments!)
|
|
121
122
|
```
|
|
122
123
|
|
|
123
124
|
</conventions>
|
|
@@ -127,12 +128,12 @@ prisma/schema/
|
|
|
127
128
|
<quick_patterns>
|
|
128
129
|
|
|
129
130
|
```typescript
|
|
130
|
-
// Server Function (GET +
|
|
131
|
+
// Server Function (GET + Auth)
|
|
131
132
|
export const getUsers = createServerFn({ method: 'GET' })
|
|
132
133
|
.middleware([authMiddleware])
|
|
133
134
|
.handler(async () => prisma.user.findMany())
|
|
134
135
|
|
|
135
|
-
// Server Function (POST + Validation +
|
|
136
|
+
// Server Function (POST + Validation + Auth)
|
|
136
137
|
export const createUser = createServerFn({ method: 'POST' })
|
|
137
138
|
.middleware([authMiddleware])
|
|
138
139
|
.inputValidator(createUserSchema)
|
|
@@ -165,12 +166,12 @@ const mutation = useMutation({
|
|
|
165
166
|
|
|
166
167
|
<ui_ux>
|
|
167
168
|
|
|
168
|
-
|
|
|
169
|
-
|
|
170
|
-
|
|
|
171
|
-
|
|
|
172
|
-
|
|
|
173
|
-
|
|
|
169
|
+
| Principle | Value |
|
|
170
|
+
|-----------|-------|
|
|
171
|
+
| Colors | 60-30-10 (background-secondary-accent) |
|
|
172
|
+
| Spacing | 8px grid |
|
|
173
|
+
| Accessibility | WCAG AA (4.5:1+ contrast) |
|
|
174
|
+
| Fonts | 2-3 fonts |
|
|
174
175
|
| Safe Area | tailwindcss-safe-area |
|
|
175
176
|
|
|
176
177
|
</ui_ux>
|
|
@@ -180,8 +181,8 @@ const mutation = useMutation({
|
|
|
180
181
|
<docs_structure>
|
|
181
182
|
```
|
|
182
183
|
docs/
|
|
183
|
-
├── guides/ #
|
|
184
|
+
├── guides/ # Getting started, conventions, patterns
|
|
184
185
|
├── library/ # tanstack-start/router/query, prisma, better-auth, t3-env, zod
|
|
185
|
-
└── design.md # UI/UX
|
|
186
|
+
└── design.md # UI/UX guide
|
|
186
187
|
```
|
|
187
188
|
</docs_structure>
|