dynamic

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Intermediate (Dynamic) Skill

中级(动态)技能

Actions

操作指令

ActionDescriptionExample
init
Project initialization (/init-dynamic feature)
/dynamic init my-saas
guide
Display development guide
/dynamic guide
help
BaaS integration help
/dynamic help
操作描述示例
init
项目初始化(/init-dynamic 功能)
/dynamic init my-saas
guide
显示开发指南
/dynamic guide
help
BaaS集成帮助
/dynamic help

init (Project Initialization)

init(项目初始化)

  1. Create Next.js + Tailwind project structure
  2. Configure bkend.ai MCP (.mcp.json)
  3. Create CLAUDE.md (Level: Dynamic specified)
  4. Create docs/ folder structure
  5. src/lib/bkend.ts client template
  6. Initialize .bkit-memory.json
  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 (Development Guide)

guide(开发指南)

  • bkend.ai auth/data configuration guide
  • Phase 1-9 full Pipeline guide
  • API integration patterns
  • bkend.ai认证/数据配置指南
  • 阶段1-9完整Pipeline指南
  • API集成模式

help (BaaS Help)

help(BaaS帮助)

  • Explain bkend.ai basic concepts
  • Auth, database, file storage usage
  • MCP integration methods
  • 解释bkend.ai基本概念
  • 认证、数据库、文件存储的使用方法
  • MCP集成方式

Target Audience

目标受众

  • Frontend developers
  • Solo entrepreneurs
  • Those who want to build fullstack services quickly
  • 前端开发者
  • 独立创业者
  • 希望快速构建全栈服务的人群

Tech Stack

技术栈

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)
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)

Language Tier Guidance (v1.3.0)

语言层级指南(v1.3.0)

Recommended: Tier 1-2 languages
Dynamic level supports full-stack development with strong AI compatibility.
TierAllowedReason
Tier 1✅ PrimaryFull AI support
Tier 2✅ YesMobile (Flutter/RN), Modern web (Vue, Astro)
Tier 3⚠️ LimitedPlatform-specific needs only
Tier 4❌ NoMigration recommended
Mobile Development:
  • React Native (Tier 1 via TypeScript) - Recommended
  • Flutter (Tier 2 via Dart) - Supported
推荐:1-2级语言
动态级别支持全栈开发,且具备强大的AI兼容性。
层级是否允许原因
层级1✅ 主要推荐完整AI支持
层级2✅ 允许移动端(Flutter/RN)、现代Web(Vue、Astro)
层级3⚠️ 有限支持仅适用于特定平台需求
层级4❌ 不允许建议迁移
移动端开发
  • React Native(通过TypeScript属于层级1)- 推荐
  • Flutter(通过Dart属于层级2)- 支持

Project Structure

项目结构

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
project/
├── src/
│   ├── app/                    # Next.js App Router
│   │   ├── (auth)/            # 认证相关路由
│   │   │   ├── login/
│   │   │   └── register/
│   │   ├── (main)/            # 主要路由
│   │   │   ├── dashboard/
│   │   │   └── settings/
│   │   ├── layout.tsx
│   │   └── page.tsx
│   │
│   ├── components/             # UI组件
│   │   ├── ui/                # 基础UI(按钮、输入框等)
│   │   └── features/          # 功能特定组件
│   │
│   ├── hooks/                  # 自定义钩子
│   │   ├── useAuth.ts
│   │   └── useQuery.ts
│   │
│   ├── lib/                    # 工具类
│   │   ├── bkend.ts           # bkend.ai客户端
│   │   └── utils.ts
│   │
│   ├── stores/                 # 状态管理(Zustand)
│   │   └── auth-store.ts
│   │
│   └── types/                  # TypeScript类型定义
│       └── index.ts
├── docs/                       # PDCA文档
│   ├── 01-plan/
│   ├── 02-design/
│   │   ├── data-model.md      # 数据模型
│   │   └── api-spec.md        # API规范
│   ├── 03-analysis/
│   └── 04-report/
├── .mcp.json                   # bkend.ai MCP配置(类型:http)
├── .env.local                  # 环境变量
├── package.json
└── README.md

Core Patterns

核心模式

bkend.ai Client Setup

bkend.ai客户端设置

typescript
// 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'}),
  },
};
typescript
// 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'}),
  },
};

Authentication Hook

认证钩子

typescript
// 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' }
  )
);
typescript
// 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' }
  )
);

Data Fetching (TanStack Query)

数据获取(TanStack Query)

typescript
// 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']);
  },
});
typescript
// 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']);
  },
});

Protected Route

受保护路由

