# Syncable Entity Types And Constants

Contributing to the Twenty codebase itself (twentyhq/twenty server internals), not for...

- Repository: https://github.com/twentyhq/twenty (60258 stars)
- Category: Engineering
- License: see repository
- Last updated: 2026-11-01
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add twentyhq/twenty --skill syncable-entity-types-and-constants -g -a claude-code -y`
Codex: `npx skills add twentyhq/twenty --skill syncable-entity-types-and-constants -g -a codex -y`
Cursor: `npx skills add twentyhq/twenty --skill syncable-entity-types-and-constants -g -a cursor -y`
Gemini CLI: `npx skills add twentyhq/twenty --skill syncable-entity-types-and-constants -g -a gemini-cli -y`

## Description

Contributing to the Twenty codebase itself (twentyhq/twenty server internals), not for building apps on top of Twenty. Define types, entities, and central constant registrations for syncable entities in Twenty's workspace migration system. Use when creating new syncable entities, defining TypeORM entities, flat entity types, or registering in central constants (ALL_ENTITY_PROPERTIES_CONFIGURATION_BY_METADATA_NAME, ALL_ONE_TO_MANY_METADATA_RELATIONS, ALL_MANY_TO_ONE_METADATA_FOREIGN_KEY, ALL_MANY_TO_ONE_METADATA_RELATIONS).

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Syncable Entity: Types & Constants (Step 1/6)

**Purpose**: Define all types, entities, and register in central constants. This is the foundation - everything else depends on these types being correct.

**When to use**: First step when creating any new syncable entity. Must be completed before other steps.

---

## Quick Start

This step creates:
1. Metadata name constant (twenty-shared)
2. TypeORM entity (extends `SyncableEntity`)
3. Flat entity types
4. Action types (universal + flat)
5. Central constant registrations (5 constants)

---

## Step 1: Add Metadata Name

**File**: `packages/twenty-shared/src/metadata/all-metadata-name.constant.ts`

```typescript
export const ALL_METADATA_NAME = {
  // ... existing entries
  myEntity: 'myEntity',
} as const;
```

---

## Step 2: Create TypeORM Entity

**File**: `src/engine/metadata-modules/my-entity/entities/my-entity.entity.ts`

```typescript
import { Entity, Column, ManyToOne, JoinColumn } from 'typeorm';
import { SyncableEntity } from 'src/engine/workspace-manager/types/syncable-entity.interface';

@Entity({ name: 'myEntity' })
export class MyEntityEntity extends SyncableEntity {
  @Column({ type: 'varchar' })
  name: string;

  @Column({ type: 'varchar' })
  label: string;

  @Column({ type: 'boolean', default: true })
  isCustom: boolean;

  // Foreign key example (optional)
  @Column({ type: 'uuid', nullable: true })
  parentEntityId: string | null;

  @ManyToOne(() => ParentEntityEntity, { nullable: true })
  @JoinColumn({ name: 'parentEntityId' })
  parentEntity: ParentEntityEntity | null;

  // JSONB column example (optional)
  @Column({ type: 'jsonb', nullable: true })
  settings: Record<string, any> | null;
}
```

**Key rules**:
- Must extend `SyncableEntity` (provides `id`, `universalIdentifier`, `applicationId`, etc.)
- Must have `isCustom` boolean column
- Use `@Column({ type: 'jsonb' })` for JSON data

---

## Step 3: Define Flat Entity Types

The rest: https://github.com/twentyhq/twenty/blob/HEAD/.claude/skills/syncable-entity-types-and-constants/SKILL.md
