generate-mdl
What it does
This skill guides building a Wren MDL project from an existing database, including schema discovery, type cleanup and YAML generation with the wren command line. It is for analysts who want to set up a semantic layer over a database they already use.
When to use it
- βWhen you want to set up a new Wren project for a database you already have.
- βWhen your team already catalogs the database in OpenMetadata and you want to import it.
- βWhen you need to scaffold a semantic project from existing tables and their relationships.
Skill link
https://github.com/Canner/WrenAI/blob/main/core/wren/src/wren/skills_content/generate-mdl/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βCreate a Wren project from our Postgres sales database, inferring the table relationships and checking that the project builds.β
5 new skills a week. 1 minute to read.
How it works
The skill has your agent read the schema with its database tools, normalize data types, generate the project files with the wren CLI and validate the build.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Generate Wren MDL β CLI Agent Workflow
Builds an MDL project by discovering database schema and converting it into Wren's YAML project format. The agent uses whatever database tools are available in its environment for introspection; the wren CLI handles type normalization, validation, and build.
For memory and query workflows after setup, run wren skills get usage.
Prerequisites
wrenCLI installed (pip install "wrenai[<datasource>]")- A working database connection (credentials available to the agent)
- A connection profile (set up via
wren profile add) or connection info ready
Alternative β import from an OpenMetadata catalog
If the user's team already catalogs this database in OpenMetadata, import
from the catalog instead of introspecting the live database. The import
carries curated table/column descriptions, tags, owners, and foreign-key
constraints (as relationships.yml), so the join-inference work in Phase 4
is mostly done:
wren context import openmetadata --host <om_url> --token <om_token> \
--service <om_service> --database <db> --schema <schema> --dry-run
wren context import openmetadata --host <om_url> --token <om_token> \
--service <om_service> --database <db> --schema <schema>
Ask the user for the OpenMetadata URL, a read-only bot or personal access
token, and the service name as it appears in OpenMetadata. --table
(repeatable) narrows the import. Without --force the command only adds
files that do not exist and lists the collisions it left untouched; --force
regenerates from OpenMetadata and discards local edits to generated files β
confirm with the user before using it. Relationships come from foreign keys
only; review whether additional joins are needed (Phase 4), then bind a
profile and finish with Phase 5 (wren context validate β wren context build).
Phase 0 β Detect existing project
Goal: If the current directory is already inside a wren project, let the user decide how to proceed.
Check whether wren_project.yml exists in the current working directory
(or any parent up to the repository root). If found:
- Tell the user that an existing wren project was detected and show its path.
- Ask:
- Reset β wipe the existing project (
models/,views/,relationships.yml,knowledge/, and rebuildwren_project.yml) and regenerate from scratch in the same directory. - New path β keep the existing project untouched and choose a
different directory for the new project. Ask the user for the new path,
then
wren context init --path <new_path>and continue from Phase 1 using that path.
- Reset β wipe the existing project (
If no existing project is detected, proceed directly to Phase 1.
Phase 1 β Establish connection and scope
Goal: Confirm the agent can reach the database and agree on scope with the user.
Verify connectivity using whichever tool is available:
- If SQLAlchemy:
engine.connect()test - If database driver: simple query like
SELECT 1 - If wren profile exists:
wren profile debugto check config - If raw SQL via wren:
wren --sql "SELECT 1"(requires profile or connection file)
- If SQLAlchemy:
Ask the user:
- Which schema(s) or dataset(s) to include (skip if only one exists)
- Whether to include all tables or a subset
- The datasource type for wren (e.g.,
postgres(including Aurora),mysql(including Aurora),bigquery,snowflake) β needed for type normalization dialect
Phase 2 β Discover schema
Goal: Collect table names, column names, column types, and constraints.
Use whatever introspection method is available. Here are common approaches ranked by convenience:
Option A: SQLAlchemy (recommended if available)
from sqlalchemy import create_engine, inspect
engine = create_engine(connection_url)
inspector = inspect(engine)
tables = inspector.get_table_names(schema="public")
for table in tables:
columns = inspector.get_columns(table, schema="public")
# columns β [{"name": "id", "type": INTEGER(), "nullable": False, ...}]
pk = inspector.get_pk_constraint(table, schema="public")
# pk β {"constrained_columns": ["id"], "name": "orders_pkey"}
fks = inspector.get_foreign_keys(table, schema="public")
# fks β [{"constrained_columns": ["customer_id"],
# "referred_table": "customers",
# "referred_columns": ["id"]}]
Option B: Database-specific driver
- psycopg / asyncpg (Postgres): Query `informatio
FAQ
What is MDL?
It is the semantic model format Wren uses to describe tables, columns and relationships in plain YAML.
Can it import from a data catalog?
Yes. The skill describes importing from OpenMetadata, which carries descriptions and foreign keys into the project.
Does it need database credentials?
Yes. Your agent needs a working connection and credentials available in its environment to read the schema.
Details
Original description by the author
Generate a Wren MDL project by exploring a database with available tools (SQLAlchemy, database drivers, MCP connectors, or raw SQL). Guides agents through schema discovery, type normalization, and MDL YAML generation using the wren CLI. Use when: user wants to create or set up a new MDL, onboard a new data source, or scaffold a project from an existing database.
repo: Canner/WrenAI
Popularity
- GitHub stars
- 18k
- Ranking position
- #10727
- License
- β
- Updated
- 11/2/2026
Comments
- β¦
More skills from this repository
dlt-connector
18kHelps your agent load data from SaaS tools such as HubSpot or Stripe into a local DuckDB file, ready for Wren SQL analysis.
enrich-context
18kHelps your agent add business meaning to a Wren data project, such as units, enum values, synonyms and standard metrics.
genbi
18kHelps your agent turn a Wren data project into a shareable browser dashboard and deploy it to the user's own hosting account.
onboarding
18kHelps your agent set up Wren Engine from scratch: check the environment, create a project, connect a database and run a first query.
Similar skills
discrawl
394kLets your agent search and summarize a saved local archive of Discord messages, check how fresh it is, and read direct messages.
clickhouse-io
280kHelps your agent optimize queries and schemas in ClickHouse databases. It applies best practices for high-performance analytical workloads. Use when analytical queries are too slow.
scientific-db-pubmed-database
280kHelps your agent search for scientific articles in the biomedical field. It's useful for research needing specific medical information.