For the complete documentation index, see llms.txt. This page is also available as Markdown.

Adding an Entity

This guide walks through every step of adding a new entity to the semantic layer — from the YAML definition through context files, relationships, and verification.


Before You Start

Ask yourself:

  • Is this a real business concept or a warehouse table? Entities model business concepts. If you are tempted to name it after a table (e.g., player_game_stats), rename it to the concept it represents (player_game).

  • Does this entity already exist under a different name? Check default/entities/ for existing entities before adding a duplicate.

  • What grain does this entity have? One row per what? (Per player? Per game? Per player per game?) The grain determines the keys and drives everything else.


Checklist

1. Create the Entity YAML

File: .lynk/default/entities/{entity}.yml

Minimum viable entity YAML:

name: {entity}
description: {one or two sentence description}

key_source: {warehouse_schema.db.table}

keys:
  - {primary_key_field}

features:
  - type: field
    name: {field_name}
    data_type: {string|number|boolean|datetime}
    source: {warehouse_schema.db.table}
    description: {description}
    field: {column_name_in_source}
    join_name: null
    filters: []

metrics:
  - name: {metric_name}
    description: {description}
    sql: {aggregation_sql}

Checklist for the YAML:

→ See Entity YAML Reference for full field documentation.


2. Add Relationships

File: .lynk/default/entities_relationships.yml

Add a relationship entry for every entity this new entity connects to.

Checklist for relationships:

→ See Relationships YAML Reference for full documentation.


3. Create the Entity Knowledge File

File: .lynk/default/entities/{entity}/{entity}__knowledge.md

Create the entity subfolder first, then the knowledge file.

Checklist for knowledge:

→ See Knowledge File Reference for writing guidance.


4. Create the Entity Task Instructions File

File: .lynk/default/entities/{entity}/{entity}__task_inst__text_to_sql.md

Checklist for task instructions:

→ See Task Instructions Reference for guidance on what to include.


5. Add Evaluations

Add at least two evaluation test cases to evaluations.yml — one easy, one medium difficulty.

File: .lynk/default/evaluations.yml

Checklist for evaluations:

→ See Evaluations YAML Reference for full field documentation.


6. Verify

Before considering the entity complete:


Quick Reference

Step
File
Reference

1. Entity YAML

default/entities/{entity}.yml

2. Relationships

default/entities_relationships.yml

3. Knowledge

default/entities/{entity}/{entity}__knowledge.md

4. Task Instructions

default/entities/{entity}/{entity}__task_inst__text_to_sql.md

5. Evaluations

default/evaluations.yml

Last updated