bknd-create-entity
Use when creating a new entity/table in Bknd. Covers entity definition with em() and entity(), primary key configuration, field basics, UI creation via admin panel, and code-first approach with type safety.
What this skill does
# 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
4. 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
4. Click **Save Field**
5. Repeat for additional fields
### Step 4: Sync Schema
Click **Sync Database** to apply changes to the actual database.
## Code Approach
### Step 1: Import Dependencies
```typescript
import { em, entity, text, number, boolean, date, enumm, json } from "bknd";
```
### Step 2: Define Entity
Create your entity within `em()`:
```typescript
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:
```typescript
const schema = em({
posts: entity("posts", {
title: text().required(),
}, {
primary_format: "uuid",
}),
});
```
### Step 4: Export Types
Enable type-safe queries:
```typescript
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
```typescript
import { App } from "bknd";
const app = new App({
data: schema,
// ... other config
});
```
### Full Example
```typescript
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
| Convention | Example | Notes |
|------------|---------|-------|
| Plural | `users`, `posts` | NOT `user`, `post` |
| Lowercase | `blog_posts` | NOT `BlogPosts` |
| snake_case | `user_profiles` | NOT `userProfiles` |
## Auto-Generated Fields
Every entity automatically includes:
| Field | Type | Description |
|-------|------|-------------|
| `id` | integer/uuid | Primary key (format depends on config) |
**Note:** For `created_at`/`updated_at`, use the timestamps plugin or add manually:
```typescript
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.
```typescript
// ✅ 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:
```typescript
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:
```typescript
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
```typescript
// 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
```bash
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
Related in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.