Token导航 LogoToken导航TokenDH.com
前端设计操作浏览器github未标认证来源可访问许可证需确认审计通过

bknd-create-entitybknd 创建实体

Agent Skill

bknd-create-entity 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

312

周安装

13

GitHub Stars

3

下载量

104
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:bknd-create-entity(bknd 创建实体)
来源仓库:https://github.com/cameronapak/bknd-skills
仓库路径:skills/bknd-create-entity
安装命令:
npx skills add https://github.com/cameronapak/bknd-skills --skill bknd-create-entity
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/cameronapak/bknd-skills --skill bknd-create-entity

简介

bknd-create-entity 用于创建新的数据库实体(表),适合在 Codex、Claude、Cursor、Gemini CLI 中构建数据模型基础单元。

  • 适用场景包括快速原型实体设计、非技术人员可视化建表及正式环境 reproducible 表结构部署。
  • 核心能力是支持 UI 模式拖拽操作与 Code 模式 TypeScript 声明两种创建途径。
  • 使用方式建议先用 UI 探索概念,确认无误后转至 Code 模式写入配置文件实现版本化管理。
  • 实体创建后会自动生成对应的 REST API 端点,可直接用于后续 CRUD 操作。

SKILL.md

Create Entity

Create a new entity (database table) in Bknd. Entities are the foundation of your data model.

Prerequisites

  • Bknd project initialized (npx bknd create or existing project)
  • For code mode: TypeScript project with bknd package installed

When to Use UI vs Code

Use UI Mode When

  • Exploring/prototyping quickly
  • Non-developer or visual learner
  • Making one-off changes
  • Testing schema ideas before committing to code

Use Code Mode When

  • Version control needed
  • Reproducible setups across environments
  • Team collaboration
  • CI/CD pipelines
  • Type safety required

UI Approach

Step 1: Access Admin Panel

  1. Start your Bknd server: npx bknd run
  2. Open browser to http://localhost:1337 (default port)
  3. Navigate to Data section in sidebar

Step 2: Create Entity

  1. Click + Add Entity button
  2. Enter entity name (use plural, lowercase: posts, users, comments)
  3. Configure primary key format:

- Integer (default): Auto-incrementing ID - UUID: Universally unique identifier

  1. Click Create

Step 3: Add Fields

After entity creation, you're taken to the field editor:

  1. Click + Add Field
  2. Select field type (text, number, boolean, date, enum, json)
  3. Configure field options:

- Name: snake_case (e.g., first_name, created_at) - Required: Toggle if field cannot be null - Default Value: Optional default

  1. Click Save Field
  2. Repeat for additional fields

Step 4: Sync Schema

Click Sync Database to apply changes to the actual database.

Code Approach

Step 1: Import Dependencies

import { em, entity, text, number, boolean, date, enumm, json } from "bknd";

Step 2: Define Entity

Create your entity within em():

const schema = em({
  posts: entity("posts", {
    title: text().required(),
    content: text(),
    published: boolean({ default_value: false }),
    view_count: number({ default_value: 0 }),
  }),
});

Step 3: Configure Primary Key (Optional)

Default is auto-incrementing integer. For UUID:

const schema = em({
  posts: entity("posts", {
    title: text().required(),
  }, {
    primary_format: "uuid",
  }),
});

Step 4: Export Types

Enable type-safe queries:

const schema = em({
  posts: entity("posts", {
    title: text().required(),
    content: text(),
  }),
});

// Extract and declare types
type Database = (typeof schema)["DB"];
declare module "bknd" {
  interface DB extends Database {}
}

Step 5: Use in App Configuration

import { App } from "bknd";

const app = new App({
  data: schema,
  // ... other config
});

Full Example

import { App, em, entity, text, number, boolean, date } from "bknd";

const schema = em({
  users: entity("users", {
    email: text().required().unique(),
    name: text(),
    active: boolean({ default_value: true }),
  }),
  posts: entity("posts", {
    title: text().required(),
    content: text(),
    published: boolean({ default_value: false }),
    published_at: date(),
  }),
});

type Database = (typeof schema)["DB"];
declare module "bknd" {
  interface DB extends Database {}
}

const app = new App({
  data: schema,
});

export default app;

Entity Naming Conventions

ConventionExampleNotes
Pluralusers, postsNOT user, post
Lowercaseblog_postsNOT BlogPosts
snake_caseuser_profilesNOT userProfiles

Auto-Generated Fields

Every entity automatically includes:

FieldTypeDescription
idinteger/uuidPrimary key (format depends on config)

Note: For created_at/updated_at, use the timestamps plugin or add manually:

entity("posts", {
  title: text().required(),
  created_at: date({ default_value: "now" }),
  updated_at: date(),
})

Common Pitfalls

Entity Already Exists

Error: Entity "posts" already defined

Fix: Each entity name must be unique within em(). Check for duplicates.

Invalid Entity Name

Error: Invalid entity name

Fix: Use lowercase letters, numbers, and underscores only. Must start with letter.

// ✅ Valid
entity("posts", { ... })
entity("user_profiles", { ... })
entity("blog_posts_2024", { ... })

// ❌ Invalid
entity("Posts", { ... })        // No uppercase
entity("2024_posts", { ... })   // Can't start with number
entity("post-items", { ... })   // No hyphens

Schema Not Syncing

Problem: Created entity in code but table doesn't exist in database.

Fix: Ensure you're using the schema in your App config:

const app = new App({
  data: schema,  // Must pass schema here
});

Then restart the server - Bknd auto-syncs on startup.

Missing Type Safety

Problem: api.data.readMany("posts",...) has no type hints.

Fix: Add type declaration:

type Database = (typeof schema)["DB"];
declare module "bknd" {
  interface DB extends Database {}
}

Verification

UI Mode

  1. Check entity appears in Data section
  2. Click entity to see fields
  3. Try creating a test record

Code Mode

// After app starts, verify entity exists
const api = app.getApi();
const result = await api.data.readMany("posts");
console.log(result); // Should return { data: [] } for empty entity

CLI Check

npx bknd debug routes
# Should show /api/data/posts endpoints

DOs and DON'Ts

DO:

  • Use plural, lowercase entity names
  • Start with essential fields; add more later
  • Add type declarations for type safety
  • Use primary_format: "uuid" for distributed systems

DON'T:

  • Use singular names (user instead of users)
  • Use PascalCase or camelCase for entity names
  • Create entities without at least one field
  • Forget to sync database after UI changes

Related Skills

  • bknd-add-field - Add fields to existing entity
  • bknd-define-relationship - Connect entities with relationships
  • bknd-modify-schema - Rename or change entity configuration
  • bknd-delete-entity - Safely remove an entity

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

37.68%
按下载量换算39

Claude

29.93%
按下载量换算31

Cursor

19.74%
按下载量换算21

Gemini CLI

8.95%
按下载量换算9

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills