historic_sql_patterns

historic_sql_patterns is a skill for Claude Code, Codex from Kaelio/ktx. It costs 28 tokens per session (964 once invoked), scanned A, original, Apache-2.0.

A detector for repeated analytical questions that use more than one database table, based on a limited set of historic SQL patterns. It produces structured evidence for a documentation system.

In plain words
What is it for?
Use it to find recurring cross-table analysis, verify the tables and columns involved, and create evidence for durable wiki or semantic-layer documentation.
Why use it?
It turns repeated query behavior into reusable knowledge while requiring join columns to be checked against both tables. This reduces the risk of documenting relationships that are not present in the data.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to find recurring cross-table analysis, verify the tables and columns involved, and create evidence for durable wiki or semantic-layer documentation.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/kaelio/ktx/historic_sql_patterns
About the project

Kaelio/ktx is a context layer that helps AI agents query analytical databases using company knowledge, approved metrics, table metadata, and relationships between columns. Data teams use it to make warehouse queries more accurate and consistent with their organization's definitions. Its catalogue add-ons teach agents how to use ktx and its data-querying interfaces.

Kaelio/ktx · 1,618 stars · on GitHub · docs.kaelio.com

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 Kaelio/ktx --skill historic_sql_patterns
Clone the repo
git clone --depth 1 https://github.com/Kaelio/ktx

Made for: Claude Code, Codex.

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 historic_sql_patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/kaelio/ktx/historic_sql_patterns/github.svg)](https://agentmods.dev/skills/kaelio/ktx/historic_sql_patterns)
Your own site
<a href="https://agentmods.dev/skills/kaelio/ktx/historic_sql_patterns"><img src="https://agentmods.dev/badge/skills/kaelio/ktx/historic_sql_patterns/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 historic_sql_patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/kaelio/ktx/historic_sql_patterns"><img src="https://agentmods.dev/badge/skills/kaelio/ktx/historic_sql_patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 28 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 964 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. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
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.00028 $0.00964
Opus 5.5 $0.00011 $0.00386
Sonnet 5.5 $0.00006 $0.00193
Haiku 4.5 $0.00003 $0.00096

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

Security

Grade A, and why

historic_sql_patterns 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 1mo 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.

packages/cli/src/skills/historic_sql_patterns/SKILL.md · 90 lines

How it starts

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

Historic SQL Patterns

Use this skill when the WorkUnit raw file is a patterns-input/part-0001.json style shard from the historic-sql adapter. Older staged bundles may still provide root patterns-input.json; when that is the WorkUnit raw file, read it the same way.

Required Workflow

  1. Read the WorkUnit notes first.
  2. Find the single pattern input file listed under the WorkUnit rawFiles section.
  3. Call read_raw_file for that exact raw file path.
  4. Identify recurring analytical intents that span at least two tables and have repeated usage signal.
  5. Emit one pattern evidence object per durable cross-table intent by calling emit_historic_sql_evidence.
  6. Stop after all pattern evidence has been emitted.

Every join column mentioned in pattern descriptions must be verified via entity_details for both sides of the join.

Identifier Verification Protocol

Before writing a wiki page or SL source on any topic:

  1. discover_data({query: "<topic>"}) - see what wikis, SL sources, and raw tables already exist. Prefer updating existing pages over creating new ones.

Before emitting any schema.table or schema.table.column into a wiki body, SL source, tables: frontmatter, sl_refs, or emit_unmapped_fallback:

  1. entity_details({connectionId, targets: [{display: "<identifier>"}]}) - confirm the identifier resolves; inspect native types, FK/PK, and sampleValues.
  2. For literal values from the source, such as status codes or plan tiers, check whether they appear in entity_details sampleValues for the relevant column. If sampleValues is short or the sample may have missed real values, run a sql_execution probe with the same warehouse connection id: sql_execution({connectionId, sql: "SELECT DISTINCT <col> FROM <ref> LIMIT 50"}).
  3. If the candidate identifier still does not resolve, do one of:
    • Use sql_execution({connectionId, sql: "SELECT 1 FROM <ref> LIMIT 0"}). If it errors, the identifier is fictional.
    • Wrap the identifier in [unverified - from <rawPath>] in the wiki body, citing the exact raw path that mentioned it.
    • When recording emit_unmapped_fallback with no_physical_table, include the failing probe error in clarification.
  4. Never copy <schema>.<table> placeholder strings from these instructions into output.

Read the full file on GitHub · 90 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. 1mo ago First seen · 90 lines · 28 tokens per session scan A 23e3951dbfd1

Subscribe to this mod's changes

historic_sql_patterns is a skill published in the GitHub repository Kaelio/ktx (1,618 stars, last pushed 1mo ago), licensed Apache-2.0. It adds 28 tokens to every session and 964 once invoked, about $0.0001 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

Other skills, from other repositories

warehouse-init

Initialize warehouse schema discovery. Generates .astro/warehouse.md with all table metadata for instant lookups. Run once per project, refresh when schema changes. Use when user says "/astronomer-data:warehouse-init" or asks to set up data discovery.

astronomer/agents · 54 tokens

analyzing-data

Queries the data warehouse with SQL and answers business questions about data. Use when answering anything that needs warehouse data - counts, metrics, trends, aggregations, joins across tables, data lookups, or ad-hoc SQL analysis (for example "who uses X", "how many Y", "show me Z", "find customers", "what is the…

astronomer/agents · 78 tokens

tracing-downstream-lineage

Trace downstream data lineage and impact analysis. Use when the user asks what depends on this data, what breaks if something changes, downstream dependencies, or needs to assess change risk before modifying a table or DAG.

astronomer/agents · 48 tokens

profiling-tables

Deep-dive data profiling for a specific table. Use when the user asks to profile a table, wants statistics about a dataset, asks about data quality, or needs to understand a table's structure and content. Requires a table name.

astronomer/agents · 52 tokens

tracing-upstream-lineage

Trace upstream data lineage. Use when the user asks where data comes from, what feeds a table, upstream dependencies, data sources, or needs to understand data origins.

astronomer/agents · 40 tokens

bi-sql-knowledge

Use Seshat's public SQL knowledge for source grain, joins, aggregation, validation, reconciliation, and transformation reasoning without executing a database.

Kemetra/Seshat-BI · 34 tokens