usage
它能做什么
这个技能指导使用 Wren 命令行回答数据问题,包括收集结构上下文、通过语义层编写 SQL 并运行。适合提出“多少”“前十名”或“趋势”这类问题的分析师和业务用户。
适用场景
- ✓当你询问某段时期内有多少订单、客户或金额时。
- ✓当你要求查看业务数据的排行榜、细分或趋势时。
- ✓当你希望从已连接的数据库中获取业务指标的报告或分析时。
技能链接
https://github.com/Canner/WrenAI/blob/main/core/wren/src/wren/skills_content/usage/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“上个季度我们新增了多少客户?与前一个季度相比情况如何?”
每周 5 个新技能,1 分钟读完。
工作原理
该技能让你的智能体检查安装,读取项目的结构和过往查询,通过语义模型编写 SQL,运行它,并展示结果。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Wren Engine CLI — Agent Workflow Guide
This guide is served by the
wrenCLI (wren skills get usage), so it always matches your installed wrenai version. Pull the deeper reference docs withwren skills get usage --full.
Preflight — Verify environment and installation
Goal: Ensure the wren CLI is available before entering any workflow.
Step 1 — Check Python virtual environment
Run python -c "import sys; print(sys.prefix)" (or equivalent) to determine
whether a virtual environment is active.
- If no venv is active, warn the user and ask whether to:
- Create one (e.g.,
python -m venv .venv && source .venv/bin/activate) - Continue without a venv (not recommended — may pollute global packages)
- Create one (e.g.,
Step 2 — Check if the wren CLI is installed
Run wren --version. If the command is not found or errors:
Tell the user that the
wrenCLI is not installed.Ask if you should help install it.
If the user agrees, determine the datasource extra to install:
Auto-detect from project: Check whether the current directory is inside a wren project (look for
wren_project.ymlup to the repository root). If found, read the active profile withcat ~/.wren/profiles.ymlor look for a datasource hint in the project's profile configuration. Extract the datasource type from there.Ask the user: If no project is detected or no datasource can be inferred, ask the user which database they plan to connect to. Valid extras:
postgres(for Aurora Postgres),mysql(for Aurora MySQL),bigquery,snowflake,clickhouse,trino,mssql,databricks,redshift,spark,athena,oracle. DuckDB is included by default — no extra needed.Install with the detected or chosen extra:
# DuckDB (no extra needed) pip install "wrenai" # Other datasources pip install "wrenai[<datasource>]"To also enable semantic memory, interactive prompts, and web UI (recommended):
pip install "wrenai[<datasource>,main]" # or for DuckDB: pip install "wrenai[main]"Verify:
wren --version
If wren --version succeeds, proceed to the relevant workflow below.
The wren CLI queries databases through an MDL (Model Definition Language) semantic layer. You write SQL against model names, not raw tables. The engine translates to the target dialect.
Two things drive everything:
- Profile — database connection + datasource type, managed via
wren profile(stored in~/.wren/profiles.yml) - Project — MDL model definitions in YAML, compiled to
target/mdl.jsonviawren context build
The CLI reads the active profile for connection info and datasource. Use wren profile list to see which profile is active, wren profile switch <name> to change it. dry-plan also accepts --datasource / -d for transpile-only use without a profile.
For memory-specific decisions, see the memory reference (run wren skills get usage --full).
For SQL syntax, CTE-based modeling, and error diagnosis, see the wren-sql reference (run wren skills get usage --full).
For project structure, MDL field definitions, and CLI workflow details, see the documentation.
Workflow 1: Answering a data question
Step 1 — Gather context
| Situation | Command |
|---|---|
| Default | wren memory fetch -q "<question>" |
| Need specific model's columns | wren memory fetch -q "..." --model <name> --threshold 0 |
| Memory not installed | Read target/mdl.json in the project directory, or run wren context show |
If this is the first query in the conversation, also run:
wren context instructions
If it returns content, treat it as rules that override defaults — apply them to all subsequent queries in this session.
Step 2 — Recall past queries
wren memory recall -q "<question>" --limit 3
Use results as few-shot examples. Skip if empty.
Step 2.5 — Assess complexity (before writing SQL)
If the question involves any of the following, consider decomposing:
- Multiple metrics or aggregations (e.g., "churn rate AND expansion revenue")
- Multi-step calculations (e.g., "month-over-month growth rate")
- Comparisons across segments (e.g., "by plan tier, by region")
- Time-series analysis requiring baseline + change (e.g., "retention curve")
Decomposition strategy:
- Identify the sub-questions (e.g.,
常见问题
我需要自己编写 SQL 吗?
不需要。你的智能体会使用项目的定义,通过语义层编写 SQL。
它会从过去的问题中学习吗?
会。该技能提到会回忆过去的查询,并从已确认的结果中学习。
如果环境中缺少该工具怎么办?
该技能会先检查 Wren 命令行,如果不可用,会提出为你安装。
详情
作者的原始描述
Wren Engine CLI workflow guide for AI agents. Answer data questions end-to-end using the wren CLI: gather schema context, recall past queries, write SQL through the MDL semantic layer, execute, and learn from confirmed results. Use when: user asks a data question, requests a report or analysis, asks about metrics, revenue, customers, orders, trends, or any business data; user says 'how many', 'show me', 'what is the', 'top N', 'compare', 'trend', 'growth', 'breakdown'; user wants to explore, analyze, filter, aggregate, or summarize data from a database; agent needs to query data, connect a dat
repo: Canner/WrenAI
热度
- GitHub 星标
- 18k
- 排名
- #10729
- 许可证
- —
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
dlt-connector
18k帮你的智能体把 HubSpot、Stripe 等 SaaS 工具的数据加载到本地 DuckDB 文件中,以便用 Wren SQL 进行分析。
enrich-context
18k帮你的智能体为 Wren 数据项目补充业务含义,例如单位、枚举值、同义词和标准指标。
genbi
18k帮你的智能体把 Wren 数据项目转化为可分享的浏览器仪表板,并部署到用户自己的托管账户。
generate-mdl
18k帮你的智能体通过探索数据库结构、规范化类型并生成 YAML 文件,来创建 Wren 语义项目。