Langsung ke konten
Skillpedia
Database18k Β· #10727

generate-mdl

Fungsinya

Skill ini memandu pembuatan proyek Wren MDL dari basis data yang sudah ada, mencakup penemuan skema, pembersihan tipe, dan pembuatan YAML dengan baris perintah wren. Skill ini untuk analis yang ingin menyiapkan lapisan semantik di atas basis data yang sudah mereka pakai.

Kapan dipakai

  • βœ“Saat Anda ingin menyiapkan proyek Wren baru untuk basis data yang sudah Anda miliki.
  • βœ“Saat tim Anda sudah mencatat basis data di OpenMetadata dan Anda ingin mengimpornya.
  • βœ“Saat Anda memerlukan kerangka proyek semantik dari tabel dan relasi yang sudah ada.

Link skill

https://github.com/Canner/WrenAI/blob/main/core/wren/src/wren/skills_content/generate-mdl/SKILL.md

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/Canner/WrenAI/blob/main/core/wren/src/wren/skills_content/generate-mdl/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit β†’

Contoh permintaan ke AI

β€œBuat proyek Wren dari basis data penjualan Postgres kami, dengan menyimpulkan relasi antar tabel dan memastikan proyeknya berhasil dibangun.”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Skill ini meminta agent membaca skema dengan alat basis datanya, menormalkan tipe data, menghasilkan berkas proyek dengan CLI wren, lalu memvalidasi hasil build.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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

  • wren CLI 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:

  1. Tell the user that an existing wren project was detected and show its path.
  2. Ask:
    • Reset β€” wipe the existing project (models/, views/, relationships.yml, knowledge/, and rebuild wren_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.

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.

  1. 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 debug to check config
    • If raw SQL via wren: wren --sql "SELECT 1" (requires profile or connection file)
  2. 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
Pertanyaan umum

Apa itu MDL?

Itu adalah format model semantik yang dipakai Wren untuk mendeskripsikan tabel, kolom, dan relasi dalam YAML biasa.

Bisakah impor dari katalog data?

Bisa. Skill ini menjelaskan impor dari OpenMetadata, yang membawa deskripsi dan foreign key ke dalam proyek.

Apakah perlu kredensial basis data?

Ya. Agent Anda memerlukan koneksi yang berfungsi dan kredensial yang tersedia di lingkungannya untuk membaca skema.

Detail

Deskripsi asli dari pembuat

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

Popularitas

Bintang GitHub
18k
Peringkat
#10727
Lisensi
β€”
Diperbarui
2/11/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa