wren-sql

wren-sql is a skill for Claude Code from Canner/wren-engine. It costs 68 tokens per session (1,232 once invoked), scanned A, original, Apache-2.0.

A guide for writing and fixing SQL queries in Wren Engine. Wren uses a semantic layer, meaning queries refer to defined business models and fields before they reach the underlying database.

In plain words
What is it for?
Use it to create or correct Wren SQL, work with arrays, structs, and JSON-like data, handle dates and times, write calculated fields, and investigate query errors.
Why use it?
It explains why ordinary table names or database-specific syntax may fail and helps diagnose errors involving dates, nested values, calculated fields, and BigQuery.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the wren plugin — 8 skills shipped together

Good fit Use it to create or correct Wren SQL, work with arrays, structs, and JSON-like data, handle dates and times, write calculated fields, and investigate query errors.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/canner/wren-engine/wren-sql
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add Canner/wren-engine --skill wren-sql
Clone the repo
git clone --depth 1 https://github.com/Canner/wren-engine

Made for: Claude Code.

Or install wren, the plugin that ships this one along with the rest of its 8 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for wren-sql

README.md
[![agentmods](https://agentmods.dev/badge/skills/canner/wren-engine/wren-sql/github.svg)](https://agentmods.dev/skills/canner/wren-engine/wren-sql)
Your own site
<a href="https://agentmods.dev/skills/canner/wren-engine/wren-sql"><img src="https://agentmods.dev/badge/skills/canner/wren-engine/wren-sql/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for wren-sql

Your own site · 80×15
<a href="https://agentmods.dev/skills/canner/wren-engine/wren-sql"><img src="https://agentmods.dev/badge/skills/canner/wren-engine/wren-sql.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 68 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,232 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00068 $0.01232
Opus 5.5 $0.00027 $0.00493
Sonnet 5.5 $0.00014 $0.00246
Haiku 4.5 $0.00007 $0.00123

Measured 3mo ago against content hash 85290979c289, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

wren-sql scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills-archive/wren-sql/SKILL.md · 133 lines

How it starts

The opening of the file, as written. The whole thing — 133 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Wren SQL

Version check

Silently fetch https://raw.githubusercontent.com/Canner/wren-engine/main/skills/versions.json. Compare the wren-sql key with this skill's version (from the frontmatter above). If the remote version is newer, notify the user before proceeding:

A newer version of the wren-sql skill is available. Update with:

npx skills add Canner/wren-engine --skill wren-sql --agent claude-code

Then continue with the workflow below regardless of update status.


Wren Engine translates SQL through a semantic layer (MDL — Model Definition Language) before executing it against a backend database. SQL must target MDL model names, not raw database tables.

For specific topics, load the relevant reference file:

Topic Reference
SQL error diagnosis and correction references/correction.md
Date/time functions and intervals references/datetime.md
ARRAY, STRUCT, JSON/VARIANT types references/types.md
BigQuery dialect quirks references/bigquery.md

Context

  • You are querying a semantic layer, not a database directly.
  • Only use model/view/column names defined in the MDL — never raw database table references.
  • Wren Engine uses a generic SQL dialect similar to ANSI SQL (DataFusion/Postgres/DuckDB), but with differences.
  • Check the dataSource field to identify the backend and apply dialect-specific rules if needed.

Core SQL Rules

  • Only SELECT statements. No DELETE, UPDATE, INSERT.
  • Only use tables and columns from the MDL schema.
  • Do not include comments in generated SQL.
  • Prefer CTEs over subqueries.
  • Identifiers are case-sensitive. Quote identifiers containing unicode, special characters (except _), or starting with a digit using double quotes.
    • Examples: "客户"."姓名", "table-name"."col", "123column"
  • Identifier quotes: " (double quotes). String literal quotes: ' (single quotes).
  • For specific date queries, use a range:
    WHERE ts >= CAST('2024-11-01 00:00:00' AS TIMESTAMP WITH TIME ZONE)
      AND ts <  CAST('2024-11-02 00:00:00' AS TIMESTAMP WITH TIME ZONE)
    
  • For ranking, use DENSE_RANK() + WHERE. Include the ranking column in SELECT.
  • Avoid correlated subqueries — use JOINs instead.
  • Use SAFE_CAST when casting might fail: SAFE_CAST(col AS INT)

Read the full file on GitHub · 133 lines

Files

What ships with it

4 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3mo ago First seen · 133 lines · 68 tokens per session scan A 85290979c289

Subscribe to this mod's changes

wren-sql is a skill published in the GitHub repository Canner/wren-engine (659 stars, last pushed 6mo ago), licensed Apache-2.0. It adds 68 tokens to every session and 1,232 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

wren-sql compared with skills from other repositories

wren-sql next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
wren-sqlCanner/wren-engineSkill6596mo agoApache-2.0A68Claude Code
malloy-lookml-reviewmalloydata/publisherSkill136todayMITA58Claude Code, Codex
effective-dbt-sqllightdash/lightdashSkill6.3ktodaynoneA0Claude Code, Codex
ecommerce-data-warehousefinsilabs/awesome-ecommerce-skillsSkill691mo agoMITA35Claude Code, Codex
analytical-databases-expertpersonamanagmentlayer/pclSkill461mo agoApache-2.0A100Claude Code
business-intelligence-expertpersonamanagmentlayer/pclSkill461mo agoApache-2.0A64Claude Code
alibabacloud-data-agent-skillaliyun/data-agent-skillSkill59todaynoneA159Claude Code, Codex