usage

Guides AI agents through Wren CLI workflows for querying databases via the MDL semantic layer.

17.7k|2.0k|Updated Mar 13, 2024
One-click install
npx skills add https://github.com/Canner/WrenAI --skill usage-canner
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: usage
Source: https://github.com/Canner/WrenAI/tree/main/core/wren/src/wren/skills_content/usage
Command: npx skills add https://github.com/Canner/WrenAI --skill usage-canner

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Answering business data questions with AI agents often fails because agents guess table names, write dialect-specific SQL, and lose context between sessions. This Skill gives agents a governed workflow for the Wren CLI so they query through a semantic layer, recall past queries, and recover from errors systematically. ## Core Features & Use Cases - End-to-end data question workflow: Gather schema context with wren memory fetch, recall past queries as few-shot examples, write dialect-neutral SQL against MDL models, execute, and store confirmed results. - Structured error recovery: Diagnose failures with wren dry-plan to separate MDL-level issues (wrong model or column names) from database-level issues (type mismatches, permissions, timeouts). - Cube query support: Answer aggregation questions like "revenue by month" or "top N customers" through wren cube query instead of hand-writing GROUP BY SQL. - Use Case: A user asks "what were our top 5 customers by revenue last quarter?" The agent recalls similar past queries, fetches schema context, checks for a matching cube, executes the query through the semantic layer, and stores the confirmed result for future sessions. ## Quick Start Ask the agent to answer a business data question such as "show me monthly revenue for 2024" using the wren CLI and let it follow the guided workflow.

Frequently Asked Questions about usage

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I answer data questions with the Wren CLI?▼

Fetch schema context with wren memory fetch, recall similar past queries with wren memory recall, then write SQL against MDL model names and execute with wren --sql. Store successful queries with wren memory store so future sessions can reuse them.

How do I debug SQL errors in Wren Engine?▼

Run wren dry-plan with the failed SQL to separate MDL-level errors from database-level errors. If dry-plan fails, check model and column names with wren memory fetch; if it succeeds but execution fails, compare the expanded SQL against the database error message.

Which databases does the Wren CLI support?▼

Wren supports postgres, mysql, bigquery, snowflake, clickhouse, trino, mssql, databricks, redshift, spark, athena, and oracle through pip extras, with DuckDB included by default. Install the matching extra such as pip install "wrenai[postgres]".

When should I use wren cube query instead of raw SQL?▼

Use wren cube query for aggregation questions like totals by month or top-N rankings when the MDL defines cubes covering the question. Fall back to wren --sql for custom JOINs, window functions, CTEs, subqueries, or when no cubes are defined.

When should I not store a query in Wren memory?▼

Do not store queries that failed, returned results the user rejected, or are exploratory such as SELECT * with LIMIT. The CLI auto-detects exploratory queries, and raw SQL without a natural language question should also be skipped.