@mandujs/skills 1.0.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.
- package/.claude-plugin/plugin.json +85 -0
- package/README.md +77 -0
- package/package.json +52 -0
- package/skills/mandu-create-api/SKILL.md +145 -0
- package/skills/mandu-create-feature/SKILL.md +99 -0
- package/skills/mandu-debug/SKILL.md +109 -0
- package/skills/mandu-deploy/SKILL.md +174 -0
- package/skills/mandu-explain/SKILL.md +121 -0
- package/skills/mandu-fs-routes/SKILL.md +131 -0
- package/skills/mandu-guard-guide/SKILL.md +150 -0
- package/skills/mandu-hydration/SKILL.md +134 -0
- package/skills/mandu-slot/SKILL.md +132 -0
- package/src/cli.ts +125 -0
- package/src/index.ts +239 -0
- package/src/init-integration.ts +106 -0
- package/templates/.claude/settings.json +37 -0
- package/templates/.mcp.json +9 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mandu-skills",
|
|
3
|
+
"description": "Claude Code plugin for Mandu Framework - architecture skills, guard hooks, MCP integration, and scaffolding workflows for agent-native fullstack development.",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"author": "konamgil",
|
|
6
|
+
"homepage": "https://github.com/konamgil/mandu",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/konamgil/mandu.git",
|
|
10
|
+
"directory": "packages/skills"
|
|
11
|
+
},
|
|
12
|
+
"license": "MPL-2.0",
|
|
13
|
+
"skills": [
|
|
14
|
+
{
|
|
15
|
+
"name": "mandu-create-feature",
|
|
16
|
+
"path": "../skills/mandu-create-feature/SKILL.md",
|
|
17
|
+
"description": "Feature scaffolding - pages, API routes, Islands via MCP negotiate/generate pipeline"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"name": "mandu-create-api",
|
|
21
|
+
"path": "../skills/mandu-create-api/SKILL.md",
|
|
22
|
+
"description": "REST API generation - CRUD endpoints, auth, file upload with contracts and tests"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name": "mandu-debug",
|
|
26
|
+
"path": "../skills/mandu-debug/SKILL.md",
|
|
27
|
+
"description": "Error diagnosis and repair - build failures, white screens, Island issues, API errors"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "mandu-explain",
|
|
31
|
+
"path": "../skills/mandu-explain/SKILL.md",
|
|
32
|
+
"description": "Mandu concept reference - Island, Filling, Guard, Contract, Slot, SSR, ISR explanations"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"name": "mandu-guard-guide",
|
|
36
|
+
"path": "../skills/mandu-guard-guide/SKILL.md",
|
|
37
|
+
"description": "Guard architecture guide - presets, violation fixes, layer rules"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"name": "mandu-deploy",
|
|
41
|
+
"path": "../skills/mandu-deploy/SKILL.md",
|
|
42
|
+
"description": "Production deployment pipeline - Docker, CI/CD, nginx configuration"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "mandu-slot",
|
|
46
|
+
"path": "../skills/mandu-slot/SKILL.md",
|
|
47
|
+
"description": "Filling API reference - ctx methods, lifecycle hooks, middleware chains"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"name": "mandu-fs-routes",
|
|
51
|
+
"path": "../skills/mandu-fs-routes/SKILL.md",
|
|
52
|
+
"description": "File-system routing - pages, API routes, layouts, dynamic params"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"name": "mandu-hydration",
|
|
56
|
+
"path": "../skills/mandu-hydration/SKILL.md",
|
|
57
|
+
"description": "Island hydration - partial hydration, client hooks, import rules"
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
"templates": {
|
|
61
|
+
".mcp.json": "../templates/.mcp.json",
|
|
62
|
+
".claude/settings.json": "../templates/.claude/settings.json"
|
|
63
|
+
},
|
|
64
|
+
"hooks": {
|
|
65
|
+
"PreToolUse": [
|
|
66
|
+
{
|
|
67
|
+
"matcher": "Edit|Write",
|
|
68
|
+
"description": "Validate architecture guard rules before file modifications"
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
},
|
|
72
|
+
"requires": {
|
|
73
|
+
"mcpServers": ["mandu"]
|
|
74
|
+
},
|
|
75
|
+
"keywords": [
|
|
76
|
+
"mandu",
|
|
77
|
+
"framework",
|
|
78
|
+
"fullstack",
|
|
79
|
+
"bun",
|
|
80
|
+
"typescript",
|
|
81
|
+
"react",
|
|
82
|
+
"island-architecture",
|
|
83
|
+
"agent-native"
|
|
84
|
+
]
|
|
85
|
+
}
|
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# @mandujs/skills
|
|
2
|
+
|
|
3
|
+
Claude Code plugin for the Mandu Framework. Provides 9 architecture skills, guard validation hooks, MCP integration, and development environment setup for agent-native fullstack development.
|
|
4
|
+
|
|
5
|
+
## 9 Skills
|
|
6
|
+
|
|
7
|
+
| Skill | Description |
|
|
8
|
+
|-------|-------------|
|
|
9
|
+
| **mandu-create-feature** | Feature scaffolding via MCP negotiate/generate pipeline |
|
|
10
|
+
| **mandu-create-api** | REST API generation with contracts and tests |
|
|
11
|
+
| **mandu-debug** | Error diagnosis and repair (8-category triage) |
|
|
12
|
+
| **mandu-explain** | Mandu concept reference (18 concepts) |
|
|
13
|
+
| **mandu-guard-guide** | Guard architecture guide (6 presets) |
|
|
14
|
+
| **mandu-deploy** | Production deployment (Docker, CI/CD, nginx) |
|
|
15
|
+
| **mandu-slot** | Filling API reference (ctx methods, lifecycle, middleware) |
|
|
16
|
+
| **mandu-fs-routes** | File-system routing rules and layout constraints |
|
|
17
|
+
| **mandu-hydration** | Island hydration and client import rules |
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
### Via `mandu init` (Recommended)
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
bunx mandu init my-app
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Skills are automatically installed during project creation.
|
|
28
|
+
|
|
29
|
+
### Manual Installation
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
bun add -D @mandujs/skills
|
|
33
|
+
bunx mandu-skills install
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Existing Project Upgrade
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
bunx mandu-skills install --force
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## What Gets Installed
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
.claude/
|
|
46
|
+
skills/
|
|
47
|
+
mandu-create-feature.md
|
|
48
|
+
mandu-create-api.md
|
|
49
|
+
mandu-debug.md
|
|
50
|
+
mandu-explain.md
|
|
51
|
+
mandu-guard-guide.md
|
|
52
|
+
mandu-deploy.md
|
|
53
|
+
mandu-slot.md
|
|
54
|
+
mandu-fs-routes.md
|
|
55
|
+
mandu-hydration.md
|
|
56
|
+
settings.json
|
|
57
|
+
.mcp.json
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## CLI
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
mandu-skills install # Install all skills
|
|
64
|
+
mandu-skills install --force # Overwrite existing
|
|
65
|
+
mandu-skills install --dry-run # Preview changes
|
|
66
|
+
mandu-skills list # List available skills
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Version Compatibility
|
|
70
|
+
|
|
71
|
+
| @mandujs/skills | @mandujs/core | @mandujs/mcp |
|
|
72
|
+
|-----------------|---------------|--------------|
|
|
73
|
+
| 1.0.x | >= 0.19.0 | >= 0.18.10 |
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
MPL-2.0
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mandujs/skills",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Claude Code skills and plugin for Mandu framework",
|
|
6
|
+
"license": "MPL-2.0",
|
|
7
|
+
"main": "./src/index.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./src/index.ts",
|
|
10
|
+
"./init-integration": "./src/init-integration.ts"
|
|
11
|
+
},
|
|
12
|
+
"bin": {
|
|
13
|
+
"mandu-skills": "./src/cli.ts"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src/**/*",
|
|
17
|
+
"skills/**/*",
|
|
18
|
+
"templates/**/*",
|
|
19
|
+
".claude-plugin/**/*",
|
|
20
|
+
"README.md"
|
|
21
|
+
],
|
|
22
|
+
"keywords": [
|
|
23
|
+
"mandu",
|
|
24
|
+
"claude-code",
|
|
25
|
+
"skills",
|
|
26
|
+
"plugin",
|
|
27
|
+
"ai",
|
|
28
|
+
"agent",
|
|
29
|
+
"architecture",
|
|
30
|
+
"guard"
|
|
31
|
+
],
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://github.com/konamgil/mandu.git",
|
|
35
|
+
"directory": "packages/skills"
|
|
36
|
+
},
|
|
37
|
+
"author": "konamgil",
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"bun": ">=1.0.0"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"@mandujs/core": ">=0.19.0"
|
|
46
|
+
},
|
|
47
|
+
"peerDependenciesMeta": {
|
|
48
|
+
"@mandujs/core": {
|
|
49
|
+
"optional": true
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mandu-create-api
|
|
3
|
+
description: |
|
|
4
|
+
REST API 생성. CRUD/인증/업로드 엔드포인트. 'API', 'endpoint', 'CRUD' 시 자동 호출
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Mandu Create API
|
|
8
|
+
|
|
9
|
+
REST API 엔드포인트를 생성하는 워크플로우.
|
|
10
|
+
Route + Contract + Slot + Test 파이프라인으로 완전한 API를 스캐폴딩합니다.
|
|
11
|
+
|
|
12
|
+
## Workflow: Route -> Contract -> Slot -> Test
|
|
13
|
+
|
|
14
|
+
### Step 1: Route 생성
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
// app/api/posts/route.ts
|
|
18
|
+
import { Mandu } from "@mandujs/core";
|
|
19
|
+
|
|
20
|
+
export default Mandu.filling()
|
|
21
|
+
.get((ctx) => ctx.ok({ posts: [] }))
|
|
22
|
+
.post(async (ctx) => {
|
|
23
|
+
const body = await ctx.body<CreatePostInput>();
|
|
24
|
+
return ctx.created({ post: body });
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Step 2: Contract 정의
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
// src/shared/contracts/post.contract.ts
|
|
32
|
+
import { z } from "zod";
|
|
33
|
+
|
|
34
|
+
export const CreatePostInput = z.object({
|
|
35
|
+
title: z.string().min(1).max(200),
|
|
36
|
+
content: z.string().min(1),
|
|
37
|
+
tags: z.array(z.string()).optional(),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export const PostResponse = z.object({
|
|
41
|
+
id: z.string(),
|
|
42
|
+
title: z.string(),
|
|
43
|
+
content: z.string(),
|
|
44
|
+
createdAt: z.string().datetime(),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export type CreatePostInput = z.infer<typeof CreatePostInput>;
|
|
48
|
+
export type PostResponse = z.infer<typeof PostResponse>;
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Step 3: Slot (서버 데이터 로더)
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
// spec/slots/posts.slot.ts
|
|
55
|
+
import { Mandu } from "@mandujs/core";
|
|
56
|
+
import { CreatePostInput } from "@/shared/contracts/post.contract";
|
|
57
|
+
|
|
58
|
+
export default Mandu.filling()
|
|
59
|
+
.guard(async (ctx) => {
|
|
60
|
+
const token = ctx.headers.get("authorization");
|
|
61
|
+
if (!token) return ctx.error(401, "Unauthorized");
|
|
62
|
+
ctx.set("userId", await verifyToken(token));
|
|
63
|
+
})
|
|
64
|
+
.post(async (ctx) => {
|
|
65
|
+
const body = await ctx.body<CreatePostInput>();
|
|
66
|
+
const validated = CreatePostInput.parse(body);
|
|
67
|
+
const post = await db.posts.create({ ...validated, userId: ctx.get("userId") });
|
|
68
|
+
return ctx.created({ post });
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Step 4: Test 작성
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
// tests/api/posts.test.ts
|
|
76
|
+
import { describe, test, expect } from "bun:test";
|
|
77
|
+
|
|
78
|
+
describe("POST /api/posts", () => {
|
|
79
|
+
test("creates a post with valid input", async () => {
|
|
80
|
+
const res = await fetch("http://localhost:3333/api/posts", {
|
|
81
|
+
method: "POST",
|
|
82
|
+
headers: {
|
|
83
|
+
"Content-Type": "application/json",
|
|
84
|
+
Authorization: "Bearer test-token",
|
|
85
|
+
},
|
|
86
|
+
body: JSON.stringify({ title: "Test", content: "Hello" }),
|
|
87
|
+
});
|
|
88
|
+
expect(res.status).toBe(201);
|
|
89
|
+
const data = await res.json();
|
|
90
|
+
expect(data.post.title).toBe("Test");
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test("returns 401 without auth", async () => {
|
|
94
|
+
const res = await fetch("http://localhost:3333/api/posts", {
|
|
95
|
+
method: "POST",
|
|
96
|
+
body: JSON.stringify({ title: "Test", content: "Hello" }),
|
|
97
|
+
});
|
|
98
|
+
expect(res.status).toBe(401);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## CRUD Pattern
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
app/api/{resource}/route.ts GET (list), POST (create)
|
|
107
|
+
app/api/{resource}/[id]/route.ts GET (read), PATCH (update), DELETE (remove)
|
|
108
|
+
src/shared/contracts/{resource}.contract.ts
|
|
109
|
+
spec/slots/{resource}.slot.ts
|
|
110
|
+
tests/api/{resource}.test.ts
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## MCP Tools
|
|
114
|
+
|
|
115
|
+
| Tool | Purpose |
|
|
116
|
+
|------|---------|
|
|
117
|
+
| `mandu_add_route` | Create route file at correct path |
|
|
118
|
+
| `mandu_create_contract` | Generate Zod contract schema |
|
|
119
|
+
| `mandu_negotiate` | Analyze API requirements |
|
|
120
|
+
| `mandu_generate` | Full scaffold generation |
|
|
121
|
+
|
|
122
|
+
## Auth Patterns
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
// Bearer token guard
|
|
126
|
+
.guard(async (ctx) => {
|
|
127
|
+
const token = ctx.headers.get("authorization")?.replace("Bearer ", "");
|
|
128
|
+
if (!token) return ctx.error(401, "Missing token");
|
|
129
|
+
ctx.set("user", await verifyToken(token));
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
// API key guard
|
|
133
|
+
.guard((ctx) => {
|
|
134
|
+
const key = ctx.headers.get("x-api-key");
|
|
135
|
+
if (key !== process.env.API_KEY) return ctx.error(403, "Invalid API key");
|
|
136
|
+
})
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Key Rules
|
|
140
|
+
|
|
141
|
+
1. 모든 API route는 `Mandu.filling()` 체인으로 export
|
|
142
|
+
2. 반드시 Contract를 먼저 정의하고 validation에 사용
|
|
143
|
+
3. `.guard()`로 인증/인가 처리 (인라인 체크 금지)
|
|
144
|
+
4. 에러는 `ctx.error(status, message)` 사용
|
|
145
|
+
5. `ctx.body()`는 반드시 await
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mandu-create-feature
|
|
3
|
+
description: |
|
|
4
|
+
Mandu 피처 생성. 페이지/API/Island 스캐폴딩. '만들어줘', 'create', 'add page' 시 자동 호출
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Mandu Create Feature
|
|
8
|
+
|
|
9
|
+
Mandu 프로젝트에 새 피처를 생성하는 5단계 워크플로우.
|
|
10
|
+
MCP 도구 파이프라인을 통해 페이지, API, Island을 자동 스캐폴딩합니다.
|
|
11
|
+
|
|
12
|
+
## 5-Phase Workflow
|
|
13
|
+
|
|
14
|
+
### Phase 1: Negotiate (요구사항 분석)
|
|
15
|
+
|
|
16
|
+
MCP 도구 `mandu_negotiate`를 호출하여 피처 요구사항을 분석합니다.
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
mandu_negotiate({ description: "사용자 프로필 페이지와 편집 기능" })
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
결과: 필요한 라우트, 컴포넌트, API 엔드포인트 목록이 반환됩니다.
|
|
23
|
+
|
|
24
|
+
### Phase 2: Add Routes (라우트 생성)
|
|
25
|
+
|
|
26
|
+
분석 결과를 바탕으로 `mandu_add_route`로 라우트를 생성합니다.
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
mandu_add_route({ path: "/users/[id]", type: "page" })
|
|
30
|
+
mandu_add_route({ path: "/api/users/[id]", type: "api" })
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
파일 생성 규칙:
|
|
34
|
+
- Page: `app/users/[id]/page.tsx`
|
|
35
|
+
- API: `app/api/users/[id]/route.ts`
|
|
36
|
+
- Layout: `app/users/layout.tsx`
|
|
37
|
+
|
|
38
|
+
### Phase 3: Create Contracts (타입 계약)
|
|
39
|
+
|
|
40
|
+
`mandu_create_contract`로 API 계약을 정의합니다.
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
mandu_create_contract({
|
|
44
|
+
name: "user",
|
|
45
|
+
methods: ["get", "patch"],
|
|
46
|
+
fields: { name: "string", email: "string", avatar: "string?" }
|
|
47
|
+
})
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
생성 위치: `src/shared/contracts/user.contract.ts`
|
|
51
|
+
|
|
52
|
+
### Phase 4: Generate Scaffold (코드 생성)
|
|
53
|
+
|
|
54
|
+
`mandu_generate`로 전체 스캐폴드를 생성합니다.
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
mandu_generate({ spec: negotiateResult })
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
생성되는 파일:
|
|
61
|
+
- `.mandu/generated/server/` - 서버 코드
|
|
62
|
+
- `.mandu/generated/web/` - 클라이언트 코드
|
|
63
|
+
- `spec/slots/*.slot.ts` - 서버 데이터 로더
|
|
64
|
+
- `app/**/*.island.tsx` - Island 컴포넌트
|
|
65
|
+
|
|
66
|
+
### Phase 5: Guard Heal (아키텍처 검증)
|
|
67
|
+
|
|
68
|
+
`mandu_guard_heal`로 생성된 코드의 아키텍처 규칙 준수를 검증합니다.
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
mandu_guard_heal({ autofix: true })
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
위반 사항이 있으면 자동 수정을 시도합니다.
|
|
75
|
+
|
|
76
|
+
## Quick Recipes
|
|
77
|
+
|
|
78
|
+
### 새 페이지 추가
|
|
79
|
+
```
|
|
80
|
+
negotiate → add_route(page) → generate
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### 새 API + 페이지
|
|
84
|
+
```
|
|
85
|
+
negotiate → add_route(page) → add_route(api) → create_contract → generate → guard_heal
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Island 추가
|
|
89
|
+
```
|
|
90
|
+
negotiate → add_route(page) → generate → island 파일에 "use client" 확인
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Key Rules
|
|
94
|
+
|
|
95
|
+
1. 항상 `mandu_negotiate`부터 시작 (분석 없이 직접 생성하지 않기)
|
|
96
|
+
2. API 엔드포인트에는 반드시 contract 생성
|
|
97
|
+
3. 생성 후 `mandu_guard_heal`로 검증
|
|
98
|
+
4. Layout에 `<html>/<head>/<body>` 태그 사용 금지
|
|
99
|
+
5. Island 파일은 `@mandujs/core/client`에서 import
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mandu-debug
|
|
3
|
+
description: |
|
|
4
|
+
에러 진단+수정. 빌드실패/하얀화면/Island안됨/API에러/CSS깨짐 시 자동 호출
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Mandu Debug
|
|
8
|
+
|
|
9
|
+
Mandu 프로젝트의 에러를 진단하고 수정하는 8카테고리 트리아지 시스템.
|
|
10
|
+
증상 → 수집 → 진단 → 수정 → 검증 순서로 진행합니다.
|
|
11
|
+
|
|
12
|
+
## Triage: 8 Error Categories
|
|
13
|
+
|
|
14
|
+
| Category | Symptoms | First Check |
|
|
15
|
+
|----------|----------|-------------|
|
|
16
|
+
| **Build** | `bun run build` fails, TS errors | `bunx mandu guard arch --ci` |
|
|
17
|
+
| **White Screen** | Page loads but blank | Browser console, SSR output |
|
|
18
|
+
| **Island** | Component not interactive | `"use client"`, import path |
|
|
19
|
+
| **API** | 4xx/5xx from endpoints | Route file, `Mandu.filling()` chain |
|
|
20
|
+
| **CSS** | Styles missing/broken | `app/globals.css`, Tailwind config |
|
|
21
|
+
| **Guard** | Architecture violations | `bunx mandu guard arch` |
|
|
22
|
+
| **HMR** | Changes not reflecting | Dev server restart, port conflict |
|
|
23
|
+
| **Hydration** | Mismatch warnings | Server vs client render diff |
|
|
24
|
+
|
|
25
|
+
## Parallel Collection Phase
|
|
26
|
+
|
|
27
|
+
문제 발생 시 동시에 수집할 정보:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# 1. Guard check (아키텍처 위반 여부)
|
|
31
|
+
bunx mandu guard arch --ci
|
|
32
|
+
|
|
33
|
+
# 2. TypeScript check
|
|
34
|
+
bunx tsc --noEmit
|
|
35
|
+
|
|
36
|
+
# 3. Dev server logs
|
|
37
|
+
# 이미 실행 중이면 터미널 출력 확인
|
|
38
|
+
|
|
39
|
+
# 4. Browser console
|
|
40
|
+
# 개발자 도구에서 에러 메시지 확인
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
MCP 도구로 수집:
|
|
44
|
+
```
|
|
45
|
+
mandu_brain_diagnose({ symptoms: "white screen on /dashboard" })
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Fix Patterns by Category
|
|
49
|
+
|
|
50
|
+
### Build Failure
|
|
51
|
+
1. `bunx tsc --noEmit` - TypeScript 에러 위치 확인
|
|
52
|
+
2. Import 경로 확인 (특히 `@mandujs/core` vs `@mandujs/core/client`)
|
|
53
|
+
3. `bun install` - 의존성 누락 확인
|
|
54
|
+
|
|
55
|
+
### White Screen
|
|
56
|
+
1. `app/layout.tsx`에 `<html>/<head>/<body>` 태그가 있는지 확인 -> 있으면 제거
|
|
57
|
+
2. `page.tsx`에서 default export 확인
|
|
58
|
+
3. SSR 에러: 서버 로그에서 렌더링 에러 확인
|
|
59
|
+
|
|
60
|
+
### Island Not Working
|
|
61
|
+
1. `"use client"` 디렉티브 확인 (파일 최상단)
|
|
62
|
+
2. Import: `@mandujs/core/client` (NOT `@mandujs/core`)
|
|
63
|
+
3. `.island.tsx` 또는 `.client.tsx` 파일 확장자 확인
|
|
64
|
+
4. `island()` API로 감싸져 있는지 확인
|
|
65
|
+
|
|
66
|
+
### API Error
|
|
67
|
+
1. `route.ts` (NOT `route.tsx`) 확인
|
|
68
|
+
2. `Mandu.filling()` 체인으로 default export 확인
|
|
69
|
+
3. `ctx.body()` await 누락 확인
|
|
70
|
+
4. `.guard()` 반환값 확인 (void = 계속, Response = 차단)
|
|
71
|
+
|
|
72
|
+
### CSS Missing
|
|
73
|
+
1. `app/globals.css` 존재 확인
|
|
74
|
+
2. Tailwind v4 import 확인: `@import "tailwindcss"`
|
|
75
|
+
3. 프로덕션: `cssPath` 옵션이 서버에 전달되는지 확인
|
|
76
|
+
|
|
77
|
+
### Guard Violation
|
|
78
|
+
1. `bunx mandu guard arch` 실행
|
|
79
|
+
2. Layer 위반: import 방향 확인 (상위 → 하위만 허용)
|
|
80
|
+
3. `mandu.config.ts`의 preset 확인
|
|
81
|
+
|
|
82
|
+
### HMR Not Working
|
|
83
|
+
1. Dev server 재시작: `Ctrl+C` → `bun run dev`
|
|
84
|
+
2. 포트 충돌: `lsof -i :3333` 또는 다른 포트 사용
|
|
85
|
+
3. `.mandu/` 캐시 삭제: `rm -rf .mandu/generated`
|
|
86
|
+
|
|
87
|
+
### Hydration Mismatch
|
|
88
|
+
1. 서버/클라이언트 렌더링 차이 확인
|
|
89
|
+
2. `Date.now()`, `Math.random()` 등 비결정적 값 제거
|
|
90
|
+
3. `useHydrated()` 훅으로 클라이언트 전용 코드 분기
|
|
91
|
+
|
|
92
|
+
## Verification
|
|
93
|
+
|
|
94
|
+
수정 후 반드시 검증:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
bunx mandu guard arch --ci # 아키텍처 검증
|
|
98
|
+
bunx tsc --noEmit # 타입 검증
|
|
99
|
+
bun run dev # 런타임 검증
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## MCP Tools for Debugging
|
|
103
|
+
|
|
104
|
+
| Tool | Purpose |
|
|
105
|
+
|------|---------|
|
|
106
|
+
| `mandu_brain_diagnose` | 증상 기반 자동 진단 |
|
|
107
|
+
| `mandu_guard` | 아키텍처 규칙 검사 |
|
|
108
|
+
| `mandu_guard_heal` | 위반 자동 수정 |
|
|
109
|
+
| `mandu_runtime_check` | 런타임 상태 점검 |
|