Building a Lynk Project
Build a complete Lynk semantic layer from scratch.
This walkthrough takes you from a blank project to a working, queryable, accurate semantic layer. It follows a recommended top-down approach: start with the big picture — what the business is and what its terms mean — then work down to the technical details of entity YAML. Every file is complete and uses a real running example — no placeholders.
What's in this section
Write domain-wide SQL rules (task instructions), clarification policy, and output format
10 min
Model a dimension entity, a fact entity, relationships, and feature chaining
20–25 min
Add evaluation test cases to validate accuracy before going to production
5–10 min
Read these pages in order.
What you can do with this
The running example is Grove — a B2B SaaS company. By the end you will have built:
A knowledge file and glossary defining what Grove is and what its terms mean
Two domains with domain-specific context
Two entities (
customerandsubscription) connected by a relationship with feature chainingEvaluation test cases that validate agent accuracy before going live
Where to go next:
Adding to an existing project instead of starting fresh? → Guides
Need to understand how a specific concept works? → Concepts
Need exact field documentation? → File-Types Reference
Project Structure
The canonical folder layout for a Lynk semantic layer project.
Naming Conventions
Lynk does not enforce file names — scoping is controlled by frontmatter fields, not paths or names. The patterns below are a recommended convention to keep context files predictable and easy to navigate. You can use different names as long as the frontmatter is correct.
We recommend using double underscore (__) as the delimiter in context file names.
{entity}__knowledge.md
Knowledge file scoped to this entity
{entity}__task_inst__text_to_sql.md
Task instructions for text-to-sql, scoped to this entity
{domain}__task_inst__text_to_sql.md
Task instructions for text-to-sql, scoped to the domain
{domain}_glossary.md
Glossary file for the domain (single underscore — standalone file)
What Goes Where
Entity YAML
default/entities/{entity}.yml
Entity
Agent + Tasks
Entity knowledge
default/entities/{entity}/{entity}__knowledge.md
Entity + domain
Agent + Tasks
Entity task instructions
default/entities/{entity}/{entity}__task_inst__text_to_sql.md
Entity + domain
Tasks only
Domain knowledge
default/domain_context/{domain}_knowledge.md
Domain-wide
Agent + Tasks
Domain task instructions
default/domain_context/{domain}__task_inst__text_to_sql.md
Domain-wide
Tasks only
Glossary
default/{domain}_glossary.md
Domain-wide
Agent + Tasks
Behavior files
default/agent/{kind}.md
Domain-wide
Agent only
Relationships
default/entities_relationships.yml
All entities
Agent + Tasks
Evaluations
default/evaluations.yml
Domain
Evals only
The Entity Subfolder Pattern
Every entity YAML file has a sibling subfolder with the same name. Context files for that entity live inside it.
When adding a new entity, create both the YAML file and the subfolder.
Custom Domain Rules
Custom domains override the default — they don't replace it.
Entity YAML files always live in
default/entities/. If a custom domain only needs different context, add context files only — not a new entity YAML.Create a custom domain entity YAML only if feature definitions must differ. For example, if
financedefinesis_activedifferently thandefault, create.lynk/finance/entities/customer.ymlwith just the changed features.Custom domain context files shadow the default. If
marketing/entities/customer/customer__knowledge.mdexists, it takes precedence over thedefaultversion for queries in themarketingdomain.
Domain Feature Resolution
When the agent queries an entity in a specific domain, features resolve in this priority order:
Domain-specific feature (in the custom domain's entity YAML) — highest priority
Multi-domain feature (matched by
domain: ["marketing", "sales"]in the feature)Wildcard feature (matched by
domain: "*")Default feature (in
default/entities/{entity}.yml) — lowest priority, the fallback
Last updated