generate-mdl
Skill này làm gì
Skill này hướng dẫn xây dựng dự án Wren MDL từ một cơ sở dữ liệu có sẵn, gồm khám phá lược đồ, làm sạch kiểu dữ liệu và sinh YAML bằng dòng lệnh wren. Skill dành cho nhà phân tích muốn thiết lập lớp ngữ nghĩa trên cơ sở dữ liệu họ đang dùng.
Khi nào nên dùng
- ✓Khi bạn muốn thiết lập một dự án Wren mới cho cơ sở dữ liệu bạn đã có.
- ✓Khi nhóm của bạn đã lập danh mục cơ sở dữ liệu trong OpenMetadata và bạn muốn nhập vào.
- ✓Khi bạn cần khởi tạo một dự án ngữ nghĩa từ các bảng hiện có và quan hệ giữa chúng.
Liên kết skill
https://github.com/Canner/WrenAI/blob/main/core/wren/src/wren/skills_content/generate-mdl/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Hãy tạo dự án Wren từ cơ sở dữ liệu Postgres bán hàng của chúng tôi, suy ra quan hệ giữa các bảng và kiểm tra xem dự án có build được không.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill để agent của bạn đọc lược đồ bằng các công cụ cơ sở dữ liệu, chuẩn hóa kiểu dữ liệu, sinh file dự án bằng wren CLI và xác thực bản build.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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
Câu hỏi thường gặp
MDL là gì?
Đó là định dạng mô hình ngữ nghĩa mà Wren dùng để mô tả bảng, cột và quan hệ bằng YAML đơn giản.
Nó có thể nhập từ danh mục dữ liệu không?
Có. Skill mô tả việc nhập từ OpenMetadata, công cụ này mang theo mô tả và khóa ngoại vào dự án.
Nó có cần thông tin xác thực cơ sở dữ liệu không?
Có. Agent của bạn cần một kết nối đang hoạt động và thông tin xác thực có sẵn trong môi trường để đọc lược đồ.
Chi tiết
Mô tả gốc của tác giả
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
Độ phổ biến
- Sao GitHub
- 18k
- Vị trí xếp hạng
- #10727
- Giấy phép
- —
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
dlt-connector
18kGiúp agent của bạn tải dữ liệu từ các công cụ SaaS như HubSpot hoặc Stripe vào một file DuckDB cục bộ, sẵn sàng cho phân tích SQL với Wren.
enrich-context
18kGiúp agent của bạn bổ sung ý nghĩa kinh doanh cho một dự án dữ liệu Wren, như đơn vị đo, giá trị liệt kê, từ đồng nghĩa và các chỉ số chuẩn.
genbi
18kGiúp agent của bạn biến dự án Wren thành bảng điều khiển trên trình duyệt có thể chia sẻ và triển khai lên tài khoản hosting của bạn.
onboarding
18kGiúp agent của bạn thiết lập Wren Engine từ đầu: kiểm tra môi trường, tạo dự án, kết nối cơ sở dữ liệu và chạy truy vấn đầu tiên.
Skill tương tự
discrawl
394kCho phép agent của bạn tìm kiếm và tóm tắt kho lưu trữ tin nhắn Discord trên máy, kiểm tra độ mới của dữ liệu và đọc tin nhắn trực tiếp.
clickhouse-io
280kGiúp agent của bạn tối ưu truy vấn và schema trong ClickHouse theo thực hành tốt nhất cho phân tích dữ liệu hiệu năng cao khi truy vấn chậm.
scientific-db-pubmed-database
280kGiúp agent của bạn tìm bài báo khoa học trong lĩnh vực y sinh. Hữu ích cho nghiên cứu cần thông tin y khoa cụ thể.