typescript
// 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}</>;
}
typescript
// 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}</>;
}

Data Model Design Principles

数据模型设计原则

typescript
// 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;
  };
}
typescript
// Base fields (auto-generated)
interface BaseDocument {
  _id: string;
  createdAt: Date;
  updatedAt: Date;
}

// User reference
interface Post extends BaseDocument {
  userId: string;        // 作者ID(引用)
  title: string;
  content: string;
  tags: string[];        // 数组字段
  metadata: {            // 嵌入对象
    viewCount: number;
    likeCount: number;
  };
}

MCP Integration

MCP集成

Claude Code CLI (Recommended)

Claude Code CLI(推荐)

bash
claude mcp add bkend --transport http https://api.bkend.ai/mcp
bash
claude mcp add bkend --transport http https://api.bkend.ai/mcp

.mcp.json (Per Project)

.mcp.json(每个项目)

json
{
  "mcpServers": {
    "bkend": {
      "type": "http",
      "url": "https://api.bkend.ai/mcp"
    }
  }
}
json
{
  "mcpServers": {
    "bkend": {
      "type": "http",
      "url": "https://api.bkend.ai/mcp"
    }
  }
}

Authentication

认证

  • OAuth 2.1 + PKCE (browser auto-auth)
  • No API Key/env vars needed
  • First MCP request opens browser -> login to bkend console -> select Organization -> approve permissions
  • Verify: "Show my bkend projects"
undefined
  • OAuth 2.1 + PKCE(浏览器自动认证)
  • 无需API密钥/环境变量
  • 首次MCP请求会打开浏览器 -> 登录bkend控制台 -> 选择组织 -> 授权权限
  • 验证:"Show my bkend projects"
undefined

Environment Variables (.env.local)

环境变量(.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
NEXT_PUBLIC_BKEND_API_URL=https://api.bkend.ai/v1
NEXT_PUBLIC_BKEND_PROJECT_ID=your-project-id
NEXT_PUBLIC_BKEND_ENV=dev
注意:项目ID可在bkend控制台(console.bkend.ai)中找到。 通过MCP:"Show my project list" -> backend_project_list

Limitations

限制

❌ Complex backend logic (serverless function limits)
❌ Large-scale traffic (within BaaS limits)
❌ Custom infrastructure control
❌ Microservices architecture
❌ 复杂后端逻辑(无服务器函数限制)
❌ 大规模流量(需在BaaS限制范围内)
❌ 自定义基础设施控制
❌ 微服务架构

When to Upgrade

升级时机

Move to Enterprise Level if you need:
→ "Traffic will increase significantly"
→ "I want to split into microservices"
→ "I need my own server/infrastructure"
→ "I need complex backend logic"
当你需要以下功能时,升级到企业级
→ "流量将显著增长"
→ "我想拆分为微服务"
→ "我需要自己的服务器/基础设施"
→ "我需要复杂的后端逻辑"

bkit Features for Dynamic Level (v1.5.1)

动态级别的bkit功能(v1.5.1)

Output Style: bkit-pdca-guide (Recommended)

输出样式:bkit-pdca-guide(推荐)

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
为获得最佳PDCA工作流体验,激活PDCA指南样式:
/output-style bkit-pdca-guide
这将提供:
  • 显示当前阶段进度的PDCA状态徽章
  • 代码变更后的差距分析建议
  • 带检查清单的自动下一阶段指导

Agent Teams (2 Teammates)

Agent团队(2名成员)

Dynamic projects support Agent Teams for parallel PDCA execution:
RoleAgentsPDCA Phases
developerbkend-expertDo, Act
qaqa-monitor, gap-detectorCheck
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团队并行执行PDCA:
角色AgentsPDCA阶段
developerbkend-expertDo, Act
qaqa-monitor, gap-detectorCheck
启用方式:
  1. 设置环境变量:
    CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1
  2. 启动团队模式:
    /pdca team {feature}
  3. 监控进度:
    /pdca team status

Agent Memory (Auto-Active)

Agent记忆(自动激活)

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

所有bkit代理会自动跨会话记住项目上下文。 无需设置——代理会使用
project
范围的记忆来处理此代码库。

Common Mistakes

常见错误

MistakeSolution
CORS errorRegister domain in bkend.ai console
401 UnauthorizedToken expired, re-login or refresh token
Data not showingCheck collection name, query conditions
Type errorSync TypeScript type definitions with schema
错误解决方案
CORS错误在bkend.ai控制台中注册域名
401未授权令牌过期,重新登录或刷新令牌
数据不显示检查集合名称、查询条件
类型错误同步TypeScript类型定义与 schema