Crowi 2.0 移行ワークフロー。Express/Swig から Next.js + ts-rest への移行時に自動適用。 キーワード: migrate, 移行, Express, Swig, legacy, 旧実装
View on GitHubJanuary 18, 2026
Select agents to install to:
npx add-skill https://github.com/crowi/crowi/blob/3e1eab941d3a574f16f4837a865e069ca97ef6f4/.claude/skills/migration/SKILL.md -a claude-code --skill crowi-migrationInstallation paths:
.claude/skills/crowi-migration/# Crowi 2.0 Migration Skill
## アーキテクチャ
```
crowi/
├── apps/
│ ├── crowi-api/ # Fastify + ts-rest (port 3300)
│ └── crowi-web/ # Next.js 16 (port 3301)
├── packages/
│ ├── api-contract/ # ts-rest 契約定義
│ └── shared/ # 共有型
└── lib/ # 旧実装(参照元)
├── routes/ # Express ルート
├── views/ # Swig テンプレート
└── models/ # Mongoose モデル
```
## 移行パターン
### Express Route → Fastify + ts-rest
```typescript
// Before: lib/routes/page.js
router.get('/pages', async (req, res) => {
const pages = await Page.find();
res.render('page/list', { pages });
});
// After: packages/api-contract/src/page.ts
export const pageContract = c.router({
listPages: {
method: 'GET',
path: '/pages',
responses: { 200: z.object({ pages: z.array(PageSchema) }) },
},
});
// After: apps/crowi-api/src/routes/page.ts
listPages: async () => {
const pages = await Page.find();
return { status: 200, body: { pages } };
},
```
### Swig Template → Next.js Page
```typescript
// Before: lib/views/page/list.html
{% for page in pages %}
<div>{{ page.path }}</div>
{% endfor %}
// After: apps/crowi-web/app/(main)/pages/page.tsx
'use client';
export default function PagesPage() {
const { data } = useQuery(['pages'], () => client.page.listPages());
return data?.body.pages.map(page => <div key={page._id}>{page.path}</div>);
}
```
## サブエージェント
| Agent | 役割 | ツール |
|-------|------|--------|
| migration-planner | 計画立案 | Read, Grep, Glob |
| migration-implementer | 実装 | Read, Write, Edit, Bash |
| migration-reviewer | レビュー | Read, Grep, Bash |
| migration-committer | コミット・PR | Read, Bash |
## ワークフロー
```
/migrate {task-name}
planner → implementer → reviewer ─┬→ committer
↑ │
└───────┘ (NEEDS_WORK)
```
## タスク管理
- キュー: `.claude/migration-state/queue.json`
- タスク: `.claude/migration-state/tasks/{task-id}.json`
- ステータス: `PLANNED` → `REVIIssues Found: