Skip to main content

Skills

Wren Engine provides skills — reusable AI agent workflow guides that teach Claude Code (or other AI coding agents) how to use the Wren CLI effectively. Skills are not plugins or extensions; they are structured prompts with decision trees that guide an agent through multi-step tasks.

Available skills

SkillPurpose
wren-usageDay-to-day workflow: gather schema context, recall past queries, write SQL, execute, store results
wren-generate-mdlOne-time setup: explore database schema, normalize types, scaffold MDL YAML project

Installation

# All skills at once
npx skills add Canner/wren-engine --skill '*' --agent claude-code

# Or via install script
curl -fsSL https://raw.githubusercontent.com/Canner/wren-engine/main/skills/install.sh | bash

After installation, start a new Claude Code session — skills are loaded at session start.

Update skills

Skills check for updates automatically and notify the agent when a newer version is available. To force-update:

# All skills
curl -fsSL https://raw.githubusercontent.com/Canner/wren-engine/main/skills/install.sh | bash -s -- --force

# Single skill
curl -fsSL https://raw.githubusercontent.com/Canner/wren-engine/main/skills/install.sh | bash -s -- --force wren-generate-mdl

wren-usage

The primary skill for day-to-day querying. It guides the agent through a complete query lifecycle.

Query workflow

User asks a question

├── 1. Gather context
│ wren memory fetch -q "..."
│ wren context instructions (first query only)

├── 2. Recall past queries
│ wren memory recall -q "..." --limit 3

├── 3. Assess complexity
│ Simple → write SQL directly
│ Complex → decompose into sub-questions

├── 4. Write and execute SQL
│ Simple: wren --sql "..."
│ Complex: wren dry-plan first, then execute

└── 5. Store result
wren memory store --nl "..." --sql "..."

Error recovery

The skill includes a two-layer error diagnosis strategy:

LayerToolDiagnoses
MDL-levelwren dry-plan failsWrong model/column names, missing relationships
DB-levelwren dry-plan succeeds but execution failsType mismatch, permissions, dialect issues

The agent checks dry-plan output first to isolate whether the error is in the semantic layer or the database.

Additional workflows

WorkflowWhen
Connect new data sourcewren profile addwren context init → build → index
After MDL changeswren context validatewren context buildwren memory index

Reference files

The skill includes two reference documents loaded on demand:

  • memory.md — Decision logic for when to index, fetch, store, and recall. Covers the hybrid retrieval strategy, store-by-default policy, and full lifecycle examples.
  • wren-sql.md — How the CTE-based rewrite pipeline works. Explains how the engine injects model CTEs, what SQL features are supported, and how to use dry-plan to diagnose errors layer by layer.

wren-generate-mdl

A one-time setup skill that walks the agent through creating an MDL project from a live database.

Seven-phase workflow

PhaseGoalKey actions
1. ConnectConfirm database accessTest connection via SQLAlchemy, driver, or wren profile debug
2. DiscoverCollect schema metadataIntrospect tables, columns, types, foreign keys
3. NormalizeConvert typeswren utils parse-type or Python parse_type()
4. ScaffoldWrite YAML projectwren context init, create model files, relationships
5. ValidateCheck integritywren context validatewren context build
6. IndexInitialize memorywren memory index
7. IterateRefine with userAdd descriptions, calculated columns, views

Schema discovery methods

The skill is tool-agnostic — it uses whatever database access the agent has:

MethodBest for
SQLAlchemy inspect()Most databases — richest metadata (PKs, FKs, types)
Database driverWhen SQLAlchemy is unavailable — query information_schema directly
Raw SQL via wrenBootstrapping when no Python driver is installed

Type normalization

Raw database types must be normalized before use in MDL:

# Single type
wren utils parse-type --type "character varying(255)" --dialect postgres
# → VARCHAR(255)

# Batch (stdin JSON)
echo '[{"column":"id","raw_type":"int8"}]' | wren utils parse-types --dialect postgres

Or via Python:

from wren.type_mapping import parse_type
normalized = parse_type("character varying(255)", "postgres") # → "VARCHAR(255)"

Skill structure

Skills are installed to ~/.claude/skills/ with this layout:

~/.claude/skills/
├── wren-usage/
│ ├── SKILL.md # Main workflow instructions
│ └── references/
│ ├── memory.md # Memory command decision logic
│ └── wren-sql.md # CTE rewrite pipeline reference
└── wren-generate-mdl/
└── SKILL.md # MDL generation workflow

Each SKILL.md has YAML frontmatter with name, description, version, and license. The agent loads the main SKILL.md when triggered, and loads reference files on demand when deeper context is needed.