# Data Seeding

> Guide to seeding initial data using SCL instance blocks. Use when this capability is needed.

- Skill: `tomevault-io/data-seeding-2` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/data-seeding-2`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/data-seeding-2/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/data-seeding-2

---

# Data Seeding Skill

> [!IMPORTANT]
> **NEVER** use Actions, Scripts, or SDK calls to seed initial static data.
> You must use SCL `instance` blocks for all static data (dictionaries, fixed records, configuration).

## 1. The `instance` Strategy
Simple Platform treats data defined in SCL as "Configuration as Data". This guarantees that:
1.  IDs are consistent across environments (Dev -> Stage -> Prod).
2.  Data is version-controlled.
3.  Deployments are idempotent (no duplicate inserts).

## 2. Syntax: The `instance` Block
Use the `instance` keyword to define records in your `*.scl` files.

### Format
```scl
instance "<app>.<model>" "<human_readable_id>" {
  <field_name> = <value>
  <relation_field> = <relation_id>
}
```

### Example: Seeding Room Types
File: `apps/com.acme.crm/records/50_data_room_types.scl`

```scl
instance "com.acme.crm.room_type" "kng" {
  code = "KNG"
  name = "King Room"
  base_rate = 250.00
  max_occupancy = 2
}

instance "com.acme.crm.room_type" "ste" {
  code = "STE"
  name = "Grand Suite"
  base_rate = 650.00
  max_occupancy = 4
}
```

### Example: Seeding with Relations
File: `apps/com.acme.crm/records/50_data_rooms.scl`

```scl
instance "com.acme.crm.room" "101" {
  room_number = "101"
  floor = "1"
  property = "hq_grand_palace"  # References instance "com.acme.crm.property" "hq_grand_palace"
  room_type = "kng"             # References instance "com.acme.crm.room_type" "kng"
  housekeeping_status = "Clean" # Enum String
}
```

## 3. Rules for Values
*   **Strings**: Double quotes `"Value"`.
*   **Numbers**: Direct `123` or `12.50`.
*   **Booleans**: `true` or `false`.
*   **Enums**: Use the exact string value `"Clean"`.
*   **Relations**: Use the **string ID** (the second argument of the `instance` definition) of the target record.

> [!TIP]
> Place your seed data in `apps/<app>/records/` with a prefix like `50_data_` to organize them.

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/simple-platform) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-13 -->

