custom-sql-to-data-model

custom-sql-to-data-model is a skill for Claude Code from twells89/sigma-skills. It costs 72 tokens per session (6,921 once invoked), scanned A, a copy of custom-sql-to-data-model, Apache-2.0.

A workflow for finding custom SQL inside Sigma workbooks and replacing repeated queries with reusable Sigma data models.

In plain words
What is it for?
Use it to scan workbooks, group identical queries, create or reuse one data model for each query, and reconnect the workbooks to those models.
Why use it?
It removes duplicate ad-hoc SQL and avoids maintaining the same query separately in multiple workbooks.

Skill for Claude Code

Written for Claude Code: user-invocable in frontmatter.

Part of the sigma-skills plugin — 6 skills shipped together

Good fit Use it to scan workbooks, group identical queries, create or reuse one data model for each query, and reconnect the workbooks to those models.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/twells89/sigma-skills/custom-sql-to-data-model
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 twells89/sigma-skills --skill custom-sql-to-data-model
Clone the repo
git clone --depth 1 https://github.com/twells89/sigma-skills

Made for: Claude Code.

Or install sigma-skills, the plugin that ships this one along with the rest of its 6 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 custom-sql-to-data-model

README.md
[![agentmods](https://agentmods.dev/badge/skills/twells89/sigma-skills/custom-sql-to-data-model/github.svg)](https://agentmods.dev/skills/twells89/sigma-skills/custom-sql-to-data-model)
Your own site
<a href="https://agentmods.dev/skills/twells89/sigma-skills/custom-sql-to-data-model"><img src="https://agentmods.dev/badge/skills/twells89/sigma-skills/custom-sql-to-data-model/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 custom-sql-to-data-model

Your own site · 80×15
<a href="https://agentmods.dev/skills/twells89/sigma-skills/custom-sql-to-data-model"><img src="https://agentmods.dev/badge/skills/twells89/sigma-skills/custom-sql-to-data-model.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 72 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 6,921 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin 88% copy Near-identical to another mod 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.00072 $0.06921
Opus 5.5 $0.00029 $0.02768
Sonnet 5.5 $0.00014 $0.01384
Haiku 4.5 $0.00007 $0.00692

Measured 28d ago against content hash 53da794f2463, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

custom-sql-to-data-model scanned grade A with 1 finding 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 28d ago.

The scan reads SKILL.md. This mod also ships 13 executable files (scripts/audit-formulas.rb, scripts/get_token.py, scripts/get-token.sh, …), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

curl -s -X POST \
Origin

This is a copy

88% identical to custom-sql-to-data-model — 48 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

custom-sql-to-data-model/SKILL.md · 626 lines

How it starts

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

Custom SQL → Data Model

End-to-end flow:

  1. Scan workbooks for source.kind: "sql" elements (Phase 1).
  2. Scan data models to index every existing SQL or warehouse-table source (Phase 1.5).
  3. Group manifest entries by normalized SQL; for each group, decide reuse an existing DM element or build a new one (Phase 1.5 → plan).
  4. Build DMs only for the to-build groups (Phase 2 / 3 / 4).
  5. Drive :swapSources from the plan, one workbook at a time (Phase 5).
  6. Audit and repair residual [Prefix/SNAKE_CASE] formulas left behind by Sigma's auto-match (Phase 6).

The key win versus the legacy GET/mutate/PUT approach: one workbook with N SQL elements is one API call with N entries in sourceMapping, and the auto-match handles formula rewrites — except for the rough edges Phase 6 catches.


Prerequisites

Required env var: SIGMA_BASE_URL. For an interactive terminal, prefer a one-time browser login through the sigma-api skill:

eval "$(bash <repo-root>/sigma-api/scripts/browser-login.sh)"

It keeps the refresh token exclusively in the OS keychain. For unattended hosts, set SIGMA_CLIENT_ID and SIGMA_CLIENT_SECRET (Sigma Administration → Developer Access) as the fallback.

The local get_token.py is a byte-identical synced copy of the canonical sigma-api provider. In default auto mode it uses a cached/refreshable browser session first, then client credentials. Override with SIGMA_AUTH_MODE / --auth-mode (auto, browser, or client-credentials). Before either auth mode succeeds, the provider requires a non-redirecting, valid-JSON GET /v2/whoami; 401, 403, non-JSON, and redirect responses fail without emitting or writing the token.

Default (shell-neutral, works in bash/zsh/PowerShell/cmd): mint a token with the stdlib-only Python script and let scripts/lib/sigma_rest.rb pick it up automatically from auth.json — no eval, no shell-specific syntax:

python3 scripts/get_token.py --workdir /tmp/custom-sql-run

Read the full file on GitHub · 626 lines

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. 28d ago Changed · +4 lines 53da794f2463
  2. 1mo ago Changed · +9 lines 1829d39db3ff
  3. 3mo ago First seen · 613 lines · 72 tokens per session scan A 0cc71542f104

Subscribe to this mod's changes

custom-sql-to-data-model is a skill published in the GitHub repository twells89/sigma-skills (16 stars, last pushed 28d ago), licensed Apache-2.0. It adds 72 tokens to every session and 6,921 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 1 finding (makes network calls). It is 88% identical to custom-sql-to-data-model, differing in 48 lines, and is treated as a copy.

Related

custom-sql-to-data-model compared with skills from other repositories

custom-sql-to-data-model next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
custom-sql-to-data-modeltwells89/sigma-skillsSkill1628d agoApache-2.0A72Claude Code
create-prprisma/ormSkill48ktodayApache-2.0A47Claude Code, Codex
schema-explorationlangchain-ai/deepagentsSkill32ktodayMITA57Claude Code, Codex
atlas-mssqlariga/atlasSkill8.9ktodayApache-2.0A163Claude Code
ha-data-storesshiwenwen/hope-agentSkill1.9kyesterdayMITA115Claude Code, Codex
bex-keyvaluebex-co/bexSkill1.6ktodayApache-2.0A117Claude Code, Codex
pentesting-mysqlxalgorix/xalgorixSkill1.6ktodayApache-2.0A65Claude Code, Codex