mcpField
D
dynamic

dynamic

github.com/ww-w-ai開発60644 回インストール4 週間前に更新
リポジトリ

dynamic について

dynamicは、Next.jsとbkend.aiでフルスタックサービスを開発するフロントエンド開発者や個人起業家向けの開発スキルです。プロジェクトの初期化に加え、BaaSの利用方法やPDCAワークフローを案内します。

主な機能

  1. 01Next.jsプロジェクト構成の初期化
  2. 02bkend.ai MCPの設定
  3. 03CLAUDE.mdとdocsフォルダーの作成
  4. 04BaaSとAPIのガイド
  5. 05PDCA各フェーズの案内
  6. 06Agent Teamsによる並列実行

活用シーン

  1. 01Next.jsフルスタックプロジェクトの開始
  2. 02bkend.aiバックエンドの設定
  3. 03認証とデータ連携方法の確認
  4. 04PDCA作業の並列実行

MCP 対応

bkend.aiをHTTP MCPサーバーとして設定し、OAuth 2.1 + PKCEで認証する方法を説明します。

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/ww-w-ai/bkit-claude-code --skill dynamic

インストール後、Claude Code で/dynamicを入力して読み込まれたか確認します。

詳細

中級(動的)スキル

アクション

アクション説明例
initプロジェクトの初期化(/init-dynamic 機能)/dynamic init my-saas
guide開発ガイドを表示/dynamic guide
helpBaaS 統合のヘルプ/dynamic help
init(プロジェクトの初期化)
  1. Next.js + Tailwind のプロジェクト構造を作成
  2. bkend.ai MCP を設定(.mcp.json)
  3. CLAUDE.md を作成(レベル:Dynamic を指定)
  4. docs/ フォルダー構造を作成
  5. src/lib/bkend.ts クライアントテンプレート
  6. .bkit-memory.json を初期化
guide(開発ガイド)
  • bkend.ai の認証/データ設定ガイド
  • フェーズ 1〜9 の Pipeline 全体ガイド
  • API 統合パターン
help(BaaS ヘルプ)
  • bkend.ai の基本概念を説明
  • 認証、データベース、ファイルストレージの使用方法
  • MCP の統合方法

対象ユーザー

  • フロントエンド開発者
  • 個人起業家
  • フルスタックサービスをすばやく構築したい方

技術スタック

Frontend:
- React / Next.js 14+
- TypeScript
- Tailwind CSS
- TanStack Query (data fetching)
- Zustand (state management)

Backend (BaaS):
- bkend.ai
  - Auto REST API
  - MongoDB database
  - Built-in authentication (JWT)
  - Real-time features (WebSocket)

Deployment:
- Vercel (frontend)
- bkend.ai (backend)
言語ティアのガイダンス(v1.3.0)

推奨:ティア 1〜2 の言語

Dynamic レベルでは、AI との高い互換性を備えたフルスタック開発をサポートします。

ティア利用可否理由
ティア 1✅ 主要AI による完全なサポート
ティア 2✅ 対応モバイル(Flutter/RN)、モダンな Web(Vue、Astro)
ティア 3⚠️ 制限ありプラットフォーム固有のニーズがある場合のみ
ティア 4❌ 不可移行を推奨

モバイル開発:

  • React Native(TypeScript 経由でティア 1)- 推奨
  • Flutter(Dart 経由でティア 2)- 対応

プロジェクト構造

