dynamic
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseIntermediate (Dynamic) Skill
中级(动态)技能
Actions
操作指令
| Action | Description | Example |
|---|---|---|
| Project initialization (/init-dynamic feature) | |
| Display development guide | |
| BaaS integration help | |
| 操作 | 描述 | 示例 |
|---|---|---|
| 项目初始化(/init-dynamic 功能) | |
| 显示开发指南 | |
| BaaS集成帮助 | |
init (Project Initialization)
init(项目初始化)
- Create Next.js + Tailwind project structure
- Configure bkend.ai MCP (.mcp.json)
- Create CLAUDE.md (Level: Dynamic specified)
- Create docs/ folder structure
- src/lib/bkend.ts client template
- Initialize .bkit-memory.json
- 创建Next.js + Tailwind项目结构
- 配置bkend.ai MCP(.mcp.json)
- 创建CLAUDE.md(指定级别:Dynamic)
- 创建docs/文件夹结构
- src/lib/bkend.ts客户端模板
- 初始化.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 languagesDynamic level supports full-stack development with strong AI compatibility.
| Tier | Allowed | Reason |
|---|---|---|
| Tier 1 | ✅ Primary | Full AI support |
| Tier 2 | ✅ Yes | Mobile (Flutter/RN), Modern web (Vue, Astro) |
| Tier 3 | ⚠️ Limited | Platform-specific needs only |
| Tier 4 | ❌ No | Migration 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.mdproject/
├── 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.mdCore 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/mcpbash
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"
undefinedEnvironment 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=devNote: 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-guideThis 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:
| Role | Agents | PDCA Phases |
|---|---|---|
| developer | bkend-expert | Do, Act |
| qa | qa-monitor, gap-detector | Check |
To enable:
- Set environment:
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 - Start team mode:
/pdca team {feature} - Monitor progress:
/pdca team status
动态项目支持Agent团队并行执行PDCA:
| 角色 | Agents | PDCA阶段 |
|---|---|---|
| developer | bkend-expert | Do, Act |
| qa | qa-monitor, gap-detector | Check |
启用方式:
- 设置环境变量:
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 - 启动团队模式:
/pdca team {feature} - 监控进度:
/pdca team status
Agent Memory (Auto-Active)
Agent记忆(自动激活)
All bkit agents automatically remember project context across sessions.
No setup needed — agents use scope memory for this codebase.
project所有bkit代理会自动跨会话记住项目上下文。
无需设置——代理会使用范围的记忆来处理此代码库。
projectCommon 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 |
| 错误 | 解决方案 |
|---|---|
| CORS错误 | 在bkend.ai控制台中注册域名 |
| 401未授权 | 令牌过期,重新登录或刷新令牌 |
| 数据不显示 | 检查集合名称、查询条件 |
| 类型错误 | 同步TypeScript类型定义与 schema |