custom-sql-to-data-model

custom-sql-to-data-model is a skill for Claude Code from twells89/sigma-migration-skills. It costs 72 tokens per session (6,621 once invoked), scanned A, original, MIT.

Instructions for finding custom SQL in Sigma workbooks and replacing it with reusable Sigma data models.

In plain words
What is it for?
Use them to scan and group SQL queries, build or reuse data models, repoint workbooks, and repair formulas after source replacement.
Why use it?
They reduce duplicated queries across workbooks and provide a planned way to reuse existing models or create new ones before changing workbook sources.

Skill for Claude Code

Written for Claude Code: user-invocable in frontmatter.

Part of the sigma-authoring plugin — 5 skills shipped together

Good fit Use them to scan and group SQL queries, build or reuse data models, repoint workbooks, and repair formulas after source replacement.

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

Made for: Claude Code.

Or install sigma-authoring, the plugin that ships this one along with the rest of its 5 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-migration-skills/custom-sql-to-data-model/github.svg)](https://agentmods.dev/skills/twells89/sigma-migration-skills/custom-sql-to-data-model)
Your own site
<a href="https://agentmods.dev/skills/twells89/sigma-migration-skills/custom-sql-to-data-model"><img src="https://agentmods.dev/badge/skills/twells89/sigma-migration-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-migration-skills/custom-sql-to-data-model"><img src="https://agentmods.dev/badge/skills/twells89/sigma-migration-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,621 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. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 5 findings, up to high

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • high Supply Chain · line 250
    Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.
    Fix: Avoid downloading and executing remote scripts. Use trusted packages from PyPI/npm. If remote fetch is required, verify checksums and use HTTPS.
  • high Supply Chain · line 584
    Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.
    Fix: Avoid downloading and executing remote scripts. Use trusted packages from PyPI/npm. If remote fetch is required, verify checksums and use HTTPS.
  • medium Data Exfiltration · line 250
    Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
    Fix: Verify the destination URL is trusted and necessary. Remove or replace with documented APIs. Ensure no secrets, tokens, or PII are transmitted.
  • medium Data Exfiltration · line 378
    Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
    Fix: Verify the destination URL is trusted and necessary. Remove or replace with documented APIs. Ensure no secrets, tokens, or PII are transmitted.
  • medium Data Exfiltration · line 553
    Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
    Fix: Verify the destination URL is trusted and necessary. Remove or replace with documented APIs. Ensure no secrets, tokens, or PII are transmitted.
How audits are shown
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.00072 $0.06621
Opus 5 $0.00036 $0.03311
Sonnet 5 $0.00014 $0.01324
Haiku 4.5 $0.00007 $0.00662

Measured 9d ago against content hash 47243de973ee, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, 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 9d ago.

The scan reads SKILL.md. This mod also ships 16 executable files (scripts/audit-formulas.rb, scripts/bootstrap.ps1, scripts/bootstrap.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 \
plugins/sigma-authoring/skills/custom-sql-to-data-model/SKILL.md · 599 lines

How it starts

The opening of the file, as written. The whole thing — 599 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 vars: SIGMA_BASE_URL, SIGMA_CLIENT_ID, SIGMA_CLIENT_SECRET

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

This writes /tmp/custom-sql-run/auth.json (mode 0600). Every Ruby script in this skill checks $SIGMA_WORKDIR/auth.json (or ./auth.json) before falling back to a fresh client-credentials exchange, so point SIGMA_WORKDIR at the same directory (or run from inside it) and every subsequent ruby scripts/*.rb invocation authenticates without any shell-specific token plumbing:

export SIGMA_WORKDIR=/tmp/custom-sql-run
ruby scripts/scan-workbooks.rb

bash/zsh convenience (equivalent, but bash-only):

eval "$(bash scripts/get-token.sh)"

Tokens expire after ~1 hour. The Ruby scripts in this skill now auto-refresh on 401 via scripts/lib/sigma_rest.rb — full-site scans on large orgs (hundreds of workbooks, sometimes >1 hour total) no longer fail mid-run. If you still see Token missing or malformed after a refresh, re-run python3 scripts/get_token.py --workdir "$SIGMA_WORKDIR" (or eval "$(bash scripts/get-token.sh)" in bash) manually.

Read the full file on GitHub · 599 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. 9d ago First seen · 599 lines · 72 tokens per session scan A 47243de973ee

Subscribe to this mod's changes

custom-sql-to-data-model is a skill published in the GitHub repository twells89/sigma-migration-skills (14 stars, last pushed today), licensed MIT. It adds 72 tokens to every session and 6,621 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

create-pr

Creates a GitHub PR with a Linear-ticket-prefixed title and a decision-led, narrative description for prisma-next. Use when the user wants to create a pull request, open a PR, or submit changes for review.

prisma/orm · 47 tokens

schema-exploration

Lists tables, describes columns and data types, identifies foreign key relationships, and maps entity relationships in a database. Use when the user asks about database schema, table structure, column types, what tables exist, ERD, foreign keys, or how entities relate.

langchain-ai/deepagents · 57 tokens

ha-data-stores

Map of Hope Agent's local data stores and safe read-only query workflow. Use when the user asks where Hope Agent stores data, wants to inspect sessions/messages/memory/logs/background jobs/knowledge indexes/settings, asks the model to query local app data, or debugging requires checking persisted state. Trigger…

shiwenwen/hope-agent · 115 tokens

supabase

Supabase / PostgREST Row-Level-Security playbook — pull the anon (or leaked servicerole) key out of the frontend JS, map tables from the auto-generated OpenAPI spec, test anonymous RLS READ disclosures (PII/secret leaks), and anonymous RLS WRITE abuse (insert/update/delete — e.g. forging…

PentesterFlow/agent · 120 tokens

nornicdb-cypher-queries

Pick fast, predictable Cypher query shapes in NornicDB — point lookups, batch retrieval, pagination, search, traversal, batched UNWIND/MERGE writes, cleanup, multi-tenant isolation. Use when writing or reviewing Cypher whose latency or throughput matters; maps user intent to the executor's hot-path query templates.

orneryd/NornicDB · 79 tokens

dsql

Build with Aurora DSQL — manage schemas, execute queries, handle migrations, diagnose query plans, diagnose cluster performance, load data, and develop applications with a serverless, distributed SQL database. Covers IAM auth, multi-tenant patterns, MySQL-to-DSQL and PostgreSQL-to-DSQL schema conversion, foreign key…

awslabs/agent-plugins · 229 tokens