project/
├── src/
│   ├── app/                    # Next.js App Router
│   │   ├── (auth)/            # Auth-related routes
│   │   │   ├── login/
│   │   │   └── register/
│   │   ├── (main)/            # Main routes
│   │   │   ├── dashboard/
│   │   │   └── settings/
│   │   ├── layout.tsx
│   │   └── page.tsx
│   │
│   ├── components/             # UI components
│   │   ├── ui/                # Basic UI (Button, Input...)
│   │   └── features/          # Feature-specific components
│   │
│   ├── hooks/                  # Custom hooks
│   │   ├── useAuth.ts
│   │   └── useQuery.ts
│   │
│   ├── lib/                    # Utilities
│   │   ├── bkend.ts           # bkend.ai client
│   │   └── utils.ts
│   │
│   ├── stores/                 # State management (Zustand)
│   │   └── auth-store.ts
│   │
│   └── types/                  # TypeScript types
│       └── index.ts
│
├── docs/                       # PDCA documents
│   ├── 01-plan/
│   ├── 02-design/
│   │   ├── data-model.md      # Data model
│   │   └── api-spec.md        # API specification
│   ├── 03-analysis/
│   └── 04-report/
│
├── .mcp.json                   # bkend.ai MCP config (type: http)
├── .env.local                  # Environment variables
├── package.json
└── README.md

コアパターン

bkend.ai クライアントのセットアップ
// lib/bkend.ts - REST Service API Client
const API_BASE = process.env.NEXT_PUBLIC_BKEND_API_URL || 'https://api.bkend.ai/v1';
const PROJECT_ID = process.env.NEXT_PUBLIC_BKEND_PROJECT_ID!;
const ENVIRONMENT = process.env.NEXT_PUBLIC_BKEND_ENV || 'dev';

async function bkendFetch(path: string, options: RequestInit = {}) {
  const token = localStorage.getItem('bkend_access_token');
  const res = await fetch(`${API_BASE}${path}`, {
    ...options,
    headers: {
      'Content-Type': 'application/json',
      'x-project-id': PROJECT_ID,
      'x-environment': ENVIRONMENT,
      ...(token && { Authorization: `Bearer ${token}` }),
      ...options.headers,
    },
  });
  if (!res.ok) throw new Error(await res.text());
  return res.json();
}

export const bkend = {
  auth: {
    signup: (body: {email: string; password: string}) => bkendFetch('/auth/email/signup', {method: 'POST', body: JSON.stringify(body)}),
    signin: (body: {email: string; password: string}) => bkendFetch('/auth/email/signin', {method: 'POST', body: JSON.stringify(body)}),
    me: () => bkendFetch('/auth/me'),
    refresh: (refreshToken: string) => bkendFetch('/auth/refresh', {method: 'POST', body: JSON.stringify({refreshToken})}),
    signout: () => bkendFetch('/auth/signout', {method: 'POST'}),
  },
  data: {
    list: (table: string, params?: Record<string,string>) => bkendFetch(`/data/${table}?${new URLSearchParams(params)}`),
    get: (table: string, id: string) => bkendFetch(`/data/${table}/${id}`),
    create: (table: string, body: any) => bkendFetch(`/data/${table}`, {method: 'POST', body: JSON.stringify(body)}),
    update: (table: string, id: string, body: any) => bkendFetch(`/data/${table}/${id}`, {method: 'PATCH', body: JSON.stringify(body)}),
    delete: (table: string, id: string) => bkendFetch(`/data/${table}/${id}`, {method: 'DELETE'}),
  },
};
認証フック
// hooks/useAuth.ts
import { create } from 'zustand';
import { persist } from 'zustand/middleware';
import { bkend } from '@/lib/bkend';

interface AuthState {
  user: User | null;
  isLoading: boolean;
  login: (email: string, password: string) => Promise<void>;
  logout: () => void;
}

export const useAuth = create<AuthState>()(
  persist(
    (set) => ({
      user: null,
      isLoading: false,

      login: async (email, password) => {
        set({ isLoading: true });
        const { user, token } = await bkend.auth.login({ email, password });
        set({ user, isLoading: false });
      },

      logout: () => {
        bkend.auth.logout();
        set({ user: null });
      },
    }),
    { name: 'auth-storage' }
  )
);
データ取得(TanStack Query)
// List query
const { data, isLoading, error } = useQuery({
  queryKey: ['items', filters],
  queryFn: () => bkend.collection('items').find(filters),
});

