# Usage

Wren Engine CLI workflow guide for AI agents.

- Repository: https://github.com/Canner/WrenAI (18031 stars)
- Category: Data and ML
- License: Apache-2.0
- Last updated: 2026-10-30
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add Canner/WrenAI --skill usage -g -a claude-code -y`
Codex: `npx skills add Canner/WrenAI --skill usage -g -a codex -y`
Cursor: `npx skills add Canner/WrenAI --skill usage -g -a cursor -y`
Gemini CLI: `npx skills add Canner/WrenAI --skill usage -g -a gemini-cli -y`

## Description

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 data source, handle errors, or manage MDL changes via the wren CLI.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Wren Engine CLI, Agent Workflow Guide

> This guide is served by the `wren` CLI (`wren skills get usage`), so it always matches your installed wrenai version. Pull the deeper reference docs with `wren 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)

### Step 2, Check if the `wren` CLI is installed

Run `wren --version`. If the command is not found or errors:

1. Tell the user that the `wren` CLI is not installed.
2. Ask if you should help install it.
3. 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.yml` up to the repository root).
   If found, read the active profile with `cat ~/.wren/profiles.yml` or 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.

4. Install with the detected or chosen extra:
   ```bash
   # DuckDB (no extra needed)
   pip install "wrenai"

The rest: https://github.com/Canner/WrenAI/blob/HEAD/core/wren/src/wren/skills_content/usage/SKILL.md