// Single item query
const { data: item } = useQuery({
  queryKey: ['items', id],
  queryFn: () => bkend.collection('items').findById(id),
  enabled: !!id,
});

// Create/Update (Mutation)
const mutation = useMutation({
  mutationFn: (newItem) => bkend.collection('items').create(newItem),
  onSuccess: () => {
    queryClient.invalidateQueries(['items']);
  },
});
保護されたルート
// components/ProtectedRoute.tsx
'use client';

import { useAuth } from '@/hooks/useAuth';
import { redirect } from 'next/navigation';

export function ProtectedRoute({ children }: { children: React.ReactNode }) {
  const { user, isLoading } = useAuth();

  if (isLoading) return <LoadingSpinner />;
  if (!user) redirect('/login');

  return <>{children}</>;
}

データモデル設計の原則

// Base fields (auto-generated)
interface BaseDocument {
  _id: string;
  createdAt: Date;
  updatedAt: Date;
}

// User reference
interface Post extends BaseDocument {
  userId: string;        // Author ID (reference)
  title: string;
  content: string;
  tags: string[];        // Array field
  metadata: {            // Embedded object
    viewCount: number;
    likeCount: number;
  };
}

MCP の統合

Claude Code CLI(推奨)
claude mcp add bkend --transport http https://api.bkend.ai/mcp
.mcp.json(プロジェクトごと)
{
  "mcpServers": {
    "bkend": {
      "type": "http",
      "url": "https://api.bkend.ai/mcp"
    }
  }
}
認証
  • OAuth 2.1 + PKCE(ブラウザーでの自動認証)
  • API Key/環境変数は不要
  • 最初の MCP リクエストでブラウザーが開きます -> bkend コンソールにログイン -> Organization を選択 -> 権限を承認
  • 確認:「自分の bkend プロジェクトを表示して」

## Environment Variables (.env.local)

NEXT_PUBLIC_BKEND_API_URL=https://api.bkend.ai/v1 NEXT_PUBLIC_BKEND_PROJECT_ID=your-project-id NEXT_PUBLIC_BKEND_ENV=dev


Note: Project ID is found in bkend console (console.bkend.ai).
Via MCP: "Show my project list" -> backend_project_list

## Limitations

❌ 複雑なバックエンドロジック(サーバーレス関数の制限) ❌ 大規模なトラフィック(BaaS の制限内) ❌ インフラのカスタム制御 ❌ マイクロサービスアーキテクチャ


## When to Upgrade

Move to **Enterprise Level** if you need:

→ 「トラフィックが大幅に増加する」 → 「マイクロサービスに分割したい」 → 「独自のサーバー/インフラが必要」 → 「複雑なバックエンドロジックが必要」


## bkit Features for Dynamic Level (v1.5.1)

### Output Style: bkit-pdca-guide (Recommended)

For optimal PDCA workflow experience, activate the PDCA guide style:

/output-style bkit-pdca-guide


This provides:
- PDCA status badges showing current phase progress
- Gap analysis suggestions after code changes
- Automatic next-phase guidance with checklists

### Agent Teams (2 Teammates)

Dynamic projects support Agent Teams for parallel PDCA execution:

| Role | Agents | PDCA Phases |
|------|--------|-------------|
| developer | bkend-expert | Do, Act |
| qa | qa-monitor, gap-detector | Check |

**To enable:**
1. Set environment: `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1`
2. Start team mode: `/pdca team {feature}`
3. Monitor progress: `/pdca team status`

### Agent Memory (Auto-Active)

All bkit agents automatically remember project context across sessions.
No setup needed — agents use `project` scope memory for this codebase.

---

## Common Mistakes

| Mistake | Solution |
|---------|----------|
| CORS error | Register domain in bkend.ai console |
| 401 Unauthorized | Token expired, re-login or refresh token |
| Data not showing | Check collection name, query conditions |
| Type error | Sync TypeScript type definitions with schema |

コメント